@cto.af/eslint-config 4.0.2 → 4.1.1

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/ava.js CHANGED
@@ -3,12 +3,12 @@
3
3
  const {rules} = require('./rules/ava.js');
4
4
  module.exports = [{
5
5
  files: [
6
- 'test/**.test.*',
7
- 'test/**.ava.*',
8
- 'test/**.spec.*',
9
- 'ava/**.test.*',
10
- 'ava/**.ava.*',
11
- 'ava/**.spec.*',
6
+ '**/test/**.test.*',
7
+ '**/test/**.ava.*',
8
+ '**/test/**.spec.*',
9
+ '**/ava/**.test.*',
10
+ '**/ava/**.ava.*',
11
+ '**/ava/**.spec.*',
12
12
  ],
13
13
  plugins: {
14
14
  ava: require('eslint-plugin-ava'),
@@ -0,0 +1,33 @@
1
+ import all from './all.js';
2
+ import ava from 'eslint-plugin-ava';
3
+ import jsdoc from 'eslint-plugin-jsdoc';
4
+ import meta from '@cto.af/eslint-plugin-meta';
5
+ import n from 'eslint-plugin-n';
6
+ import {plugin} from 'typescript-eslint';
7
+ import stylistic from '@stylistic/eslint-plugin';
8
+
9
+ export default [
10
+ {
11
+ ignores: [
12
+ 'test/**',
13
+ ],
14
+ },
15
+ ...all,
16
+ {
17
+ files: [
18
+ 'rules/*.js',
19
+ ],
20
+ settings: {
21
+ meta: {
22
+ libs: {
23
+ ava,
24
+ jsdoc,
25
+ n,
26
+ '@stylistic': stylistic,
27
+ '@typescript-eslint': plugin,
28
+ },
29
+ },
30
+ },
31
+ ...meta.configs.all,
32
+ },
33
+ ];
package/mocha.js ADDED
@@ -0,0 +1,36 @@
1
+ 'use strict';
2
+
3
+ const globals = require('globals');
4
+ const mocha = require('eslint-plugin-mocha');
5
+
6
+ module.exports = [{
7
+ files: [
8
+ 'test/**/*.spec.js',
9
+ 'test/**/*.spec.ts',
10
+ 'test/**/*.spec.cjs',
11
+ 'test/**/*.spec.mjs',
12
+ 'tests/**/*.spec.js',
13
+ 'tests/**/*.spec.ts',
14
+ 'tests/**/*.spec.cjs',
15
+ 'tests/**/*.spec.mjs',
16
+ 'test/**/*.test.js',
17
+ 'test/**/*.test.ts',
18
+ 'test/**/*.test.cjs',
19
+ 'test/**/*.test.mjs',
20
+ 'tests/**/*.test.js',
21
+ 'tests/**/*.test.ts',
22
+ 'tests/**/*.test.cjs',
23
+ 'tests/**/*.test.mjs',
24
+
25
+ ],
26
+ languageOptions: {
27
+ globals: globals.mocha,
28
+ },
29
+ plugins: {
30
+ mocha,
31
+ },
32
+ rules: {
33
+ ...mocha.configs.recommended.rules,
34
+ 'mocha/no-mocha-arrows': 'off',
35
+ },
36
+ }];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cto.af/eslint-config",
3
- "version": "4.0.2",
3
+ "version": "4.1.1",
4
4
  "description": "hildjj's lint rules",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -15,22 +15,31 @@
15
15
  "license": "MIT",
16
16
  "repository": "cto-af/eslint-config",
17
17
  "dependencies": {
18
- "@stylistic/eslint-plugin": "1.7.0",
19
- "eslint-plugin-n": "16.6.2",
20
- "globals": "15.0.0"
18
+ "@stylistic/eslint-plugin": "2.3.0",
19
+ "eslint-plugin-n": "17.9.0",
20
+ "globals": "15.6.0"
21
21
  },
22
22
  "devDependencies": {
23
- "@hildjj/sort-rules": "link:sort-rules",
24
- "eslint": "^8.57.0",
25
- "eslint-find-rules": "^4.1.0",
26
- "eslint-plugin-ava": "^14.0.0",
27
- "eslint-plugin-jsdoc": "^48.2.2",
28
- "eslint-plugin-markdown": "^4.0.1",
29
- "npm-check-updates": "^16.14.18",
30
- "typescript": "^5.4.3",
31
- "typescript-eslint": "^7.5.0"
23
+ "@cto.af/eslint-plugin-meta": "github:cto-af/eslint-plugin-meta",
24
+ "eslint": "^9.5.0",
25
+ "eslint-plugin-ava": "^15.0.1",
26
+ "eslint-plugin-jsdoc": "^48.4.0",
27
+ "eslint-plugin-markdown": "^5.0.0",
28
+ "eslint-plugin-mocha": "10.4.3",
29
+ "typescript": "5.5.2",
30
+ "typescript-eslint": "^8.0.0-alpha.33"
32
31
  },
33
- "packageManager": "pnpm@8.15.6",
32
+ "overrides": {
33
+ "@typescript-eslint/utils": "8.0.0-alpha.33",
34
+ "@typescript-eslint/parser": "8.0.0-alpha.33"
35
+ },
36
+ "pnpm": {
37
+ "overrides": {
38
+ "@typescript-eslint/utils": "8.0.0-alpha.33",
39
+ "@typescript-eslint/parser": "8.0.0-alpha.33"
40
+ }
41
+ },
42
+ "packageManager": "pnpm@9.4.0",
34
43
  "engines": {
35
44
  "node": ">=18"
36
45
  }
package/rules/ava.js CHANGED
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
+ /* eslint meta/no-unused-rules: ["error", {ignore: ["n"]}] */
4
+
3
5
  module.exports = {
4
6
  rules: {
5
- // Check: ava
6
-
7
7
  // [ava](https://github.com/avajs/eslint-plugin-ava?tab=readme-ov-file#rules)
8
8
  'ava/assertion-arguments': 'error',
9
9
  'ava/hooks-order': 'error',
package/rules/js.js CHANGED
@@ -2,8 +2,6 @@
2
2
 
3
3
  module.exports = {
4
4
  rules: {
5
- // Check: @, @stylistic, n
6
-
7
5
  // [Possible Problems](https://eslint.org/docs/rules/#possible-problems)
8
6
  'array-callback-return': ['error', {allowImplicit: true}],
9
7
  'constructor-super': 'error',
@@ -38,7 +36,6 @@ module.exports = {
38
36
  'no-loss-of-precision': 'error',
39
37
  'no-misleading-character-class': 'error',
40
38
  'no-new-native-nonconstructor': 'error',
41
- 'no-new-symbol': 'error',
42
39
  'no-obj-calls': 'error',
43
40
  'no-promise-executor-return': 'error',
44
41
  'no-prototype-builtins': 'error',
@@ -67,6 +64,9 @@ module.exports = {
67
64
  },
68
65
  ],
69
66
  'no-use-before-define': 'error',
67
+ // Doesn't account for try blocks
68
+ // See https://github.com/eslint/eslint/issues/17579
69
+ 'no-useless-assignment': 'off',
70
70
  'no-useless-backreference': 'error',
71
71
  'require-atomic-updates': 'error',
72
72
  'use-isnan': 'error',
@@ -102,7 +102,6 @@ module.exports = {
102
102
  'id-length': 'off', // Not needed
103
103
  'id-match': 'off', // Not needed
104
104
  'init-declarations': 'error',
105
- 'line-comment-position': 'off', // I'm all over the place on these
106
105
  'logical-assignment-operators': 'off', // No.
107
106
  'max-classes-per-file': 'off', // No.
108
107
  'max-depth': 'off', // No.
@@ -111,7 +110,6 @@ module.exports = {
111
110
  'max-nested-callbacks': 'off', // No.
112
111
  'max-params': ['error', 4],
113
112
  'max-statements': 'off', // No.
114
- 'multiline-comment-style': ['error', 'separate-lines'],
115
113
  'new-cap': 'error',
116
114
  'no-alert': 'error',
117
115
  'no-array-constructor': 'error',
@@ -259,7 +257,7 @@ module.exports = {
259
257
  '@stylistic/jsx-curly-spacing': 'off', // Not needed
260
258
  '@stylistic/jsx-equals-spacing': 'off', // Not needed
261
259
  '@stylistic/jsx-first-prop-new-line': 'off', // Not needed
262
- '@stylistic/jsx-indent': 'off', // Not needed
260
+ '@stylistic/jsx-function-call-newline': 'off', // Not needed
263
261
  '@stylistic/jsx-indent-props': 'off', // Not needed
264
262
  '@stylistic/jsx-max-props-per-line': 'off', // Not needed
265
263
  '@stylistic/jsx-newline': 'off', // Not needed
@@ -274,6 +272,7 @@ module.exports = {
274
272
 
275
273
  '@stylistic/key-spacing': 'error',
276
274
  '@stylistic/keyword-spacing': 'error',
275
+ '@stylistic/line-comment-position': 'off', // Too hard to change
277
276
  '@stylistic/linebreak-style': 'error',
278
277
  '@stylistic/lines-around-comment': ['error', {
279
278
  allowArrayStart: true,
@@ -295,6 +294,7 @@ module.exports = {
295
294
  }],
296
295
  '@stylistic/max-statements-per-line': 'off',
297
296
  '@stylistic/member-delimiter-style': 'off',
297
+ '@stylistic/multiline-comment-style': 'off', // Not important
298
298
  '@stylistic/multiline-ternary': ['error', 'always-multiline'],
299
299
  '@stylistic/new-parens': 'error',
300
300
  '@stylistic/newline-per-chained-call': 'error',
@@ -359,7 +359,6 @@ module.exports = {
359
359
  'n/no-unsupported-features/es-syntax': 'error',
360
360
  'n/no-unsupported-features/node-builtins': 'error',
361
361
  'n/process-exit-as-throw': 'error',
362
- 'n/shebang': 'off', // This always seems to be wrong
363
362
 
364
363
  // [Best Practices](https://github.com/eslint-community/eslint-plugin-n#best-practices)
365
364
  'n/no-deprecated-api': 'error',
@@ -370,21 +369,20 @@ module.exports = {
370
369
  // Doesn't work for `import 'regenerator-runtime/runtime'`
371
370
  'n/file-extension-in-import': 'error',
372
371
  'n/global-require': 'off',
372
+ 'n/hashbang': 'off', // Try turning this on sometime
373
373
  'n/no-mixed-requires': 'error',
374
- // No
375
- 'n/no-process-env': 'off',
374
+ 'n/no-process-env': 'off', // No
376
375
  'n/no-restricted-import': 'off',
377
376
  'n/no-restricted-require': 'off',
378
377
  'n/no-sync': 'off',
379
-
380
378
  'n/prefer-global/buffer': ['error', 'never'],
381
- // Hopefully only used in tests and cli
382
- 'n/prefer-global/console': 'off',
379
+ 'n/prefer-global/console': 'off', // Hopefully only used in tests and cli
383
380
  'n/prefer-global/process': 'off',
384
381
  'n/prefer-global/text-decoder': ['error', 'always'],
385
382
  'n/prefer-global/text-encoder': ['error', 'always'],
386
383
  'n/prefer-global/url': ['error', 'always'],
387
384
  'n/prefer-global/url-search-params': ['error', 'always'],
385
+ 'n/prefer-node-protocol': 'error', // Turn off when needed
388
386
  // Not yet
389
387
  'n/prefer-promises/dns': 'off',
390
388
  'n/prefer-promises/fs': 'off',
package/rules/ts.js CHANGED
@@ -1,56 +1,24 @@
1
- /* eslint-disable capitalized-comments */
2
1
  'use strict';
3
2
 
3
+ const {builtinRules} = require('eslint/use-at-your-own-risk');
4
+ const ts = require('typescript-eslint');
5
+
6
+ const originalDisabled = {};
7
+ builtinRules.forEach((_, r) => {
8
+ if (ts.plugin.rules[r]) {
9
+ originalDisabled[r] = 'off';
10
+ }
11
+ });
12
+
13
+ /* eslint meta/no-unused-rules: ["error", {ignore: ["@stylistic"]}] */
14
+
4
15
  module.exports = {
5
16
  rules: {
6
- // Check: @typescript-eslint
17
+ // [original disabled for extension](https://typescript-eslint.io/rules/?=extension#extension-rules)
18
+ ...originalDisabled,
7
19
 
8
20
  // [@typescript-eslint/eslint-recommended](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/eslint-recommended-raw.ts)
9
- 'constructor-super': 'off', // ts(2335) & ts(2377)
10
- 'getter-return': 'off', // ts(2378)
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-symbol': '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
- 'prefer-const': 'error', // ts provides better types with const
27
- 'prefer-rest-params': 'error', // ts provides better types with rest args over arguments
28
- 'prefer-spread': 'error', // ts transpiles spread to apply, so no need for manual apply
29
-
30
- // [original disabled for extension](https://typescript-eslint.io/rules/?=extension#extension-rules)
31
- 'class-methods-use-this': 'off',
32
- 'consistent-return': 'off',
33
- 'default-param-last': 'off',
34
- 'dot-notation': 'off',
35
- 'init-declarations': 'off',
36
- 'max-params': 'off',
37
- 'no-array-constructor': 'off',
38
- // 'no-dupe-class-members': 'off',
39
- 'no-empty-function': 'off',
40
- 'no-implied-eval': 'off',
41
- 'no-invalid-this': 'off',
42
- 'no-loop-func': 'off',
43
- 'no-loss-of-precision': 'off',
44
- // 'no-magic-numbers': 'off',
45
- 'no-shadow': 'off',
46
- 'no-throw-literal': 'off',
47
- 'no-unused-expressions': 'off',
48
- 'no-unused-vars': 'off',
49
- 'no-use-before-define': 'off',
50
- 'no-useless-constructor': 'off',
51
- 'prefer-destructuring': 'off',
52
- 'prefer-promise-reject-errors': 'off',
53
- 'require-await': 'off',
21
+ ...ts.configs.eslintRecommended.rules,
54
22
 
55
23
  // [typescript-eslint](https://typescript-eslint.io/rules/)
56
24
  '@typescript-eslint/adjacent-overload-signatures': 'error',
@@ -58,9 +26,12 @@ module.exports = {
58
26
  '@typescript-eslint/await-thenable': 'off', // Can't config
59
27
  '@typescript-eslint/ban-ts-comment': ['error', {
60
28
  'ts-expect-error': 'allow-with-description',
29
+ 'ts-ignore': true,
30
+ 'ts-nocheck': true,
31
+ 'ts-check': false,
32
+ 'minimumDescriptionLength': 3,
61
33
  }],
62
34
  '@typescript-eslint/ban-tslint-comment': 'error',
63
- '@typescript-eslint/ban-types': 'off', // Not needed
64
35
  '@typescript-eslint/class-literal-property-style': ['error', 'getters'],
65
36
  '@typescript-eslint/class-methods-use-this': 'error',
66
37
  '@typescript-eslint/consistent-generic-constructors': [
@@ -101,7 +72,7 @@ module.exports = {
101
72
  '@typescript-eslint/no-duplicate-type-constituents': 'error',
102
73
  '@typescript-eslint/no-dynamic-delete': 'error',
103
74
  '@typescript-eslint/no-empty-function': 'error',
104
- '@typescript-eslint/no-empty-interface': 'error',
75
+ '@typescript-eslint/no-empty-object-type': 'error',
105
76
  '@typescript-eslint/no-explicit-any': 'off', // Too hard
106
77
  '@typescript-eslint/no-extra-non-null-assertion': 'error',
107
78
  '@typescript-eslint/no-extraneous-class': 'error',
@@ -113,7 +84,6 @@ module.exports = {
113
84
  '@typescript-eslint/no-invalid-this': 'error',
114
85
  '@typescript-eslint/no-invalid-void-type': 'error',
115
86
  '@typescript-eslint/no-loop-func': 'error',
116
- '@typescript-eslint/no-loss-of-precision': 'error',
117
87
  '@typescript-eslint/no-magic-numbers': 'off', // Too late
118
88
  '@typescript-eslint/no-meaningless-void-operator': 'off', // Can't config
119
89
  '@typescript-eslint/no-misused-new': 'error',
@@ -127,11 +97,13 @@ module.exports = {
127
97
  '@typescript-eslint/no-redundant-type-constituents': 'off', // Can't config
128
98
  '@typescript-eslint/no-require-imports': 'error',
129
99
  '@typescript-eslint/no-restricted-imports': 'off', // Not needed
100
+ '@typescript-eslint/no-restricted-types': 'off', // Not needed
130
101
  '@typescript-eslint/no-shadow': 'error',
131
102
  '@typescript-eslint/no-this-alias': 'error',
132
103
  '@typescript-eslint/no-unnecessary-boolean-literal-compare': 'off', // Can't config
133
104
  '@typescript-eslint/no-unnecessary-condition': 'off', // Can't config
134
105
  '@typescript-eslint/no-unnecessary-qualifier': 'off', // Can't config
106
+ '@typescript-eslint/no-unnecessary-template-expression': 'error',
135
107
  '@typescript-eslint/no-unnecessary-type-arguments': 'off', // Can't config
136
108
  '@typescript-eslint/no-unnecessary-type-assertion': 'off', // Can't config
137
109
  '@typescript-eslint/no-unnecessary-type-constraint': 'error',
@@ -140,6 +112,7 @@ module.exports = {
140
112
  '@typescript-eslint/no-unsafe-call': 'off', // Can't config
141
113
  '@typescript-eslint/no-unsafe-declaration-merging': 'error',
142
114
  '@typescript-eslint/no-unsafe-enum-comparison': 'error',
115
+ '@typescript-eslint/no-unsafe-function-type': 'error',
143
116
  '@typescript-eslint/no-unsafe-member-access': 'off', // Can't config
144
117
  '@typescript-eslint/no-unsafe-return': 'off', // Can't config
145
118
  '@typescript-eslint/no-unsafe-unary-minus': 'error',
@@ -156,8 +129,7 @@ module.exports = {
156
129
  '@typescript-eslint/no-use-before-define': 'error',
157
130
  '@typescript-eslint/no-useless-constructor': 'error',
158
131
  '@typescript-eslint/no-useless-empty-export': 'error',
159
- '@typescript-eslint/no-useless-template-literals': 'error',
160
- '@typescript-eslint/no-var-requires': 'error',
132
+ '@typescript-eslint/no-wrapper-object-types': 'error', // Turn off in cbor projects
161
133
  '@typescript-eslint/non-nullable-type-assertion-style': 'off', // Can't config
162
134
  '@typescript-eslint/only-throw-error': 'error',
163
135
  '@typescript-eslint/parameter-properties': 'error',
@@ -179,14 +151,12 @@ module.exports = {
179
151
  '@typescript-eslint/prefer-regexp-exec': 'off', // Can't config
180
152
  '@typescript-eslint/prefer-return-this-type': 'off', // Can't config
181
153
  '@typescript-eslint/prefer-string-starts-ends-with': 'off', // Can't config
182
- '@typescript-eslint/prefer-ts-expect-error': 'error',
183
154
  '@typescript-eslint/promise-function-async': 'off', // Can't config
184
155
  '@typescript-eslint/require-array-sort-compare': 'off', // Can't config
185
156
  '@typescript-eslint/require-await': 'error',
186
157
  '@typescript-eslint/restrict-plus-operands': 'off', // Can't config
187
158
  '@typescript-eslint/restrict-template-expressions': 'off', // Can't config
188
159
  '@typescript-eslint/return-await': 'error',
189
- '@typescript-eslint/sort-type-constituents': 'error',
190
160
  '@typescript-eslint/strict-boolean-expressions': 'off', // Can't config
191
161
  '@typescript-eslint/switch-exhaustiveness-check': 'off', // Can't config
192
162
  '@typescript-eslint/triple-slash-reference': 'error',
@@ -197,7 +167,7 @@ module.exports = {
197
167
 
198
168
  // These are the stylistic rules that require TS. All of the
199
169
  // others from the JS rules should work as-is.
200
- // [Stylistc](https://eslint.style/packages/default)
170
+ // [Stylistc](https://eslint.style/packages/ts#rules)
201
171
  '@stylistic/member-delimiter-style': 'error',
202
172
  '@stylistic/type-annotation-spacing': 'error',
203
173
  '@stylistic/type-generic-spacing': 'error',