@dr.pogodin/eslint-configs 0.0.5 → 0.0.7

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/README.md CHANGED
@@ -146,12 +146,15 @@ and it applies to them the following rule sets:
146
146
  the `recommended` rule set, with minor overrides, and many additional rules
147
147
  enabled.
148
148
 
149
- - [eslint-plugin-react-hooks](https://www.npmjs.com/package/eslint-plugin-react-hooks) —
150
- all rules enabled.
151
-
152
149
  Additionally, it applies to all other files matched by any other [ESLint]
153
- configuration object, to forbid using JSX syntax in files with extensions
154
- different from `.jsx` or `.tsx`.
150
+ configuration object; and it applies to them the following rule sets:
151
+
152
+ - [eslint-plugin-react-hooks](https://www.npmjs.com/package/eslint-plugin-react-hooks)
153
+ — all rules enabled (it has to apply to all files, as hooks do not have
154
+ to live ony inside JSX or TSX files exclusively).
155
+
156
+ - the rule that forbids using JSX syntax in files with extensions different from
157
+ `.jsx` or `.tsx`.
155
158
 
156
159
  ### `configs.typescript`
157
160
  [`configs.typescript`]: #configstypescript
@@ -71,6 +71,9 @@ export default defineConfig([{
71
71
  'import/no-unused-modules': 'error',
72
72
  'import/no-useless-path-segments': 'error',
73
73
  'import/no-webpack-loader-syntax': 'error',
74
+ 'import/order': ['error', {
75
+ groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
76
+ }],
74
77
 
75
78
  // These rules are provided by "@stylistic/eslint-plugin",
76
79
  // and (re-)configured for our taste, somewhat differently from
@@ -212,7 +215,9 @@ export default defineConfig([{
212
215
  'no-new-wrappers': 'error',
213
216
  'no-object-constructor': 'error',
214
217
  'no-octal-escape': 'error',
215
- 'no-param-reassign': 'error',
218
+ 'no-param-reassign': ['error', {
219
+ props: true,
220
+ }],
216
221
  'no-promise-executor-return': 'error',
217
222
  'no-proto': 'error',
218
223
  'no-return-assign': 'error',
@@ -222,6 +227,7 @@ export default defineConfig([{
222
227
  'no-shadow': 'error',
223
228
  'no-template-curly-in-string': 'error',
224
229
  'no-throw-literal': 'error',
230
+ 'no-unassigned-vars': 'error',
225
231
  'no-undef-init': 'error',
226
232
  'no-underscore-dangle': 'error',
227
233
  'no-unmodified-loop-condition': 'error',
@@ -256,6 +262,17 @@ export default defineConfig([{
256
262
  'require-atomic-updates': 'error',
257
263
  'require-await': 'error',
258
264
  'require-yield': 'error',
265
+
266
+ // TODO: Disabled for now, as there is one thing I don't like about it:
267
+ // in TypeScript it sorts type imports together with other imported members,
268
+ // while I'd prefer to have all type member imports first, followed by other
269
+ // imported members after.
270
+ /*
271
+ 'sort-imports': ['error', {
272
+ ignoreDeclarationSort: true,
273
+ }],
274
+ */
275
+
259
276
  'sort-keys': ['error', 'asc', {
260
277
  allowLineSeparatedGroups: true,
261
278
  }],
package/config/jest.js CHANGED
@@ -39,6 +39,8 @@ export default defineConfig([{
39
39
  'jest/prefer-todo': 'error',
40
40
  'jest/require-to-throw-message': 'error',
41
41
 
42
+ 'no-console': 'off',
43
+
42
44
  '@typescript-eslint/unbound-method': 'off',
43
45
  },
44
46
  }]);
package/config/react.js CHANGED
@@ -18,7 +18,6 @@ export default defineConfig([{
18
18
  },
19
19
  plugins: {
20
20
  react,
21
- 'react-hooks': reactHooks,
22
21
  },
23
22
  settings: {
24
23
  react: {
@@ -101,20 +100,33 @@ export default defineConfig([{
101
100
  'react/sort-comp': 'error',
102
101
  'react/style-prop-object': 'error',
103
102
  'react/void-dom-elements-no-children': 'error',
104
-
105
- // Rules provided by eslint-plugin-react-hooks.
106
- 'react-hooks/exhaustive-deps': 'error',
107
- 'react-hooks/rules-of-hooks': 'error',
103
+ },
104
+ }, {
105
+ files: ['**/*.jsx'],
106
+ name: 'dr.pogodin/react/jsx',
107
+ rules: {
108
+ // This is our preferred naming scheme for pure JSX code (i.e., non-TypeScript).
109
+ 'react/function-component-definition': ['error', {
110
+ namedComponents: 'function-declaration',
111
+ unnamedComponents: 'arrow-function',
112
+ }],
108
113
  },
109
114
  }, {
110
115
  name: 'dr.pogodin/react/global',
111
116
  plugins: {
112
117
  react,
118
+ 'react-hooks': reactHooks,
113
119
  },
114
120
  rules: {
115
121
  'react/jsx-filename-extension': ['error', {
116
122
  allow: 'as-needed',
117
123
  extensions: ['.jsx', '.tsx'],
118
124
  }],
125
+
126
+ // Rules provided by eslint-plugin-react-hooks; they should be applied to
127
+ // all files, as hooks do not have to live exclusively in .jsx / .tsx files
128
+ // alongside JSX syntax!
129
+ 'react-hooks/exhaustive-deps': 'error',
130
+ 'react-hooks/rules-of-hooks': 'error',
119
131
  },
120
132
  }]);
@@ -52,6 +52,7 @@ export default tsEsLint.config(
52
52
  '@typescript-eslint/no-mixed-enums': 'error',
53
53
  '@typescript-eslint/no-non-null-asserted-nullish-coalescing': 'error',
54
54
  '@typescript-eslint/no-redeclare': 'error',
55
+ '@typescript-eslint/no-unnecessary-type-conversion': 'error',
55
56
 
56
57
  // NOTE: The core rule variant reports incorrect errors on TypeScript
57
58
  // code, thus disabled.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dr.pogodin/eslint-configs",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "ESLint configurations for TypeScript and/or React projects",
5
5
  "type": "module",
6
6
  "main": "./config/index.js",
@@ -31,19 +31,19 @@
31
31
  "dependencies": {
32
32
  "@babel/eslint-parser": "^7.27.1",
33
33
  "@babel/eslint-plugin": "^7.27.1",
34
- "@babel/preset-env": "^7.27.1",
34
+ "@babel/preset-env": "^7.27.2",
35
35
  "@babel/preset-react": "^7.27.1",
36
36
  "@babel/preset-typescript": "^7.27.1",
37
- "@eslint/js": "^9.26.0",
38
- "@stylistic/eslint-plugin": "^4.1.0",
39
- "eslint": "^9.26.0",
40
- "eslint-import-resolver-typescript": "^4.3.4",
37
+ "@eslint/js": "^9.27.0",
38
+ "@stylistic/eslint-plugin": "^4.4.0",
39
+ "eslint": "^9.27.0",
40
+ "eslint-import-resolver-typescript": "^4.3.5",
41
41
  "eslint-plugin-import": "^2.31.0",
42
42
  "eslint-plugin-jest": "^28.11.0",
43
43
  "eslint-plugin-jsx-a11y": "^6.10.2",
44
44
  "eslint-plugin-react": "^7.37.4",
45
45
  "eslint-plugin-react-hooks": "^5.2.0",
46
46
  "typescript": "^5.7.0",
47
- "typescript-eslint": "^8.31.1"
47
+ "typescript-eslint": "^8.32.1"
48
48
  }
49
49
  }