Skip to content

Commit b1a6203

Browse files
committed
Enforce use of type-only imports.
1 parent 2343746 commit b1a6203

40 files changed

+90
-62
lines changed

config/modules/postcss-easy-import.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
declare module 'postcss-easy-import' {
2-
import { Plugin } from 'postcss'
2+
import type { Plugin } from 'postcss'
33

44
export default function (opts: {
55
prefix: string | boolean
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
declare module 'postcss-hexrgba' {
2-
import { Plugin } from 'postcss'
2+
import type { Plugin } from 'postcss'
33
export default function (): Plugin
44
}

config/modules/webpack-rtl-plugin.d.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
declare module 'webpack-rtl-plugin' {
2-
import { ConfigOptions, Plugin } from 'rtlcss'
3-
import cssnano from 'cssnano'
4-
import webpack, { WebpackPluginInstance } from 'webpack'
2+
import type { ConfigOptions, Plugin } from 'rtlcss'
3+
import type cssnano from 'cssnano'
4+
import type { WebpackPluginInstance } from 'webpack'
5+
import type webpack from 'webpack'
56

67
class WebpackRtlPlugin implements WebpackPluginInstance {
78
constructor(options?: {

config/webpack-css.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import path from 'path'
2-
import { Configuration, EntryObject } from 'webpack'
3-
import { Config as PostCssConfig } from 'postcss-load-config'
2+
import type { Configuration, EntryObject } from 'webpack'
3+
import type { Config as PostCssConfig } from 'postcss-load-config'
44
import libsass from 'sass'
55
import cssnano from 'cssnano'
66
import autoprefixer from 'autoprefixer'
@@ -30,7 +30,7 @@ export const cssWebpackConfig: Configuration = {
3030
entry: {
3131
...entriesFromFiles(
3232
['src/css/*.scss', '!src/css/**/_*.scss'],
33-
filename => `${path.parse(filename).name}-style`
33+
filename => `${path.parse(filename).name}-css`
3434
),
3535
...entriesFromFiles(
3636
'node_modules/codemirror/theme/*.css',
@@ -96,7 +96,7 @@ export const cssWebpackConfig: Configuration = {
9696
chunk?.name ?
9797
`${chunk.name}.css`
9898
.replace(/^codemirror-theme-/, 'editor-themes/')
99-
.replace(/-style\.css$/, '.css') :
99+
.replace(/-css\.css$/, '.css') :
100100
'[name].css'
101101
}),
102102
new WebpackRTLPlugin({

config/webpack-js.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { DefinePlugin, Configuration } from 'webpack'
1+
import type { Configuration } from 'webpack'
2+
import { DefinePlugin } from 'webpack'
23
import { join, resolve } from 'path'
34
import ESLintPlugin from 'eslint-webpack-plugin'
45
import RemoveEmptyScriptsPlugin from 'webpack-remove-empty-scripts'

eslint.config.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,11 @@ export default typescript.config(
5858
assertionStyle: 'angle-bracket',
5959
objectLiteralTypeAssertions: 'never'
6060
}],
61+
'@typescript-eslint/consistent-type-imports': 'error',
62+
'@typescript-eslint/consistent-type-exports': 'error',
6163
'@typescript-eslint/no-confusing-void-expression': ['error', { ignoreArrowShorthand: true }],
6264
'@typescript-eslint/no-for-in-array': 'error',
65+
'@typescript-eslint/no-import-type-side-effects': 'error',
6366
'@typescript-eslint/no-inferrable-types': ['error', { ignoreProperties: true, ignoreParameters: false }],
6467
'@typescript-eslint/no-unused-vars': ['error', {
6568
argsIgnorePattern: '^_',

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
"description": "Manage code snippets running on a WordPress-powered site through a graphical interface.",
44
"homepage": "https://wordpress.org/plugins/code-snippets",
55
"version": "3.6.5.1",
6-
"main": "dist/edit.js",
6+
"main": "src/dist/edit.js",
77
"directories": {
88
"test": "tests"
99
},
1010
"scripts": {
1111
"test": "eslint && npm run phpcs",
12-
"build": "webpack --mode development",
13-
"watch": "webpack --mode development --watch",
12+
"build": "webpack",
13+
"watch": "webpack --watch",
1414
"bundle": "ts-node scripts/bundle.ts",
1515
"phpcs": "src/vendor/bin/phpcs -s --colors ./phpcs.xml",
1616
"phpcbf": "src/vendor/bin/phpcbf ./phpcs.xml",

scripts/bundle.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { spawn } from 'child_process'
22
import { createWriteStream } from 'fs'
33
import * as process from 'node:process'
4-
import { webpack as webpackAsync, Configuration } from 'webpack'
4+
import type { Configuration } from 'webpack'
5+
import { webpack as webpackAsync } from 'webpack'
56
import plugin from '../package.json'
67
import webpackConfig from '../webpack.config'
78
import { cleanup, copy, resolve } from './utils/files'

src/js/components/SnippetForm/SnippetEditor/CodeEditorShortcuts.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { __, _x } from '@wordpress/i18n'
22
import classnames from 'classnames'
33
import React from 'react'
4-
import { KEYBOARD_KEYS, KeyboardShortcut } from '../../../types/KeyboardShortcut'
4+
import type { KeyboardShortcut } from '../../../types/KeyboardShortcut'
5+
import { KEYBOARD_KEYS } from '../../../types/KeyboardShortcut'
56
import { isMacOS } from '../../../utils/general'
67

78
const shortcuts: KeyboardShortcut[] = [

src/js/components/SnippetForm/SnippetEditor/SnippetEditor.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import React, { useEffect } from 'react'
22
import { __, _x } from '@wordpress/i18n'
33
import { addQueryArgs } from '@wordpress/url'
4-
import { Editor, EditorConfiguration } from 'codemirror'
5-
import { SNIPPET_TYPE_SCOPES, SNIPPET_TYPES, SnippetScope, SnippetType } from '../../../types/Snippet'
4+
import type { Editor, EditorConfiguration } from 'codemirror'
5+
import type { SnippetScope, SnippetType } from '../../../types/Snippet'
6+
import { SNIPPET_TYPE_SCOPES, SNIPPET_TYPES } from '../../../types/Snippet'
67
import '../../../editor'
78
import { isLicensed } from '../../../utils/general'
89
import { getSnippetType, isProType } from '../../../utils/snippets'

0 commit comments

Comments
 (0)