@wordpress/eslint-plugin 25.1.0 → 25.2.1-next.v.202605131006.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -127,8 +127,9 @@ The granular rulesets will not define any environment globals. As such, if they
|
|
|
127
127
|
| [no-dom-globals-in-react-fc](https://github.com/WordPress/gutenberg/tree/HEAD/packages/eslint-plugin/docs/rules/no-dom-globals-in-react-fc.md) | Disallow use of DOM globals in the render cycle of a React function component. | |
|
|
128
128
|
| [components-no-missing-40px-size-prop](https://github.com/WordPress/gutenberg/tree/HEAD/packages/eslint-plugin/docs/rules/components-no-missing-40px-size-prop.md) | Disallow missing `__next40pxDefaultSize` prop on `@wordpress/components` components. | ✓ |
|
|
129
129
|
| [components-no-unsafe-button-disabled](https://github.com/WordPress/gutenberg/tree/HEAD/packages/eslint-plugin/docs/rules/components-no-unsafe-button-disabled.md) | Disallow using `disabled` on Button without `accessibleWhenDisabled`. | ✓ |
|
|
130
|
-
| [no-unsafe-render-order](https://github.com/WordPress/gutenberg/tree/HEAD/packages/eslint-plugin/docs/rules/no-unsafe-render-order.md)
|
|
130
|
+
| [no-unsafe-render-order](https://github.com/WordPress/gutenberg/tree/HEAD/packages/eslint-plugin/docs/rules/no-unsafe-render-order.md) | Prevent unsafe `render` composition orders that silently remove semantics. | ✓ |
|
|
131
131
|
| [no-i18n-in-save](https://github.com/WordPress/gutenberg/tree/HEAD/packages/eslint-plugin/docs/rules/no-i18n-in-save.md) | Disallow translation functions in block save methods. | |
|
|
132
|
+
| [no-non-module-stylesheet-imports](https://github.com/WordPress/gutenberg/tree/HEAD/packages/eslint-plugin/docs/rules/no-non-module-stylesheet-imports.md) | Disallow importing non-module stylesheets from JavaScript files. | |
|
|
132
133
|
| [no-unmerged-classname](https://github.com/WordPress/gutenberg/tree/HEAD/packages/eslint-plugin/docs/rules/no-unmerged-classname.md) | Disallow unmerged `className` in components that spread rest props. | |
|
|
133
134
|
| [no-unguarded-get-range-at](https://github.com/WordPress/gutenberg/tree/HEAD/packages/eslint-plugin/docs/rules/no-unguarded-get-range-at.md) | Disallow the usage of unguarded `getRangeAt` calls. | ✓ |
|
|
134
135
|
| [no-unsafe-wp-apis](https://github.com/WordPress/gutenberg/tree/HEAD/packages/eslint-plugin/docs/rules/no-unsafe-wp-apis.md) | Disallow the usage of unsafe APIs from `@wordpress/*` packages | ✓ |
|
|
@@ -146,6 +147,7 @@ If you are upgrading from a previous version that used `.eslintrc.*` files:
|
|
|
146
147
|
|
|
147
148
|
1. Replace your `.eslintrc.*` file with an `eslint.config.mjs` file.
|
|
148
149
|
2. Change `extends` arrays to import + spread:
|
|
150
|
+
|
|
149
151
|
```js
|
|
150
152
|
// Old (.eslintrc.js)
|
|
151
153
|
module.exports = {
|
|
@@ -156,14 +158,17 @@ If you are upgrading from a previous version that used `.eslintrc.*` files:
|
|
|
156
158
|
import wordpress from '@wordpress/eslint-plugin';
|
|
157
159
|
export default [ ...wordpress.configs.recommended ];
|
|
158
160
|
```
|
|
161
|
+
|
|
159
162
|
3. Convert `overrides` to separate config objects with `files` patterns.
|
|
160
163
|
4. Replace `env` with `languageOptions.globals` using the [`globals`](https://www.npmjs.com/package/globals) package.
|
|
161
164
|
5. Delete your `.eslintignore` file and move patterns into an `ignores` config object.
|
|
162
165
|
6. Update rule prefixes in inline comments: `eslint-comments/*` has been renamed to `@eslint-community/eslint-comments/*`. For example:
|
|
166
|
+
|
|
163
167
|
```diff
|
|
164
168
|
- /* eslint-disable eslint-comments/no-unlimited-disable */
|
|
165
169
|
+ /* eslint-disable @eslint-community/eslint-comments/no-unlimited-disable */
|
|
166
170
|
```
|
|
171
|
+
|
|
167
172
|
7. Remove any `/* eslint-env */` comments — they are no longer supported in ESLint v10. Use `languageOptions.globals` in your config instead.
|
|
168
173
|
|
|
169
174
|
For a comprehensive walkthrough with examples and troubleshooting, see the [Gutenberg ESLint v10 migration guide](https://github.com/WordPress/gutenberg/blob/HEAD/docs/how-to-guides/eslint-v10-migration.md). See also the [ESLint migration guide](https://eslint.org/docs/latest/use/configure/migration-guide) for general flat config details.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/eslint-plugin",
|
|
3
|
-
"version": "25.1.0",
|
|
3
|
+
"version": "25.2.1-next.v.202605131006.0+2a3d07cab",
|
|
4
4
|
"description": "ESLint plugin for WordPress development.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
"@babel/eslint-parser": "^7.28.6",
|
|
45
45
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.4.0",
|
|
46
46
|
"@eslint/compat": "^2.0.0",
|
|
47
|
-
"@wordpress/babel-preset-default": "^8.45.0",
|
|
48
|
-
"@wordpress/prettier-config": "^4.45.0",
|
|
49
|
-
"@wordpress/theme": "^0.
|
|
47
|
+
"@wordpress/babel-preset-default": "^8.45.1-next.v.202605131006.0+2a3d07cab",
|
|
48
|
+
"@wordpress/prettier-config": "^4.45.1-next.v.202605131006.0+2a3d07cab",
|
|
49
|
+
"@wordpress/theme": "^0.13.1-next.v.202605131006.0+2a3d07cab",
|
|
50
50
|
"cosmiconfig": "^7.0.0",
|
|
51
51
|
"eslint-config-prettier": "^10.0.0",
|
|
52
52
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"eslint-plugin-playwright": "^2.1.0",
|
|
58
58
|
"eslint-plugin-prettier": "^5.0.0",
|
|
59
59
|
"eslint-plugin-react": "^7.37.0",
|
|
60
|
-
"eslint-plugin-react-hooks": "
|
|
60
|
+
"eslint-plugin-react-hooks": "7.1.1",
|
|
61
61
|
"globals": "^16.0.0",
|
|
62
62
|
"requireindex": "^1.2.0",
|
|
63
63
|
"typescript-eslint": "^8.0.0"
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"publishConfig": {
|
|
84
84
|
"access": "public"
|
|
85
85
|
},
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "8804fa29bc78a1d98e5a4d40c3e180ddd907016c"
|
|
87
87
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { RuleTester } from 'eslint';
|
|
2
|
+
import rule from '../no-non-module-stylesheet-imports';
|
|
3
|
+
|
|
4
|
+
const ruleTester = new RuleTester( {
|
|
5
|
+
languageOptions: {
|
|
6
|
+
sourceType: 'module',
|
|
7
|
+
ecmaVersion: 6,
|
|
8
|
+
},
|
|
9
|
+
} );
|
|
10
|
+
|
|
11
|
+
ruleTester.run( 'no-non-module-stylesheet-imports', rule, {
|
|
12
|
+
valid: [
|
|
13
|
+
{ code: "import './component';" },
|
|
14
|
+
{ code: "import styles from './style.module.css';" },
|
|
15
|
+
{ code: "import styles from './style.module.scss';" },
|
|
16
|
+
{ code: "import styles from './style.module.sass';" },
|
|
17
|
+
{ code: "import theme from './style.module.css?inline';" },
|
|
18
|
+
{ code: "import './style.module.css';" },
|
|
19
|
+
{ code: "import './style.module.scss?inline';" },
|
|
20
|
+
],
|
|
21
|
+
invalid: [
|
|
22
|
+
{
|
|
23
|
+
code: "import './style.css';",
|
|
24
|
+
errors: [ { messageId: 'noNonModuleStylesheet' } ],
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
code: "import './style.scss';",
|
|
28
|
+
errors: [ { messageId: 'noNonModuleStylesheet' } ],
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
code: "import './style.sass';",
|
|
32
|
+
errors: [ { messageId: 'noNonModuleStylesheet' } ],
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
code: "import styles from './style.scss';",
|
|
36
|
+
errors: [ { messageId: 'noNonModuleStylesheet' } ],
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
} );
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const STYLESHEET_EXTENSIONS = /\.(?:css|scss|sass)$/i;
|
|
2
|
+
const MODULE_STYLESHEET_EXTENSIONS = /\.module\.(?:css|scss|sass)$/i;
|
|
3
|
+
|
|
4
|
+
/** @type {import('eslint').Rule.RuleModule} */
|
|
5
|
+
module.exports = {
|
|
6
|
+
meta: {
|
|
7
|
+
type: 'problem',
|
|
8
|
+
docs: {
|
|
9
|
+
description:
|
|
10
|
+
'Disallow importing non-module stylesheets from JavaScript files.',
|
|
11
|
+
url: 'https://github.com/WordPress/gutenberg/blob/HEAD/packages/eslint-plugin/docs/rules/no-non-module-stylesheet-imports.md',
|
|
12
|
+
},
|
|
13
|
+
schema: [],
|
|
14
|
+
messages: {
|
|
15
|
+
noNonModuleStylesheet:
|
|
16
|
+
'Import non-module stylesheets through the package stylesheet entry point instead of JavaScript. If you want to import from JavaScript, use a CSS module.',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
create( context ) {
|
|
20
|
+
return {
|
|
21
|
+
ImportDeclaration( node ) {
|
|
22
|
+
if ( typeof node.source.value !== 'string' ) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const importPath = stripQueryAndHash( node.source.value );
|
|
27
|
+
if ( ! STYLESHEET_EXTENSIONS.test( importPath ) ) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if ( MODULE_STYLESHEET_EXTENSIONS.test( importPath ) ) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
context.report( {
|
|
36
|
+
node,
|
|
37
|
+
messageId: 'noNonModuleStylesheet',
|
|
38
|
+
} );
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @param {string} importPath Import source path.
|
|
46
|
+
* @return {string} Import source path without query or hash suffixes.
|
|
47
|
+
*/
|
|
48
|
+
function stripQueryAndHash( importPath ) {
|
|
49
|
+
return importPath.replace( /[?#].*$/, '' );
|
|
50
|
+
}
|