eslint-config-beslogic 2.0.2 → 2.2.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/CHANGELOG.md CHANGED
@@ -1,5 +1,74 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.2.1
4
+
5
+ - Bumped `eslint-plugin-react` to `^7.33`
6
+ - Check context objects with `react/display-name`
7
+ - Added React 18 deprecations
8
+ - Remove accidental recommendation to install `eslint-plugn-react-redux` from non-redux presets in `README.md`
9
+ - Now enforce at least 1 newline after imports even with dprint preset.
10
+ - Turn on `allowImplicit`, `checkForEach`, and `allowVoid` for rule `array-callback-return`
11
+ - Bumped `eslint-plugin-total-functions` to `>=6.0`
12
+ - which bumps `typescript` dependency to `4.7.3`
13
+ - Bumped `eslint-plugin-testing-library` to `^6.0` which enables a lot more rules by default
14
+ - Bumped `eslint-plugin-unicorn` to `>=49.0`
15
+ - Re-enabled `prefer-event-target` in Angular preset
16
+ - Disabled deprecated `unicorn/no-unsafe-regex`
17
+ - Start checking arguments again for `unicorn/no-useless-undefined`
18
+ now that it can also autofix `undefined` defaults to optional parameters
19
+ - Re-enabled `unicorn/no-nested-ternary`, which allows a single nested level if parenthesised
20
+ - Bumped `eslint-plugin-sonarjs` to `^1.0`
21
+ - Updated vulnerable dependencies
22
+ - They updated their license
23
+ - Bumped `eslint-plugin-simple-import-sort` to `>=12.0`
24
+ - Bumped `eslint-plugin-regexp` to `^2.0`
25
+ - Reduced dependencies
26
+ - Removal of deprecated rules: <https://github.com/ota-meshi/eslint-plugin-regexp#removed>
27
+ - Bumped `eslint-plugin-jest` to `^28.0.0`
28
+ - `jest/no-if` has been replaced by `jest/no-conditional-in-test`
29
+ - `jest/prefer-importing-jest-globals` is enabled by default, which removes needing a dependency
30
+ on often outdated `@types/jest` and removes the need for `types: ["jest"]` in `tsconfig.json`
31
+ - Bumped `dprint` to `^0.40.2` to prepare for process plugins
32
+
33
+ - Bumped `@typescript-eslint/eslint-plugin` to `^7.4`
34
+ - Re-enabled `@typescript-eslint/no-import-type-side-effects`
35
+ and set `@typescript-eslint/consistent-type-imports` back to default options
36
+ - Bumped `eslint` to `^8.56`
37
+ - which bumps `typescript` dependency to `4.7.5`
38
+ - Prefered `@typescript-eslint/prefer-destructuring` over `autofix/prefer-destructuring`
39
+ - Disabled `@typescript-eslint/key-spacing`, `autofix/func-call-spacing`,
40
+ and `lines-around-comment` in `dprint` preset
41
+
42
+ - Patched-out prettier from nx generators
43
+ - Used Search&Replace based package patching:
44
+ - Removes `patch-package` from dependencies
45
+ - Removes bundled git patches
46
+ - Speedup check for `eslint-plugin-total-functions` install
47
+
48
+ - Bumped `eslint-plugin-n` to `>=16.2`. Notably, this:
49
+ - improves support for ts-node
50
+ - Updates documentation links
51
+ - Sets Node 16 as the minimal default w/o having to configure `engines` in `package.json`
52
+ - Allow for automatic ts mapping detection
53
+ - Re-enabled `n/no-unpublished-*` rules by default as it's now based on package being public/private
54
+ - Set `ignoreTypeImport: true` by default for `n/no-unpublished-import`
55
+
56
+ ## 2.1.0
57
+
58
+ - Bumped the following minimum versions:
59
+ - `@angular-eslint/eslint-plugin@>=16.2`
60
+ - `@angular-eslint/eslint-plugin-template@>=16.2`
61
+ - `@angular-eslint/template-parser@>=16.2`
62
+ - `@typescript-eslint/eslint-plugin@^6.2`
63
+ - `eslint-plugin-jest@^27.2.3`
64
+ - `eslint-plugin-unused-imports@^3.0`
65
+ - Assuming `node>=16`, `typescript>=4.5` and `@angular/compiler>=16.2.5`
66
+ - This should speedup config parsing that had to check for specific versions
67
+ - Made `eslint-plugin-total-functions` optional due to its extra-strictness and it had to be
68
+ explicitly specified anyway due to version resolution issues
69
+ - Added link to changelog in README
70
+ - Improved detection of installed peer dependencies' version number to be more accurate and faster
71
+
3
72
  ## 2.0.2
4
73
 
5
74
  - Disabled the following rules in Storybook stories:
@@ -10,6 +79,7 @@
10
79
 
11
80
  ## 2.0.0
12
81
 
13
- - Created CHANGELOG.md
82
+ - Created `CHANGELOG.md`
14
83
  - Changed the maximum line length from `120` to `100`
15
- - Split language-specific `editor.defaultFormatter` to work around <https://github.com/microsoft/vscode/issues/168411>
84
+ - Split language-specific `editor.defaultFormatter` to work around
85
+ <https://github.com/microsoft/vscode/issues/168411>
package/README.md CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  ## Installation and usage
4
4
 
5
- Run `npm i --save-dev eslint-config-beslogic eslint-plugin-total-functions`
5
+ Run `npm i --save-dev eslint-config-beslogic`\
6
+ For extra strict TypeScript linting, you can also install [eslint-plugin-total-functions](https://www.npmjs.com/package/eslint-plugin-total-functions): `npm i --save-dev eslint-plugin-total-functions`\
7
+ The installation will be automatically detected and configured.
6
8
 
7
9
  Depending on your needs, you will need to also install other peer dependencies for linting.
8
10
 
@@ -17,7 +19,7 @@ These are configuration files you'll have to update manually to best work with t
17
19
 
18
20
  ### `package.json`
19
21
 
20
- Add the following `scripts` and `engines`:
22
+ Add the following `scripts`:
21
23
 
22
24
  ```json
23
25
  "scripts": {
@@ -25,11 +27,6 @@ Add the following `scripts` and `engines`:
25
27
  "lint": "dprint check && npm run eslint",
26
28
  "lint:fix": "dprint fmt && npm run eslint -- --fix"
27
29
  },
28
- "// node 16": "14 won't install peer deps properly + prefer EventTarget (only available node 16)",
29
- "engines": {
30
- "node": ">=16",
31
- "npm": ">=8"
32
- }
33
30
  ```
34
31
 
35
32
  ### Base `tsconfig.json`
@@ -48,7 +45,7 @@ Extend the following in your base `tsconfig.json` (follow link for more details)
48
45
  "extends": "eslint-config-beslogic/tsconfig.4.3.json",
49
46
  ```
50
47
 
51
- "No Unchecked Indexed Access" makes index accesses even stricter. You may not want it in your project. You can disable it with `"compilerOptions": { "noUncheckedIndexedAccess": false }`.
48
+ "No Unchecked Indexed Access" makes index accesses even stricter. You may not want it in your project or in your tests. You can disable it with `"compilerOptions": { "noUncheckedIndexedAccess": false }`.
52
49
 
53
50
  If deploying / bundling with an Angular npm package, also set `angularCompilerOptions": { "strictMetadataEmit": true }`
54
51
 
@@ -110,10 +107,13 @@ Basic javascript configs, is extended by all other configs except `beslogic/type
110
107
 
111
108
  ### `beslogic/typescript`
112
109
 
113
- Basic TypeScript-specific configs and `TSX` support, is extended by all other TypeScript exclusive configs. To avoid rules conflicts, it does **not** already extend from `beslogic/javascript`. So you should extend from both in a pure TypeScript project. You may also need to specify `parserOptions.project`. ie: `"parserOptions": { "project": ["tsconfig.json"] },` and `"parser": "@typescript-eslint/parser"`.
110
+ Basic TypeScript-specific configs and `TSX` support, is extended by all other TypeScript exclusive configs. To avoid rules conflicts, it does **not** already extend from `beslogic/javascript`. So you should extend from both in a pure TypeScript project. You may also need to specify `parserOptions.project`. ie: `"parserOptions": { "project": ["tsconfig.json"] },` and `"parser": "@typescript-eslint/parser"` if you reconfigure some rules yourself.
114
111
 
115
112
  For the linting to be fully effective, please make sure that your base `tsconfig.json` extends `eslint-config-beslogic/tsconfig.X.X.json` (see [Parallel configurations](#parallel-configurations)).
116
113
 
114
+ For extra strict TypeScript linting, you can also install [eslint-plugin-total-functions](https://www.npmjs.com/package/eslint-plugin-total-functions): `npm i --save-dev eslint-plugin-total-functions`\
115
+ The installation will be automatically detected and configured.
116
+
117
117
  ### `beslogic/node-js`
118
118
 
119
119
  Configurations for NodeJS backends.
@@ -131,7 +131,7 @@ Configurations for projects using RxJs. Already extends and `beslogic/typescript
131
131
  Add the following `devDependencies` to your `package.json`:
132
132
 
133
133
  ```shell
134
- npm install --save-dev eslint-plugin-rxjs eslint-plugin-total-functions
134
+ npm install --save-dev eslint-plugin-rxjs
135
135
  ```
136
136
 
137
137
  ### `beslogic/react`
@@ -141,7 +141,7 @@ Configurations for React projects. Comes with `JSX` support.
141
141
  Add the following `devDependencies` to your `package.json`:
142
142
 
143
143
  ```shell
144
- npm install --save-dev eslint-plugin-jsx-a11y eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-redux eslint-plugin-react-prefer-function-component
144
+ npm install --save-dev eslint-plugin-jsx-a11y eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-prefer-function-component
145
145
  ```
146
146
 
147
147
  ### `beslogic/react-native`
@@ -151,7 +151,7 @@ Configurations for [React Native](https://reactnative.dev/) projects, including
151
151
  Add the following `devDependencies` to your `package.json`:
152
152
 
153
153
  ```shell
154
- npm install --save-dev eslint-plugin-react-native eslint-plugin-jsx-a11y eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-redux eslint-plugin-react-prefer-function-component
154
+ npm install --save-dev eslint-plugin-react-native eslint-plugin-jsx-a11y eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-prefer-function-component
155
155
  ```
156
156
 
157
157
  ### `beslogic/react-redux`
@@ -161,7 +161,7 @@ Configurations for React projects using the Redux bindings. Already extends `bes
161
161
  Add the following `devDependencies` to your `package.json`:
162
162
 
163
163
  ```shell
164
- npm install --save-dev eslint-plugin-react-redux eslint-plugin-jsx-a11y eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-redux eslint-plugin-react-prefer-function-component
164
+ npm install --save-dev eslint-plugin-react-redux eslint-plugin-jsx-a11y eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-prefer-function-component
165
165
  ```
166
166
 
167
167
  ### `beslogic/mui`
@@ -171,7 +171,7 @@ npm install --save-dev eslint-plugin-react-redux eslint-plugin-jsx-a11y eslint-p
171
171
  Add the following `devDependencies` to your `package.json`:
172
172
 
173
173
  ```shell
174
- npm install --save-dev eslint-plugin-mui eslint-plugin-jsx-a11y eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-redux eslint-plugin-react-prefer-function-component eslint-plugin-total-functions
174
+ npm install --save-dev eslint-plugin-mui eslint-plugin-jsx-a11y eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-prefer-function-component
175
175
  ```
176
176
 
177
177
  ### `beslogic/angular`
@@ -184,7 +184,7 @@ If bundling with an npm package set `"strictMetadataEmit": true` under `angularC
184
184
  Add the following `devDependencies` to your `package.json`:
185
185
 
186
186
  ```shell
187
- npm install --save-dev @angular-eslint/eslint-plugin @angular-eslint/eslint-plugin-template @angular-eslint/template-parser github:BesLogic/eslint-plugin-rxjs-angular#dist eslint-plugin-angular-file-naming eslint-plugin-total-functions
187
+ npm install --save-dev @angular-eslint/eslint-plugin @angular-eslint/eslint-plugin-template @angular-eslint/template-parser github:BesLogic/eslint-plugin-rxjs-angular#dist eslint-plugin-angular-file-naming
188
188
  ```
189
189
 
190
190
  ### `beslogic/storybook`
@@ -211,3 +211,7 @@ You must also extend the base configuration in a `dprint.json` file (see [Parall
211
211
  ### `beslogic/json-like`
212
212
 
213
213
  Enforces stylistic rules for JS objects to look like valid JSON objects.
214
+
215
+ ## Changelog
216
+
217
+ You can view the changelog under the [Code Tab](https://www.npmjs.com/package/eslint-config-beslogic?activeTab=code), or at <https://socket.dev/npm/package/eslint-config-beslogic/files/latest/CHANGELOG.md>
package/angular.js CHANGED
@@ -1,20 +1,10 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  // Copyright 2024 Beslogic Inc.
3
3
 
4
- const { getProjectModuleVersion, jestNoRestrictedSyntax } = require("./lib/utils")
4
+ const { getModuleVersion, jestNoRestrictedSyntax } = require("./lib/utils")
5
5
 
6
- let angularEslintPluginVersion = 15
7
- try {
8
- angularEslintPluginVersion = getProjectModuleVersion("@angular-eslint/eslint-plugin")
9
- } catch (error) {
10
- console.warn(error)
11
- }
12
- let typescriptVersion = 4.3
13
- try {
14
- typescriptVersion = getProjectModuleVersion("typescript")
15
- } catch (error) {
16
- console.warn(error)
17
- }
6
+ const angularEslintVersion = getModuleVersion("@angular-eslint/eslint-plugin", 16.2)
7
+ const typescriptVersion = getModuleVersion("typescript", 4.7)
18
8
 
19
9
  const javascriptConfig = require("./javascript")
20
10
  const typescriptConfig = require("./typescript")
@@ -28,33 +18,29 @@ const noRestrictedSyntax = [
28
18
  "message":
29
19
  "Angular hooks need to be functions defined on the prototype: https://github.com/angular/angular/issues/7270#issuecomment-201137617"
30
20
  },
21
+ // TODO: Possibly implement that ourselves?
22
+ // Upstream request: https://github.com/MelvinVermeer/eslint-plugin-no-relative-import-paths/issues/30
31
23
  {
32
24
  "selector": "ImportDeclaration[source.value=/\\.\\.\\u002F?$/]",
33
25
  "message": "Don't use imports that ends in \"..\" or \"../\""
34
26
  },
35
27
  // From typescript configs, but allow on @Input()
36
- angularEslintPluginVersion >= 16
37
- ? {
38
- "selector":
39
- "PropertyDefinition[definite=true]:not(:has(Decorator[expression.callee.name=\"Input\"] Property[key.name=\"required\"][value.value=true]))",
40
- "message":
41
- "Forbidden non-null property assertion. https://typescript-eslint.io/rules/no-non-null-assertion . " +
42
- "This is only allowed on required component @Input({ required:true }). https://angular.io/api/core/Input#required"
43
- }
44
- : {
45
- "selector":
46
- "PropertyDefinition[definite=true]:not(:has(Decorator[expression.callee.name=\"Input\"]))",
47
- "message":
48
- "Forbidden non-null property assertion. https://typescript-eslint.io/rules/no-non-null-assertion . " +
49
- "This is only allowed on component @Input() restricted by its selector."
50
- }
28
+ {
29
+ "selector":
30
+ "PropertyDefinition[definite=true]:not(:has(Decorator[expression.callee.name=\"Input\"] Property[key.name=\"required\"][value.value=true]))",
31
+ "message":
32
+ "Forbidden non-null property assertion. https://typescript-eslint.io/rules/no-non-null-assertion . " +
33
+ "This is only allowed on required component @Input({ required:true }). https://angular.io/api/core/Input#required"
34
+ }
51
35
  ]
52
36
 
53
- const typeDefinitionOverride = typescriptConfig.overrides?.find(override =>
54
- override.files === "*.d.ts"
55
- )
37
+ const typeDefinitionOverride = typescriptConfig
38
+ .overrides
39
+ ?.find(override => override.files === "*.d.ts")
56
40
 
57
- const preferArrowFunctionsConfig = javascriptConfig.rules?.["prefer-arrow/prefer-arrow-functions"]
41
+ const preferArrowFunctionsConfig = javascriptConfig
42
+ .rules
43
+ ?.["prefer-arrow/prefer-arrow-functions"]
58
44
  ?.[1]
59
45
  const preventAbbreviationsConfig = {
60
46
  ...javascriptConfig.rules?.["unicorn/prevent-abbreviations"]?.[1]
@@ -107,7 +93,7 @@ module.exports = {
107
93
  ],
108
94
  // Autofix for this rule was broken: https://github.com/angular-eslint/angular-eslint/pull/1602
109
95
  // somewhat fixed in 16.1, but not proper: https://github.com/angular-eslint/angular-eslint/issues/1197
110
- "@angular-eslint/template/attributes-order": angularEslintPluginVersion >= 17.1
96
+ "@angular-eslint/template/attributes-order": angularEslintVersion >= 17.1
111
97
  ? "error"
112
98
  : "off",
113
99
  // and it was added in 14.2.0. Not enforcing it for now allows a wider range of versions.
@@ -158,9 +144,6 @@ module.exports = {
158
144
  ]
159
145
  }
160
146
  ],
161
- // "@angular-eslint/template/prefer-ngsrc": angularEslintPluginVersion >= 16.2
162
- // ? "error"
163
- // : "off",
164
147
  // This constantly requires wrapping images in an additional div or knowing the exact display size.
165
148
  // Doesn't support relative sizing either, not sure if worth even trying to enforce.
166
149
  "@angular-eslint/template/prefer-ngsrc": "off",
@@ -183,6 +166,12 @@ module.exports = {
183
166
  "plugin:@angular-eslint/template/process-inline-templates"
184
167
  ],
185
168
  "parserOptions": {
169
+ // TODO: Try "project": true https://typescript-eslint.io/blog/parser-options-project-true/
170
+ // This wouldn't work for tsconfig.spec.ts though
171
+ // https://typescript-eslint.io/blog/parser-options-project-true/#investigating-custom-tsconfig-names
172
+ // https://github.com/typescript-eslint/typescript-eslint/issues/7383#issuecomment-2073032501
173
+ // TODO: even better, try: https://typescript-eslint.io/packages/parser/#experimental_useprojectservice
174
+ // "EXPERIMENTAL_useProjectService": true,
186
175
  "project": [
187
176
  "tsconfig?(.*).json",
188
177
  "projects/*/tsconfig?(.*).json",
@@ -190,9 +179,9 @@ module.exports = {
190
179
  ],
191
180
  // TODO: Consider use a tsconfig.eslint.json instead
192
181
  // https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/README.md#parseroptionscreatedefaultprogram
193
- "createDefaultProgram": true,
182
+ "deprecated__createDefaultProgram": true,
194
183
  // Needed specifically for @typescript-eslint/consistent-type-imports
195
- "emitDecoratorMetadata": true
184
+ "emitDecoratorMetadata": typescriptVersion >= 5
196
185
  },
197
186
  "rules": {
198
187
  /*
@@ -289,32 +278,8 @@ module.exports = {
289
278
  ],
290
279
  // Incompatible with Angular's dependecy injection
291
280
  "@typescript-eslint/no-invalid-this": "off",
292
- // Both redundant with Angular's dependecy injection
293
- "@typescript-eslint/no-parameter-properties": "off",
281
+ // Redundant with Angular's dependecy injection
294
282
  "@typescript-eslint/parameter-properties": "off",
295
-
296
- /*
297
- * These two configs are meant to work around the following issue wit Decorators:
298
- * https://github.com/typescript-eslint/typescript-eslint/issues/5468#issuecomment-1906180432
299
- * Once the following PR is merged, we can check for that specific @typescript-eslint version
300
- * to only apply the workaround before it.
301
- * https://github.com/typescript-eslint/typescript-eslint/pull/8335
302
- */
303
- // This only relates to TypeScript 5.0's --verbatimModuleSyntax,
304
- // by not enforcing this rule yet, we are not loosing much compared to what we had before.
305
- // We have to disable it for the "fixStyle: 'inline-type-imports'" workaround to be allowed at all time
306
- "@typescript-eslint/no-import-type-side-effects": "off",
307
- "@typescript-eslint/consistent-type-imports": [
308
- "error",
309
- typescriptVersion < 4.5
310
- ? {}
311
- : {
312
- // Sets the autofix to use `import { type A } from '...'` which works around the above mentionned issue
313
- // This only affects autofixing to help devs not aware of this edge case, both styles are always allowed.
314
- "fixStyle": "inline-type-imports" // Only available since typescript 4.5
315
- }
316
- ],
317
-
318
283
  "unicorn/no-keyword-prefix": [
319
284
  "error",
320
285
  {
@@ -325,8 +290,6 @@ module.exports = {
325
290
  ]
326
291
  }
327
292
  ],
328
- // False positives with Angular's EventEmitter: https://github.com/sindresorhus/eslint-plugin-unicorn/issues/1853
329
- "unicorn/prefer-event-target": "off",
330
293
  // Angular is ESM
331
294
  "unicorn/prefer-module": "error",
332
295
  // This is not supported in Angular's Vite builder https://github.com/angular/angular-cli/issues/26507
package/dprint.js CHANGED
@@ -177,11 +177,13 @@ module.exports = {
177
177
  "computed-property-spacing": "off",
178
178
  "autofix/computed-property-spacing": "off",
179
179
  "func-call-spacing": "off",
180
+ "autofix/func-call-spacing": "off",
180
181
  "@typescript-eslint/func-call-spacing": "off",
181
182
  "generator-star-spacing": "off",
182
183
  "autofix/generator-star-spacing": "off",
183
184
  "key-spacing": "off",
184
185
  "autofix/key-spacing": "off",
186
+ "@typescript-eslint/key-spacing": "off",
185
187
  "keyword-spacing": "off",
186
188
  "autofix/keyword-spacing": "off",
187
189
  "@typescript-eslint/keyword-spacing": "off",
@@ -224,8 +226,9 @@ module.exports = {
224
226
  /*
225
227
  * Unconfigurable or unknown linked configuration
226
228
  */
227
- "@typescript-eslint/lines-around-comment": "off",
229
+ "lines-around-comment": "off",
228
230
  "autofix/lines-around-comment": "off",
231
+ "@typescript-eslint/lines-around-comment": "off",
229
232
  "no-extra-parens": "off",
230
233
  "autofix/no-extra-parens": "off",
231
234
  "@typescript-eslint/no-extra-parens": "off",
@@ -236,8 +239,7 @@ module.exports = {
236
239
  "new-parens": "off",
237
240
  "autofix/new-parens": "off",
238
241
  "no-floating-decimal": "off",
239
- "autofix/no-floating-decimal": "off",
240
- "import/newline-after-import": "off"
242
+ "autofix/no-floating-decimal": "off"
241
243
  }
242
244
  }
243
245
  ]
package/javascript.js CHANGED
@@ -69,7 +69,7 @@ module.exports = {
69
69
  ],
70
70
  "extends": [
71
71
  "eslint:recommended",
72
- "plugin:sonarjs/recommended",
72
+ "plugin:sonarjs/recommended-legacy",
73
73
  "plugin:unicorn/all",
74
74
  "plugin:regexp/all",
75
75
  "plugin:import/recommended",
@@ -90,6 +90,7 @@ module.exports = {
90
90
  "ignorePatterns": ["node_modules/"],
91
91
  // Useful when using experimental features and code transpiled by Babel
92
92
  "parser": "@babel/eslint-parser",
93
+ "reportUnusedDisableDirectives": true,
93
94
  "overrides": [
94
95
  {
95
96
  "files": [
@@ -430,9 +431,18 @@ module.exports = {
430
431
  { "considerQueryString": true }
431
432
  ],
432
433
  "import/no-empty-named-blocks": "error",
434
+ // exactCount has issues with require, at least that's taken care of by dprint:
435
+ // https://github.com/import-js/eslint-plugin-import/issues/2905
436
+ // With https://github.com/dprint/dprint-plugin-typescript/issues/394 we could disable this
437
+ // rule entirely in dprint preset.
433
438
  "import/newline-after-import": [
434
439
  "error",
435
- { "considerComments": true }
440
+ {
441
+ /* eslint-disable-next-line etc/no-commented-out-code
442
+ -- see above comment, bump minimal eslint-plugin-import when this is fixed and enforced */
443
+ // "exactCount": false,
444
+ "considerComments": true
445
+ }
436
446
  ],
437
447
  "import/no-named-as-default": "error",
438
448
  "import/no-named-as-default-member": "error",
@@ -469,6 +479,9 @@ module.exports = {
469
479
  "case": "camelCase"
470
480
  }
471
481
  ],
482
+ // Only works on 3 node imports by default, and can't configure a default for all imports.
483
+ // Leave it up to the programmer.
484
+ "unicorn/import-style": "off",
472
485
  "unicorn/no-array-reduce": [
473
486
  "error",
474
487
  {
@@ -486,16 +499,10 @@ module.exports = {
486
499
  ]
487
500
  }
488
501
  ],
489
- "unicorn/no-nested-ternary": "off",
490
502
  "unicorn/no-null": "off",
491
- // Not as bad in frontend environment
492
- "unicorn/no-unsafe-regex": "warn",
493
- "unicorn/no-useless-undefined": [
494
- "error",
495
- {
496
- "checkArguments": false
497
- }
498
- ],
503
+ // This rule has been deprecated in favor of eslint-plugin-regexp
504
+ "unicorn/no-unsafe-regex": "off",
505
+ "unicorn/no-useless-undefined": "error",
499
506
  "unicorn/numeric-separators-style": "error",
500
507
  "unicorn/prefer-add-event-listener": "error",
501
508
  "unicorn/prefer-array-find": [
@@ -569,18 +576,18 @@ module.exports = {
569
576
  {
570
577
  "groups": [
571
578
  // Side effect imports.
572
- ["^\\u0000"],
579
+ [String.raw`^\u0000`],
573
580
  // Node.js builtins prefixed with `node:`.
574
581
  ["^node:"],
575
582
  // Packages.
576
583
  // Things that start with a letter (or digit or underscore), or `@` followed by a letter.
577
- ["^@?\\w"],
584
+ [String.raw`^@?\w`],
578
585
  // Absolute imports and other imports such as Vue-style `@/foo`.
579
586
  // Anything not matched in another group.
580
587
  ["^"],
581
588
  // Relative imports.
582
589
  // Anything that starts with a dot or src/
583
- ["^(\\.|src/)"]
590
+ [String.raw`^(\.|src/)`]
584
591
  ]
585
592
  }
586
593
  ],
@@ -623,6 +630,8 @@ module.exports = {
623
630
  ],
624
631
  // I don't think this is that much more readable imo. Especially for regexp beginners
625
632
  "regexp/prefer-named-capture-group": "off",
633
+ // TODO: Re-enable once VSCode has syntax highlighting for the v flag
634
+ "regexp/require-unicode-sets-regexp": "off",
626
635
  // Obsoleted by eslint-plugin-regexp
627
636
  "no-invalid-regexp": "off",
628
637
  "prefer-named-capture-group": "off",
@@ -633,7 +642,10 @@ module.exports = {
633
642
  * Excludes rules taken care of by eslint-plugin-autofix
634
643
  */
635
644
  "accessor-pairs": "error",
636
- "array-callback-return": "error",
645
+ "array-callback-return": [
646
+ "error",
647
+ { "allowImplicit": true, "checkForEach": true, "allowVoid": true }
648
+ ],
637
649
  "block-scoped-var": "error",
638
650
  "camelcase": "error",
639
651
  "class-methods-use-this": "error",
@@ -828,7 +840,8 @@ module.exports = {
828
840
  ],
829
841
  "patterns": [
830
842
  {
831
- // no-realtive-import paths doesn't catch ./..
843
+ // no-relative-import paths doesn't catch ./..
844
+ // TODO: Consider fixing ourselves
832
845
  // https://github.com/MelvinVermeer/eslint-plugin-no-relative-import-paths/issues/30
833
846
  "group": ["./../"],
834
847
  "message": "Relative parent imports are not allowed."
package/jest.js CHANGED
@@ -1,5 +1,8 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  // Copyright 2024 Beslogic Inc.
3
+ const { getModuleVersion } = require("./lib/utils")
4
+
5
+ const jestGlobalsVersion = getModuleVersion("@jest/globals", 29)
3
6
 
4
7
  /** @type {import("eslint").Linter.Config} */
5
8
  module.exports = {
@@ -67,6 +70,12 @@ module.exports = {
67
70
  "onlyFunctionsWithExpectInLoop": true
68
71
  }
69
72
  ],
73
+ // https://github.com/jestjs/jest/issues/15084
74
+ // Since this will require a major jest version bump anyway,
75
+ // I feel confortable not waiting for our own major version bump to add this
76
+ ...(jestGlobalsVersion < 30
77
+ ? { "jest/prefer-importing-jest-globals": "off" }
78
+ : {}),
70
79
  // Top-level describe is often used for component name, which is capitalized
71
80
  "jest/prefer-lowercase-title": [
72
81
  "error",
package/json-like.js CHANGED
@@ -29,6 +29,7 @@ module.exports = {
29
29
  "error",
30
30
  "double"
31
31
  ],
32
- "autofix/quote-props": "error"
32
+ "autofix/quote-props": "error",
33
+ "unicorn/prefer-string-raw": "off"
33
34
  }
34
35
  }