@mrpalmer/eslint-config 2.4.0 → 2.4.2

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/configs/base.js CHANGED
@@ -3,238 +3,245 @@ import mrpalmerPlugin from '@mrpalmer/eslint-plugin'
3
3
  import { defineConfig } from 'eslint/config'
4
4
  import pluginImport from 'eslint-plugin-import-x'
5
5
 
6
- export default defineConfig(
7
- {
8
- name: 'eslint/recommended',
9
- ...eslint.configs.recommended,
6
+ export default defineConfig({
7
+ extends: [
8
+ {
9
+ name: 'eslint/recommended',
10
+ ...eslint.configs.recommended,
11
+ },
12
+ mrpalmerPlugin.configs.recommended,
13
+ pluginImport.flatConfigs.recommended,
14
+ ],
15
+ files: [
16
+ '**/*.js',
17
+ '**/*.cjs',
18
+ '**/*.mjs',
19
+ '**/*.jsx',
20
+ '**/*.ts',
21
+ '**/*.mts',
22
+ '**/*.tsx',
23
+ ],
24
+ name: 'mrpalmer/base',
25
+
26
+ linterOptions: {
27
+ reportUnusedDisableDirectives: 'error',
10
28
  },
11
- mrpalmerPlugin.configs.recommended,
12
- {
13
- name: 'mrpalmer/base',
29
+ rules: {
30
+ 'accessor-pairs': 'error',
31
+ 'array-callback-return': 'error',
32
+ 'arrow-body-style': 'off',
33
+ 'block-scoped-var': 'error',
34
+ camelcase: 'off',
35
+ 'capitalized-comments': 'off',
36
+ 'class-methods-use-this': 'off',
37
+ complexity: ['error', 20],
38
+ 'consistent-return': 'error',
39
+ 'consistent-this': 'off',
40
+ curly: ['error', 'multi-line'],
41
+ 'default-case': 'error',
42
+ 'default-case-last': 'error',
43
+ 'default-param-last': 'off',
44
+ 'dot-notation': 'error',
45
+ eqeqeq: ['error', 'smart'],
46
+ 'func-name-matching': 'error',
47
+ 'func-names': 'error',
48
+ 'func-style': 'off',
49
+ 'grouped-accessor-pairs': 'off',
50
+ 'guard-for-in': 'error',
51
+ 'id-denylist': 'error',
52
+ 'id-length': 'off',
53
+ 'id-match': [
54
+ 'error',
55
+ // camelCase, PascalCase, __filename, CONST_VALUE, stream$, $el
56
+ '^\\$?(__)?(([A-Z]|[a-z]|[0-9]+)|([A-Z_]))*\\$?$',
57
+ ],
58
+ 'init-declarations': 'off',
59
+ 'logical-assignment-operators': [
60
+ 'warn',
61
+ 'always',
62
+ { enforceForIfStatements: true },
63
+ ],
64
+ 'max-classes-per-file': 'off',
65
+ 'max-depth': ['error', 4],
66
+ 'max-lines': [
67
+ 'error',
68
+ { max: 2500, skipBlankLines: false, skipComments: false },
69
+ ],
70
+ 'max-lines-per-function': 'off',
71
+ 'max-nested-callbacks': ['error', 7],
72
+ 'max-params': ['error', { max: 7 }],
73
+ 'max-statements': 'off',
74
+ 'new-cap': 'error',
75
+ 'no-alert': 'error',
76
+ 'no-array-constructor': 'error',
77
+ 'no-await-in-loop': 'error',
78
+ 'no-bitwise': 'error',
79
+ 'no-caller': 'error',
80
+ 'no-console': 'off',
81
+ 'no-constant-binary-expression': 'error',
82
+ 'no-constructor-return': 'error',
83
+ 'no-continue': 'off',
84
+ 'no-div-regex': 'error',
85
+ 'no-duplicate-imports': 'off',
86
+ 'no-else-return': 'off',
87
+ 'no-empty-function': 'off',
88
+ 'no-empty-static-block': 'warn',
89
+ 'no-eq-null': 'off',
90
+ 'no-eval': 'error',
91
+ 'no-extend-native': 'error',
92
+ 'no-extra-bind': 'error',
93
+ 'no-extra-label': 'error',
94
+ 'no-implicit-coercion': 'off',
95
+ 'no-implicit-globals': 'error',
96
+ 'no-implied-eval': 'error',
97
+ 'no-inline-comments': 'off',
98
+ 'no-inner-declarations': 'error',
99
+ 'no-invalid-this': 'error',
100
+ 'no-iterator': 'error',
101
+ 'no-label-var': 'error',
102
+ 'no-labels': 'error',
103
+ 'no-lone-blocks': 'error',
104
+ 'no-lonely-if': 'error',
105
+ 'no-loop-func': 'error',
106
+ 'no-magic-numbers': 'off',
107
+ 'no-multi-assign': 'error',
108
+ 'no-multi-str': 'error',
109
+ 'no-negated-condition': 'error',
110
+ 'no-nested-ternary': 'off',
111
+ 'no-new': 'error',
112
+ 'no-new-func': 'error',
113
+ 'no-new-native-nonconstructor': 'error',
114
+ 'no-new-wrappers': 'error',
115
+ 'no-object-constructor': 'error',
116
+ 'no-octal-escape': 'error',
117
+ 'no-param-reassign': 'off',
118
+ 'no-plusplus': 'off',
119
+ 'no-promise-executor-return': 'off',
120
+ 'no-proto': 'error',
121
+ 'no-restricted-exports': 'off',
122
+ 'no-restricted-globals': ['error', 'event', 'fdescribe'],
123
+ 'no-restricted-imports': 'off',
124
+ 'no-restricted-properties': 'off',
125
+ 'no-restricted-syntax': ['error', 'WithStatement'],
126
+ 'no-return-assign': 'error',
127
+ 'no-script-url': 'error',
128
+ 'no-self-compare': 'error',
129
+ 'no-sequences': 'error',
130
+ 'no-shadow': 'off',
131
+ 'no-template-curly-in-string': 'error',
132
+ 'no-ternary': 'off',
133
+ 'no-throw-literal': 'error',
134
+ 'no-unassigned-vars': 'error',
135
+ 'no-undef-init': 'error',
136
+ 'no-undefined': 'off',
137
+ 'no-underscore-dangle': 'off',
138
+ 'no-unmodified-loop-condition': 'error',
139
+ 'no-unneeded-ternary': 'error',
140
+ 'no-unreachable-loop': 'error',
141
+ 'no-unused-expressions': 'off',
142
+ 'no-unused-private-class-members': 'error',
143
+ 'no-unused-vars': [
144
+ 'error',
145
+ {
146
+ args: 'after-used',
147
+ argsIgnorePattern: '^_',
148
+ ignoreRestSiblings: true,
149
+ varsIgnorePattern: '^ignored',
150
+ },
151
+ ],
152
+ 'no-use-before-define': ['error', 'nofunc'],
153
+ 'no-useless-assignment': 'warn',
154
+ 'no-useless-call': 'error',
155
+ 'no-useless-computed-key': 'error',
156
+ 'no-useless-concat': 'error',
157
+ 'no-useless-constructor': 'error',
158
+ 'no-useless-rename': 'error',
159
+ 'no-useless-return': 'error',
160
+ 'no-var': 'error',
161
+ 'no-void': 'off',
162
+ 'no-warning-comments': [
163
+ 'error',
164
+ { location: 'anywhere', terms: ['fixme'] },
165
+ ],
166
+ 'object-shorthand': ['error', 'properties'],
167
+ 'one-var': ['error', { initialized: 'never', uninitialized: 'always' }],
168
+ 'operator-assignment': 'off',
169
+ 'prefer-arrow-callback': [
170
+ 'error',
171
+ { allowNamedFunctions: true, allowUnboundThis: true },
172
+ ],
173
+ 'prefer-const': 'error',
174
+ 'prefer-destructuring': 'off',
175
+ 'prefer-exponentiation-operator': 'warn',
176
+ 'prefer-named-capture-group': 'off',
177
+ 'prefer-numeric-literals': 'error',
178
+ 'prefer-object-has-own': 'error',
179
+ 'prefer-object-spread': 'warn',
180
+ 'prefer-promise-reject-errors': 'off',
181
+ 'prefer-regex-literals': 'off',
182
+ 'prefer-rest-params': 'error',
183
+ 'prefer-spread': 'error',
184
+ 'prefer-template': 'error',
185
+ 'preserve-caught-error': 'warn',
186
+ radix: 'error',
187
+ 'require-atomic-updates': 'off',
188
+ 'require-await': 'off',
189
+ 'require-unicode-regexp': 'off',
190
+ 'sort-imports': 'off',
191
+ 'sort-keys': 'off',
192
+ 'sort-vars': 'off',
193
+ strict: 'error',
194
+ 'symbol-description': 'error',
195
+ 'unicode-bom': ['error', 'never'],
196
+ 'vars-on-top': 'error',
197
+ yoda: 'error',
14
198
 
15
- linterOptions: {
16
- reportUnusedDisableDirectives: 'error',
17
- },
18
- rules: {
19
- 'accessor-pairs': 'error',
20
- 'array-callback-return': 'error',
21
- 'arrow-body-style': 'off',
22
- 'block-scoped-var': 'error',
23
- camelcase: 'off',
24
- 'capitalized-comments': 'off',
25
- 'class-methods-use-this': 'off',
26
- complexity: ['error', 20],
27
- 'consistent-return': 'error',
28
- 'consistent-this': 'off',
29
- curly: ['error', 'multi-line'],
30
- 'default-case': 'error',
31
- 'default-case-last': 'error',
32
- 'default-param-last': 'off',
33
- 'dot-notation': 'error',
34
- eqeqeq: ['error', 'smart'],
35
- 'func-name-matching': 'error',
36
- 'func-names': 'error',
37
- 'func-style': 'off',
38
- 'grouped-accessor-pairs': 'off',
39
- 'guard-for-in': 'error',
40
- 'id-denylist': 'error',
41
- 'id-length': 'off',
42
- 'id-match': [
43
- 'error',
44
- // camelCase, PascalCase, __filename, CONST_VALUE, stream$, $el
45
- '^\\$?(__)?(([A-Z]|[a-z]|[0-9]+)|([A-Z_]))*\\$?$',
46
- ],
47
- 'init-declarations': 'off',
48
- 'logical-assignment-operators': [
49
- 'warn',
50
- 'always',
51
- { enforceForIfStatements: true },
52
- ],
53
- 'max-classes-per-file': 'off',
54
- 'max-depth': ['error', 4],
55
- 'max-lines': [
56
- 'error',
57
- { max: 2500, skipBlankLines: false, skipComments: false },
58
- ],
59
- 'max-lines-per-function': 'off',
60
- 'max-nested-callbacks': ['error', 7],
61
- 'max-params': ['error', { max: 7 }],
62
- 'max-statements': 'off',
63
- 'new-cap': 'error',
64
- 'no-alert': 'error',
65
- 'no-array-constructor': 'error',
66
- 'no-await-in-loop': 'error',
67
- 'no-bitwise': 'error',
68
- 'no-caller': 'error',
69
- 'no-console': 'off',
70
- 'no-constant-binary-expression': 'error',
71
- 'no-constructor-return': 'error',
72
- 'no-continue': 'off',
73
- 'no-div-regex': 'error',
74
- 'no-duplicate-imports': 'off',
75
- 'no-else-return': 'off',
76
- 'no-empty-function': 'off',
77
- 'no-empty-static-block': 'warn',
78
- 'no-eq-null': 'off',
79
- 'no-eval': 'error',
80
- 'no-extend-native': 'error',
81
- 'no-extra-bind': 'error',
82
- 'no-extra-label': 'error',
83
- 'no-implicit-coercion': 'off',
84
- 'no-implicit-globals': 'error',
85
- 'no-implied-eval': 'error',
86
- 'no-inline-comments': 'off',
87
- 'no-inner-declarations': 'error',
88
- 'no-invalid-this': 'error',
89
- 'no-iterator': 'error',
90
- 'no-label-var': 'error',
91
- 'no-labels': 'error',
92
- 'no-lone-blocks': 'error',
93
- 'no-lonely-if': 'error',
94
- 'no-loop-func': 'error',
95
- 'no-magic-numbers': 'off',
96
- 'no-multi-assign': 'error',
97
- 'no-multi-str': 'error',
98
- 'no-negated-condition': 'error',
99
- 'no-nested-ternary': 'off',
100
- 'no-new': 'error',
101
- 'no-new-func': 'error',
102
- 'no-new-native-nonconstructor': 'error',
103
- 'no-new-wrappers': 'error',
104
- 'no-object-constructor': 'error',
105
- 'no-octal-escape': 'error',
106
- 'no-param-reassign': 'off',
107
- 'no-plusplus': 'off',
108
- 'no-promise-executor-return': 'off',
109
- 'no-proto': 'error',
110
- 'no-restricted-exports': 'off',
111
- 'no-restricted-globals': ['error', 'event', 'fdescribe'],
112
- 'no-restricted-imports': 'off',
113
- 'no-restricted-properties': 'off',
114
- 'no-restricted-syntax': ['error', 'WithStatement'],
115
- 'no-return-assign': 'error',
116
- 'no-script-url': 'error',
117
- 'no-self-compare': 'error',
118
- 'no-sequences': 'error',
119
- 'no-shadow': 'off',
120
- 'no-template-curly-in-string': 'error',
121
- 'no-ternary': 'off',
122
- 'no-throw-literal': 'error',
123
- 'no-unassigned-vars': 'error',
124
- 'no-undef-init': 'error',
125
- 'no-undefined': 'off',
126
- 'no-underscore-dangle': 'off',
127
- 'no-unmodified-loop-condition': 'error',
128
- 'no-unneeded-ternary': 'error',
129
- 'no-unreachable-loop': 'error',
130
- 'no-unused-expressions': 'off',
131
- 'no-unused-private-class-members': 'error',
132
- 'no-unused-vars': [
133
- 'error',
134
- {
135
- args: 'after-used',
136
- argsIgnorePattern: '^_',
137
- ignoreRestSiblings: true,
138
- varsIgnorePattern: '^ignored',
139
- },
140
- ],
141
- 'no-use-before-define': ['error', 'nofunc'],
142
- 'no-useless-assignment': 'warn',
143
- 'no-useless-call': 'error',
144
- 'no-useless-computed-key': 'error',
145
- 'no-useless-concat': 'error',
146
- 'no-useless-constructor': 'error',
147
- 'no-useless-rename': 'error',
148
- 'no-useless-return': 'error',
149
- 'no-var': 'error',
150
- 'no-void': 'off',
151
- 'no-warning-comments': [
152
- 'error',
153
- { location: 'anywhere', terms: ['fixme'] },
154
- ],
155
- 'object-shorthand': ['error', 'properties'],
156
- 'one-var': ['error', { initialized: 'never', uninitialized: 'always' }],
157
- 'operator-assignment': 'off',
158
- 'prefer-arrow-callback': [
159
- 'error',
160
- { allowNamedFunctions: true, allowUnboundThis: true },
161
- ],
162
- 'prefer-const': 'error',
163
- 'prefer-destructuring': 'off',
164
- 'prefer-exponentiation-operator': 'warn',
165
- 'prefer-named-capture-group': 'off',
166
- 'prefer-numeric-literals': 'error',
167
- 'prefer-object-has-own': 'error',
168
- 'prefer-object-spread': 'warn',
169
- 'prefer-promise-reject-errors': 'off',
170
- 'prefer-regex-literals': 'off',
171
- 'prefer-rest-params': 'error',
172
- 'prefer-spread': 'error',
173
- 'prefer-template': 'error',
174
- 'preserve-caught-error': 'warn',
175
- radix: 'error',
176
- 'require-atomic-updates': 'off',
177
- 'require-await': 'off',
178
- 'require-unicode-regexp': 'off',
179
- 'sort-imports': 'off',
180
- 'sort-keys': 'off',
181
- 'sort-vars': 'off',
182
- strict: 'error',
183
- 'symbol-description': 'error',
184
- 'unicode-bom': ['error', 'never'],
185
- 'vars-on-top': 'error',
186
- yoda: 'error',
187
- },
199
+ 'import-x/consistent-type-specifier-style': ['error', 'prefer-inline'],
200
+ 'import-x/dynamic-import-chunkname': 'off',
201
+ 'import-x/exports-last': 'off',
202
+ 'import-x/extensions': 'off',
203
+ 'import-x/first': 'error',
204
+ 'import-x/group-exports': 'off',
205
+ 'import-x/max-dependencies': 'off',
206
+ 'import-x/newline-after-import': 'off',
207
+ 'import-x/no-absolute-path': 'error',
208
+ 'import-x/no-amd': 'error',
209
+ 'import-x/no-anonymous-default-export': [
210
+ 'error',
211
+ { allowArray: true, allowObject: true },
212
+ ],
213
+ 'import-x/no-commonjs': 'off',
214
+ 'import-x/no-cycle': 'off',
215
+ 'import-x/no-default-export': 'off',
216
+ 'import-x/no-deprecated': 'warn',
217
+ 'import-x/no-dynamic-require': 'off',
218
+ 'import-x/no-empty-named-blocks': 'warn',
219
+ 'import-x/no-extraneous-dependencies': 'error',
220
+ 'import-x/no-import-module-exports': 'error',
221
+ 'import-x/no-internal-modules': 'off',
222
+ 'import-x/no-mutable-exports': 'error',
223
+ 'import-x/no-named-default': 'error',
224
+ 'import-x/no-named-export': 'off',
225
+ 'import-x/no-namespace': 'off',
226
+ 'import-x/no-nodejs-modules': 'off',
227
+ 'import-x/no-relative-packages': 'warn',
228
+ 'import-x/no-relative-parent-imports': 'off',
229
+ 'import-x/no-rename-default': 'off',
230
+ 'import-x/no-restricted-paths': 'off',
231
+ 'import-x/no-self-import': 'error',
232
+ 'import-x/no-unassigned-import': 'off',
233
+ 'import-x/no-unused-modules': 'off',
234
+ 'import-x/no-useless-path-segments': 'error',
235
+ 'import-x/no-webpack-loader-syntax': 'error',
236
+ 'import-x/order': 'off',
237
+ 'import-x/prefer-default-export': 'off',
238
+ 'import-x/prefer-namespace-import': 'off',
239
+ 'import-x/unambiguous': 'off',
240
+
241
+ 'mrpalmer/require-package-scope': 'off',
188
242
  },
189
- pluginImport.flatConfigs.recommended,
190
- {
191
- name: 'mrpalmer/import',
192
- rules: {
193
- 'import-x/consistent-type-specifier-style': ['error', 'prefer-inline'],
194
- 'import-x/dynamic-import-chunkname': 'off',
195
- 'import-x/exports-last': 'off',
196
- 'import-x/extensions': 'off',
197
- 'import-x/first': 'error',
198
- 'import-x/group-exports': 'off',
199
- 'import-x/max-dependencies': 'off',
200
- 'import-x/newline-after-import': 'off',
201
- 'import-x/no-absolute-path': 'error',
202
- 'import-x/no-amd': 'error',
203
- 'import-x/no-anonymous-default-export': [
204
- 'error',
205
- { allowArray: true, allowObject: true },
206
- ],
207
- 'import-x/no-commonjs': 'off',
208
- 'import-x/no-cycle': 'off',
209
- 'import-x/no-default-export': 'off',
210
- 'import-x/no-deprecated': 'warn',
211
- 'import-x/no-dynamic-require': 'off',
212
- 'import-x/no-empty-named-blocks': 'warn',
213
- 'import-x/no-extraneous-dependencies': 'error',
214
- 'import-x/no-import-module-exports': 'error',
215
- 'import-x/no-internal-modules': 'off',
216
- 'import-x/no-mutable-exports': 'error',
217
- 'import-x/no-named-default': 'error',
218
- 'import-x/no-named-export': 'off',
219
- 'import-x/no-namespace': 'off',
220
- 'import-x/no-nodejs-modules': 'off',
221
- 'import-x/no-relative-packages': 'warn',
222
- 'import-x/no-relative-parent-imports': 'off',
223
- 'import-x/no-rename-default': 'off',
224
- 'import-x/no-restricted-paths': 'off',
225
- 'import-x/no-self-import': 'error',
226
- 'import-x/no-unassigned-import': 'off',
227
- 'import-x/no-unused-modules': 'off',
228
- 'import-x/no-useless-path-segments': 'error',
229
- 'import-x/no-webpack-loader-syntax': 'error',
230
- 'import-x/order': 'off',
231
- 'import-x/prefer-default-export': 'off',
232
- 'import-x/prefer-namespace-import': 'off',
233
- 'import-x/unambiguous': 'off',
234
- },
235
- settings: {
236
- 'import-x/ignore': ['node_modules', '.json$', '.(scss|less|css|styl)$'],
237
- 'import-x/resolver-x': [pluginImport.createNodeResolver()],
238
- },
239
- }
240
- )
243
+ settings: {
244
+ 'import-x/ignore': ['node_modules', '.json$', '.(scss|less|css|styl)$'],
245
+ 'import-x/resolver-x': [pluginImport.createNodeResolver()],
246
+ },
247
+ })
package/configs/react.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  getMinimumSupportedVersion,
10
10
  } from '../utils/packageJson.js'
11
11
 
12
- const oldestSupportedReactVersion = '16.5.2'
12
+ const oldestSupportedReactVersion = '18.0.0'
13
13
 
14
14
  const allDeps = getAllDependencies()
15
15
  const minimumSupportedReactVersion =
package/configs/tests.js CHANGED
@@ -184,7 +184,17 @@ export default defineConfig(
184
184
  name: 'mrpalmer/jest/typescript',
185
185
  rules: {
186
186
  '@typescript-eslint/unbound-method': 'off',
187
- 'jest/unbound-method': 'error',
187
+
188
+ ...(hasJest
189
+ ? {
190
+ 'jest/unbound-method': 'error',
191
+ }
192
+ : hasVitest
193
+ ? {
194
+ // feature is planned but not supported yet
195
+ // 'vitest/unbound-method': 'error',
196
+ }
197
+ : {}),
188
198
  },
189
199
  }
190
200
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrpalmer/eslint-config",
3
- "version": "2.4.0",
3
+ "version": "2.4.2",
4
4
  "description": "Mike Palmer's personal ESLint rules",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -33,7 +33,8 @@
33
33
  "dependencies": {
34
34
  "@eslint-react/eslint-plugin": "^2.3.7",
35
35
  "@eslint/js": "^9.39.1",
36
- "@mrpalmer/eslint-plugin": "^1.0.3",
36
+ "@eslint/json": "^0.14.0",
37
+ "@mrpalmer/eslint-plugin": "^1.1.1",
37
38
  "@vitest/eslint-plugin": "^1.4.3",
38
39
  "eslint-import-resolver-typescript": "^4.4.4",
39
40
  "eslint-plugin-import-x": "^4.16.1",
@@ -1,6 +1,9 @@
1
+ import { createRequire } from 'node:module'
1
2
  import { readPackageUpSync } from 'read-package-up'
2
3
  import * as semver from 'semver'
3
4
 
5
+ const require = createRequire(import.meta.url)
6
+
4
7
  /** @typedef {Record<string, string>} Dependencies */
5
8
 
6
9
  /**
@@ -27,12 +30,21 @@ export function getAllDependencies() {
27
30
  * @returns {string | undefined}
28
31
  */
29
32
  export function getMinimumSupportedVersion(allDeps, depName) {
33
+ try {
34
+ return require(`${depName}/package.json`).version
35
+ } catch {
36
+ // fallback to logic below
37
+ }
38
+
30
39
  if (!allDeps[depName]) {
31
40
  return undefined
32
41
  }
42
+ const range = semver.validRange(allDeps[depName])
43
+ if (!range) {
44
+ return undefined
45
+ }
33
46
 
34
- const versions = semver
35
- .validRange(allDeps[depName])
47
+ const versions = range
36
48
  .replace(/[>=<|]/g, ' ')
37
49
  .split(' ')
38
50
  .filter(Boolean)