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