@zendeskgarden/eslint-config 40.0.0 → 41.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 +72 -76
- package/index.js +34 -30
- package/package.json +18 -16
- package/plugins/jest.js +28 -3
- package/plugins/node.js +96 -0
- package/plugins/notice.js +13 -6
- package/plugins/react.js +26 -6
- package/plugins/{typescript-semantics.js → typescript-type-checked.js} +64 -16
- package/plugins/typescript.js +56 -61
- package/{plugins/node/best-practices.js → rules/layout-formatting.js} +3 -4
- package/rules/{possible-errors.js → possible-problems.js} +45 -9
- package/rules/suggestions.js +293 -0
- package/plugins/node/possible-errors.js +0 -48
- package/plugins/node/stylistic-issues.js +0 -48
- package/rules/best-practices.js +0 -168
- package/rules/es6.js +0 -61
- package/rules/strict-mode.js +0 -13
- package/rules/stylistic-issues.js +0 -95
- package/rules/variables.js +0 -38
package/README.md
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
# Garden ESLint Config [![npm version][npm version badge]][npm version link] [![Build Status][build status badge]][build status link]
|
|
1
|
+
# Garden ESLint Config [![npm version][npm version badge]][npm version link] [![Build Status][build status badge]][build status link]
|
|
2
2
|
|
|
3
3
|
[npm version badge]: https://flat.badgen.net/npm/v/@zendeskgarden/eslint-config
|
|
4
4
|
[npm version link]: https://www.npmjs.com/package/@zendeskgarden/eslint-config
|
|
5
5
|
[build status badge]: https://flat.badgen.net/circleci/github/zendeskgarden/eslint-config/main?label=build
|
|
6
6
|
[build status link]: https://circleci.com/gh/zendeskgarden/eslint-config/tree/main
|
|
7
|
-
[dependency status badge]: https://flat.badgen.net/david/dev/zendeskgarden/eslint-config?label=dependencies
|
|
8
|
-
[dependency status link]: https://david-dm.org/zendeskgarden/eslint-config?type=dev
|
|
9
7
|
|
|
10
8
|
> :seedling: Garden is the design system by Zendesk
|
|
11
9
|
|
|
@@ -16,22 +14,22 @@ selection of associated [plugins](#plugins).
|
|
|
16
14
|
## Installation
|
|
17
15
|
|
|
18
16
|
```sh
|
|
19
|
-
npm install eslint @
|
|
17
|
+
npm install eslint @zendeskgarden/eslint-config
|
|
20
18
|
```
|
|
21
19
|
|
|
22
20
|
## Usage
|
|
23
21
|
|
|
24
|
-
Add a
|
|
22
|
+
Add a `eslint.config.mjs` to your project like this:
|
|
25
23
|
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
```js
|
|
25
|
+
import config from '@zendeskgarden/eslint-config';
|
|
26
|
+
|
|
27
|
+
export default config;
|
|
30
28
|
```
|
|
31
29
|
|
|
32
30
|
Now Garden linting rules will apply to your project. See the [ESLint
|
|
33
|
-
Documentation](
|
|
34
|
-
for more details on
|
|
31
|
+
Documentation](https://eslint.org/docs/latest/extend/shareable-configs#using-a-shareable-config)
|
|
32
|
+
for more details on using shareable configuration files.
|
|
35
33
|
|
|
36
34
|
### Plugins
|
|
37
35
|
|
|
@@ -43,104 +41,102 @@ Install the following dependency in addition to those [listed](#installation)
|
|
|
43
41
|
above.
|
|
44
42
|
|
|
45
43
|
```sh
|
|
46
|
-
npm install jest
|
|
44
|
+
npm install jest
|
|
47
45
|
```
|
|
48
46
|
|
|
49
|
-
|
|
47
|
+
Update the default configuration.
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
import config from '@zendeskgarden/eslint-config';
|
|
51
|
+
import jestPlugin from '@zendeskgarden/eslint-config/plugins/jest.js';
|
|
50
52
|
|
|
51
|
-
|
|
52
|
-
{
|
|
53
|
-
"extends": ["@zendeskgarden", "@zendeskgarden/eslint-config/plugins/jest"]
|
|
54
|
-
}
|
|
53
|
+
export default [...config, jestPlugin];
|
|
55
54
|
```
|
|
56
55
|
|
|
57
56
|
In some cases, it may be useful to limit the scope of the Jest rules via
|
|
58
|
-
`
|
|
59
|
-
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
]
|
|
69
|
-
}
|
|
57
|
+
`files`.
|
|
58
|
+
|
|
59
|
+
```js
|
|
60
|
+
export default [
|
|
61
|
+
...config,
|
|
62
|
+
{
|
|
63
|
+
files: ['**/*.spec.*'],
|
|
64
|
+
...jestPlugin
|
|
65
|
+
}
|
|
66
|
+
];
|
|
70
67
|
```
|
|
71
68
|
|
|
72
69
|
#### React
|
|
73
70
|
|
|
74
71
|
The React plugin bundles rules for React, React Hooks, and JSX accessibility.
|
|
75
|
-
Install the following
|
|
76
|
-
|
|
72
|
+
Install the following dependency in addition to those [listed](#installation)
|
|
73
|
+
above.
|
|
77
74
|
|
|
78
75
|
```sh
|
|
79
|
-
npm install
|
|
76
|
+
npm install react
|
|
80
77
|
```
|
|
81
78
|
|
|
82
|
-
|
|
79
|
+
Update the default configuration.
|
|
80
|
+
|
|
81
|
+
```js
|
|
82
|
+
import config from '@zendeskgarden/eslint-config';
|
|
83
|
+
import reactPlugin from '@zendeskgarden/eslint-config/plugins/react.js';
|
|
83
84
|
|
|
84
|
-
|
|
85
|
-
{
|
|
86
|
-
"extends": ["@zendeskgarden", "@zendeskgarden/eslint-config/plugins/react"]
|
|
87
|
-
}
|
|
85
|
+
export default [...config, reactPlugin];
|
|
88
86
|
```
|
|
89
87
|
|
|
90
88
|
#### TypeScript
|
|
91
89
|
|
|
92
|
-
Install the following
|
|
93
|
-
|
|
90
|
+
Install the following dependency in addition to those [listed](#installation)
|
|
91
|
+
above.
|
|
94
92
|
|
|
95
93
|
```sh
|
|
96
|
-
npm install typescript
|
|
94
|
+
npm install typescript
|
|
97
95
|
```
|
|
98
96
|
|
|
99
|
-
|
|
97
|
+
Update the default configuration.
|
|
98
|
+
|
|
99
|
+
```js
|
|
100
|
+
import config from '@zendeskgarden/eslint-config';
|
|
101
|
+
import typescriptPlugin from '@zendeskgarden/eslint-config/plugins/typescript.js';
|
|
100
102
|
|
|
101
|
-
|
|
102
|
-
{
|
|
103
|
-
"extends": [
|
|
104
|
-
"@zendeskgarden",
|
|
105
|
-
"@zendeskgarden/eslint-config/plugins/typescript"
|
|
106
|
-
]
|
|
107
|
-
}
|
|
103
|
+
export default [...config, typescriptPlugin];
|
|
108
104
|
```
|
|
109
105
|
|
|
110
106
|
For mixed JS and TS codebases, it may be useful to limit the scope of the
|
|
111
|
-
TypeScript rules via `
|
|
112
|
-
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
{
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
]
|
|
122
|
-
}
|
|
107
|
+
TypeScript rules via `files`.
|
|
108
|
+
|
|
109
|
+
```js
|
|
110
|
+
export default [
|
|
111
|
+
...config,
|
|
112
|
+
{
|
|
113
|
+
files: ['**/*.{ts, tsx}'],
|
|
114
|
+
...typescriptPlugin
|
|
115
|
+
}
|
|
116
|
+
];
|
|
123
117
|
```
|
|
124
118
|
|
|
125
119
|
The `typescript` plugin covers rules for syntax checking. An additional
|
|
126
|
-
`typescript-
|
|
127
|
-
`typescript-
|
|
128
|
-
Set `parserOptions.project` to a valid TSConfig for the project. See
|
|
129
|
-
[typescript-eslint
|
|
130
|
-
documentation](https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/TYPED_LINTING.md)
|
|
120
|
+
`typescript-type-checked` plugin provides rules based on semantics. The
|
|
121
|
+
`typescript-type-checked` plugin requires type information in order to execute.
|
|
122
|
+
Set `languageOptions.parserOptions.project` to a valid TSConfig for the project. See
|
|
123
|
+
[typescript-eslint documentation](https://typescript-eslint.io/getting-started/typed-linting)
|
|
131
124
|
for details.
|
|
132
125
|
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
126
|
+
```js
|
|
127
|
+
export default [
|
|
128
|
+
...config,
|
|
129
|
+
typescriptPlugin,
|
|
130
|
+
typescriptTypeCheckedPlugin,
|
|
131
|
+
{
|
|
132
|
+
languageOptions: {
|
|
133
|
+
parserOptions: {
|
|
134
|
+
project: ['./tsconfig.json'],
|
|
135
|
+
requireConfigFile: false
|
|
136
|
+
}
|
|
137
|
+
}
|
|
142
138
|
}
|
|
143
|
-
|
|
139
|
+
];
|
|
144
140
|
```
|
|
145
141
|
|
|
146
142
|
## Resources
|
|
@@ -167,6 +163,6 @@ conduct](.github/CODE_OF_CONDUCT.md). Please participate accordingly.
|
|
|
167
163
|
|
|
168
164
|
## License
|
|
169
165
|
|
|
170
|
-
Copyright
|
|
166
|
+
Copyright 2024 Zendesk
|
|
171
167
|
|
|
172
168
|
Licensed under the [Apache License, Version 2.0](LICENSE.md)
|
package/index.js
CHANGED
|
@@ -5,34 +5,38 @@
|
|
|
5
5
|
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
8
|
+
import babelParser from '@babel/eslint-parser';
|
|
9
|
+
import eslintLayoutFormatting from './rules/layout-formatting.js';
|
|
10
|
+
import eslintPossibleProblems from './rules/possible-problems.js';
|
|
11
|
+
import eslintSuggestions from './rules/suggestions.js';
|
|
12
|
+
import globals from 'globals';
|
|
13
|
+
import nodePlugin from './plugins/node.js';
|
|
14
|
+
|
|
15
|
+
export default [
|
|
16
|
+
eslintLayoutFormatting,
|
|
17
|
+
eslintPossibleProblems,
|
|
18
|
+
eslintSuggestions,
|
|
19
|
+
nodePlugin,
|
|
20
|
+
{
|
|
21
|
+
languageOptions: {
|
|
22
|
+
globals: {
|
|
23
|
+
...globals.browser,
|
|
24
|
+
...globals.es2020
|
|
25
|
+
},
|
|
26
|
+
parser: babelParser,
|
|
27
|
+
parserOptions: {
|
|
28
|
+
ecmaFeatures: {
|
|
29
|
+
// allow `return` statements in the global scope
|
|
30
|
+
globalReturn: false,
|
|
31
|
+
// enable global strict mode
|
|
32
|
+
impliedStrict: true,
|
|
33
|
+
// enable JSX
|
|
34
|
+
jsx: true
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
linterOptions: {
|
|
39
|
+
reportUnusedDisableDirectives: true
|
|
35
40
|
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
};
|
|
41
|
+
}
|
|
42
|
+
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zendeskgarden/eslint-config",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "41.0.0",
|
|
4
4
|
"description": "Garden ESLint config",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Zendesk Garden <garden@zendesk.com>",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"bugs": {
|
|
10
10
|
"url": "https://github.com/zendeskgarden/eslint-config/issues"
|
|
11
11
|
},
|
|
12
|
+
"type": "module",
|
|
12
13
|
"main": "index.js",
|
|
13
14
|
"files": [
|
|
14
15
|
"plugins",
|
|
@@ -16,28 +17,29 @@
|
|
|
16
17
|
],
|
|
17
18
|
"scripts": {
|
|
18
19
|
"format": "prettier-package-json --write",
|
|
19
|
-
"lint": "eslint index.js plugins/*.js rules/*.js --max-warnings 0",
|
|
20
|
+
"lint": "eslint eslint.config.js index.js plugins/*.js rules/*.js --max-warnings 0",
|
|
20
21
|
"prepare": "husky",
|
|
21
22
|
"tag": "[ `git rev-parse --abbrev-ref HEAD` = 'main' ] && standard-version --no-verify",
|
|
22
23
|
"test": "npm run format && npm run lint && git diff --quiet"
|
|
23
24
|
},
|
|
24
|
-
"
|
|
25
|
-
"@babel/eslint-parser": "
|
|
26
|
-
"eslint": "
|
|
27
|
-
"eslint-plugin-n": "^17.0.0"
|
|
28
|
-
},
|
|
29
|
-
"devDependencies": {
|
|
30
|
-
"@babel/core": "7.24.5",
|
|
31
|
-
"@babel/eslint-parser": "7.24.5",
|
|
32
|
-
"@typescript-eslint/eslint-plugin": "7.8.0",
|
|
33
|
-
"@typescript-eslint/parser": "7.8.0",
|
|
34
|
-
"eslint": "8.57.0",
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@babel/eslint-parser": "7.24.6",
|
|
27
|
+
"@eslint/compat": "1.0.3",
|
|
35
28
|
"eslint-plugin-jest": "28.5.0",
|
|
36
29
|
"eslint-plugin-jsx-a11y": "6.8.0",
|
|
37
|
-
"eslint-plugin-n": "17.
|
|
38
|
-
"eslint-plugin-notice": "0.
|
|
39
|
-
"eslint-plugin-react": "7.34.
|
|
30
|
+
"eslint-plugin-n": "17.7.0",
|
|
31
|
+
"eslint-plugin-notice": "1.0.0-eslint9",
|
|
32
|
+
"eslint-plugin-react": "7.34.2",
|
|
40
33
|
"eslint-plugin-react-hooks": "4.6.2",
|
|
34
|
+
"globals": "15.3.0",
|
|
35
|
+
"typescript-eslint": "7.12.0"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"eslint": "^9.0.0"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@babel/core": "7.24.6",
|
|
42
|
+
"eslint": "9.4.0",
|
|
41
43
|
"husky": "9.0.11",
|
|
42
44
|
"jest": "29.7.0",
|
|
43
45
|
"prettier-package-json": "2.8.0",
|
package/plugins/jest.js
CHANGED
|
@@ -5,14 +5,25 @@
|
|
|
5
5
|
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
import globals from 'globals';
|
|
9
|
+
import jestPlugin from 'eslint-plugin-jest';
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
plugins: {
|
|
13
|
+
jest: jestPlugin
|
|
14
|
+
},
|
|
15
|
+
languageOptions: {
|
|
16
|
+
globals: globals.jest
|
|
17
|
+
},
|
|
11
18
|
rules: {
|
|
12
19
|
// have control over `test` and `it` usages
|
|
13
20
|
'jest/consistent-test-it': 0,
|
|
14
21
|
// enforce assertion to be made in a test body
|
|
15
22
|
'jest/expect-expect': 2,
|
|
23
|
+
// enforces a maximum number assertion calls in a test body
|
|
24
|
+
'max-expects': 0,
|
|
25
|
+
// enforces a maximum depth to nested describe calls
|
|
26
|
+
'max-nested-describe': 0,
|
|
16
27
|
// disallow alias methods
|
|
17
28
|
'jest/no-alias-methods': 2,
|
|
18
29
|
// disallow commented out tests
|
|
@@ -21,6 +32,8 @@ module.exports = {
|
|
|
21
32
|
'jest/no-conditional-expect': 0,
|
|
22
33
|
// disallow conditionals in test
|
|
23
34
|
'jest/no-conditional-in-test': 0,
|
|
35
|
+
// isallow confusing usages of jest.setTimeout
|
|
36
|
+
'jest/no-confusing-set-timeout': 2,
|
|
24
37
|
// disallow use of deprecated functions
|
|
25
38
|
'jest/no-deprecated-functions': 2,
|
|
26
39
|
// disallow disabled tests
|
|
@@ -45,6 +58,8 @@ module.exports = {
|
|
|
45
58
|
'jest/no-large-snapshots': 0,
|
|
46
59
|
// disallow manually importing from `__mocks__`
|
|
47
60
|
'jest/no-mocks-import': 2,
|
|
61
|
+
// disallow specific `jest.` methods
|
|
62
|
+
'jest/no-restricted-jest-methods': 0,
|
|
48
63
|
// disallow specific matchers & modifiers
|
|
49
64
|
'jest/no-restricted-matchers': 0,
|
|
50
65
|
// disallow using `expect` outside of `it` or `test` blocks
|
|
@@ -57,16 +72,26 @@ module.exports = {
|
|
|
57
72
|
'jest/no-untyped-mock-factory': 2,
|
|
58
73
|
// suggest using `toBeCalledWith()` or `toHaveBeenCalledWith()`
|
|
59
74
|
'jest/prefer-called-with': 0,
|
|
75
|
+
// suggest using the built-in comparison matchers
|
|
76
|
+
'jest/prefer-comparison-matcher': 2,
|
|
60
77
|
// prefer using `.each` rather than manual loops
|
|
61
78
|
'jest/prefer-each': 2,
|
|
79
|
+
// suggest using the built-in equality matchers
|
|
80
|
+
'jest/prefer-equality-matcher': 2,
|
|
62
81
|
// suggest using `expect.assertions()` OR `expect.hasAssertions()`
|
|
63
82
|
'jest/prefer-expect-assertions': 0,
|
|
64
83
|
// suggest `await expect(...).resolves` over `expect(await ...)` syntax
|
|
65
84
|
'jest/prefer-expect-resolves': 2,
|
|
85
|
+
// prefer having hooks in a consistent order
|
|
86
|
+
'jest/prefer-hooks-in-order': 2,
|
|
66
87
|
// suggest having hooks before any test cases
|
|
67
88
|
'jest/prefer-hooks-on-top': 0,
|
|
89
|
+
// prefer importing Jest globals
|
|
90
|
+
'jest/prefer-importing-jest-globals': 0,
|
|
68
91
|
// enforce lowercase test names
|
|
69
92
|
'jest/prefer-lowercase-title': [1, { ignore: ['describe'] }],
|
|
93
|
+
// prefer mock resolved/rejected shorthands for promises
|
|
94
|
+
'jest/prefer-mock-promise-shorthand': 1,
|
|
70
95
|
// suggest having a hint for snapshots
|
|
71
96
|
'jest/prefer-snapshot-hint': 1,
|
|
72
97
|
// suggest using `jest.spyOn()`
|
package/plugins/node.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import globals from 'globals';
|
|
9
|
+
import nodePlugin from 'eslint-plugin-n';
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
plugins: {
|
|
13
|
+
n: nodePlugin
|
|
14
|
+
},
|
|
15
|
+
languageOptions: {
|
|
16
|
+
globals: globals.node
|
|
17
|
+
},
|
|
18
|
+
rules: {
|
|
19
|
+
// enforce `return` after a callback
|
|
20
|
+
'n/callback-return': 0,
|
|
21
|
+
// enforce either `module.exports` or `exports`
|
|
22
|
+
'n/exports-style': 0,
|
|
23
|
+
// enforce the style of file extensions in `import` declarations
|
|
24
|
+
'n/file-extension-in-import': 0,
|
|
25
|
+
// enforce `require()` on top-level module scope
|
|
26
|
+
'n/global-require': 1,
|
|
27
|
+
// require error handling in callbacks
|
|
28
|
+
'n/handle-callback-err': 0,
|
|
29
|
+
// suggest correct usage of hashbang
|
|
30
|
+
'n/hashbang': 0,
|
|
31
|
+
// ensure Node.js-style error-first callback pattern is followed
|
|
32
|
+
'n/no-callback-literal': 1,
|
|
33
|
+
// disallow deprecated APIs
|
|
34
|
+
'n/no-deprecated-api': 2,
|
|
35
|
+
// disallow the assignment to `exports`
|
|
36
|
+
'n/no-exports-assign': 2,
|
|
37
|
+
// disallow `import` declarations which import extraneous modules
|
|
38
|
+
'n/no-extraneous-import': 0,
|
|
39
|
+
// disallow `require()` expressions which import extraneous modules
|
|
40
|
+
'n/no-extraneous-require': 0,
|
|
41
|
+
// disallow `import` declarations which import non-existence modules
|
|
42
|
+
'n/no-missing-import': 2,
|
|
43
|
+
// disallow `require()` expressions which import non-existence modules
|
|
44
|
+
'n/no-missing-require': 2,
|
|
45
|
+
// disallow mixing regular variable and `require` declarations
|
|
46
|
+
'n/no-mixed-requires': [0, false],
|
|
47
|
+
// disallow `new` operators with calls to `require`
|
|
48
|
+
'n/no-new-require': 0,
|
|
49
|
+
// disallow string concatenation with `__dirname` and `__filename`
|
|
50
|
+
'n/no-path-concat': 2,
|
|
51
|
+
// disallow use of `process.env`
|
|
52
|
+
'n/no-process-env': 0,
|
|
53
|
+
// disallow `process.exit()`
|
|
54
|
+
'n/no-process-exit': 2,
|
|
55
|
+
// disallow specified modules when loaded by `import` declarations
|
|
56
|
+
'n/no-restricted-import': 0,
|
|
57
|
+
// disallow specified modules when loaded by `require`
|
|
58
|
+
'n/no-restricted-require': 0,
|
|
59
|
+
// disallow use of synchronous methods
|
|
60
|
+
'n/no-sync': 0,
|
|
61
|
+
// disallow `bin` files that npm ignores
|
|
62
|
+
'n/no-unpublished-bin': 2,
|
|
63
|
+
// disallow `import` declarations which import private modules
|
|
64
|
+
'n/no-unpublished-import': 0,
|
|
65
|
+
// disallow `require()` expressions which import private modules
|
|
66
|
+
'n/no-unpublished-require': 0,
|
|
67
|
+
// disallow unsupported ECMAScript built-ins on the specified version
|
|
68
|
+
'n/no-unsupported-features/es-builtins': 2,
|
|
69
|
+
// disallow unsupported ECMAScript syntax on the specified version
|
|
70
|
+
'n/no-unsupported-features/es-syntax': 0,
|
|
71
|
+
// disallow unsupported Node.js built-in APIs on the specified version
|
|
72
|
+
'n/no-unsupported-features/node-builtins': 2,
|
|
73
|
+
// enforce either `Buffer` or `require("buffer").Buffer`
|
|
74
|
+
'n/prefer-global/buffer': [2, 'always'],
|
|
75
|
+
// enforce either `console` or `require("console")`
|
|
76
|
+
'n/prefer-global/console': [2, 'always'],
|
|
77
|
+
// enforce either `process` or `require("process")`
|
|
78
|
+
'n/prefer-global/process': [2, 'always'],
|
|
79
|
+
// enforce either `TextDecoder` or `require("util").TextDecoder`
|
|
80
|
+
'n/prefer-global/text-decoder': [2, 'always'],
|
|
81
|
+
// enforce either `TextEncoder` or `require("util").TextEncoder`
|
|
82
|
+
'n/prefer-global/text-encoder': [2, 'always'],
|
|
83
|
+
// enforce either `URL` or `require("url").URL`
|
|
84
|
+
'n/prefer-global/url': [2, 'always'],
|
|
85
|
+
// enforce either `URLSearchParams` or `require("url").URLSearchParams`
|
|
86
|
+
'n/prefer-global/url-search-params': [2, 'always'],
|
|
87
|
+
// enforce using the `node:` protocol when importing Node.js builtin modules
|
|
88
|
+
'n/prefer-node-protocol': [2, { version: '>=16.0.0' }],
|
|
89
|
+
// enforce `require("dns").promises`
|
|
90
|
+
'n/prefer-promises/dns': 1,
|
|
91
|
+
// enforce `require("fs").promises`
|
|
92
|
+
'n/prefer-promises/fs': 1,
|
|
93
|
+
// make process.exit() expressions the same code path as throw
|
|
94
|
+
'n/process-exit-as-throw': 2
|
|
95
|
+
}
|
|
96
|
+
};
|
package/plugins/notice.js
CHANGED
|
@@ -7,13 +7,20 @@ const TEMPLATE = `/**
|
|
|
7
7
|
|
|
8
8
|
`;
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
import noticePlugin from 'eslint-plugin-notice';
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
plugins: {
|
|
14
|
+
notice: noticePlugin
|
|
15
|
+
},
|
|
12
16
|
rules: {
|
|
13
17
|
// throw an error when a file doesn't have a copyright notice
|
|
14
|
-
'notice/notice': [
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
'notice/notice': [
|
|
19
|
+
2,
|
|
20
|
+
{
|
|
21
|
+
template: TEMPLATE,
|
|
22
|
+
onNonMatchingHeader: 'replace'
|
|
23
|
+
}
|
|
24
|
+
]
|
|
18
25
|
}
|
|
19
26
|
};
|
package/plugins/react.js
CHANGED
|
@@ -5,12 +5,23 @@
|
|
|
5
5
|
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
import { fixupPluginRules } from '@eslint/compat';
|
|
9
|
+
import jsxA11yPlugin from 'eslint-plugin-jsx-a11y';
|
|
10
|
+
import reactHooksPlugin from 'eslint-plugin-react-hooks';
|
|
11
|
+
import reactPlugin from 'eslint-plugin-react';
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
plugins: {
|
|
15
|
+
react: reactPlugin,
|
|
16
|
+
// TODO remove fixup when eslint-plugin-react-hooks 5.x is released
|
|
17
|
+
'react-hooks': fixupPluginRules(reactHooksPlugin),
|
|
18
|
+
'jsx-a11y': jsxA11yPlugin
|
|
19
|
+
},
|
|
20
|
+
languageOptions: {
|
|
21
|
+
parserOptions: {
|
|
22
|
+
ecmaFeatures: {
|
|
23
|
+
jsx: true
|
|
24
|
+
}
|
|
14
25
|
}
|
|
15
26
|
},
|
|
16
27
|
settings: {
|
|
@@ -19,6 +30,9 @@ module.exports = {
|
|
|
19
30
|
}
|
|
20
31
|
},
|
|
21
32
|
rules: {
|
|
33
|
+
...jsxA11yPlugin.configs.recommended.rules,
|
|
34
|
+
// disallow `aria-hidden="true"` from being set on focusable elements
|
|
35
|
+
'jsx-a11y/no-aria-hidden-on-focusable': 2,
|
|
22
36
|
// enforces using semantic DOM elements over the ARIA role property.
|
|
23
37
|
'jsx-a11y/prefer-tag-over-role': 2,
|
|
24
38
|
|
|
@@ -26,6 +40,8 @@ module.exports = {
|
|
|
26
40
|
'react/boolean-prop-naming': 1,
|
|
27
41
|
// forbid "button" element without an explicit "type" attribute
|
|
28
42
|
'react/button-has-type': 2,
|
|
43
|
+
// enforce using `onChange` or `readonly` attribute when checked is used
|
|
44
|
+
'react/checked-requires-onchange-or-readonly': 2,
|
|
29
45
|
// enforce all defaultProps are defined and not "required" in propTypes
|
|
30
46
|
'react/default-props-match-prop-types': 0,
|
|
31
47
|
// enforce consistent usage of destructuring assignment of props, state, and context
|
|
@@ -102,6 +118,8 @@ module.exports = {
|
|
|
102
118
|
'react/jsx-no-constructed-context-values': 2,
|
|
103
119
|
// enforce no duplicate props
|
|
104
120
|
'react/jsx-no-duplicate-props': 2,
|
|
121
|
+
// disallow problematic leaked values from being rendered
|
|
122
|
+
'react/jsx-no-leaked-render': 2,
|
|
105
123
|
// prevent using string literals in React component definition
|
|
106
124
|
'react/jsx-no-literals': 0,
|
|
107
125
|
// forbid `javascript:` URLs
|
|
@@ -182,6 +200,8 @@ module.exports = {
|
|
|
182
200
|
'react/no-unknown-property': 2,
|
|
183
201
|
// prevent usage of unsafe lifecycle methods
|
|
184
202
|
'react/no-unsafe': 2,
|
|
203
|
+
// disallow creating unstable components inside components
|
|
204
|
+
'react/no-unstable-nested-components': 2,
|
|
185
205
|
// Prevent declaring unused methods of component class
|
|
186
206
|
'react/no-unused-class-component-methods': 2,
|
|
187
207
|
// prevent definitions of unused prop types
|