@wordpress/eslint-plugin 24.6.1-next.v.202604091042.0 → 25.0.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 +64 -19
- package/configs/babel-parser-compat.js +69 -0
- package/configs/custom.js +37 -28
- package/configs/es5.js +100 -93
- package/configs/esnext.js +61 -53
- package/configs/i18n.js +24 -13
- package/configs/index.js +15 -1
- package/configs/jsdoc.js +80 -77
- package/configs/jshint.js +18 -16
- package/configs/jsx-a11y.js +24 -18
- package/configs/react.js +68 -39
- package/configs/recommended-with-formatting.js +51 -35
- package/configs/recommended.js +40 -29
- package/configs/test-e2e.js +18 -10
- package/configs/test-playwright.js +6 -3
- package/configs/test-unit.js +15 -8
- package/eslintrc/index.js +173 -0
- package/index.js +46 -2
- package/package.json +25 -20
- package/rules/__tests__/components-no-missing-40px-size-prop.js +5 -3
- package/rules/__tests__/components-no-unsafe-button-disabled.js +5 -3
- package/rules/__tests__/data-no-store-string-literals.js +77 -37
- package/rules/__tests__/dependency-group.js +1 -1
- package/rules/__tests__/i18n-ellipsis.js +1 -1
- package/rules/__tests__/i18n-hyphenated-range.js +1 -1
- package/rules/__tests__/i18n-no-collapsible-whitespace.js +1 -1
- package/rules/__tests__/i18n-no-flanking-whitespace.js +1 -1
- package/rules/__tests__/i18n-no-placeholders-only.js +1 -1
- package/rules/__tests__/i18n-no-variables.js +1 -1
- package/rules/__tests__/i18n-text-domain.js +1 -2
- package/rules/__tests__/i18n-translator-comments.js +1 -1
- package/rules/__tests__/no-base-control-with-label-without-id.js +5 -3
- package/rules/__tests__/no-dom-globals-in-constructor.js +9 -5
- package/rules/__tests__/no-dom-globals-in-module-scope.js +10 -33
- package/rules/__tests__/no-dom-globals-in-react-cc-render.js +9 -5
- package/rules/__tests__/no-dom-globals-in-react-fc.js +9 -5
- package/rules/__tests__/no-ds-tokens.js +8 -6
- package/rules/__tests__/no-global-active-element.js +1 -1
- package/rules/__tests__/no-global-get-selection.js +1 -1
- package/rules/__tests__/no-i18n-in-save.js +5 -3
- package/rules/__tests__/no-setting-ds-tokens.js +7 -5
- package/rules/__tests__/no-unguarded-get-range-at.js +1 -1
- package/rules/__tests__/no-unknown-ds-tokens.js +5 -3
- package/rules/__tests__/no-unmerged-classname.js +5 -3
- package/rules/__tests__/no-unsafe-wp-apis.js +1 -1
- package/rules/__tests__/no-unused-vars-before-return.js +5 -3
- package/rules/__tests__/no-wp-process-env.js +1 -1
- package/rules/__tests__/react-no-unsafe-timeout.js +1 -1
- package/rules/__tests__/use-recommended-components.js +1 -3
- package/rules/__tests__/valid-sprintf.js +1 -1
- package/rules/__tests__/wp-global-usage.js +1 -1
- package/rules/no-setting-ds-tokens.js +1 -1
package/configs/jsdoc.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
const globals = require( 'globals' );
|
|
5
|
+
const jsdocPlugin = require( 'eslint-plugin-jsdoc' );
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* The temporary list of types defined in Gutenberg which are allowed to avoid
|
|
@@ -72,83 +73,85 @@ const typescriptUtilityTypes = [
|
|
|
72
73
|
'false',
|
|
73
74
|
];
|
|
74
75
|
|
|
75
|
-
module.exports =
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
76
|
+
module.exports = [
|
|
77
|
+
jsdocPlugin.configs[ 'flat/recommended' ],
|
|
78
|
+
{
|
|
79
|
+
settings: {
|
|
80
|
+
jsdoc: {
|
|
81
|
+
preferredTypes: {
|
|
82
|
+
object: 'Object',
|
|
83
|
+
},
|
|
84
|
+
tagNamePreference: {
|
|
85
|
+
returns: 'return',
|
|
86
|
+
yields: 'yield',
|
|
87
|
+
},
|
|
85
88
|
},
|
|
86
89
|
},
|
|
90
|
+
rules: {
|
|
91
|
+
'jsdoc/no-defaults': 'off',
|
|
92
|
+
'jsdoc/no-undefined-types': [
|
|
93
|
+
'error',
|
|
94
|
+
{
|
|
95
|
+
definedTypes: [
|
|
96
|
+
// Required to reference browser types because we don't have the `browser` environment enabled for the project.
|
|
97
|
+
// Here we filter out all browser globals that don't begin with an uppercase letter because those
|
|
98
|
+
// generally refer to window-level event listeners and are not a valid type to reference (e.g. `onclick`).
|
|
99
|
+
...Object.keys( globals.browser ).filter( ( k ) =>
|
|
100
|
+
/^[A-Z]/.test( k )
|
|
101
|
+
),
|
|
102
|
+
...typescriptUtilityTypes,
|
|
103
|
+
...temporaryWordPressInternalTypes,
|
|
104
|
+
...temporaryExternalTypes,
|
|
105
|
+
'void',
|
|
106
|
+
'React',
|
|
107
|
+
],
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
'jsdoc/require-jsdoc': 'off',
|
|
111
|
+
'jsdoc/require-param-description': 'off',
|
|
112
|
+
'jsdoc/require-returns': 'off',
|
|
113
|
+
'jsdoc/require-yields': 'off',
|
|
114
|
+
'jsdoc/tag-lines': [
|
|
115
|
+
1,
|
|
116
|
+
'any',
|
|
117
|
+
{
|
|
118
|
+
startLines: null,
|
|
119
|
+
endLines: 0,
|
|
120
|
+
applyToEndTag: false,
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
'jsdoc/no-multi-asterisks': [
|
|
124
|
+
'error',
|
|
125
|
+
{ preventAtMiddleLines: false },
|
|
126
|
+
],
|
|
127
|
+
'jsdoc/check-access': 'error',
|
|
128
|
+
'jsdoc/check-alignment': 'error',
|
|
129
|
+
'jsdoc/check-line-alignment': [
|
|
130
|
+
'error',
|
|
131
|
+
'always',
|
|
132
|
+
{
|
|
133
|
+
tags: [ 'param', 'arg', 'argument', 'property', 'prop' ],
|
|
134
|
+
preserveMainDescriptionPostDelimiter: true,
|
|
135
|
+
},
|
|
136
|
+
],
|
|
137
|
+
'jsdoc/check-param-names': 'error',
|
|
138
|
+
'jsdoc/check-property-names': 'error',
|
|
139
|
+
'jsdoc/check-tag-names': 'error',
|
|
140
|
+
'jsdoc/check-types': 'error',
|
|
141
|
+
'jsdoc/check-values': 'off',
|
|
142
|
+
'jsdoc/empty-tags': 'error',
|
|
143
|
+
'jsdoc/implements-on-classes': 'error',
|
|
144
|
+
'jsdoc/require-param': 'error',
|
|
145
|
+
'jsdoc/require-param-name': 'error',
|
|
146
|
+
'jsdoc/require-param-type': 'error',
|
|
147
|
+
'jsdoc/require-property': 'error',
|
|
148
|
+
'jsdoc/require-property-description': 'error',
|
|
149
|
+
'jsdoc/require-property-name': 'error',
|
|
150
|
+
'jsdoc/require-property-type': 'error',
|
|
151
|
+
'jsdoc/require-returns-check': 'error',
|
|
152
|
+
'jsdoc/require-returns-description': 'error',
|
|
153
|
+
'jsdoc/require-returns-type': 'error',
|
|
154
|
+
'jsdoc/valid-types': 'error',
|
|
155
|
+
},
|
|
87
156
|
},
|
|
88
|
-
|
|
89
|
-
'jsdoc/no-defaults': 'off',
|
|
90
|
-
'jsdoc/no-undefined-types': [
|
|
91
|
-
'error',
|
|
92
|
-
{
|
|
93
|
-
definedTypes: [
|
|
94
|
-
// Required to reference browser types because we don't have the `browser` environment enabled for the project.
|
|
95
|
-
// Here we filter out all browser globals that don't begin with an uppercase letter because those
|
|
96
|
-
// generally refer to window-level event listeners and are not a valid type to reference (e.g. `onclick`).
|
|
97
|
-
...Object.keys( globals.browser ).filter( ( k ) =>
|
|
98
|
-
/^[A-Z]/.test( k )
|
|
99
|
-
),
|
|
100
|
-
...typescriptUtilityTypes,
|
|
101
|
-
...temporaryWordPressInternalTypes,
|
|
102
|
-
...temporaryExternalTypes,
|
|
103
|
-
'void',
|
|
104
|
-
'React',
|
|
105
|
-
],
|
|
106
|
-
},
|
|
107
|
-
],
|
|
108
|
-
'jsdoc/require-jsdoc': 'off',
|
|
109
|
-
'jsdoc/require-param-description': 'off',
|
|
110
|
-
'jsdoc/require-returns': 'off',
|
|
111
|
-
'jsdoc/require-yields': 'off',
|
|
112
|
-
'jsdoc/tag-lines': [
|
|
113
|
-
1,
|
|
114
|
-
'any',
|
|
115
|
-
{
|
|
116
|
-
startLines: null,
|
|
117
|
-
endLines: 0,
|
|
118
|
-
applyToEndTag: false,
|
|
119
|
-
},
|
|
120
|
-
],
|
|
121
|
-
'jsdoc/no-multi-asterisks': [
|
|
122
|
-
'error',
|
|
123
|
-
{ preventAtMiddleLines: false },
|
|
124
|
-
],
|
|
125
|
-
'jsdoc/check-access': 'error',
|
|
126
|
-
'jsdoc/check-alignment': 'error',
|
|
127
|
-
'jsdoc/check-line-alignment': [
|
|
128
|
-
'error',
|
|
129
|
-
'always',
|
|
130
|
-
{
|
|
131
|
-
tags: [ 'param', 'arg', 'argument', 'property', 'prop' ],
|
|
132
|
-
preserveMainDescriptionPostDelimiter: true,
|
|
133
|
-
},
|
|
134
|
-
],
|
|
135
|
-
'jsdoc/check-param-names': 'error',
|
|
136
|
-
'jsdoc/check-property-names': 'error',
|
|
137
|
-
'jsdoc/check-tag-names': 'error',
|
|
138
|
-
'jsdoc/check-types': 'error',
|
|
139
|
-
'jsdoc/check-values': 'off',
|
|
140
|
-
'jsdoc/empty-tags': 'error',
|
|
141
|
-
'jsdoc/implements-on-classes': 'error',
|
|
142
|
-
'jsdoc/require-param': 'error',
|
|
143
|
-
'jsdoc/require-param-name': 'error',
|
|
144
|
-
'jsdoc/require-param-type': 'error',
|
|
145
|
-
'jsdoc/require-property': 'error',
|
|
146
|
-
'jsdoc/require-property-description': 'error',
|
|
147
|
-
'jsdoc/require-property-name': 'error',
|
|
148
|
-
'jsdoc/require-property-type': 'error',
|
|
149
|
-
'jsdoc/require-returns-check': 'error',
|
|
150
|
-
'jsdoc/require-returns-description': 'error',
|
|
151
|
-
'jsdoc/require-returns-type': 'error',
|
|
152
|
-
'jsdoc/valid-types': 'error',
|
|
153
|
-
},
|
|
154
|
-
};
|
|
157
|
+
];
|
package/configs/jshint.js
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
module.exports =
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
module.exports = [
|
|
2
|
+
{
|
|
3
|
+
rules: {
|
|
4
|
+
curly: 'error',
|
|
5
|
+
eqeqeq: 'error',
|
|
6
|
+
'no-caller': 'error',
|
|
7
|
+
'no-cond-assign': [ 'error', 'except-parens' ],
|
|
8
|
+
'no-eq-null': 'error',
|
|
9
|
+
'no-irregular-whitespace': 'error',
|
|
10
|
+
'no-trailing-spaces': 'error',
|
|
11
|
+
'no-undef': 'error',
|
|
12
|
+
'no-unused-expressions': 'error',
|
|
13
|
+
'no-unused-vars': [ 'error', { ignoreRestSiblings: true } ],
|
|
14
|
+
'one-var': [ 'error', 'always' ],
|
|
15
|
+
quotes: [ 'error', 'single' ],
|
|
16
|
+
'wrap-iife': [ 'error', 'any' ],
|
|
17
|
+
},
|
|
16
18
|
},
|
|
17
|
-
|
|
19
|
+
];
|
package/configs/jsx-a11y.js
CHANGED
|
@@ -1,19 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
{
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
const jsxA11yPlugin = require( 'eslint-plugin-jsx-a11y' );
|
|
5
|
+
|
|
6
|
+
module.exports = [
|
|
7
|
+
jsxA11yPlugin.flatConfigs.recommended,
|
|
8
|
+
{
|
|
9
|
+
rules: {
|
|
10
|
+
// False positives with `render` props (e.g. `<Text render={ <h1 /> }>…</Text>`).
|
|
11
|
+
// See https://github.com/WordPress/gutenberg/issues/76501
|
|
12
|
+
'jsx-a11y/heading-has-content': 'off',
|
|
13
|
+
'jsx-a11y/label-has-associated-control': [
|
|
14
|
+
'error',
|
|
15
|
+
{
|
|
16
|
+
assert: 'htmlFor',
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
'jsx-a11y/media-has-caption': 'off',
|
|
20
|
+
'jsx-a11y/no-noninteractive-tabindex': 'off',
|
|
21
|
+
'jsx-a11y/role-has-required-aria-props': 'off',
|
|
22
|
+
'jsx-quotes': 'error',
|
|
23
|
+
},
|
|
18
24
|
},
|
|
19
|
-
|
|
25
|
+
];
|
package/configs/react.js
CHANGED
|
@@ -1,45 +1,74 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
const { fixupPluginRules } = require( '@eslint/compat' );
|
|
5
|
+
const reactPlugin = require( 'eslint-plugin-react' );
|
|
6
|
+
const reactHooksPlugin = require( 'eslint-plugin-react-hooks' );
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
const wpRules = require( '../rules' );
|
|
12
|
+
|
|
13
|
+
const wpPlugin = { rules: wpRules };
|
|
14
|
+
|
|
15
|
+
const fixedReactPlugin = fixupPluginRules( reactPlugin );
|
|
16
|
+
|
|
17
|
+
module.exports = [
|
|
18
|
+
{
|
|
19
|
+
plugins: {
|
|
20
|
+
react: fixedReactPlugin,
|
|
6
21
|
},
|
|
22
|
+
rules: reactPlugin.configs.flat.recommended.rules,
|
|
23
|
+
languageOptions: reactPlugin.configs.flat.recommended.languageOptions,
|
|
7
24
|
},
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
25
|
+
{
|
|
26
|
+
plugins: {
|
|
27
|
+
'@wordpress': wpPlugin,
|
|
28
|
+
'react-hooks': reactHooksPlugin,
|
|
11
29
|
},
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
{
|
|
18
|
-
excludePattern: '^use',
|
|
19
|
-
},
|
|
20
|
-
],
|
|
21
|
-
'react/display-name': 'off',
|
|
22
|
-
'react/jsx-curly-spacing': [
|
|
23
|
-
'error',
|
|
24
|
-
{
|
|
25
|
-
when: 'always',
|
|
26
|
-
children: true,
|
|
30
|
+
languageOptions: {
|
|
31
|
+
parserOptions: {
|
|
32
|
+
ecmaFeatures: {
|
|
33
|
+
jsx: true,
|
|
34
|
+
},
|
|
27
35
|
},
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
'react/jsx-key': 'error',
|
|
33
|
-
'react/jsx-tag-spacing': 'error',
|
|
34
|
-
'react/no-children-prop': 'off',
|
|
35
|
-
'react/prop-types': 'off',
|
|
36
|
-
'react/react-in-jsx-scope': 'off',
|
|
37
|
-
'react-hooks/exhaustive-deps': [
|
|
38
|
-
'warn',
|
|
39
|
-
{
|
|
40
|
-
additionalHooks: '^(useSelect|useSuspenseSelect)$',
|
|
36
|
+
},
|
|
37
|
+
settings: {
|
|
38
|
+
react: {
|
|
39
|
+
version: 'detect',
|
|
41
40
|
},
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
},
|
|
42
|
+
rules: {
|
|
43
|
+
'@wordpress/no-unused-vars-before-return': [
|
|
44
|
+
'error',
|
|
45
|
+
{
|
|
46
|
+
excludePattern: '^use',
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
'react/display-name': 'off',
|
|
50
|
+
'react/jsx-curly-spacing': [
|
|
51
|
+
'error',
|
|
52
|
+
{
|
|
53
|
+
when: 'always',
|
|
54
|
+
children: true,
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
'react/jsx-equals-spacing': 'error',
|
|
58
|
+
'react/jsx-indent': [ 'error', 'tab' ],
|
|
59
|
+
'react/jsx-indent-props': [ 'error', 'tab' ],
|
|
60
|
+
'react/jsx-key': 'error',
|
|
61
|
+
'react/jsx-tag-spacing': 'error',
|
|
62
|
+
'react/no-children-prop': 'off',
|
|
63
|
+
'react/prop-types': 'off',
|
|
64
|
+
'react/react-in-jsx-scope': 'off',
|
|
65
|
+
'react-hooks/exhaustive-deps': [
|
|
66
|
+
'warn',
|
|
67
|
+
{
|
|
68
|
+
additionalHooks: '^(useSelect|useSuspenseSelect)$',
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
'react-hooks/rules-of-hooks': 'error',
|
|
72
|
+
},
|
|
44
73
|
},
|
|
45
|
-
|
|
74
|
+
];
|
|
@@ -1,38 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
const globals = require( 'globals' );
|
|
5
|
+
const { fixupPluginRules } = require( '@eslint/compat' );
|
|
6
|
+
const importPlugin = fixupPluginRules( require( 'eslint-plugin-import' ) );
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
const jsxA11yConfig = require( './jsx-a11y' );
|
|
12
|
+
const customConfig = require( './custom' );
|
|
13
|
+
const reactConfig = require( './react' );
|
|
14
|
+
const esnextConfig = require( './esnext' );
|
|
15
|
+
const i18nConfig = require( './i18n' );
|
|
16
|
+
|
|
17
|
+
module.exports = [
|
|
18
|
+
...jsxA11yConfig,
|
|
19
|
+
...customConfig,
|
|
20
|
+
...reactConfig,
|
|
21
|
+
...esnextConfig,
|
|
22
|
+
...i18nConfig,
|
|
23
|
+
{
|
|
24
|
+
plugins: {
|
|
25
|
+
import: importPlugin,
|
|
23
26
|
},
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
languageOptions: {
|
|
28
|
+
globals: {
|
|
29
|
+
...globals.node,
|
|
30
|
+
window: 'writable',
|
|
31
|
+
document: 'writable',
|
|
32
|
+
SCRIPT_DEBUG: 'readonly',
|
|
33
|
+
wp: 'readonly',
|
|
30
34
|
},
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
},
|
|
36
|
+
settings: {
|
|
37
|
+
'import/extensions': [ '.js', '.jsx' ],
|
|
38
|
+
'import/resolver': {
|
|
39
|
+
typescript: true,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
rules: {
|
|
43
|
+
'import/no-extraneous-dependencies': [
|
|
44
|
+
'error',
|
|
45
|
+
{
|
|
46
|
+
peerDependencies: true,
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
'import/no-unresolved': 'error',
|
|
50
|
+
'import/default': 'warn',
|
|
51
|
+
'import/named': 'warn',
|
|
52
|
+
},
|
|
35
53
|
},
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
module.exports = config;
|
|
54
|
+
];
|
package/configs/recommended.js
CHANGED
|
@@ -3,52 +3,63 @@
|
|
|
3
3
|
*/
|
|
4
4
|
const { cosmiconfigSync } = require( 'cosmiconfig' );
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
6
|
/**
|
|
11
7
|
* Internal dependencies
|
|
12
8
|
*/
|
|
13
9
|
const { isPackageInstalled } = require( '../utils' );
|
|
10
|
+
const recommendedWithFormattingConfig = require( './recommended-with-formatting' );
|
|
14
11
|
|
|
15
|
-
const config =
|
|
16
|
-
extends: [ require.resolve( './recommended-with-formatting.js' ) ],
|
|
17
|
-
};
|
|
12
|
+
const config = [ ...recommendedWithFormattingConfig ];
|
|
18
13
|
|
|
19
14
|
if ( isPackageInstalled( 'prettier' ) ) {
|
|
20
|
-
|
|
15
|
+
const eslintPluginPrettier = require( 'eslint-plugin-prettier' );
|
|
16
|
+
const eslintConfigPrettier = require( 'eslint-config-prettier' );
|
|
21
17
|
|
|
22
18
|
const { config: localPrettierConfig } =
|
|
23
19
|
cosmiconfigSync( 'prettier' ).search() || {};
|
|
24
20
|
const defaultPrettierConfig = require( '@wordpress/prettier-config' );
|
|
25
21
|
const prettierConfig = { ...defaultPrettierConfig, ...localPrettierConfig };
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
22
|
+
|
|
23
|
+
config.push( eslintConfigPrettier, {
|
|
24
|
+
plugins: {
|
|
25
|
+
prettier: eslintPluginPrettier,
|
|
26
|
+
},
|
|
27
|
+
rules: {
|
|
28
|
+
...eslintConfigPrettier.rules,
|
|
29
|
+
'prettier/prettier': [ 'error', prettierConfig ],
|
|
30
|
+
// Prettier _disables_ this rule, but we want it!
|
|
31
|
+
// See https://github.com/prettier/eslint-config-prettier?tab=readme-ov-file#curly
|
|
32
|
+
// > This rule requires certain options.
|
|
33
|
+
// > …
|
|
34
|
+
// > If you like this rule, it can be used just fine with Prettier as long as you don't use the "multi-line" or "multi-or-nest" option.
|
|
35
|
+
curly: [ 'error', 'all' ],
|
|
36
|
+
},
|
|
37
|
+
} );
|
|
35
38
|
}
|
|
36
39
|
|
|
37
40
|
if ( isPackageInstalled( 'typescript' ) ) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
const tseslint = require( 'typescript-eslint' );
|
|
42
|
+
|
|
43
|
+
config.push(
|
|
44
|
+
tseslint.configs.eslintRecommended,
|
|
45
|
+
{
|
|
46
|
+
settings: {
|
|
47
|
+
'import/resolver': {
|
|
48
|
+
typescript: {
|
|
49
|
+
extensions: [ '.js', '.jsx', '.ts', '.tsx' ],
|
|
50
|
+
},
|
|
51
|
+
},
|
|
42
52
|
},
|
|
53
|
+
ignores: [ '**/*.d.ts' ],
|
|
43
54
|
},
|
|
44
|
-
};
|
|
45
|
-
config.extends.push( 'plugin:@typescript-eslint/eslint-recommended' );
|
|
46
|
-
config.ignorePatterns = [ '**/*.d.ts' ];
|
|
47
|
-
config.plugins = [ '@typescript-eslint' ];
|
|
48
|
-
config.overrides = [
|
|
49
55
|
{
|
|
50
56
|
files: [ '**/*.ts', '**/*.tsx' ],
|
|
51
|
-
|
|
57
|
+
languageOptions: {
|
|
58
|
+
parser: tseslint.parser,
|
|
59
|
+
},
|
|
60
|
+
plugins: {
|
|
61
|
+
'@typescript-eslint': tseslint.plugin,
|
|
62
|
+
},
|
|
52
63
|
rules: {
|
|
53
64
|
'no-duplicate-imports': 'off',
|
|
54
65
|
'import/no-duplicates': 'error',
|
|
@@ -75,8 +86,8 @@ if ( isPackageInstalled( 'typescript' ) ) {
|
|
|
75
86
|
'import/default': 'off',
|
|
76
87
|
'import/named': 'off',
|
|
77
88
|
},
|
|
78
|
-
}
|
|
79
|
-
|
|
89
|
+
}
|
|
90
|
+
);
|
|
80
91
|
}
|
|
81
92
|
|
|
82
93
|
module.exports = config;
|
package/configs/test-e2e.js
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
const globals = require( 'globals' );
|
|
5
|
+
const jestPlugin = require( 'eslint-plugin-jest' );
|
|
6
|
+
|
|
7
|
+
module.exports = [
|
|
8
|
+
jestPlugin.configs[ 'flat/recommended' ],
|
|
9
|
+
{
|
|
10
|
+
languageOptions: {
|
|
11
|
+
globals: {
|
|
12
|
+
...globals.browser,
|
|
13
|
+
browser: 'readonly',
|
|
14
|
+
page: 'readonly',
|
|
15
|
+
wp: 'readonly',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
5
18
|
},
|
|
6
|
-
|
|
7
|
-
browser: 'readonly',
|
|
8
|
-
page: 'readonly',
|
|
9
|
-
wp: 'readonly',
|
|
10
|
-
},
|
|
11
|
-
};
|
|
19
|
+
];
|
package/configs/test-unit.js
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
const jestPlugin = require( 'eslint-plugin-jest' );
|
|
5
|
+
|
|
6
|
+
module.exports = [
|
|
7
|
+
jestPlugin.configs[ 'flat/recommended' ],
|
|
8
|
+
{
|
|
9
|
+
rules: {
|
|
10
|
+
'jest/expect-expect': [
|
|
11
|
+
'error',
|
|
12
|
+
{ assertFunctionNames: [ 'expect', 'measurePerformance' ] },
|
|
13
|
+
],
|
|
14
|
+
},
|
|
8
15
|
},
|
|
9
|
-
|
|
16
|
+
];
|