@aarongoldenthal/eslint-config-standard 42.0.1 → 43.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 +90 -45
- package/base-configs.js +51 -23
- package/eslint-comments-config.js +2 -1
- package/esm-config.js +3 -2
- package/jest-config.js +8 -4
- package/jsdoc-configs.js +134 -0
- package/node-config.js +10 -2
- package/package.json +19 -8
- package/playwright-config.js +2 -1
- package/promise-config.js +2 -1
- package/recommended-esm-base.js +24 -0
- package/recommended-esm.js +3 -20
- package/recommended-ts.js +13 -0
- package/recommended.js +2 -2
- package/settings.js +31 -0
- package/typescript-eslint-configs.js +258 -0
- package/unicorn-configs.js +8 -6
- package/vitest-config.js +15 -3
- package/jsdoc-config.js +0 -119
package/README.md
CHANGED
|
@@ -5,58 +5,71 @@
|
|
|
5
5
|
Custom ESLint configuration for all projects. Includes flat-config formatted
|
|
6
6
|
configurations compatible with ESLint v9+ for the following:
|
|
7
7
|
|
|
8
|
-
| Plugin Name | Config name | Rule Prefix
|
|
9
|
-
| ------------------------------------------------- | -------------------------------------------------------------------------- |
|
|
10
|
-
| `eslint` | [`base-configs`](./base-configs.js) | none, `core`
|
|
11
|
-
| `@eslint-community/eslint-plugin-eslint-comments` | [`eslint-comments-config`](./eslint-comments-config.js) | `comments`
|
|
12
|
-
| `eslint-plugin-jest` | [`jest-config`](./jest-config.js) | `jest`
|
|
13
|
-
| `eslint-plugin-jsdoc` | [`jsdoc-
|
|
14
|
-
| `eslint-plugin-n` | [`node-config`](./node-config.js) | `node`
|
|
15
|
-
| `eslint-plugin-playwright` | [`playwright-config`](./playwright-config.js) | `playwright`
|
|
16
|
-
| `eslint-plugin-promise` | [`promise-config`](./promise-config.js) | `promise`
|
|
17
|
-
| `eslint-plugin-unicorn` | [`unicorn-configs`](./unicorn-configs.js), [`esm-config`](./esm-config.js) | `unicorn`
|
|
18
|
-
| `eslint-plugin-vitest` | [`vitest-config`](./vitest-config.js) | `vitest`
|
|
8
|
+
| Plugin Name | Config name | Rule Prefix |
|
|
9
|
+
| ------------------------------------------------- | -------------------------------------------------------------------------- | -------------------- |
|
|
10
|
+
| `eslint` | [`base-configs`](./base-configs.js) | none, `core` |
|
|
11
|
+
| `@eslint-community/eslint-plugin-eslint-comments` | [`eslint-comments-config`](./eslint-comments-config.js) | `comments` |
|
|
12
|
+
| `eslint-plugin-jest` | [`jest-config`](./jest-config.js) | `jest` |
|
|
13
|
+
| `eslint-plugin-jsdoc` | [`jsdoc-configs`](./jsdoc-configs.js) | `jsdoc` |
|
|
14
|
+
| `eslint-plugin-n` | [`node-config`](./node-config.js) | `node` |
|
|
15
|
+
| `eslint-plugin-playwright` | [`playwright-config`](./playwright-config.js) | `playwright` |
|
|
16
|
+
| `eslint-plugin-promise` | [`promise-config`](./promise-config.js) | `promise` |
|
|
17
|
+
| `eslint-plugin-unicorn` | [`unicorn-configs`](./unicorn-configs.js), [`esm-config`](./esm-config.js) | `unicorn` |
|
|
18
|
+
| `eslint-plugin-vitest` | [`vitest-config`](./vitest-config.js) | `vitest` |
|
|
19
|
+
| `typescript-eslint` | [`typescript-eslint-configs`](./typescript-eslint-configs.js) | `@typescript-eslint` |
|
|
19
20
|
|
|
20
21
|
As flat configs, the package defines all required plugins/configurations as
|
|
21
22
|
`dependencies`. Since flat config allows flexibility in the rule prefixes (that
|
|
22
23
|
is, they don't have to match the plugin name), the rules prefixes are adapted
|
|
23
|
-
in some cases to be more intuitive or readable. Since they may be
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
in some cases to be more intuitive or readable. Since they may be single
|
|
25
|
+
configs or arrays of configs, file names that are singular export a single
|
|
26
|
+
config object (for example `promise-config`) and file names that are plural
|
|
27
|
+
export an array of config objects (for example `base-configs`).
|
|
27
28
|
|
|
28
29
|
The `core` prefix has only one rule, `core/complexity`, that has a higher threshold.
|
|
29
30
|
This provides a secondary check for cases where the lower threshold in the `complexity`
|
|
30
|
-
rule is
|
|
31
|
+
rule is turned off, which otherwise allows unbounded complexity. Since re-use of core
|
|
31
32
|
rules is an experimental capability, this must be enabled with environment variable
|
|
32
33
|
`ENABLE_ESLINT_CORE_RULE_DUPLICATES=true`.
|
|
33
34
|
|
|
34
|
-
Most rule configurations are applicable to
|
|
35
|
-
|
|
35
|
+
Most rule configurations are applicable to all JavaScript and TypeScript files
|
|
36
|
+
(matching `'**/*.{js,mjs,cjs,ts,mts,cts}'`). The following configurations are
|
|
37
|
+
exceptions and are applicable to files as noted:
|
|
36
38
|
|
|
37
|
-
- `base-configs` sets `sourceType` to `commonjs` for `*.js
|
|
38
|
-
`module` for `*.mjs` files.
|
|
39
|
+
- `base-configs` sets `sourceType` to `commonjs` for `*.{js,cjs,ts,cts}` files and
|
|
40
|
+
`module` for `*.{mjs,mts}` files.
|
|
39
41
|
- `base-configs` includes a config that disables some rules for test files
|
|
40
42
|
matching any of the following test patterns (for example `max-lines`,
|
|
41
43
|
`max-lines-per-function`).
|
|
42
44
|
- `jest-config` applies rules to files matching
|
|
43
|
-
`'**/__tests__/**/*.{js,mjs,cjs}'` or
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
`'**/__tests__/**/*.{js,mjs,cjs,ts,mts,cts}'` or
|
|
46
|
+
`'**/?(*.)+(spec|test).{js,mjs,cjs,ts,mts,cts}'`.
|
|
47
|
+
- `vitest-config` applies rules to ESM files matching
|
|
48
|
+
`'**/__tests__/**/*.{js,mjs,ts,mts}'` or `'**/?(*.)+(spec|test).{js,mjs,ts,mts}'`.
|
|
49
|
+
- `playwright-config`: applies rules to files matching
|
|
50
|
+
`'**/*.pwtest.{js,mjs,cjs,ts,mts,cts}'`, which differentiates them from
|
|
51
|
+
Jest/Vitest test files.
|
|
48
52
|
- `unicorn-configs` includes a config that disables some rules for test files
|
|
49
53
|
(matching any of the following test patterns), and applies some ESM-specific
|
|
50
|
-
rules only applicable to `*.mjs` files.
|
|
54
|
+
rules only applicable to `*.{mjs,mts}` files.
|
|
55
|
+
- `typescript-eslint-configs` applies `typescript-eslint` rules to JavaScript
|
|
56
|
+
and all TypeScript files. Some of these rules extend core ESLint rules,
|
|
57
|
+
so those core ESLint rules are turned off in this config to avoid conflicts.
|
|
58
|
+
It also applies TypeScript-specific rules to TypeScript files only, and
|
|
59
|
+
configures the `@typescript-eslint/parser` set to use the closest
|
|
60
|
+
`tsconfig.json` file. For rules that are ESM/CJS specific, it assumes
|
|
61
|
+
`*.{js,ts}` files are ESM, which differs from `base-configs`. To ensure
|
|
62
|
+
proper rule overrides, this config should be applied after `base-configs`
|
|
63
|
+
and `esm-config`.
|
|
51
64
|
|
|
52
65
|
With ESLint v9 the majority of formatting rules are deprecated and removed from
|
|
53
66
|
`base-configs`, but the `eslint-config-prettier` package is included and can be
|
|
54
67
|
added to the config if `prettier` is also being used to ensure it takes priority
|
|
55
|
-
for formatting.
|
|
68
|
+
for formatting, although it should be included last.
|
|
56
69
|
|
|
57
70
|
There is also an `esm-config` included for projects using ES modules instead of
|
|
58
|
-
CommonJS modules. This config sets `sourceType` to `module` for `*.js`
|
|
59
|
-
includes `unicorn-
|
|
71
|
+
CommonJS modules. This config sets `sourceType` to `module` for `*.{js,ts}`
|
|
72
|
+
files and includes `unicorn-configs` ESM-specific rules.
|
|
60
73
|
|
|
61
74
|
### Usage
|
|
62
75
|
|
|
@@ -64,10 +77,18 @@ This module is now pure ESM, so must be called from an ESM file, either
|
|
|
64
77
|
`eslint.config.js` (if the project is ESM) or `eslint.config.mjs` (if the
|
|
65
78
|
project is CJS).
|
|
66
79
|
|
|
67
|
-
There
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
80
|
+
There are three versions of `recommended` configurations
|
|
81
|
+
covering CommonJS, ESM, and TypeScript, and the individual configurations can
|
|
82
|
+
be manually configured as well.
|
|
83
|
+
|
|
84
|
+
#### `recommended` configuration
|
|
85
|
+
|
|
86
|
+
The `recommended` configuration is for CommonJS with all plugin configurations
|
|
87
|
+
enabled except `vitest-config` (it does include `jest-config`) and
|
|
88
|
+
`typescript-eslint-configs`. It does apply ESM-specific rules to
|
|
89
|
+
`*.{mjs,mts}` files. The rules are applicable to all JavaScript and TypeScript
|
|
90
|
+
files, but don't require TypeScript (no rules with types). To configure
|
|
91
|
+
`eslint.config.mjs` with this configuration:
|
|
71
92
|
|
|
72
93
|
```js
|
|
73
94
|
import { defineConfig, globalIgnores } from 'eslint/config';
|
|
@@ -75,17 +96,21 @@ import recommendedConfig from '@aarongoldenthal/eslint-config-standard/recommend
|
|
|
75
96
|
|
|
76
97
|
export default defineConfig([
|
|
77
98
|
recommendedConfig,
|
|
78
|
-
globalIgnores(['
|
|
99
|
+
globalIgnores(['node_modules/**', 'coverage/**'])
|
|
79
100
|
]);
|
|
80
101
|
```
|
|
81
102
|
|
|
82
|
-
Note the optional `
|
|
103
|
+
Note the optional `globalIgnores` config that can be added last to ignore certain
|
|
83
104
|
directories.
|
|
84
105
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
`
|
|
88
|
-
It
|
|
106
|
+
#### `recommended-esm` configuration
|
|
107
|
+
|
|
108
|
+
The `recommended-esm` configuration is the same as the `recommended` config,
|
|
109
|
+
but for ESM. It includes the `vitest-config` instead of the
|
|
110
|
+
`jest-config`, and also the `esm-config` (applicable to `*.{js,ts}` files),
|
|
111
|
+
but doesn't include `typescript-eslint-configs`. The rules are also applicable
|
|
112
|
+
to all JavaScript and TypeScript files, but don't require TypeScript (no rules
|
|
113
|
+
with types). It can be configured with:
|
|
89
114
|
|
|
90
115
|
```js
|
|
91
116
|
import { defineConfig, globalIgnores } from 'eslint/config';
|
|
@@ -93,13 +118,31 @@ import recommendedConfig from '@aarongoldenthal/eslint-config-standard/recommend
|
|
|
93
118
|
|
|
94
119
|
export default defineConfig([
|
|
95
120
|
recommendedConfig,
|
|
96
|
-
globalIgnores(['
|
|
121
|
+
globalIgnores(['node_modules/**', 'coverage/**'])
|
|
122
|
+
]);
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
#### `recommended-ts` configuration
|
|
126
|
+
|
|
127
|
+
The `recommended-ts` configuration is the same as the `recommended-esm` config,
|
|
128
|
+
but also includes `typescript-eslint-configs`, and therefore requires
|
|
129
|
+
TypeScript (an optional peer dependency) and a `tsconfig.json` file. It can
|
|
130
|
+
be configured with:
|
|
131
|
+
|
|
132
|
+
```js
|
|
133
|
+
import { defineConfig, globalIgnores } from 'eslint/config';
|
|
134
|
+
import recommendedConfig from '@aarongoldenthal/eslint-config-standard/recommended-ts';
|
|
135
|
+
|
|
136
|
+
export default defineConfig([
|
|
137
|
+
recommendedConfig,
|
|
138
|
+
globalIgnores(['node_modules/**', 'coverage/**'])
|
|
97
139
|
]);
|
|
98
140
|
```
|
|
99
141
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
142
|
+
### Using individual configurations
|
|
143
|
+
|
|
144
|
+
To configure `eslint.config.js` with individual plugins, see the `recommended*`
|
|
145
|
+
configurations as examples.
|
|
103
146
|
|
|
104
147
|
Notes:
|
|
105
148
|
|
|
@@ -107,7 +150,9 @@ Notes:
|
|
|
107
150
|
except `esm-config` and `prettier`, so those settings take precedence.
|
|
108
151
|
- The `jest-config` and `vitest-config` have the same file applicability, so
|
|
109
152
|
only one should be used.
|
|
110
|
-
- If used, the `esm-config` should be configured after all functional
|
|
111
|
-
to ensure the overridden settings take precedence.
|
|
153
|
+
- If used, the `esm-config` should be configured after all functional
|
|
154
|
+
JavaScript rules to ensure the overridden settings take precedence.
|
|
155
|
+
- If used, the `typescript-eslint-configs` should be configured after all
|
|
156
|
+
other rules to ensure the overridden settings take precedence.
|
|
112
157
|
- If used, the `prettier` config should be included last to take priority in
|
|
113
158
|
disabling the applicable rules from all other configurations.
|
package/base-configs.js
CHANGED
|
@@ -1,30 +1,51 @@
|
|
|
1
1
|
/* eslint-disable max-lines -- required given number of rules */
|
|
2
|
+
import { filePatterns, thresholds } from './settings.js';
|
|
2
3
|
import { defineConfig } from 'eslint/config';
|
|
3
4
|
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
const eslintRulesCoveredByTsc = {
|
|
6
|
+
// All applicable rules listed for clarity.
|
|
7
|
+
// Those already configured are commented out.
|
|
8
|
+
'constructor-super': 'off', // Ts(2335) & ts(2377)
|
|
9
|
+
'getter-return': 'off', // Ts(2378)
|
|
10
|
+
'no-class-assign': 'off', // Ts(2629)
|
|
11
|
+
'no-const-assign': 'off', // Ts(2588)
|
|
12
|
+
'no-dupe-args': 'off', // Ts(2300)
|
|
13
|
+
'no-dupe-class-members': 'off', // Ts(2393) & ts(2300)
|
|
14
|
+
'no-dupe-keys': 'off', // Ts(1117)
|
|
15
|
+
'no-func-assign': 'off', // Ts(2630)
|
|
16
|
+
'no-import-assign': 'off', // Ts(2632) & ts(2540)
|
|
17
|
+
'no-new-native-nonconstructor': 'off', // Ts(7009)
|
|
18
|
+
'no-obj-calls': 'off', // Ts(2349)
|
|
19
|
+
'no-redeclare': 'off', // Ts(2451)
|
|
20
|
+
'no-setter-return': 'off', // Ts(2408)
|
|
21
|
+
'no-this-before-super': 'off', // Ts(2376) & ts(17009)
|
|
22
|
+
'no-undef': 'off', // Ts(2304) & ts(2552)
|
|
23
|
+
'no-unreachable': 'off', // Ts(7027)
|
|
24
|
+
'no-unsafe-negation': 'off', // Ts(2365) & ts(2322) & ts(2358)
|
|
25
|
+
// 'no-var': 'error', // Ts transpiles let/const to var, so no need for vars any more
|
|
26
|
+
'no-with': 'off' // Ts(1101) & ts(2410)
|
|
27
|
+
// 'prefer-const': 'error', // Ts provides better types with const
|
|
28
|
+
// 'prefer-rest-params': 'error', // Ts provides better types with rest args over arguments
|
|
29
|
+
// 'prefer-spread': 'error' // Ts transpiles spread to apply, so no need for manual apply
|
|
30
|
+
};
|
|
10
31
|
|
|
11
32
|
const configs = [
|
|
12
33
|
{
|
|
13
|
-
files: [
|
|
34
|
+
files: [...filePatterns.baseJsTs, ...filePatterns.commonJsTs],
|
|
14
35
|
languageOptions: {
|
|
15
36
|
sourceType: 'commonjs'
|
|
16
37
|
},
|
|
17
38
|
name: 'CJS files'
|
|
18
39
|
},
|
|
19
40
|
{
|
|
20
|
-
files: [
|
|
41
|
+
files: [...filePatterns.esmJsTs],
|
|
21
42
|
languageOptions: {
|
|
22
43
|
sourceType: 'module'
|
|
23
44
|
},
|
|
24
45
|
name: 'ESM files'
|
|
25
46
|
},
|
|
26
47
|
{
|
|
27
|
-
files: [
|
|
48
|
+
files: [...filePatterns.allJs, ...filePatterns.allTs],
|
|
28
49
|
linterOptions: {
|
|
29
50
|
reportUnusedDisableDirectives: 'error',
|
|
30
51
|
reportUnusedInlineConfigs: 'error'
|
|
@@ -104,7 +125,7 @@ const configs = [
|
|
|
104
125
|
'class-methods-use-this': 'error',
|
|
105
126
|
complexity: [
|
|
106
127
|
'error',
|
|
107
|
-
{ max:
|
|
128
|
+
{ max: thresholds.complexityLow, variant: 'modified' }
|
|
108
129
|
],
|
|
109
130
|
'consistent-return': 'error',
|
|
110
131
|
// Disabled due to 'unicorn/no-this-assignment
|
|
@@ -130,19 +151,19 @@ const configs = [
|
|
|
130
151
|
'init-declarations': 'off',
|
|
131
152
|
'logical-assignment-operators': ['error', 'always'],
|
|
132
153
|
'max-classes-per-file': ['error', 1],
|
|
133
|
-
'max-depth': ['error', { max:
|
|
134
|
-
'max-lines': ['error',
|
|
154
|
+
'max-depth': ['error', { max: thresholds.nested }],
|
|
155
|
+
'max-lines': ['error', thresholds.maxLines],
|
|
135
156
|
'max-lines-per-function': [
|
|
136
157
|
'error',
|
|
137
158
|
{
|
|
138
|
-
max:
|
|
159
|
+
max: thresholds.maxFunctionLines,
|
|
139
160
|
skipBlankLines: true,
|
|
140
161
|
skipComments: true
|
|
141
162
|
}
|
|
142
163
|
],
|
|
143
|
-
'max-nested-callbacks': ['error', { max:
|
|
144
|
-
'max-params': ['error', { max:
|
|
145
|
-
'max-statements': ['error', { max:
|
|
164
|
+
'max-nested-callbacks': ['error', { max: thresholds.nested }],
|
|
165
|
+
'max-params': ['error', { max: thresholds.maxParameters }],
|
|
166
|
+
'max-statements': ['error', { max: thresholds.maxStatements }],
|
|
146
167
|
'new-cap': 'error',
|
|
147
168
|
'no-alert': 'error',
|
|
148
169
|
'no-array-constructor': 'error',
|
|
@@ -354,10 +375,11 @@ const configs = [
|
|
|
354
375
|
{
|
|
355
376
|
files: [
|
|
356
377
|
// Patterns for jest-config, vitest-config
|
|
357
|
-
|
|
358
|
-
|
|
378
|
+
...filePatterns.testAllJs,
|
|
379
|
+
...filePatterns.testAllTs,
|
|
359
380
|
// Pattern for playwright-config
|
|
360
|
-
|
|
381
|
+
...filePatterns.playwrightJs,
|
|
382
|
+
...filePatterns.playwrightTs
|
|
361
383
|
],
|
|
362
384
|
name: 'eslint (test and pwtest files)',
|
|
363
385
|
rules: {
|
|
@@ -370,7 +392,7 @@ const configs = [
|
|
|
370
392
|
// Undefined is a common value to test no value
|
|
371
393
|
'no-undefined': 'off',
|
|
372
394
|
// Tests frequently check array elements, destructuring is
|
|
373
|
-
//
|
|
395
|
+
// less intuitive
|
|
374
396
|
'prefer-destructuring': 'off',
|
|
375
397
|
// Regexes in tests frequently check for match patterns, but
|
|
376
398
|
// groups are not captured
|
|
@@ -379,6 +401,13 @@ const configs = [
|
|
|
379
401
|
// runner awaits implicitly
|
|
380
402
|
'require-await': 'off'
|
|
381
403
|
}
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
files: [...filePatterns.allTs],
|
|
407
|
+
name: 'eslint (rules covered by typescript)',
|
|
408
|
+
rules: {
|
|
409
|
+
...eslintRulesCoveredByTsc
|
|
410
|
+
}
|
|
382
411
|
}
|
|
383
412
|
];
|
|
384
413
|
|
|
@@ -386,9 +415,8 @@ if (process.env.ENABLE_ESLINT_CORE_RULE_DUPLICATES === 'true') {
|
|
|
386
415
|
const { builtinRules } = await import('eslint/use-at-your-own-risk');
|
|
387
416
|
const complexity = builtinRules.get('complexity');
|
|
388
417
|
|
|
389
|
-
const complexityThresholdHigh = 15;
|
|
390
418
|
const coreDuplicateConfig = {
|
|
391
|
-
files: [
|
|
419
|
+
files: [...filePatterns.allJs, ...filePatterns.allTs],
|
|
392
420
|
name: 'eslint core duplicates (all files)',
|
|
393
421
|
plugins: {
|
|
394
422
|
// Add plugin that duplicates the required rules
|
|
@@ -397,7 +425,7 @@ if (process.env.ENABLE_ESLINT_CORE_RULE_DUPLICATES === 'true') {
|
|
|
397
425
|
rules: {
|
|
398
426
|
'core/complexity': [
|
|
399
427
|
'error',
|
|
400
|
-
{ max:
|
|
428
|
+
{ max: thresholds.complexityHigh, variant: 'modified' }
|
|
401
429
|
]
|
|
402
430
|
}
|
|
403
431
|
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { defineConfig } from 'eslint/config';
|
|
2
2
|
import eslintCommentsPlugin from '@eslint-community/eslint-plugin-eslint-comments';
|
|
3
|
+
import { filePatterns } from './settings.js';
|
|
3
4
|
|
|
4
5
|
// Create local variable due to vitest v4 coverage changes
|
|
5
6
|
const config = defineConfig({
|
|
6
|
-
files: [
|
|
7
|
+
files: [...filePatterns.allJs, ...filePatterns.allTs],
|
|
7
8
|
name: 'eslint-comments (all files)',
|
|
8
9
|
plugins: { comments: eslintCommentsPlugin },
|
|
9
10
|
rules: {
|
package/esm-config.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { defineConfig } from 'eslint/config';
|
|
2
|
+
import { filePatterns } from './settings.js';
|
|
2
3
|
import unicornPlugin from 'eslint-plugin-unicorn';
|
|
3
4
|
|
|
4
5
|
// Create local variable due to vitest v4 coverage changes
|
|
5
6
|
const config = defineConfig({
|
|
6
|
-
files: [
|
|
7
|
+
files: [...filePatterns.baseJsTs],
|
|
7
8
|
languageOptions: {
|
|
8
9
|
sourceType: 'module'
|
|
9
10
|
},
|
|
10
|
-
name: 'esm (js files)',
|
|
11
|
+
name: 'esm (js/ts files)',
|
|
11
12
|
plugins: { unicorn: unicornPlugin },
|
|
12
13
|
rules: {
|
|
13
14
|
'unicorn/prefer-module': 'error',
|
package/jest-config.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { defineConfig } from 'eslint/config';
|
|
2
|
+
import { filePatterns } from './settings.js';
|
|
2
3
|
import globals from 'globals';
|
|
3
4
|
import jestPlugin from 'eslint-plugin-jest';
|
|
4
5
|
|
|
5
6
|
// Create local variable due to vitest v4 coverage changes
|
|
6
7
|
const config = defineConfig({
|
|
7
|
-
files: [
|
|
8
|
-
'**/__tests__/**/*.{js,mjs,cjs}',
|
|
9
|
-
'**/?(*.)+(spec|test).{js,mjs,cjs}'
|
|
10
|
-
],
|
|
8
|
+
files: [...filePatterns.testAllJs, ...filePatterns.testAllTs],
|
|
11
9
|
languageOptions: {
|
|
12
10
|
globals: {
|
|
13
11
|
...globals.jest
|
|
@@ -31,6 +29,7 @@ const config = defineConfig({
|
|
|
31
29
|
'jest/no-disabled-tests': 'error',
|
|
32
30
|
'jest/no-done-callback': 'error',
|
|
33
31
|
'jest/no-duplicate-hooks': 'error',
|
|
32
|
+
'jest/no-error-equal': 'off',
|
|
34
33
|
'jest/no-export': 'error',
|
|
35
34
|
'jest/no-focused-tests': 'error',
|
|
36
35
|
'jest/no-hooks': 'off',
|
|
@@ -59,6 +58,8 @@ const config = defineConfig({
|
|
|
59
58
|
'jest/no-standalone-expect': 'error',
|
|
60
59
|
'jest/no-test-prefixes': 'error',
|
|
61
60
|
'jest/no-test-return-statement': 'error',
|
|
61
|
+
'jest/no-unnecessary-assertion': 'off',
|
|
62
|
+
'jest/no-unneeded-async-expect-function': 'error',
|
|
62
63
|
'jest/no-untyped-mock-factory': 'off',
|
|
63
64
|
'jest/prefer-called-with': 'error',
|
|
64
65
|
'jest/prefer-comparison-matcher': 'error',
|
|
@@ -73,6 +74,7 @@ const config = defineConfig({
|
|
|
73
74
|
'jest/prefer-jest-mocked': 'error',
|
|
74
75
|
'jest/prefer-lowercase-title': 'error',
|
|
75
76
|
'jest/prefer-mock-promise-shorthand': 'error',
|
|
77
|
+
'jest/prefer-mock-return-shorthand': 'error',
|
|
76
78
|
'jest/prefer-snapshot-hint': 'error',
|
|
77
79
|
'jest/prefer-spy-on': 'error',
|
|
78
80
|
'jest/prefer-strict-equal': 'error',
|
|
@@ -83,9 +85,11 @@ const config = defineConfig({
|
|
|
83
85
|
'jest/require-hook': 'error',
|
|
84
86
|
'jest/require-to-throw-message': 'error',
|
|
85
87
|
'jest/require-top-level-describe': 'error',
|
|
88
|
+
'jest/unbound-method': 'off',
|
|
86
89
|
'jest/valid-describe-callback': 'error',
|
|
87
90
|
'jest/valid-expect': 'error',
|
|
88
91
|
'jest/valid-expect-in-promise': 'error',
|
|
92
|
+
'jest/valid-expect-with-promise': 'off',
|
|
89
93
|
'jest/valid-mock-module-path': 'error',
|
|
90
94
|
'jest/valid-title': 'error'
|
|
91
95
|
}
|
package/jsdoc-configs.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { defineConfig } from 'eslint/config';
|
|
2
|
+
import { filePatterns } from './settings.js';
|
|
3
|
+
import jsdocPlugin from 'eslint-plugin-jsdoc';
|
|
4
|
+
|
|
5
|
+
// Create local variable due to vitest v4 coverage changes
|
|
6
|
+
const config = defineConfig(
|
|
7
|
+
{
|
|
8
|
+
files: [...filePatterns.allJs, ...filePatterns.allTs],
|
|
9
|
+
name: 'jsdoc (all files)',
|
|
10
|
+
plugins: { jsdoc: jsdocPlugin },
|
|
11
|
+
rules: {
|
|
12
|
+
'jsdoc/check-access': 'error', // Recommended
|
|
13
|
+
'jsdoc/check-alignment': 'error', // Recommended
|
|
14
|
+
'jsdoc/check-indentation': [
|
|
15
|
+
'error',
|
|
16
|
+
// Exclude default, as well as tags covered by check-line-alignment
|
|
17
|
+
{
|
|
18
|
+
excludeTags: [
|
|
19
|
+
'example',
|
|
20
|
+
'param',
|
|
21
|
+
'property',
|
|
22
|
+
'returns',
|
|
23
|
+
'throws',
|
|
24
|
+
'typedef'
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
'jsdoc/check-line-alignment': [
|
|
29
|
+
'error',
|
|
30
|
+
'always',
|
|
31
|
+
{
|
|
32
|
+
tags: ['param', 'property', 'returns', 'throws', 'typedef']
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
'jsdoc/check-param-names': 'error', // Recommended
|
|
36
|
+
'jsdoc/check-property-names': 'error', // Recommended
|
|
37
|
+
'jsdoc/check-syntax': 'error',
|
|
38
|
+
'jsdoc/check-tag-names': 'error', // Recommended
|
|
39
|
+
'jsdoc/check-template-names': 'error',
|
|
40
|
+
'jsdoc/check-types': 'error', // Recommended
|
|
41
|
+
'jsdoc/check-values': 'error', // Recommended
|
|
42
|
+
'jsdoc/convert-to-jsdoc-comments': 'off',
|
|
43
|
+
'jsdoc/empty-tags': 'error', // Recommended
|
|
44
|
+
'jsdoc/escape-inline-tags': 'error',
|
|
45
|
+
'jsdoc/implements-on-classes': 'error', // Recommended
|
|
46
|
+
'jsdoc/imports-as-dependencies': 'error',
|
|
47
|
+
'jsdoc/informative-docs': 'error',
|
|
48
|
+
'jsdoc/lines-before-block': 'off',
|
|
49
|
+
'jsdoc/match-description': 'error',
|
|
50
|
+
'jsdoc/multiline-blocks': 'error', // Recommended
|
|
51
|
+
'jsdoc/no-bad-blocks': 'error',
|
|
52
|
+
'jsdoc/no-blank-blocks': 'error',
|
|
53
|
+
'jsdoc/no-defaults': ['error', { contexts: ['any'] }],
|
|
54
|
+
'jsdoc/no-missing-syntax': 'off',
|
|
55
|
+
'jsdoc/no-multi-asterisks': 'error', // Recommended
|
|
56
|
+
'jsdoc/no-restricted-syntax': 'off',
|
|
57
|
+
'jsdoc/no-types': 'off',
|
|
58
|
+
'jsdoc/no-undefined-types': 'error', // Recommended
|
|
59
|
+
'jsdoc/prefer-import-tag': 'error',
|
|
60
|
+
'jsdoc/reject-any-type': 'error', // Recommended
|
|
61
|
+
'jsdoc/reject-function-type': 'error', // Recommended
|
|
62
|
+
'jsdoc/require-asterisk-prefix': 'error',
|
|
63
|
+
'jsdoc/require-description': 'error',
|
|
64
|
+
'jsdoc/require-description-complete-sentence': 'error',
|
|
65
|
+
'jsdoc/require-example': 'off',
|
|
66
|
+
'jsdoc/require-file-overview': 'off',
|
|
67
|
+
'jsdoc/require-hyphen-before-param-description': ['error', 'never'],
|
|
68
|
+
'jsdoc/require-jsdoc': [
|
|
69
|
+
'error',
|
|
70
|
+
{
|
|
71
|
+
publicOnly: true,
|
|
72
|
+
require: {
|
|
73
|
+
ArrowFunctionExpression: true,
|
|
74
|
+
ClassDeclaration: true,
|
|
75
|
+
ClassExpression: true,
|
|
76
|
+
FunctionDeclaration: true,
|
|
77
|
+
FunctionExpression: true
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
], // Recommended
|
|
81
|
+
'jsdoc/require-next-description': 'error',
|
|
82
|
+
'jsdoc/require-next-type': 'error', // Recommended
|
|
83
|
+
'jsdoc/require-param': 'error', // Recommended
|
|
84
|
+
'jsdoc/require-param-description': 'error', // Recommended
|
|
85
|
+
'jsdoc/require-param-name': 'error', // Recommended
|
|
86
|
+
'jsdoc/require-param-type': 'error', // Recommended
|
|
87
|
+
'jsdoc/require-property': 'error', // Recommended
|
|
88
|
+
'jsdoc/require-property-description': 'error', // Recommended
|
|
89
|
+
'jsdoc/require-property-name': 'error', // Recommended
|
|
90
|
+
'jsdoc/require-property-type': 'error', // Recommended
|
|
91
|
+
'jsdoc/require-rejects': 'off',
|
|
92
|
+
'jsdoc/require-returns': 'error', // Recommended
|
|
93
|
+
'jsdoc/require-returns-check': 'error', // Recommended
|
|
94
|
+
'jsdoc/require-returns-description': 'error', // Recommended
|
|
95
|
+
'jsdoc/require-returns-type': 'error', // Recommended
|
|
96
|
+
'jsdoc/require-template': 'error',
|
|
97
|
+
'jsdoc/require-template-description': 'error',
|
|
98
|
+
'jsdoc/require-throws': 'error',
|
|
99
|
+
'jsdoc/require-throws-description': 'error',
|
|
100
|
+
'jsdoc/require-throws-type': 'error', // Recommended
|
|
101
|
+
'jsdoc/require-yields': 'error', // Recommended
|
|
102
|
+
'jsdoc/require-yields-check': 'error', // Recommended
|
|
103
|
+
'jsdoc/require-yields-description': 'error',
|
|
104
|
+
'jsdoc/require-yields-type': 'error', // Recommended
|
|
105
|
+
'jsdoc/sort-tags': 'error',
|
|
106
|
+
'jsdoc/tag-lines': [
|
|
107
|
+
// Recommended
|
|
108
|
+
'error',
|
|
109
|
+
'never',
|
|
110
|
+
{ applyToEndTag: false, startLines: 1 }
|
|
111
|
+
],
|
|
112
|
+
'jsdoc/ts-method-signature-style': 'off',
|
|
113
|
+
'jsdoc/ts-no-empty-object-type': 'off',
|
|
114
|
+
'jsdoc/ts-no-unnecessary-template-expression': 'off',
|
|
115
|
+
'jsdoc/ts-prefer-function-type': 'off',
|
|
116
|
+
'jsdoc/type-formatting': 'off',
|
|
117
|
+
'jsdoc/valid-types': 'error' // Recommended
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
files: [...filePatterns.allTs],
|
|
122
|
+
name: 'jsdoc (rules covered by typescript)',
|
|
123
|
+
rules: {
|
|
124
|
+
// Disable types in JSDoc since redundant with TS.
|
|
125
|
+
'jsdoc/no-types': 'error',
|
|
126
|
+
'jsdoc/require-param-type': 'off',
|
|
127
|
+
'jsdoc/require-property-type': 'off',
|
|
128
|
+
'jsdoc/require-returns-type': 'off',
|
|
129
|
+
'jsdoc/require-throws-type': 'off'
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
export default config;
|
package/node-config.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { defineConfig } from 'eslint/config';
|
|
2
|
+
import { filePatterns } from './settings.js';
|
|
2
3
|
import globals from 'globals';
|
|
3
4
|
import nodePlugin from 'eslint-plugin-n';
|
|
4
5
|
|
|
5
6
|
// Create local variable due to vitest v4 coverage changes
|
|
6
7
|
const config = defineConfig({
|
|
7
|
-
files: [
|
|
8
|
+
files: [...filePatterns.allJs, ...filePatterns.allTs],
|
|
8
9
|
languageOptions: {
|
|
9
10
|
globals: {
|
|
10
11
|
...globals.node
|
|
@@ -15,7 +16,14 @@ const config = defineConfig({
|
|
|
15
16
|
rules: {
|
|
16
17
|
'node/callback-return': 'error',
|
|
17
18
|
'node/exports-style': 'error',
|
|
18
|
-
|
|
19
|
+
// Disable for "*.ts" since it adds a ".js" extension to all imports,
|
|
20
|
+
// regardless of the file type. See
|
|
21
|
+
// https://github.com/eslint-community/eslint-plugin-n/issues/422.
|
|
22
|
+
'node/file-extension-in-import': [
|
|
23
|
+
'error',
|
|
24
|
+
'always',
|
|
25
|
+
{ '.cts': 'never', '.mts': 'never', '.ts': 'never' }
|
|
26
|
+
],
|
|
19
27
|
'node/global-require': 'error',
|
|
20
28
|
'node/handle-callback-err': 'error',
|
|
21
29
|
'node/hashbang': 'error',
|