@aarongoldenthal/eslint-config-standard 27.0.1 → 29.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 +87 -64
- package/base-configs.js +367 -0
- package/eslint-comments-config.js +13 -12
- package/esm-config.js +6 -2
- package/jest-config.js +85 -85
- package/jsdoc-config.js +5 -1
- package/node-config.js +48 -40
- package/package.json +21 -19
- package/playwright-config.js +58 -56
- package/promise-config.js +5 -1
- package/recommended-esm.js +27 -0
- package/recommended.js +23 -14
- package/sonarjs-config.js +16 -4
- package/unicorn-configs.js +157 -0
- package/vitest-config.js +64 -68
- package/index.js +0 -362
- package/recommended-vitest.js +0 -16
- package/unicorn-config.js +0 -137
package/README.md
CHANGED
|
@@ -2,83 +2,106 @@
|
|
|
2
2
|
|
|
3
3
|
## Summary
|
|
4
4
|
|
|
5
|
-
Custom
|
|
6
|
-
for
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
`eslint-
|
|
11
|
-
`
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
- `
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
config
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
5
|
+
Custom ESLint configuration for all projects. Includes flat-config formatted
|
|
6
|
+
configurations compatible with ESLint v9+ for the following:
|
|
7
|
+
|
|
8
|
+
| Plugin Name | Config filename | Rule Prefix |
|
|
9
|
+
| ------------------------------------------------- | -------------------------------------------------------------------------------- | --------------------- |
|
|
10
|
+
| `eslint` | [`base-configs.js`](./base-configs.js) | |
|
|
11
|
+
| `@eslint-community/eslint-plugin-eslint-comments` | [`eslint-comments-config.js`](./eslint-comments-config.js) | `comments` |
|
|
12
|
+
| `eslint-plugin-jest` | [`jest-config.js`](./jest-config.js) | `jest` |
|
|
13
|
+
| `eslint-plugin-jsdoc` | [`jsdoc-config.js`](./jsdoc-config.js) | `jsdoc` |
|
|
14
|
+
| `eslint-plugin-n` | [`node-config.js`](./node-config.js) | `node` |
|
|
15
|
+
| `eslint-plugin-playwright` | [`playwright-config.js`](./playwright-config.js) | `playwright` |
|
|
16
|
+
| `eslint-plugin-promise` | [`promise-config.js`](./promise-config.js) | `promise` |
|
|
17
|
+
| `eslint-plugin-sonarjs` | [`sonarjs-config.js`](./sonarjs-config.js) | `sonarjs`, `sonarjs2` |
|
|
18
|
+
| `eslint-plugin-unicorn` | [`unicorn-configs.js`](./unicorn-configs.js), [`esm-config.js`](./esm-config.js) | `unicorn` |
|
|
19
|
+
| `eslint-plugin-vitest` | [`vitest-config.js`](./vitest-config.js) | `vitest` |
|
|
20
|
+
|
|
21
|
+
As flat configs, the package defines all required plugins/configurations as
|
|
22
|
+
`dependencies`. Since flat config allows flexibility in the rule prefixes (that
|
|
23
|
+
is, they don't have to match the plugin name), the rules prefixes are adapted
|
|
24
|
+
in some cases to be more intuitive or readable. Since they may be combined, and
|
|
25
|
+
flat config doesn't allow nested arrays of rules, file names that are singular
|
|
26
|
+
export a single config object (for example `jsdoc-config.js`), and file names
|
|
27
|
+
that are plural export an array of config objects (for example `base-configs.js`).
|
|
28
|
+
|
|
29
|
+
The `sonarjs2` prefix has only one rule, `sonarjs2/cognitive-complexity`,
|
|
30
|
+
that has a higher threshold. This provides a secondary check for cases where
|
|
31
|
+
the lower threshold in the `sonarjs/cognitive-complexity` rule is
|
|
32
|
+
disabled, which otherwise allows unbounded complexity.
|
|
33
|
+
|
|
34
|
+
Most rule configurations are applicable to files matching `'**/*.{js,mjs,cjs}'`. The
|
|
35
|
+
following configurations are exceptions and are applicable to files as noted:
|
|
36
|
+
|
|
37
|
+
- `base-configs.js` includes a config that disables some rules for test files
|
|
38
|
+
matching any of the following test patterns (for example `max-lines`,
|
|
39
|
+
`max-lines-per-function`).
|
|
40
|
+
- `jest-config` applies rules to files matching
|
|
41
|
+
`'**/__tests__/**/*.{js,mjs,cjs}'` or `'**/?(*.)+(spec|test).{js,mjs,cjs}'`.
|
|
42
|
+
- `vitest-config` applies rules to files matching
|
|
43
|
+
`'**/__tests__/**/*.{js,mjs}'` or `'**/?(*.)+(spec|test).{js,mjs}'`.
|
|
44
|
+
- `playwright-config`: applies rules to files matching `'**/*.pwtest.{js,mjs,cjs}'`,
|
|
45
|
+
which differentiates them from Jest/Vitest test files.
|
|
46
|
+
- `unicorn-configs.js` includes a config that disables some rules for test files
|
|
47
|
+
(matching any of the following test patterns).
|
|
48
|
+
|
|
49
|
+
With ESLint v9 the majority of formatting rules are deprecated and removed from
|
|
50
|
+
`base-configs`, but the `eslint-config-prettier` package is included and can be
|
|
51
|
+
added to the config if `prettier` is also being used to ensure it takes priority for
|
|
52
|
+
formatting.
|
|
53
|
+
|
|
54
|
+
There is also an `esm-config` included with rule overrides for projects using
|
|
55
|
+
ES modules instead of Common JS modules.
|
|
29
56
|
|
|
30
57
|
### Usage
|
|
31
58
|
|
|
32
59
|
There is a `recommended` configuration with all plugin configurations enabled
|
|
33
|
-
except `esm-config` and `vitest-config` (it
|
|
34
|
-
configure .
|
|
60
|
+
except `esm-config` and `vitest-config` (it does include `jest-config`). To
|
|
61
|
+
configure `eslint.config.js` with this configuration:
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
const recommendedConfig = require('@aarongoldenthal/eslint-config-standard/recommended');
|
|
35
65
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
66
|
+
module.exports = [
|
|
67
|
+
...recommendedConfig,
|
|
68
|
+
{
|
|
69
|
+
ignores: ['.vscode/**', 'archive/**', 'node_modules/**', 'coverage/**'],
|
|
70
|
+
name: 'ignores'
|
|
71
|
+
}
|
|
72
|
+
];
|
|
40
73
|
```
|
|
41
74
|
|
|
42
|
-
|
|
75
|
+
Note the optional `ignores` config that can be added last to ignore certain
|
|
76
|
+
directories.
|
|
77
|
+
|
|
78
|
+
There is also a `recommended-esm` configuration that's the same as the
|
|
43
79
|
`recommended` config, but includes the `vitest-config` instead of the
|
|
44
|
-
`jest-config`, and can be configured with:
|
|
80
|
+
`jest-config`, and also the `esm-config`. It can be configured with:
|
|
45
81
|
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
"extends": ["@aarongoldenthal/eslint-config-standard/recommended-vitest"]
|
|
49
|
-
}
|
|
50
|
-
```
|
|
82
|
+
```js
|
|
83
|
+
import recommendedConfig from '@aarongoldenthal/eslint-config-standard/recommended-esm.js';
|
|
51
84
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
"@aarongoldenthal/eslint-config-standard/jest-config",
|
|
60
|
-
"@aarongoldenthal/eslint-config-standard/jsdoc-config",
|
|
61
|
-
"@aarongoldenthal/eslint-config-standard/node-config",
|
|
62
|
-
"@aarongoldenthal/eslint-config-standard/playwright-config",
|
|
63
|
-
"@aarongoldenthal/eslint-config-standard/promise-config",
|
|
64
|
-
"@aarongoldenthal/eslint-config-standard/sonarjs-config",
|
|
65
|
-
"@aarongoldenthal/eslint-config-standard/unicorn-config",
|
|
66
|
-
"@aarongoldenthal/eslint-config-standard/vitest-config",
|
|
67
|
-
"@aarongoldenthal/eslint-config-standard",
|
|
68
|
-
"@aarongoldenthal/eslint-config-standard/esm-config",
|
|
69
|
-
"prettier"
|
|
70
|
-
]
|
|
71
|
-
}
|
|
85
|
+
export default [
|
|
86
|
+
...recommendedConfig,
|
|
87
|
+
{
|
|
88
|
+
ignores: ['.vscode/**', 'archive/**', 'node_modules/**', 'coverage/**'],
|
|
89
|
+
name: 'ignores'
|
|
90
|
+
}
|
|
91
|
+
];
|
|
72
92
|
```
|
|
73
93
|
|
|
94
|
+
To configure `eslint.config.js` with individual plugins, see the
|
|
95
|
+
[`recommended`](./recommended.js) or
|
|
96
|
+
[`recommended-esm`](./recommended-esm.js) configurations as examples.
|
|
97
|
+
|
|
74
98
|
Notes:
|
|
75
99
|
|
|
76
|
-
- If used, the
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
one should be used.
|
|
100
|
+
- If used, the `base-configs` should be included after other configurations,
|
|
101
|
+
except `esm-config` and `prettier`, so those settings take precedence.
|
|
102
|
+
- The `jest-config` and `vitest-config` have the same file applicability, so
|
|
103
|
+
only one should be used.
|
|
81
104
|
- If used, the `esm-config` should be configured after all functional rules
|
|
82
105
|
to ensure the overridden settings take precedence.
|
|
83
|
-
- If used, the `prettier` should be included last to take priority in
|
|
84
|
-
the applicable rules from all other configurations.
|
|
106
|
+
- If used, the `prettier` config should be included last to take priority in
|
|
107
|
+
disabling the applicable rules from all other configurations.
|
package/base-configs.js
ADDED
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
/* eslint-disable max-lines -- required given number of rules */
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const complexityThreshold = 20;
|
|
5
|
+
const maxFunctionLinesThreshold = 30;
|
|
6
|
+
const maxLinesThreshold = 300;
|
|
7
|
+
const maxParametersThreshold = 4;
|
|
8
|
+
const maxStatementsThreshold = 50;
|
|
9
|
+
const nestedThreshold = 5;
|
|
10
|
+
|
|
11
|
+
module.exports = [
|
|
12
|
+
{
|
|
13
|
+
files: ['**/*.{js,mjs,cjs}'],
|
|
14
|
+
languageOptions: {
|
|
15
|
+
sourceType: 'commonjs'
|
|
16
|
+
},
|
|
17
|
+
linterOptions: {
|
|
18
|
+
reportUnusedDisableDirectives: 'error'
|
|
19
|
+
},
|
|
20
|
+
name: 'eslint (all files)',
|
|
21
|
+
rules: {
|
|
22
|
+
// Possible problems
|
|
23
|
+
'array-callback-return': 'error',
|
|
24
|
+
'constructor-super': 'error', // Recommended
|
|
25
|
+
'for-direction': 'error', // Recommended
|
|
26
|
+
'getter-return': 'error', // Recommended
|
|
27
|
+
'no-async-promise-executor': 'error', // Recommended
|
|
28
|
+
'no-await-in-loop': 'error',
|
|
29
|
+
'no-class-assign': 'error', // Recommended
|
|
30
|
+
'no-compare-neg-zero': 'error', // Recommended
|
|
31
|
+
'no-cond-assign': 'error', // Recommended
|
|
32
|
+
'no-const-assign': 'error', // Recommended
|
|
33
|
+
'no-constant-binary-expression': 'error', // Recommended
|
|
34
|
+
'no-constant-condition': 'error', // Recommended
|
|
35
|
+
'no-constructor-return': 'error',
|
|
36
|
+
'no-control-regex': 'error', // Recommended
|
|
37
|
+
'no-debugger': 'error', // Recommended
|
|
38
|
+
'no-dupe-args': 'error', // Recommended
|
|
39
|
+
'no-dupe-class-members': 'error', // Recommended
|
|
40
|
+
'no-dupe-else-if': 'error', // Recommended
|
|
41
|
+
'no-dupe-keys': 'error', // Recommended
|
|
42
|
+
'no-duplicate-case': 'error', // Recommended
|
|
43
|
+
'no-duplicate-imports': 'error',
|
|
44
|
+
'no-empty-character-class': 'error', // Recommended
|
|
45
|
+
'no-empty-pattern': 'error', // Recommended
|
|
46
|
+
'no-ex-assign': 'error', // Recommended
|
|
47
|
+
'no-fallthrough': 'error', // Recommended
|
|
48
|
+
'no-func-assign': 'error', // Recommended
|
|
49
|
+
'no-import-assign': 'error', // Recommended
|
|
50
|
+
'no-inner-declarations': 'error',
|
|
51
|
+
'no-invalid-regexp': 'error', // Recommended
|
|
52
|
+
'no-irregular-whitespace': ['error', { skipStrings: true }], // Recommended
|
|
53
|
+
'no-loss-of-precision': 'error', // Recommended
|
|
54
|
+
'no-misleading-character-class': 'error', // Recommended
|
|
55
|
+
'no-new-native-nonconstructor': 'error', // Recommended
|
|
56
|
+
'no-obj-calls': 'error', // Recommended
|
|
57
|
+
'no-promise-executor-return': 'error',
|
|
58
|
+
'no-prototype-builtins': 'error', // Recommended
|
|
59
|
+
'no-self-assign': 'error', // Recommended
|
|
60
|
+
'no-self-compare': 'error',
|
|
61
|
+
'no-setter-return': 'error', // Recommended
|
|
62
|
+
'no-sparse-arrays': 'error', // Recommended
|
|
63
|
+
'no-template-curly-in-string': 'error',
|
|
64
|
+
'no-this-before-super': 'error', // Recommended
|
|
65
|
+
'no-undef': 'error', // Recommended
|
|
66
|
+
'no-unexpected-multiline': 'error', // Recommended, Prettier
|
|
67
|
+
'no-unmodified-loop-condition': 'error',
|
|
68
|
+
'no-unreachable': 'error', // Recommended
|
|
69
|
+
'no-unreachable-loop': 'error',
|
|
70
|
+
'no-unsafe-finally': 'error', // Recommended
|
|
71
|
+
'no-unsafe-negation': 'error', // Recommended
|
|
72
|
+
'no-unsafe-optional-chaining': 'error', // Recommended
|
|
73
|
+
'no-unused-private-class-members': 'error', // Recommended
|
|
74
|
+
'no-unused-vars': ['error', { args: 'all' }], // Recommended
|
|
75
|
+
'no-use-before-define': ['error', { functions: false }],
|
|
76
|
+
'no-useless-backreference': 'error', // Recommended
|
|
77
|
+
'require-atomic-updates': 'error',
|
|
78
|
+
'use-isnan': 'error', // Recommended
|
|
79
|
+
'valid-typeof': 'error', // Recommended
|
|
80
|
+
|
|
81
|
+
// Suggestions
|
|
82
|
+
// eslint-disable-next-line sort-keys -- match eslint docs
|
|
83
|
+
'accessor-pairs': 'error',
|
|
84
|
+
'arrow-body-style': ['error', 'as-needed'],
|
|
85
|
+
'block-scoped-var': 'error',
|
|
86
|
+
camelcase: 'error',
|
|
87
|
+
'capitalized-comments': [
|
|
88
|
+
'error',
|
|
89
|
+
'always',
|
|
90
|
+
{ ignoreConsecutiveComments: true, ignorePattern: 'nosemgrep' }
|
|
91
|
+
],
|
|
92
|
+
'class-methods-use-this': 'error',
|
|
93
|
+
complexity: ['error', complexityThreshold],
|
|
94
|
+
'consistent-return': 'error',
|
|
95
|
+
// Disabled due to 'unicorn/no-this-assignment
|
|
96
|
+
'consistent-this': 'off',
|
|
97
|
+
curly: 'error', // Prettier
|
|
98
|
+
'default-case': 'error',
|
|
99
|
+
'default-case-last': 'error',
|
|
100
|
+
'default-param-last': 'error',
|
|
101
|
+
'dot-notation': ['error', { allowPattern: '^[a-z]+(_[a-z]+)+$' }],
|
|
102
|
+
eqeqeq: ['error', 'always'],
|
|
103
|
+
'func-name-matching': 'off',
|
|
104
|
+
'func-names': 'off',
|
|
105
|
+
'func-style': [
|
|
106
|
+
'error',
|
|
107
|
+
'declaration',
|
|
108
|
+
{ allowArrowFunctions: true }
|
|
109
|
+
],
|
|
110
|
+
'grouped-accessor-pairs': ['error', 'getBeforeSet'],
|
|
111
|
+
'guard-for-in': 'error',
|
|
112
|
+
'id-denylist': 'off',
|
|
113
|
+
'id-length': 'off',
|
|
114
|
+
'id-match': 'off',
|
|
115
|
+
'init-declarations': 'off',
|
|
116
|
+
'logical-assignment-operators': ['error', 'always'],
|
|
117
|
+
'max-classes-per-file': ['error', 1],
|
|
118
|
+
'max-depth': ['error', { max: nestedThreshold }],
|
|
119
|
+
'max-lines': ['error', maxLinesThreshold],
|
|
120
|
+
'max-lines-per-function': [
|
|
121
|
+
'error',
|
|
122
|
+
{
|
|
123
|
+
max: maxFunctionLinesThreshold,
|
|
124
|
+
skipBlankLines: true,
|
|
125
|
+
skipComments: true
|
|
126
|
+
}
|
|
127
|
+
],
|
|
128
|
+
'max-nested-callbacks': ['error', { max: nestedThreshold }],
|
|
129
|
+
'max-params': ['error', { max: maxParametersThreshold }],
|
|
130
|
+
'max-statements': ['error', { max: maxStatementsThreshold }],
|
|
131
|
+
'new-cap': 'error',
|
|
132
|
+
'no-alert': 'error',
|
|
133
|
+
'no-array-constructor': 'error',
|
|
134
|
+
'no-bitwise': 'error',
|
|
135
|
+
'no-caller': 'error',
|
|
136
|
+
'no-case-declarations': 'error', // Recommended
|
|
137
|
+
'no-console': 'off',
|
|
138
|
+
'no-continue': 'error',
|
|
139
|
+
'no-delete-var': 'error', // Recommended
|
|
140
|
+
'no-div-regex': 'error',
|
|
141
|
+
'no-else-return': 'error',
|
|
142
|
+
'no-empty': 'error', // Recommended
|
|
143
|
+
'no-empty-function': ['error', { allow: ['arrowFunctions'] }],
|
|
144
|
+
'no-empty-static-block': 'error', // Recommended
|
|
145
|
+
'no-eq-null': 'error',
|
|
146
|
+
'no-eval': 'error',
|
|
147
|
+
'no-extend-native': 'error',
|
|
148
|
+
'no-extra-bind': 'error',
|
|
149
|
+
'no-extra-boolean-cast': 'error', // Recommended
|
|
150
|
+
'no-extra-label': 'error',
|
|
151
|
+
'no-global-assign': 'error', // Recommended
|
|
152
|
+
'no-implicit-coercion': 'error',
|
|
153
|
+
'no-implicit-globals': 'off',
|
|
154
|
+
'no-implied-eval': 'error',
|
|
155
|
+
'no-inline-comments': 'off',
|
|
156
|
+
'no-invalid-this': 'error',
|
|
157
|
+
'no-iterator': 'error',
|
|
158
|
+
'no-label-var': 'error',
|
|
159
|
+
'no-labels': 'error',
|
|
160
|
+
'no-lone-blocks': 'error',
|
|
161
|
+
'no-lonely-if': 'error',
|
|
162
|
+
'no-loop-func': 'error',
|
|
163
|
+
'no-magic-numbers': ['error', { ignore: [-1, 0, 1] }],
|
|
164
|
+
'no-multi-assign': 'error',
|
|
165
|
+
'no-multi-str': 'error',
|
|
166
|
+
// Disabled in favor of unicorn/no-negated-condition
|
|
167
|
+
'no-negated-condition': 'off',
|
|
168
|
+
// Disabled in favor of unicorn/no-nested-ternary
|
|
169
|
+
'no-nested-ternary': 'off',
|
|
170
|
+
'no-new': 'error',
|
|
171
|
+
'no-new-func': 'error',
|
|
172
|
+
'no-new-wrappers': 'error',
|
|
173
|
+
'no-nonoctal-decimal-escape': 'error', // Recommended
|
|
174
|
+
'no-object-constructor': 'error',
|
|
175
|
+
'no-octal': 'error', // Recommended
|
|
176
|
+
'no-octal-escape': 'error',
|
|
177
|
+
'no-param-reassign': ['error', { props: false }],
|
|
178
|
+
'no-plusplus': 'off',
|
|
179
|
+
'no-proto': 'error',
|
|
180
|
+
'no-redeclare': 'error', // Recommended
|
|
181
|
+
'no-regex-spaces': 'error', // Recommended
|
|
182
|
+
'no-restricted-exports': 'off',
|
|
183
|
+
'no-restricted-globals': 'off',
|
|
184
|
+
'no-restricted-imports': 'off',
|
|
185
|
+
'no-restricted-properties': 'off',
|
|
186
|
+
'no-restricted-syntax': 'off',
|
|
187
|
+
'no-return-assign': 'error',
|
|
188
|
+
'no-script-url': 'error',
|
|
189
|
+
'no-sequences': ['error', { allowInParentheses: false }],
|
|
190
|
+
'no-shadow': 'error',
|
|
191
|
+
'no-shadow-restricted-names': 'error', // Recommended
|
|
192
|
+
'no-ternary': 'off',
|
|
193
|
+
'no-throw-literal': 'error',
|
|
194
|
+
'no-undef-init': 'error',
|
|
195
|
+
// Disabled, too many valid positives
|
|
196
|
+
'no-undefined': 'off',
|
|
197
|
+
'no-underscore-dangle': 'error',
|
|
198
|
+
'no-unneeded-ternary': 'error',
|
|
199
|
+
'no-unused-expressions': [
|
|
200
|
+
'error',
|
|
201
|
+
{ allowShortCircuit: true, allowTernary: true }
|
|
202
|
+
],
|
|
203
|
+
'no-unused-labels': 'error', // Recommended
|
|
204
|
+
'no-useless-call': 'error',
|
|
205
|
+
'no-useless-catch': 'error', // Recommended
|
|
206
|
+
'no-useless-computed-key': 'error',
|
|
207
|
+
'no-useless-concat': 'error',
|
|
208
|
+
'no-useless-constructor': 'error',
|
|
209
|
+
'no-useless-escape': 'error', // Recommended
|
|
210
|
+
'no-useless-rename': 'error',
|
|
211
|
+
'no-useless-return': 'error',
|
|
212
|
+
'no-var': 'error',
|
|
213
|
+
'no-void': 'error',
|
|
214
|
+
'no-warning-comments': [
|
|
215
|
+
'error',
|
|
216
|
+
{ terms: ['TODO', 'FIXME', 'HACK', 'XXX', 'BUG'] }
|
|
217
|
+
],
|
|
218
|
+
'no-with': 'error', // Recommended
|
|
219
|
+
'object-shorthand': 'error',
|
|
220
|
+
'one-var': 'off',
|
|
221
|
+
'operator-assignment': 'error',
|
|
222
|
+
'prefer-arrow-callback': 'error',
|
|
223
|
+
'prefer-const': 'error',
|
|
224
|
+
'prefer-destructuring': ['error', { array: true, object: true }],
|
|
225
|
+
'prefer-exponentiation-operator': 'error',
|
|
226
|
+
'prefer-named-capture-group': 'error',
|
|
227
|
+
'prefer-numeric-literals': 'error',
|
|
228
|
+
'prefer-object-has-own': 'error',
|
|
229
|
+
'prefer-object-spread': ['error'],
|
|
230
|
+
'prefer-promise-reject-errors': 'error',
|
|
231
|
+
'prefer-regex-literals': 'error',
|
|
232
|
+
'prefer-rest-params': 'error',
|
|
233
|
+
'prefer-spread': 'error',
|
|
234
|
+
'prefer-template': 'error',
|
|
235
|
+
radix: ['error', 'as-needed'],
|
|
236
|
+
'require-await': 'error',
|
|
237
|
+
'require-unicode-regexp': 'off',
|
|
238
|
+
'require-yield': 'error', // Recommended
|
|
239
|
+
'sort-imports': ['error', { allowSeparatedGroups: true }],
|
|
240
|
+
'sort-keys': [
|
|
241
|
+
'error',
|
|
242
|
+
'asc',
|
|
243
|
+
{ caseSensitive: true, natural: true }
|
|
244
|
+
],
|
|
245
|
+
'sort-vars': 'error',
|
|
246
|
+
// 'spaced-comment': 'off',
|
|
247
|
+
strict: 'error',
|
|
248
|
+
'symbol-description': 'error',
|
|
249
|
+
// Disabled due to no-var
|
|
250
|
+
'vars-on-top': 'off',
|
|
251
|
+
yoda: 'error',
|
|
252
|
+
|
|
253
|
+
// Layout & Formatting
|
|
254
|
+
// eslint-disable-next-line sort-keys -- match eslint docs
|
|
255
|
+
'line-comment-position': 'off',
|
|
256
|
+
'unicode-bom': 'off' // Prettier
|
|
257
|
+
|
|
258
|
+
// Deprecated
|
|
259
|
+
// 'array-bracket-newline': 'off', // Prettier
|
|
260
|
+
// 'array-bracket-spacing': 'off', // Prettier
|
|
261
|
+
// 'array-element-newline': 'off', // Prettier
|
|
262
|
+
// 'arrow-parens': ['error', 'always'], // Prettier
|
|
263
|
+
// 'arrow-spacing': 'error', // Prettier
|
|
264
|
+
// 'block-spacing': 'error', // Prettier
|
|
265
|
+
// 'brace-style': ['error', 'stroustrup'], // Prettier
|
|
266
|
+
// 'comma-dangle': ['error', 'never'], // Prettier
|
|
267
|
+
// 'comma-spacing': ['error', { after: true, before: false }], // Prettier
|
|
268
|
+
// 'comma-style': 'off', // Prettier
|
|
269
|
+
// 'computed-property-spacing': ['error', 'never'], // Prettier
|
|
270
|
+
// 'dot-location': ['error', 'property'], // Prettier
|
|
271
|
+
// 'eol-last': ['error', 'always'], // Prettier
|
|
272
|
+
// 'func-call-spacing': ['error', 'never'], // Prettier
|
|
273
|
+
// 'function-call-argument-newline': 'off', // Prettier
|
|
274
|
+
// 'function-paren-newline': 'off', // Prettier
|
|
275
|
+
// 'generator-star-spacing': 'off', // Prettier
|
|
276
|
+
// 'implicit-arrow-linebreak': 'off', // Prettier
|
|
277
|
+
// indent: ['error', 4, { SwitchCase: 1 }], // Prettier
|
|
278
|
+
// 'jsx-quotes': 'off', // Prettier
|
|
279
|
+
// 'key-spacing': 'error', // Prettier
|
|
280
|
+
// 'keyword-spacing': ['error', { after: true, before: true }], // Prettier
|
|
281
|
+
// 'linebreak-style': ['error', 'unix'], // Prettier
|
|
282
|
+
// 'lines-around-comment': 'off', // Prettier
|
|
283
|
+
// 'lines-between-class-members': 'off',
|
|
284
|
+
// 'max-len': 'off', // Prettier
|
|
285
|
+
// 'max-statements-per-line': ['error', { max: 1 }],
|
|
286
|
+
// 'multiline-comment-style': ['error', 'separate-lines'],
|
|
287
|
+
// 'multiline-ternary': 'off', // Prettier
|
|
288
|
+
// 'new-parens': 'error', // Prettier
|
|
289
|
+
// 'newline-per-chained-call': 'off', // Prettier
|
|
290
|
+
// 'no-confusing-arrow': 'error', // Prettier
|
|
291
|
+
// 'no-extra-parens': 'off', // Prettier
|
|
292
|
+
// 'no-extra-semi': 'error', // Prettier
|
|
293
|
+
// 'no-floating-decimal': 'error', // Prettier
|
|
294
|
+
// 'no-mixed-operators': 'error', // Prettier
|
|
295
|
+
// 'no-mixed-spaces-and-tabs': 'error', // Prettier
|
|
296
|
+
// 'no-multi-spaces': 'error', // Prettier
|
|
297
|
+
// 'no-multiple-empty-lines': 'off', // Prettier
|
|
298
|
+
// 'no-new-object': 'off', // replaced by no-object-constructor
|
|
299
|
+
// 'no-new-symbol': 'off', // replaced by no-new-native-nonconstructor
|
|
300
|
+
// 'no-return-await': 'off',
|
|
301
|
+
// 'no-tabs': 'off', // Prettier
|
|
302
|
+
// 'no-trailing-spaces': 'error', // Prettier
|
|
303
|
+
// 'no-whitespace-before-property': 'error', // Prettier
|
|
304
|
+
// 'nonblock-statement-body-position': 'off', // Prettier
|
|
305
|
+
// 'object-curly-newline': 'off', // Prettier
|
|
306
|
+
// 'object-curly-spacing': ['error', 'always'], // Prettier
|
|
307
|
+
// 'object-property-newline': 'off', // Prettier
|
|
308
|
+
// 'one-var-declaration-per-line': 'off', // Prettier
|
|
309
|
+
// 'operator-linebreak': 'off', // Prettier
|
|
310
|
+
// 'padded-blocks': ['error', 'never'], // Prettier
|
|
311
|
+
// 'padding-line-between-statements': 'off',
|
|
312
|
+
// 'quote-props': 'off', // Prettier
|
|
313
|
+
// quotes: ['error', 'single'], // Prettier
|
|
314
|
+
// 'rest-spread-spacing': 'error', // Prettier
|
|
315
|
+
// semi: ['error', 'always'], // Prettier
|
|
316
|
+
// 'semi-spacing': 'error', // Prettier
|
|
317
|
+
// 'semi-style': ['error', 'last'], // Prettier
|
|
318
|
+
// 'space-before-blocks': ['error', 'always'], // Prettier
|
|
319
|
+
// 'space-before-function-paren': [
|
|
320
|
+
// 'error',
|
|
321
|
+
// {
|
|
322
|
+
// anonymous: 'always',
|
|
323
|
+
// asyncArrow: 'always',
|
|
324
|
+
// named: 'never'
|
|
325
|
+
// }
|
|
326
|
+
// ], // Prettier
|
|
327
|
+
// 'space-in-parens': ['error', 'never'], // Prettier
|
|
328
|
+
// 'space-infix-ops': 'off', // Prettier
|
|
329
|
+
// 'space-unary-ops': 'off', // Prettier
|
|
330
|
+
// 'switch-colon-spacing': 'off', // Prettier
|
|
331
|
+
// 'template-curly-spacing': 'error', // Prettier
|
|
332
|
+
// 'template-tag-spacing': 'off', // Prettier
|
|
333
|
+
// 'wrap-iife': 'error', // Prettier
|
|
334
|
+
// 'wrap-regex': 'off', // Prettier
|
|
335
|
+
// 'yield-star-spacing': 'off' // Prettier
|
|
336
|
+
}
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
files: [
|
|
340
|
+
// Patterns for jest-config, vitest-config
|
|
341
|
+
'**/__tests__/**/*.{js,mjs,cjs}',
|
|
342
|
+
'**/?(*.)+(spec|test).{js,mjs,cjs}',
|
|
343
|
+
// Pattern for playwright-config
|
|
344
|
+
'**/*.pwtest.{js,mjs,cjs}'
|
|
345
|
+
],
|
|
346
|
+
name: 'eslint (test and pwtest files)',
|
|
347
|
+
rules: {
|
|
348
|
+
// Assuming 1 test file per module, it can exceed limit
|
|
349
|
+
'max-lines': 'off',
|
|
350
|
+
// Describes are functions and frequently exceed limit
|
|
351
|
+
'max-lines-per-function': 'off',
|
|
352
|
+
// Tests frequently use indices and counts
|
|
353
|
+
'no-magic-numbers': 'off',
|
|
354
|
+
// Undefined is a common value to test no value
|
|
355
|
+
'no-undefined': 'off',
|
|
356
|
+
// Tests frequently check array elements, destructuring is
|
|
357
|
+
// les intuitive
|
|
358
|
+
'prefer-destructuring': 'off',
|
|
359
|
+
// Regexes in tests frequently check for match patterns, but
|
|
360
|
+
// groups are not captured
|
|
361
|
+
'prefer-named-capture-group': 'off',
|
|
362
|
+
// Async tests frequently return promises, which the test
|
|
363
|
+
// runner awaits implicitly
|
|
364
|
+
'require-await': 'off'
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
];
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const eslintCommentsPlugin = require('@eslint-community/eslint-plugin-eslint-comments');
|
|
4
|
+
|
|
3
5
|
module.exports = {
|
|
4
|
-
|
|
6
|
+
files: ['**/*.{js,mjs,cjs}'],
|
|
7
|
+
name: 'eslint-comments (all files)',
|
|
8
|
+
plugins: { comments: eslintCommentsPlugin },
|
|
5
9
|
rules: {
|
|
6
|
-
'
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
'
|
|
11
|
-
'
|
|
12
|
-
'
|
|
13
|
-
'@eslint-community/eslint-comments/no-unused-disable': 'error',
|
|
14
|
-
'@eslint-community/eslint-comments/no-unused-enable': 'error',
|
|
15
|
-
'@eslint-community/eslint-comments/no-use': [
|
|
10
|
+
'comments/disable-enable-pair': ['error', { allowWholeFile: true }],
|
|
11
|
+
'comments/no-aggregating-enable': 'error',
|
|
12
|
+
'comments/no-duplicate-disable': 'error',
|
|
13
|
+
'comments/no-unlimited-disable': 'error',
|
|
14
|
+
'comments/no-unused-disable': 'error',
|
|
15
|
+
'comments/no-unused-enable': 'error',
|
|
16
|
+
'comments/no-use': [
|
|
16
17
|
'error',
|
|
17
18
|
{
|
|
18
19
|
allow: [
|
|
@@ -23,6 +24,6 @@ module.exports = {
|
|
|
23
24
|
]
|
|
24
25
|
}
|
|
25
26
|
],
|
|
26
|
-
'
|
|
27
|
+
'comments/require-description': 'error'
|
|
27
28
|
}
|
|
28
29
|
};
|
package/esm-config.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const unicornPlugin = require('eslint-plugin-unicorn');
|
|
4
|
+
|
|
3
5
|
module.exports = {
|
|
4
|
-
|
|
6
|
+
files: ['**/*.{js,mjs}'],
|
|
7
|
+
languageOptions: {
|
|
5
8
|
sourceType: 'module'
|
|
6
9
|
},
|
|
7
|
-
|
|
10
|
+
name: 'esm (all files)',
|
|
11
|
+
plugins: { unicorn: unicornPlugin },
|
|
8
12
|
rules: {
|
|
9
13
|
'unicorn/prefer-export-from': 'error',
|
|
10
14
|
'unicorn/prefer-module': 'error',
|