@cto.af/eslint-config 3.0.2 → 4.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/LICENSE.md +1 -1
- package/README.md +60 -1
- package/all.js +13 -0
- package/allModule.js +6 -0
- package/ava.js +13 -53
- package/es6.js +7 -0
- package/globals.js +3 -0
- package/ignores.js +9 -0
- package/index.js +6 -392
- package/js.js +23 -0
- package/jsdoc.js +12 -75
- package/jsdoc_ts.js +12 -0
- package/markdown.js +35 -0
- package/mjs.js +11 -0
- package/module.js +8 -0
- package/package.json +28 -24
- package/rules/ava.js +44 -0
- package/rules/js.js +392 -0
- package/rules/jsdoc.js +69 -0
- package/rules/ts.js +205 -0
- package/ts.js +13 -220
- package/modules.js +0 -32
- package/typescript.js +0 -17
package/LICENSE.md
CHANGED
package/README.md
CHANGED
|
@@ -1 +1,60 @@
|
|
|
1
|
-
|
|
1
|
+
# @cto-af/eslint-config
|
|
2
|
+
|
|
3
|
+
EsLint rules for [cto.af](https://cto.af) projects, using ESLint flat configs.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install -D eslint @cto-af/eslint-config
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Optionally:
|
|
12
|
+
```sh
|
|
13
|
+
npm install -D typescript-eslint typescript eslint-plugin-ava eslint-plugin-jsdoc eslint-plugin-markdown
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## CommonJS project:
|
|
17
|
+
|
|
18
|
+
eslint.config.js
|
|
19
|
+
|
|
20
|
+
```cjs
|
|
21
|
+
module.exports = require('@cto.af/eslint-config');
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## ES6 project:
|
|
25
|
+
|
|
26
|
+
eslint.config.js
|
|
27
|
+
|
|
28
|
+
```mjs
|
|
29
|
+
import es6 from '@cto.af/eslint-config/es6.js';
|
|
30
|
+
|
|
31
|
+
export default es6;
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## TS Project:
|
|
35
|
+
|
|
36
|
+
eslint.config.js:
|
|
37
|
+
|
|
38
|
+
```mjs
|
|
39
|
+
import es6 from '@cto.af/eslint-config/es6.js';
|
|
40
|
+
import ts from '@cto.af/eslint-config/ts.js';
|
|
41
|
+
|
|
42
|
+
export default [
|
|
43
|
+
...es6,
|
|
44
|
+
ts,
|
|
45
|
+
];
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Turn on everything:
|
|
49
|
+
|
|
50
|
+
eslint.config.js:
|
|
51
|
+
|
|
52
|
+
```mjs
|
|
53
|
+
import all from '@cto.af/eslint-config/all.js';
|
|
54
|
+
import mod from '@cto.af/eslint-config/module.js';
|
|
55
|
+
|
|
56
|
+
export default [
|
|
57
|
+
...all,
|
|
58
|
+
mod,
|
|
59
|
+
];
|
|
60
|
+
```
|
package/all.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Turn on everything. Requires all of the optional dependencies.
|
|
4
|
+
module.exports = [
|
|
5
|
+
...require('./ignores.js'),
|
|
6
|
+
...require('./js'),
|
|
7
|
+
...require('./mjs'),
|
|
8
|
+
...require('./ts'),
|
|
9
|
+
...require('./jsdoc'),
|
|
10
|
+
...require('./jsdoc_ts'),
|
|
11
|
+
...require('./ava'),
|
|
12
|
+
...require('./markdown'),
|
|
13
|
+
];
|
package/allModule.js
ADDED
package/ava.js
CHANGED
|
@@ -1,57 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
// root: true,
|
|
13
|
-
// extends: '@cto.af'
|
|
14
|
-
// }
|
|
15
|
-
|
|
16
|
-
module.exports = {
|
|
17
|
-
plugins: [
|
|
18
|
-
'ava',
|
|
3
|
+
const {rules} = require('./rules/ava.js');
|
|
4
|
+
module.exports = [{
|
|
5
|
+
files: [
|
|
6
|
+
'test/**.test.*',
|
|
7
|
+
'test/**.ava.*',
|
|
8
|
+
'test/**.spec.*',
|
|
9
|
+
'ava/**.test.*',
|
|
10
|
+
'ava/**.ava.*',
|
|
11
|
+
'ava/**.spec.*',
|
|
19
12
|
],
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
'ava/hooks-order': 'error',
|
|
23
|
-
'ava/max-asserts': 'off',
|
|
24
|
-
'ava/no-async-fn-without-await': 'error',
|
|
25
|
-
'ava/no-duplicate-modifiers': 'error',
|
|
26
|
-
'ava/no-identical-title': 'error',
|
|
27
|
-
'ava/no-ignored-test-files': 'off', // Buggy
|
|
28
|
-
'ava/no-incorrect-deep-equal': 'error',
|
|
29
|
-
'ava/no-import-test-files': 'error',
|
|
30
|
-
'ava/no-inline-assertions': 'error',
|
|
31
|
-
'ava/no-nested-tests': 'error',
|
|
32
|
-
'ava/no-only-test': 'error',
|
|
33
|
-
'ava/no-skip-assert': 'error',
|
|
34
|
-
'ava/no-skip-test': 'error',
|
|
35
|
-
'ava/no-todo-implementation': 'error',
|
|
36
|
-
'ava/no-todo-test': 'error',
|
|
37
|
-
'ava/no-unknown-modifiers': 'error',
|
|
38
|
-
'ava/prefer-async-await': 'error',
|
|
39
|
-
'ava/prefer-power-assert': 'off',
|
|
40
|
-
'ava/prefer-t-regex': 'error',
|
|
41
|
-
'ava/test-title-format': 'error',
|
|
42
|
-
'ava/test-title': 'error',
|
|
43
|
-
'ava/use-t-throws-async-well': 'error',
|
|
44
|
-
'ava/use-t-well': 'error',
|
|
45
|
-
'ava/use-t': 'error',
|
|
46
|
-
'ava/use-test': 'error',
|
|
47
|
-
'ava/use-true-false': 'off',
|
|
48
|
-
|
|
49
|
-
// [Possible Errors](https://github.com/eslint-community/eslint-plugin-n#possible-errors)
|
|
50
|
-
'n/no-extraneous-import': ['error', {
|
|
51
|
-
// This is an extraneous error because of the way ava is built and the
|
|
52
|
-
// way that esplugin-n finds depedencies.
|
|
53
|
-
allowModules: ['ava'],
|
|
54
|
-
}],
|
|
55
|
-
'n/no-extraneous-require': ['error', {allowModules: ['ava']}],
|
|
13
|
+
plugins: {
|
|
14
|
+
ava: require('eslint-plugin-ava'),
|
|
56
15
|
},
|
|
57
|
-
|
|
16
|
+
rules,
|
|
17
|
+
}];
|
package/es6.js
ADDED
package/globals.js
ADDED
package/ignores.js
ADDED
package/index.js
CHANGED
|
@@ -1,394 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
plugins: [
|
|
10
|
-
'n',
|
|
11
|
-
],
|
|
12
|
-
ignorePatterns: [
|
|
13
|
-
'coverage/',
|
|
14
|
-
'node_modules/',
|
|
15
|
-
'docs/',
|
|
16
|
-
],
|
|
17
|
-
parserOptions: {
|
|
18
|
-
ecmaVersion: 2020,
|
|
19
|
-
},
|
|
20
|
-
reportUnusedDisableDirectives: true,
|
|
21
|
-
rules: {
|
|
22
|
-
// Last updated 2023-06-26, v8.43.0
|
|
23
|
-
// eslint-plugin-n 16.0.1
|
|
24
|
-
|
|
25
|
-
// [Possible Problems](https://eslint.org/docs/rules/#possible-problems)
|
|
26
|
-
'array-callback-return': ['error', {allowImplicit: true}],
|
|
27
|
-
'constructor-super': 'error',
|
|
28
|
-
'for-direction': 'error',
|
|
29
|
-
'getter-return': 'error',
|
|
30
|
-
'no-async-promise-executor': 'error',
|
|
31
|
-
'no-await-in-loop': 'off', // I'll figure these out myself.
|
|
32
|
-
'no-class-assign': 'error',
|
|
33
|
-
'no-compare-neg-zero': 'error',
|
|
34
|
-
'no-cond-assign': 'error',
|
|
35
|
-
'no-const-assign': 'error',
|
|
36
|
-
'no-constant-binary-expression': 'error',
|
|
37
|
-
'no-constant-condition': 'error',
|
|
38
|
-
'no-constructor-return': 'error',
|
|
39
|
-
'no-control-regex': 'error',
|
|
40
|
-
'no-debugger': 'error',
|
|
41
|
-
'no-dupe-args': 'error',
|
|
42
|
-
'no-dupe-class-members': 'error',
|
|
43
|
-
'no-dupe-else-if': 'error',
|
|
44
|
-
'no-dupe-keys': 'error',
|
|
45
|
-
'no-duplicate-case': 'error',
|
|
46
|
-
'no-duplicate-imports': 'error',
|
|
47
|
-
'no-empty-character-class': 'error',
|
|
48
|
-
'no-empty-pattern': 'error',
|
|
49
|
-
'no-ex-assign': 'error',
|
|
50
|
-
'no-fallthrough': 'error',
|
|
51
|
-
'no-func-assign': 'error',
|
|
52
|
-
'no-import-assign': 'error',
|
|
53
|
-
'no-inner-declarations': 'error',
|
|
54
|
-
'no-invalid-regexp': 'error',
|
|
55
|
-
'no-irregular-whitespace': 'error',
|
|
56
|
-
'no-loss-of-precision': 'error',
|
|
57
|
-
'no-misleading-character-class': 'error',
|
|
58
|
-
'no-new-native-nonconstructor': 'error',
|
|
59
|
-
'no-new-symbol': 'error',
|
|
60
|
-
'no-obj-calls': 'error',
|
|
61
|
-
'no-promise-executor-return': 'error',
|
|
62
|
-
'no-prototype-builtins': 'error',
|
|
63
|
-
'no-self-assign': 'error',
|
|
64
|
-
'no-self-compare': 'error',
|
|
65
|
-
'no-setter-return': 'error',
|
|
66
|
-
'no-sparse-arrays': 'error',
|
|
67
|
-
'no-template-curly-in-string': 'error',
|
|
68
|
-
'no-this-before-super': 'error',
|
|
69
|
-
'no-undef': 'error',
|
|
70
|
-
'no-unexpected-multiline': 'error',
|
|
71
|
-
'no-unmodified-loop-condition': 'error',
|
|
72
|
-
'no-unreachable': 'error',
|
|
73
|
-
'no-unreachable-loop': 'error',
|
|
74
|
-
'no-unsafe-finally': 'error',
|
|
75
|
-
'no-unsafe-negation': 'error',
|
|
76
|
-
'no-unsafe-optional-chaining': 'error',
|
|
77
|
-
'no-unused-private-class-members': 'error',
|
|
78
|
-
'no-unused-vars': [
|
|
79
|
-
'error', {
|
|
80
|
-
args: 'none',
|
|
81
|
-
argsIgnorePattern: '^_',
|
|
82
|
-
caughtErrors: 'all',
|
|
83
|
-
caughtErrorsIgnorePattern: '^(_|ignore)',
|
|
84
|
-
varsIgnorePattern: '^_',
|
|
85
|
-
},
|
|
86
|
-
],
|
|
87
|
-
'no-use-before-define': 'error',
|
|
88
|
-
'no-useless-backreference': 'error',
|
|
89
|
-
'require-atomic-updates': 'error',
|
|
90
|
-
'use-isnan': 'error',
|
|
91
|
-
'valid-typeof': ['error', {requireStringLiterals: true}],
|
|
92
|
-
|
|
93
|
-
// [Suggestions](https://eslint.org/docs/rules/#suggestions)
|
|
94
|
-
'accessor-pairs': 'error',
|
|
95
|
-
'arrow-body-style': ['error', 'as-needed'],
|
|
96
|
-
'block-scoped-var': 'error',
|
|
97
|
-
'camelcase': 'off', // If I had started with this.
|
|
98
|
-
'capitalized-comments': ['error', 'always', {
|
|
99
|
-
ignoreConsecutiveComments: true,
|
|
100
|
-
ignorePattern: 'c8',
|
|
101
|
-
}],
|
|
102
|
-
'class-methods-use-this': 'warn',
|
|
103
|
-
// This one is pedantic even for me.
|
|
104
|
-
'complexity': 'off',
|
|
105
|
-
'consistent-return': 'error',
|
|
106
|
-
'consistent-this': 'off', // Not needed anymore with =>
|
|
107
|
-
'curly': ['error', 'multi-line'],
|
|
108
|
-
// I use exhastive cases a lot, which makes the default unreachable
|
|
109
|
-
'default-case': 'off',
|
|
110
|
-
'default-case-last': 'error',
|
|
111
|
-
'default-param-last': 'error',
|
|
112
|
-
'dot-notation': 'error',
|
|
113
|
-
'eqeqeq': ['error', 'always', {null: 'ignore'}],
|
|
114
|
-
'func-name-matching': 'error',
|
|
115
|
-
'func-names': ['error', 'as-needed'],
|
|
116
|
-
'func-style': ['error', 'declaration', {allowArrowFunctions: true}],
|
|
117
|
-
'grouped-accessor-pairs': 'error',
|
|
118
|
-
'guard-for-in': 'error',
|
|
119
|
-
'id-denylist': 'off', // Not needed
|
|
120
|
-
'id-length': 'off', // Not needed
|
|
121
|
-
'id-match': 'off', // Not needed
|
|
122
|
-
'init-declarations': 'error',
|
|
123
|
-
'logical-assignment-operators': 'off', // No.
|
|
124
|
-
'max-classes-per-file': 'off', // No.
|
|
125
|
-
'max-depth': 'off', // No.
|
|
126
|
-
'max-lines': 'off', // No.
|
|
127
|
-
'max-lines-per-function': 'off', // No.
|
|
128
|
-
'max-nested-callbacks': 'off', // No.
|
|
129
|
-
'max-params': ['error', 4],
|
|
130
|
-
'max-statements': 'off', // No.
|
|
131
|
-
'multiline-comment-style': ['error', 'separate-lines'],
|
|
132
|
-
'new-cap': 'error',
|
|
133
|
-
'no-array-constructor': 'error',
|
|
134
|
-
'no-alert': 'error',
|
|
135
|
-
'no-bitwise': 'off', // Lol. Not in these projects
|
|
136
|
-
'no-caller': 'error',
|
|
137
|
-
'no-case-declarations': 'error',
|
|
138
|
-
'no-confusing-arrow': 'error',
|
|
139
|
-
'no-console': 'error',
|
|
140
|
-
'no-continue': 'off', // Why?
|
|
141
|
-
'no-delete-var': 'error',
|
|
142
|
-
'no-div-regex': 'error',
|
|
143
|
-
'no-else-return': 'error',
|
|
144
|
-
'no-empty': 'error',
|
|
145
|
-
'no-empty-function': 'error',
|
|
146
|
-
'no-empty-static-block': 'error',
|
|
147
|
-
'no-eq-null': 'off', // I disagree with this one.
|
|
148
|
-
'no-eval': 'error',
|
|
149
|
-
'no-extend-native': 'error',
|
|
150
|
-
'no-extra-bind': 'error',
|
|
151
|
-
'no-extra-boolean-cast': 'error',
|
|
152
|
-
'no-extra-label': 'error',
|
|
153
|
-
'no-extra-semi': 'error',
|
|
154
|
-
'no-floating-decimal': 'error',
|
|
155
|
-
'no-global-assign': 'error',
|
|
156
|
-
'no-implicit-coercion': 'error',
|
|
157
|
-
'no-implicit-globals': 'error',
|
|
158
|
-
'no-implied-eval': 'error',
|
|
159
|
-
'no-inline-comments': 'off', // Meta.
|
|
160
|
-
'no-invalid-this': 'error',
|
|
161
|
-
'no-iterator': 'error',
|
|
162
|
-
'no-label-var': 'error',
|
|
163
|
-
'no-labels': 'error',
|
|
164
|
-
'no-lone-blocks': 'error',
|
|
165
|
-
'no-lonely-if': 'error',
|
|
166
|
-
'no-loop-func': 'error',
|
|
167
|
-
// No shot at this for node-cbor. For other projects, yes.
|
|
168
|
-
'no-magic-numbers': 'off',
|
|
169
|
-
'no-mixed-operators': 'error',
|
|
170
|
-
'no-multi-assign': 'error',
|
|
171
|
-
'no-multi-str': 'error',
|
|
172
|
-
'no-negated-condition': 'error',
|
|
173
|
-
'no-nested-ternary': 'error',
|
|
174
|
-
'no-new': 'error',
|
|
175
|
-
'no-new-func': 'error',
|
|
176
|
-
'no-new-wrappers': 'warn',
|
|
177
|
-
'no-nonoctal-decimal-escape': 'error',
|
|
178
|
-
'no-object-constructor': 'error',
|
|
179
|
-
'no-octal': 'error',
|
|
180
|
-
'no-octal-escape': 'warn',
|
|
181
|
-
'no-param-reassign': 'off', // I do this all the time.
|
|
182
|
-
'no-plusplus': 'off', // What?
|
|
183
|
-
'no-proto': 'error',
|
|
184
|
-
'no-redeclare': 'error',
|
|
185
|
-
'no-regex-spaces': 'error',
|
|
186
|
-
'no-restricted-exports': 'off', // Not needed
|
|
187
|
-
'no-restricted-globals': 'off', // Not needed
|
|
188
|
-
'no-restricted-imports': 'off', // Not needed
|
|
189
|
-
'no-restricted-properties': 'off', // Not needed
|
|
190
|
-
'no-restricted-syntax': 'off', // Not needed
|
|
191
|
-
'no-return-assign': 'error',
|
|
192
|
-
'no-script-url': 'error',
|
|
193
|
-
'no-sequences': 'error',
|
|
194
|
-
'no-shadow': 'error',
|
|
195
|
-
'no-shadow-restricted-names': 'error',
|
|
196
|
-
'no-ternary': 'off', // No.
|
|
197
|
-
'no-throw-literal': 'error',
|
|
198
|
-
'no-undef-init': 'off', // Turns out I need this often enough
|
|
199
|
-
'no-undefined': 'off', // No.
|
|
200
|
-
'no-underscore-dangle': 'off', // Maybe one day.
|
|
201
|
-
'no-unneeded-ternary': 'error',
|
|
202
|
-
'no-unused-expressions': ['error', {allowShortCircuit: true}],
|
|
203
|
-
'no-unused-labels': 'error',
|
|
204
|
-
'no-useless-call': 'error',
|
|
205
|
-
'no-useless-catch': 'error',
|
|
206
|
-
'no-useless-computed-key': 'error',
|
|
207
|
-
'no-useless-concat': 'error',
|
|
208
|
-
'no-useless-constructor': 'off', // I like useless constructors
|
|
209
|
-
'no-useless-escape': 'error',
|
|
210
|
-
'no-useless-rename': 'error',
|
|
211
|
-
'no-useless-return': 'error',
|
|
212
|
-
'no-var': 'error',
|
|
213
|
-
'no-void': 'error',
|
|
214
|
-
'no-warning-comments': 'off', // Only turn this on periodically
|
|
215
|
-
'no-with': 'error',
|
|
216
|
-
'object-shorthand': 'error',
|
|
217
|
-
'one-var': ['error', 'never'],
|
|
218
|
-
'one-var-declaration-per-line': 'error',
|
|
219
|
-
'operator-assignment': 'error',
|
|
220
|
-
'prefer-arrow-callback': 'error',
|
|
221
|
-
'prefer-const': 'error',
|
|
222
|
-
'prefer-destructuring': 'error',
|
|
223
|
-
'prefer-exponentiation-operator': 'error',
|
|
224
|
-
'prefer-named-capture-group': 'error',
|
|
225
|
-
'prefer-numeric-literals': 'error',
|
|
226
|
-
'prefer-object-has-own': 'off', // Not yet
|
|
227
|
-
'prefer-object-spread': 'error',
|
|
228
|
-
'prefer-promise-reject-errors': 'warn',
|
|
229
|
-
'prefer-regex-literals': 'error',
|
|
230
|
-
'prefer-rest-params': 'error',
|
|
231
|
-
'prefer-spread': 'error',
|
|
232
|
-
'prefer-template': 'error',
|
|
233
|
-
'quote-props': ['error', 'consistent-as-needed'],
|
|
234
|
-
'radix': 'error',
|
|
235
|
-
'require-await': 'error',
|
|
236
|
-
'require-unicode-regexp': 'off', // No.
|
|
237
|
-
'require-yield': 'error',
|
|
238
|
-
'sort-imports': 'error',
|
|
239
|
-
'sort-keys': 'off', // Pedantic
|
|
240
|
-
'sort-vars': 'off', // Pedantic
|
|
241
|
-
'spaced-comment': ['error', 'always'],
|
|
242
|
-
'strict': ['error', 'global'],
|
|
243
|
-
'symbol-description': 'error',
|
|
244
|
-
'vars-on-top': 'error',
|
|
245
|
-
'yoda': ['error', 'never', {exceptRange: true}],
|
|
246
|
-
|
|
247
|
-
// [Layout & Formatting](https://eslint.org/docs/rules/#layout-formatting)
|
|
248
|
-
'array-bracket-newline': ['error', 'consistent'],
|
|
249
|
-
'array-bracket-spacing': ['error', 'never'],
|
|
250
|
-
'array-element-newline': ['error', 'consistent'],
|
|
251
|
-
'arrow-parens': ['error', 'as-needed'],
|
|
252
|
-
'arrow-spacing': 'error',
|
|
253
|
-
'block-spacing': ['error', 'always'],
|
|
254
|
-
'brace-style': ['error', '1tbs'],
|
|
255
|
-
'comma-dangle': ['error', {
|
|
256
|
-
arrays: 'always-multiline',
|
|
257
|
-
objects: 'always-multiline',
|
|
258
|
-
imports: 'always-multiline',
|
|
259
|
-
exports: 'always-multiline',
|
|
260
|
-
functions: 'never',
|
|
261
|
-
}],
|
|
262
|
-
'comma-spacing': 'error',
|
|
263
|
-
'comma-style': ['error', 'last'],
|
|
264
|
-
'computed-property-spacing': 'error',
|
|
265
|
-
'dot-location': ['error', 'property'],
|
|
266
|
-
'eol-last': 'error',
|
|
267
|
-
'func-call-spacing': 'error',
|
|
268
|
-
'function-call-argument-newline': ['error', 'consistent'],
|
|
269
|
-
'function-paren-newline': ['error', 'consistent'],
|
|
270
|
-
'generator-star-spacing': 'error',
|
|
271
|
-
'implicit-arrow-linebreak': ['error', 'beside'],
|
|
272
|
-
'indent': ['error', 2, {SwitchCase: 1}],
|
|
273
|
-
'jsx-quotes': 'off', // Not needed
|
|
274
|
-
'key-spacing': 'error',
|
|
275
|
-
'keyword-spacing': 'error',
|
|
276
|
-
'line-comment-position': 'off', // I'm all over the place on these
|
|
277
|
-
'linebreak-style': 'error',
|
|
278
|
-
'lines-around-comment': ['error', {
|
|
279
|
-
allowBlockStart: true,
|
|
280
|
-
allowClassStart: true,
|
|
281
|
-
}],
|
|
282
|
-
'lines-between-class-members': ['error', 'always', {
|
|
283
|
-
exceptAfterSingleLine: true,
|
|
284
|
-
}],
|
|
285
|
-
'max-len': ['error', 80, {
|
|
286
|
-
ignoreRegExpLiterals: true,
|
|
287
|
-
ignoreStrings: true,
|
|
288
|
-
ignoreTemplateLiterals: true,
|
|
289
|
-
ignoreUrls: true,
|
|
290
|
-
}],
|
|
291
|
-
'max-statements-per-line': 'off',
|
|
292
|
-
'multiline-ternary': ['error', 'always-multiline'],
|
|
293
|
-
'new-parens': 'error',
|
|
294
|
-
'newline-per-chained-call': 'error',
|
|
295
|
-
'no-extra-parens': 'off', // Too fiddly to torn off everything.
|
|
296
|
-
'no-mixed-spaces-and-tabs': 'error',
|
|
297
|
-
'no-multi-spaces': 'error',
|
|
298
|
-
'no-multiple-empty-lines': ['error', {max: 1}],
|
|
299
|
-
'no-tabs': 'error',
|
|
300
|
-
'no-trailing-spaces': 'error',
|
|
301
|
-
'no-whitespace-before-property': 'error',
|
|
302
|
-
'nonblock-statement-body-position': 'error',
|
|
303
|
-
'object-curly-newline': 'error',
|
|
304
|
-
'object-curly-spacing': ['error', 'never'],
|
|
305
|
-
'object-property-newline': ['error', {allowAllPropertiesOnSameLine: true}],
|
|
306
|
-
'operator-linebreak': ['error', 'after'],
|
|
307
|
-
'padded-blocks': ['error', 'never'],
|
|
308
|
-
'padding-line-between-statements': 'error',
|
|
309
|
-
'quotes': ['error', 'single', {avoidEscape: true}],
|
|
310
|
-
'rest-spread-spacing': ['error', 'never'],
|
|
311
|
-
// Massive breaking change. I changed my mind.
|
|
312
|
-
'semi': ['error', 'always'],
|
|
313
|
-
'semi-spacing': 'error',
|
|
314
|
-
'semi-style': ['error'],
|
|
315
|
-
'space-before-blocks': 'error',
|
|
316
|
-
'space-before-function-paren': ['error', 'never'],
|
|
317
|
-
'space-in-parens': 'error',
|
|
318
|
-
'space-infix-ops': ['error', {int32Hint: false}],
|
|
319
|
-
'space-unary-ops': 'error',
|
|
320
|
-
'switch-colon-spacing': 'error',
|
|
321
|
-
'template-curly-spacing': 'error',
|
|
322
|
-
'template-tag-spacing': 'error',
|
|
323
|
-
'unicode-bom': 'error',
|
|
324
|
-
'wrap-iife': 'error',
|
|
325
|
-
'wrap-regex': 'off', // No.
|
|
326
|
-
'yield-star-spacing': ['error', 'before'],
|
|
327
|
-
|
|
328
|
-
// [Possible Errors](https://github.com/eslint-community/eslint-plugin-n#possible-errors)
|
|
329
|
-
'n/handle-callback-err': ['error', 'er'],
|
|
330
|
-
'n/no-callback-literal': 'error',
|
|
331
|
-
'n/no-exports-assign': 'error',
|
|
332
|
-
'n/no-extraneous-import': 'error',
|
|
333
|
-
'n/no-extraneous-require': 'error',
|
|
334
|
-
'n/no-missing-import': ['error', {
|
|
335
|
-
allowModules: ['ava'], // Ava uses fancy new stuff, so shows up unavailable.
|
|
336
|
-
}],
|
|
337
|
-
'n/no-missing-require': 'off', // This one doesn't work yet:
|
|
338
|
-
'n/no-new-require': 'error',
|
|
339
|
-
'n/no-path-concat': 'error',
|
|
340
|
-
'n/no-process-exit': 'off', // No.
|
|
341
|
-
'n/no-unpublished-bin': 'error',
|
|
342
|
-
'n/no-unpublished-import': 'off', // Doesn't work
|
|
343
|
-
'n/no-unpublished-require': 'off', // Doesn't work
|
|
344
|
-
'n/no-unsupported-features/es-builtins': 'error',
|
|
345
|
-
'n/no-unsupported-features/es-syntax': 'error',
|
|
346
|
-
'n/no-unsupported-features/node-builtins': 'error',
|
|
347
|
-
'n/process-exit-as-throw': 'error',
|
|
348
|
-
'n/shebang': 'off', // This always seems to be wrong
|
|
349
|
-
|
|
350
|
-
// [Best Practices](https://github.com/eslint-community/eslint-plugin-n#best-practices)
|
|
351
|
-
'n/no-deprecated-api': 'error',
|
|
352
|
-
|
|
353
|
-
// [Stylistic Issues](https://github.com/eslint-community/eslint-plugin-n#stylistic-issues)
|
|
354
|
-
'n/callback-return': 'off', // No
|
|
355
|
-
'n/exports-style': 'off',
|
|
356
|
-
// Doesn't work for `import 'regenerator-runtime/runtime'`
|
|
357
|
-
'n/file-extension-in-import': 'error',
|
|
358
|
-
'n/global-require': 'off',
|
|
359
|
-
'n/no-mixed-requires': 'error',
|
|
360
|
-
// No
|
|
361
|
-
'n/no-process-env': 'off',
|
|
362
|
-
'n/no-restricted-import': 'off',
|
|
363
|
-
'n/no-restricted-require': 'off',
|
|
364
|
-
'n/no-sync': 'off',
|
|
365
|
-
|
|
366
|
-
'n/prefer-global/buffer': ['error', 'never'],
|
|
367
|
-
// Hopefully only used in tests and cli
|
|
368
|
-
'n/prefer-global/console': 'off',
|
|
369
|
-
'n/prefer-global/process': 'off',
|
|
370
|
-
'n/prefer-global/text-decoder': ['error', 'always'],
|
|
371
|
-
'n/prefer-global/text-encoder': ['error', 'always'],
|
|
372
|
-
'n/prefer-global/url': ['error', 'always'],
|
|
373
|
-
'n/prefer-global/url-search-params': ['error', 'always'],
|
|
374
|
-
// Not yet
|
|
375
|
-
'n/prefer-promises/dns': 'off',
|
|
376
|
-
'n/prefer-promises/fs': 'off',
|
|
377
|
-
},
|
|
378
|
-
overrides: [
|
|
379
|
-
{
|
|
380
|
-
files: ['*.mjs'],
|
|
381
|
-
parserOptions: {sourceType: 'module'},
|
|
382
|
-
rules: {
|
|
383
|
-
// [Possible Errors](https://eslint.org/docs/rules/#possible-errors)
|
|
384
|
-
'n/no-unsupported-features/es-syntax': [
|
|
385
|
-
'error',
|
|
386
|
-
{
|
|
387
|
-
version: '>=12.19',
|
|
388
|
-
ignores: ['modules'],
|
|
389
|
-
},
|
|
390
|
-
],
|
|
391
|
-
},
|
|
392
|
-
},
|
|
393
|
-
],
|
|
394
|
-
};
|
|
3
|
+
// Just the core rules, no optional dependencies needed.
|
|
4
|
+
module.exports = [
|
|
5
|
+
...require('./ignores.js'),
|
|
6
|
+
...require('./js'),
|
|
7
|
+
...require('./mjs'),
|
|
8
|
+
];
|
package/js.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const globals = require('globals');
|
|
4
|
+
const {rules} = require('./rules/js.js');
|
|
5
|
+
|
|
6
|
+
module.exports = [{
|
|
7
|
+
files: [
|
|
8
|
+
'**/*.js',
|
|
9
|
+
'**/*.cjs',
|
|
10
|
+
'**/*.mjs',
|
|
11
|
+
'**/*.ts',
|
|
12
|
+
],
|
|
13
|
+
plugins: {
|
|
14
|
+
'@stylistic': require('@stylistic/eslint-plugin'),
|
|
15
|
+
'n': require('eslint-plugin-n'),
|
|
16
|
+
},
|
|
17
|
+
languageOptions: {
|
|
18
|
+
globals: globals.node,
|
|
19
|
+
ecmaVersion: 2022,
|
|
20
|
+
sourceType: 'commonjs',
|
|
21
|
+
},
|
|
22
|
+
rules,
|
|
23
|
+
}];
|