@mrpalmer/eslint-config 2.3.1 → 2.4.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/configs/react.js CHANGED
@@ -57,6 +57,7 @@ export default defineConfig(
57
57
  'jsx-a11y/prefer-tag-over-role': 'off',
58
58
  'jsx-a11y/tabindex-no-positive': 'warn',
59
59
 
60
+ '@eslint-react/jsx-dollar': 'warn',
60
61
  '@eslint-react/jsx-key-before-spread': 'warn',
61
62
  '@eslint-react/jsx-no-iife': 'warn',
62
63
  '@eslint-react/jsx-no-undef': 'error',
@@ -64,7 +65,6 @@ export default defineConfig(
64
65
  '@eslint-react/jsx-shorthand-fragment': 'warn',
65
66
  '@eslint-react/no-children-prop': 'warn',
66
67
  '@eslint-react/no-class-component': 'warn',
67
- '@eslint-react/no-forbidden-props': 'off',
68
68
  '@eslint-react/no-leaked-conditional-rendering': 'off', // will be enabled for typescript files below
69
69
  '@eslint-react/no-missing-component-display-name': 'warn',
70
70
  '@eslint-react/no-missing-context-display-name': 'warn',
@@ -0,0 +1,190 @@
1
+ import pluginVitest from '@vitest/eslint-plugin'
2
+ import { defineConfig } from 'eslint/config'
3
+ import pluginJest from 'eslint-plugin-jest'
4
+ import pluginJestDom from 'eslint-plugin-jest-dom'
5
+ import pluginTestingLibrary from 'eslint-plugin-testing-library'
6
+ import { getAllDependencies } from '../utils/packageJson.js'
7
+
8
+ const allDeps = new Set(Object.keys(getAllDependencies()))
9
+
10
+ const hasJest = allDeps.has('jest')
11
+ const hasVitest = allDeps.has('vitest')
12
+ const hasJestDom = allDeps.has('@testing-library/jest-dom')
13
+ const hasTestingLibraryDom = allDeps.has('@testing-library/dom')
14
+ const hasTestingLibraryReact = allDeps.has('@testing-library/react')
15
+ const hasTestingLibrary = hasTestingLibraryDom || hasTestingLibraryReact
16
+
17
+ export default defineConfig(
18
+ {
19
+ extends: [
20
+ hasJest && {
21
+ name: 'jest/recommended',
22
+ ...pluginJest.configs['flat/recommended'],
23
+ },
24
+ hasJest && { name: 'jest/style', ...pluginJest.configs['flat/style'] },
25
+ hasVitest && pluginVitest.configs.recommended,
26
+ hasJestDom && {
27
+ name: 'jest-dom/recommended',
28
+ ...pluginJestDom.configs['flat/recommended'],
29
+ },
30
+ hasTestingLibraryReact
31
+ ? {
32
+ name: 'testing-library/react',
33
+ ...pluginTestingLibrary.configs['flat/react'],
34
+ }
35
+ : hasTestingLibraryDom
36
+ ? {
37
+ name: 'testing-library/dom',
38
+ ...pluginTestingLibrary.configs['flat/dom'],
39
+ }
40
+ : null,
41
+ ].filter(Boolean),
42
+ files: ['**/__tests__/**/*.+(js|ts)?(x)', '**/*.{spec,test}.+(js|ts)?(x)'],
43
+ name: 'mrpalmer/jest',
44
+
45
+ rules: {
46
+ // we don't need a display name in test files
47
+ '@eslint-react/no-missing-component-display-name': 'off',
48
+ '@eslint-react/no-missing-context-display-name': 'off',
49
+
50
+ ...(hasJest
51
+ ? {
52
+ 'jest/consistent-test-it': 'warn',
53
+ 'jest/max-expects': 'off',
54
+ 'jest/max-nested-describe': 'error',
55
+ 'jest/no-conditional-in-test': 'error',
56
+ 'jest/no-confusing-set-timeout': 'error',
57
+ 'jest/no-duplicate-hooks': 'off',
58
+ 'jest/no-hooks': 'off',
59
+ 'jest/no-large-snapshots': ['warn', { maxSize: 300 }],
60
+ 'jest/no-restricted-jest-methods': 'off',
61
+ 'jest/no-restricted-matchers': 'off',
62
+ 'jest/no-test-return-statement': 'off',
63
+ 'jest/no-untyped-mock-factory': 'error',
64
+ 'jest/padding-around-after-all-blocks': 'off',
65
+ 'jest/padding-around-after-each-blocks': 'off',
66
+ 'jest/padding-around-all': 'off',
67
+ 'jest/padding-around-before-all-blocks': 'off',
68
+ 'jest/padding-around-before-each-blocks': 'off',
69
+ 'jest/padding-around-describe-blocks': 'off',
70
+ 'jest/padding-around-expect-groups': 'off',
71
+ 'jest/padding-around-test-blocks': 'off',
72
+ 'jest/prefer-called-with': 'error',
73
+ 'jest/prefer-comparison-matcher': 'warn',
74
+ 'jest/prefer-each': 'warn',
75
+ 'jest/prefer-ending-with-an-expect': 'warn',
76
+ 'jest/prefer-equality-matcher': 'warn',
77
+ 'jest/prefer-expect-assertions': 'off',
78
+ 'jest/prefer-expect-resolves': 'off',
79
+ 'jest/prefer-hooks-in-order': 'error',
80
+ 'jest/prefer-hooks-on-top': 'error',
81
+ 'jest/prefer-importing-jest-globals': 'off',
82
+ 'jest/prefer-jest-mocked': 'warn',
83
+ 'jest/prefer-lowercase-title': 'off',
84
+ 'jest/prefer-mock-promise-shorthand': 'warn',
85
+ 'jest/prefer-snapshot-hint': ['error', 'multi'],
86
+ 'jest/prefer-spy-on': 'warn',
87
+ 'jest/prefer-strict-equal': 'off',
88
+ 'jest/prefer-todo': 'warn',
89
+ 'jest/require-hook': 'off',
90
+ 'jest/require-to-throw-message': 'off',
91
+ 'jest/require-top-level-describe': 'off',
92
+ 'jest/unbound-method': 'off',
93
+ 'jest/valid-mock-module-path': 'warn',
94
+ }
95
+ : {}),
96
+
97
+ ...(hasVitest
98
+ ? {
99
+ 'vitest/consistent-test-filename': 'off',
100
+ 'vitest/consistent-test-it': 'warn',
101
+ 'vitest/consistent-vitest-vi': 'warn',
102
+ 'vitest/hoisted-apis-on-top': 'error',
103
+ 'vitest/max-expects': 'off',
104
+ 'vitest/max-nested-describe': 'error',
105
+ 'vitest/no-alias-methods': 'off',
106
+ 'vitest/no-conditional-expect': 'error',
107
+ 'vitest/no-conditional-in-test': 'error',
108
+ 'vitest/no-conditional-tests': 'error',
109
+ 'vitest/no-disabled-tests': 'warn',
110
+ 'vitest/no-duplicate-hooks': 'off',
111
+ 'vitest/no-focused-tests': 'error',
112
+ 'vitest/no-hooks': 'off',
113
+ 'vitest/no-importing-vitest-globals': 'off',
114
+ 'vitest/no-interpolation-in-snapshots': 'warn',
115
+ 'vitest/no-large-snapshots': ['warn', { maxSize: 300 }],
116
+ 'vitest/no-mocks-import': 'error',
117
+ 'vitest/no-restricted-matchers': 'off',
118
+ 'vitest/no-restricted-vi-methods': 'off',
119
+ 'vitest/no-standalone-expect': 'error',
120
+ 'vitest/no-test-prefixes': 'off',
121
+ 'vitest/no-test-return-statement': 'error',
122
+ 'vitest/prefer-called-once': 'warn',
123
+ 'vitest/prefer-called-times': 'off',
124
+ 'vitest/prefer-called-with': 'error',
125
+ 'vitest/prefer-comparison-matcher': 'warn',
126
+ 'vitest/prefer-describe-function-title': 'warn',
127
+ 'vitest/prefer-each': 'warn',
128
+ 'vitest/prefer-equality-matcher': 'warn',
129
+ 'vitest/prefer-expect-assertions': 'off',
130
+ 'vitest/prefer-expect-resolves': 'off',
131
+ 'vitest/prefer-expect-type-of': 'warn',
132
+ 'vitest/prefer-hooks-in-order': 'error',
133
+ 'vitest/prefer-hooks-on-top': 'error',
134
+ 'vitest/prefer-import-in-mock': 'warn',
135
+ 'vitest/prefer-importing-vitest-globals': 'off',
136
+ 'vitest/prefer-lowercase-title': 'off',
137
+ 'vitest/prefer-mock-promise-shorthand': 'warn',
138
+ 'vitest/prefer-snapshot-hint': ['error', 'multi'],
139
+ 'vitest/prefer-spy-on': 'warn',
140
+ 'vitest/prefer-strict-boolean-matchers': 'off',
141
+ 'vitest/prefer-strict-equal': 'off',
142
+ 'vitest/prefer-to-be': 'warn',
143
+ 'vitest/prefer-to-be-falsy': 'off',
144
+ 'vitest/prefer-to-be-object': 'warn',
145
+ 'vitest/prefer-to-be-truthy': 'off',
146
+ 'vitest/prefer-to-contain': 'warn',
147
+ 'vitest/prefer-to-have-length': 'warn',
148
+ 'vitest/prefer-todo': 'warn',
149
+ 'vitest/prefer-vi-mocked': 'warn',
150
+ 'vitest/require-awaited-expect-poll': 'error',
151
+ 'vitest/require-hook': 'off',
152
+ 'vitest/require-mock-type-parameters': 'off',
153
+ 'vitest/require-to-throw-message': 'off',
154
+ 'vitest/require-top-level-describe': 'off',
155
+ 'vitest/valid-expect-in-promise': 'error',
156
+ 'vitest/warn-todo': 'warn',
157
+
158
+ // disable style rules
159
+ 'vitest/padding-around-after-all-blocks': 'off',
160
+ 'vitest/padding-around-after-each-blocks': 'off',
161
+ 'vitest/padding-around-all': 'off',
162
+ 'vitest/padding-around-before-all-blocks': 'off',
163
+ 'vitest/padding-around-before-each-blocks': 'off',
164
+ 'vitest/padding-around-describe-blocks': 'off',
165
+ 'vitest/padding-around-expect-groups': 'off',
166
+ 'vitest/padding-around-test-blocks': 'off',
167
+ }
168
+ : {}),
169
+
170
+ ...(hasTestingLibrary
171
+ ? {
172
+ 'testing-library/consistent-data-testid': 'off',
173
+ 'testing-library/no-test-id-queries': 'warn',
174
+ 'testing-library/prefer-explicit-assert': 'warn',
175
+ 'testing-library/prefer-implicit-assert': 'off',
176
+ 'testing-library/prefer-query-matchers': 'off',
177
+ 'testing-library/prefer-user-event': 'error',
178
+ }
179
+ : null),
180
+ },
181
+ },
182
+ {
183
+ files: ['**/__tests__/**/*.ts?(x)', '**/*.{spec,test}.ts?(x)'],
184
+ name: 'mrpalmer/jest/typescript',
185
+ rules: {
186
+ '@typescript-eslint/unbound-method': 'off',
187
+ 'jest/unbound-method': 'error',
188
+ },
189
+ }
190
+ )
@@ -133,6 +133,7 @@ export default defineConfig({
133
133
  '@typescript-eslint/no-unnecessary-type-arguments': 'warn',
134
134
  '@typescript-eslint/no-unnecessary-type-conversion': 'warn',
135
135
  '@typescript-eslint/no-unsafe-type-assertion': 'error',
136
+ '@typescript-eslint/no-unused-private-class-members': 'error',
136
137
  '@typescript-eslint/no-useless-empty-export': 'error',
137
138
  '@typescript-eslint/parameter-properties': [
138
139
  'error',
package/index.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import globals from 'globals'
2
2
  import base from './configs/base.js'
3
- import jest from './configs/jest.js'
4
3
  import react from './configs/react.js'
4
+ import tests from './configs/tests.js'
5
5
  import typescript from './configs/typescript.js'
6
6
 
7
7
  const configs = {
8
- all: [...base, ...typescript, ...react, ...jest],
8
+ all: [...base, ...typescript, ...react, ...tests],
9
9
  base,
10
- jest,
11
10
  react,
11
+ tests,
12
12
  typescript,
13
13
  }
14
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrpalmer/eslint-config",
3
- "version": "2.3.1",
3
+ "version": "2.4.0",
4
4
  "description": "Mike Palmer's personal ESLint rules",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -23,28 +23,29 @@
23
23
  "prebuild": "rm -rf types",
24
24
  "build": "tsc",
25
25
  "check-config": "run-p check-config:*",
26
- "check-config:jest": "cd test && validate-config -f component.test.js",
27
- "check-config:jest-ts": "cd test && validate-config -f component.test.ts",
28
26
  "check-config:js": "cd test && validate-config -f index.js",
27
+ "check-config:tests": "cd test && validate-config -f component.test.js",
28
+ "check-config:tests-ts": "cd test && validate-config -f component.test.ts",
29
29
  "check-config:ts": "cd test && validate-config -f index.ts",
30
30
  "dev": "cd test && eslint-config-inspector",
31
31
  "validate": "npm run check-config"
32
32
  },
33
33
  "dependencies": {
34
- "@eslint-react/eslint-plugin": "^2.2.2",
35
- "@eslint/js": "^9.31.0",
34
+ "@eslint-react/eslint-plugin": "^2.3.7",
35
+ "@eslint/js": "^9.39.1",
36
36
  "@mrpalmer/eslint-plugin": "^1.0.3",
37
+ "@vitest/eslint-plugin": "^1.4.3",
37
38
  "eslint-import-resolver-typescript": "^4.4.4",
38
39
  "eslint-plugin-import-x": "^4.16.1",
39
- "eslint-plugin-jest": "^29.0.1",
40
+ "eslint-plugin-jest": "^29.2.0",
40
41
  "eslint-plugin-jest-dom": "^5.5.0",
41
42
  "eslint-plugin-jsx-a11y": "^6.10.2",
42
- "eslint-plugin-react-hooks": "^7.0.0",
43
- "eslint-plugin-testing-library": "^7.13.3",
43
+ "eslint-plugin-react-hooks": "^7.0.1",
44
+ "eslint-plugin-testing-library": "^7.13.5",
44
45
  "globals": "^16.4.0",
45
46
  "read-package-up": "^11.0.0",
46
47
  "semver": "^7.7.3",
47
- "typescript-eslint": "^8.46.1"
48
+ "typescript-eslint": "^8.47.0"
48
49
  },
49
50
  "peerDependencies": {
50
51
  "@testing-library/dom": "*",
@@ -1,2 +1,2 @@
1
- declare const _default: import("@eslint/core", { with: { "resolution-mode": "require" } }).ConfigObject<import("@eslint/core", { with: { "resolution-mode": "require" } }).RulesConfig>[];
1
+ declare const _default: import("eslint/config").Config[];
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: import("@eslint/core", { with: { "resolution-mode": "require" } }).ConfigObject<import("@eslint/core", { with: { "resolution-mode": "require" } }).RulesConfig>[];
1
+ declare const _default: import("eslint/config").Config[];
2
2
  export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: import("eslint/config").Config[];
2
+ export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: import("@eslint/core", { with: { "resolution-mode": "require" } }).ConfigObject<import("@eslint/core", { with: { "resolution-mode": "require" } }).RulesConfig>[];
1
+ declare const _default: import("eslint/config").Config[];
2
2
  export default _default;
package/types/index.d.ts CHANGED
@@ -4,15 +4,15 @@ declare namespace _default {
4
4
  }
5
5
  export default _default;
6
6
  export namespace configs {
7
- export let all: import("@eslint/core", { with: { "resolution-mode": "require" } }).ConfigObject<import("@eslint/core", { with: { "resolution-mode": "require" } }).RulesConfig>[];
7
+ export let all: import("eslint/config").Config[];
8
8
  export { base };
9
- export { jest };
10
9
  export { react };
10
+ export { tests };
11
11
  export { typescript };
12
12
  }
13
13
  import globals from 'globals';
14
14
  import base from './configs/base.js';
15
- import jest from './configs/jest.js';
16
15
  import react from './configs/react.js';
16
+ import tests from './configs/tests.js';
17
17
  import typescript from './configs/typescript.js';
18
18
  export { globals };
package/configs/jest.js DELETED
@@ -1,105 +0,0 @@
1
- import { defineConfig } from 'eslint/config'
2
- import pluginJest from 'eslint-plugin-jest'
3
- import pluginJestDom from 'eslint-plugin-jest-dom'
4
- import pluginTestingLibrary from 'eslint-plugin-testing-library'
5
- import { getAllDependencies } from '../utils/packageJson.js'
6
-
7
- const allDeps = new Set(Object.keys(getAllDependencies()))
8
-
9
- const hasJestDom = allDeps.has('@testing-library/jest-dom')
10
- const hasTestingLibraryDom = allDeps.has('@testing-library/dom')
11
- const hasTestingLibraryReact = allDeps.has('@testing-library/react')
12
- const hasTestingLibrary = hasTestingLibraryDom || hasTestingLibraryReact
13
-
14
- export default defineConfig(
15
- {
16
- extends: [
17
- { name: 'jest/recommended', ...pluginJest.configs['flat/recommended'] },
18
- { name: 'jest/style', ...pluginJest.configs['flat/style'] },
19
- hasJestDom && {
20
- name: 'jest-dom/recommended',
21
- ...pluginJestDom.configs['flat/recommended'],
22
- },
23
- hasTestingLibraryReact
24
- ? {
25
- name: 'testing-library/react',
26
- ...pluginTestingLibrary.configs['flat/react'],
27
- }
28
- : hasTestingLibraryDom
29
- ? {
30
- name: 'testing-library/dom',
31
- ...pluginTestingLibrary.configs['flat/dom'],
32
- }
33
- : null,
34
- ].filter(Boolean),
35
- files: ['**/__tests__/**/*.+(js|ts)?(x)', '**/*.{spec,test}.+(js|ts)?(x)'],
36
- name: 'mrpalmer/jest',
37
-
38
- rules: {
39
- // we don't need a display name in test files
40
- '@eslint-react/no-missing-component-display-name': 'off',
41
- '@eslint-react/no-missing-context-display-name': 'off',
42
-
43
- 'jest/consistent-test-it': 'off',
44
- 'jest/max-expects': 'off',
45
- 'jest/max-nested-describe': 'error',
46
- 'jest/no-conditional-in-test': 'error',
47
- 'jest/no-confusing-set-timeout': 'error',
48
- 'jest/no-duplicate-hooks': 'off',
49
- 'jest/no-hooks': 'off',
50
- 'jest/no-large-snapshots': ['warn', { maxSize: 300 }],
51
- 'jest/no-restricted-jest-methods': 'off',
52
- 'jest/no-restricted-matchers': 'off',
53
- 'jest/no-test-return-statement': 'off',
54
- 'jest/no-untyped-mock-factory': 'error',
55
- 'jest/padding-around-after-all-blocks': 'off',
56
- 'jest/padding-around-after-each-blocks': 'off',
57
- 'jest/padding-around-all': 'off',
58
- 'jest/padding-around-before-all-blocks': 'off',
59
- 'jest/padding-around-before-each-blocks': 'off',
60
- 'jest/padding-around-describe-blocks': 'off',
61
- 'jest/padding-around-expect-groups': 'off',
62
- 'jest/padding-around-test-blocks': 'off',
63
- 'jest/prefer-called-with': 'error',
64
- 'jest/prefer-comparison-matcher': 'warn',
65
- 'jest/prefer-each': 'warn',
66
- 'jest/prefer-ending-with-an-expect': 'warn',
67
- 'jest/prefer-equality-matcher': 'warn',
68
- 'jest/prefer-expect-assertions': 'off',
69
- 'jest/prefer-expect-resolves': 'off',
70
- 'jest/prefer-hooks-in-order': 'error',
71
- 'jest/prefer-hooks-on-top': 'error',
72
- 'jest/prefer-importing-jest-globals': 'off',
73
- 'jest/prefer-jest-mocked': 'warn',
74
- 'jest/prefer-lowercase-title': 'off',
75
- 'jest/prefer-mock-promise-shorthand': 'warn',
76
- 'jest/prefer-snapshot-hint': ['error', 'multi'],
77
- 'jest/prefer-spy-on': 'off',
78
- 'jest/prefer-strict-equal': 'off',
79
- 'jest/prefer-todo': 'warn',
80
- 'jest/require-hook': 'off',
81
- 'jest/require-to-throw-message': 'off',
82
- 'jest/require-top-level-describe': 'off',
83
- 'jest/unbound-method': 'off',
84
-
85
- ...(hasTestingLibrary
86
- ? {
87
- 'testing-library/consistent-data-testid': 'off',
88
- 'testing-library/no-test-id-queries': 'warn',
89
- 'testing-library/prefer-explicit-assert': 'warn',
90
- 'testing-library/prefer-implicit-assert': 'off',
91
- 'testing-library/prefer-query-matchers': 'off',
92
- 'testing-library/prefer-user-event': 'error',
93
- }
94
- : null),
95
- },
96
- },
97
- {
98
- files: ['**/__tests__/**/*.ts?(x)', '**/*.{spec,test}.ts?(x)'],
99
- name: 'mrpalmer/jest/typescript',
100
- rules: {
101
- '@typescript-eslint/unbound-method': 'off',
102
- 'jest/unbound-method': 'error',
103
- },
104
- }
105
- )
@@ -1,2 +0,0 @@
1
- declare const _default: import("@eslint/core", { with: { "resolution-mode": "require" } }).ConfigObject<import("@eslint/core", { with: { "resolution-mode": "require" } }).RulesConfig>[];
2
- export default _default;