linter-bundle 7.6.0 → 7.7.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/CHANGELOG.md CHANGED
@@ -6,10 +6,48 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
- [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v7.6.0...HEAD)
9
+ [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v7.7.0...HEAD)
10
+
11
+ ## [7.7.0] - 2025-07-25
12
+
13
+ ### Breaking changes
14
+
15
+ - [general] Drop support for Node.js version less than 20.12.0, 21.*.* and 23.*.* as some of the ESLint plugins are not supporting them anymore
16
+ - [eslint] Removed deprecated `@stylistic/eslint-plugin-jsx` plugin
17
+
18
+ ### Changed
19
+
20
+ - [eslint] Updated `eslint` from `9.26.0` to `9.31.0`
21
+ - [eslint] Updated `eslint-import-resolver-typescript` from `4.3.4` to `4.4.4`
22
+ - [eslint] Updated `eslint-plugin-functional` from `9.0.1` to `9.0.2`
23
+ - [eslint] Updated `eslint-plugin-import` from `2.31.0` to `2.32.0`
24
+ - [eslint] Updated `eslint-plugin-jest` from `28.11.0` to `29.0.1`
25
+ - [eslint] Updated `eslint-plugin-jsdoc` from `50.6.17` to `51.4.1`
26
+ - [eslint] Updated `eslint-plugin-n` from `17.18.0` to `17.21.0`
27
+ - [eslint] Updated `eslint-plugin-unicorn` from `59.0.1` to `60.0.0`
28
+ - [eslint] Updated `globals` from `16.1.0` to `16.3.0`
29
+ - [eslint] Updated `@stylistic/eslint-plugin` from `4.2.0` to `5.2.2`
30
+ - [eslint] Updated `typescript-eslint` from `8.32.1` to `8.38.0`
31
+ - [markdownlint] Updated `markdownlint-cli` from `0.44.0` to `0.45.0`
32
+ - [stylelint] Updated `stylelint` from `16.19.1` to `16.22.0`
33
+ - [stylelint] Updated `stylelint-scss` from `6.12.0` to `6.12.1`
34
+ - [eslint] Added [`no-unassigned-vars`](https://github.com/eslint/eslint/blob/main/docs/src/rules/no-unassigned-vars.md) rule
35
+ - [eslint] Added [`unicorn/prefer-class-fields`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-class-fields.md) rule
36
+ - [eslint] Added [`unicorn/no-array-reverse`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-reverse.md) rule
37
+ - [eslint] Added [`unicorn/require-module-specifiers`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/require-module-specifiers.md) rule
38
+ - [eslint] Added [`unicorn/no-useless-error-capture-stack-trace`](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-useless-error-capture-stack-trace.md) rule
39
+ - [eslint] Added [`jest/prefer-ending-with-an-expect`](https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/prefer-ending-with-an-expect.md) rule
40
+ - [eslint] Added but disabled [`import/enforce-node-protocol-usage`](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/enforce-node-protocol-usage.md) rule, as this is covered by `unicorn/prefer-node-protocol`
41
+ - [eslint] Added but disabled [`n/no-top-level-await`](https://github.com/eslint-community/eslint-plugin-n/blob/master/docs/rules/no-top-level-await.md) rule as it conflicts with `unicorn/prefer-top-level-await`
42
+ - [eslint] Rename `@stylistic/func-call-spacing` to `@stylistic/function-call-spacing`
43
+ - [stylelint] Activate `custom-property-empty-line-before` rule and `ignore` `"after-custom-property"`
44
+
45
+ [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v7.6.0...v7.7.0)
10
46
 
11
47
  ## [7.6.0] - 2025-05-14
12
48
 
49
+ ### Changed
50
+
13
51
  - [general] Added support for `.css` files in ESLint and Stylelint rules
14
52
  - [eslint] Updated `eslint` from `9.24.0` to `9.26.0`
15
53
  - [eslint] Updated `eslint-import-resolver-typescript` from `4.3.2` to `4.3.4`
@@ -35,6 +73,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
35
73
 
36
74
  ## [7.5.0] - 2025-04-08
37
75
 
76
+ ### Changed
77
+
38
78
  - [eslint] Updated `eslint` from `9.23.0` to `9.24.0`
39
79
  - [eslint] Updated `eslint-import-resolver-typescript` from `4.2.2` to `4.3.2`
40
80
  - [eslint] Updated `eslint-plugin-jsdoc` from `50.6.8` to `50.6.9`
@@ -51,13 +91,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
51
91
 
52
92
  [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v7.4.0...v7.5.0)
53
93
 
54
- ### Changed
55
-
56
- - [eslint] Updated `eslint` from `9.22.0` to `9.23.0`
57
- - [eslint/react] Activated `allowExpressions` of the `@typescript-eslint/explicit-function-return-type`rule also for the React overrides
58
-
59
- [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v7.3.0...v7.4.0)
60
-
61
94
  ## [7.4.0] - 2025-03-23
62
95
 
63
96
  ### Changed
@@ -151,7 +184,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
151
184
  - [eslint] The prefixes "override-" has been removed from the specialized rule files and the suffix `.cjs` has been replaced by `.mjs`
152
185
  - [stylelint] The stylelint configuration has been renamed from `linter-bundle/stylelint.cjs` to `linter-bundle/stylelint.mjs`
153
186
  - [stylelint] As the interface for rules changed slightly, I had to remove some auto-fixes for the previously forked stylistic rules.
154
- - [general] Drop support for Node.js version less than v20.9.0 and v21.1.0 as a lot of ESLint plugins are not supporting them
187
+ - [general] Drop support for Node.js version less than v20.9.0 and v21.1.0 as a lot of the ESLint plugins are not supporting them
155
188
 
156
189
  ### Fixed
157
190
 
package/TODO.md ADDED
@@ -0,0 +1,68 @@
1
+ <!-- markdownlint-disable -->
2
+
3
+ - Dateien ignorieren, die nicht zu git hochgeladen werden.
4
+ z.B. sollte der Markdownlinter die TODO.md ignorieren
5
+
6
+ Aktivierung dieser Regeln: https://eslint.style/packages/plus
7
+
8
+ shared-settings für linter-bundle custom settings verwenden?
9
+ https://eslint.org/blog/2022/08/new-config-system-part-2/#shared-settings-are-exactly-the-same
10
+
11
+ ---
12
+
13
+ - Aktuell sind die Versionen von den Audit-Tools hardcodiert in der lint.js hinterlegt:
14
+ 'better-npm-audit@3.7.3',
15
+ 'improved-yarn-audit@3.0.0',
16
+ Das sollte irgendwo hinterlegt werden, so z.B. check-outdated drauf zugreifen kann. (z.B. die optionalDependencies? Sind diese nach dem regulären Installieren noch vorhanden und lassen sich entsprechend auslesen? Werden diese von check-outdated geprüft?)
17
+
18
+ - Timing funktioniert nicht - siehe HexEd.it-core
19
+
20
+ - Wie erreichen wir auto-completion in der .linter-bundle.js datei?
21
+ .linter-bundle.json vielleicht mit Schema-Datei?
22
+
23
+ <!-- markdownlint-disable -->
24
+
25
+ - Bereiche in Readme aufklappbar machen:
26
+ <details>
27
+ summary>yarn</summary>
28
+
29
+ ```shell
30
+ yarn add click-to-react-component
31
+ ```
32
+ </details>
33
+
34
+ - Make git diff-branch configurable
35
+ on GitHub Actions this could be used:
36
+ - run: git diff --name-only -z origin/${GITHUB_BASE_REF}
37
+ Is there a variable with includes origin/ already?
38
+
39
+ Some tools like Gatsby ship deprecated dependencies of eslint and @typescript-eslint.
40
+ Since npm installs packages alphabetically, the outdated `gatsby` dependencies are installed in the `node_modules` root, instead of the newer `linter-bundle` dependencies. Since the old versions often do not support new rules or new options, this may cause linting to fail with errors like this:
41
+
42
+ ```bash
43
+ Error while loading rule 'import/no-unused-modules': .eslintrc.js » ./node_modules/linter-bundle/eslint/index.js:
44
+ Configuration for rule "@typescript-eslint/no-throw-literal" is invalid:
45
+ Value [{"allowThrowingAny":false,"allowThrowingUnknown":true}] should NOT have more than 0 items.
46
+ ```
47
+
48
+ To solve such problems, npm supports [`overrides`](https://docs.npmjs.com/cli/v8/configuring-npm/package-json#overrides) as of version [8.3](https://github.com/npm/cli/releases/tag/v8.3.0), while yarn supports [`resolutions`](https://classic.yarnpkg.com/en/docs/selective-version-resolutions/).
49
+
50
+ By using the `enforce-deps` option, linter-bundle will ensure the right versions of the dependencies are installed, and if not it automatically write these options to your package.json and then run an `npm i` or `yarn`, before starting the linting to ensure that the correct dependency versions are installed.
51
+
52
+ ```json
53
+ "overrides": {
54
+ "@typescript-eslint/eslint-plugin": "$linter-bundle",
55
+ "@typescript-eslint/parser": "$linter-bundle",
56
+ "eslint": "$linter-bundle"
57
+ }
58
+ ```
59
+
60
+ - Option to lint only changed files in Git
61
+ - [lint-staged](https://github.com/okonet/lint-staged)
62
+ - [affected](https://www.npmjs.com/package/affected)
63
+ - [git-affected-files](https://www.npmjs.com/package/git-affected-files)
64
+ - [affected-files](https://www.npmjs.com/package/affected-files)
65
+ - [is-affected](https://www.npmjs.com/package/is-affected)
66
+
67
+ - Find stylelint rule which checks for wrong values like:
68
+ `padding-top: 3px 3px 0;`
package/eslint/index.mjs CHANGED
@@ -9,7 +9,6 @@ import stylisticPlugin from '@stylistic/eslint-plugin';
9
9
  // @ts-expect-error -- There are no type definitions for this plugin
10
10
  import eslintCommentsPlugin from 'eslint-plugin-eslint-comments';
11
11
  import functionalPlugin from 'eslint-plugin-functional';
12
- // @ts-expect-error -- There are no type definitions for this plugin
13
12
  import importPlugin from 'eslint-plugin-import';
14
13
  // @ts-expect-error -- There are no type definitions for this plugin
15
14
  import jsxA11YPlugin from 'eslint-plugin-jsx-a11y';
@@ -346,6 +345,7 @@ export default [
346
345
  'no-this-before-super': 'error',
347
346
  'no-throw-literal': 'off', // Covered by @typescript-eslint/no-throw-literal
348
347
  'no-trailing-spaces': 'error',
348
+ 'no-unassigned-vars': 'error',
349
349
  'no-undef-init': 'error',
350
350
  'no-undef': 'off', // Covered by TypeScript
351
351
  'no-undefined': 'off', // @todo "Using the void operator to generate the value of undefined if necessary." should be disableable
@@ -452,7 +452,7 @@ export default [
452
452
  '@stylistic/brace-style': ['error', 'stroustrup', { allowSingleLine: true }],
453
453
  '@stylistic/comma-dangle': ['error', { generics: 'ignore' }],
454
454
  '@stylistic/comma-spacing': 'error',
455
- '@stylistic/func-call-spacing': 'error',
455
+ '@stylistic/function-call-spacing': 'error',
456
456
  '@stylistic/indent': [
457
457
  'error',
458
458
  'tab',
@@ -1053,6 +1053,7 @@ export default [
1053
1053
  'unicorn/no-array-for-each': 'error',
1054
1054
  'unicorn/no-array-method-this-argument': 'error',
1055
1055
  'unicorn/no-array-reduce': ['error', { allowSimpleOperations: true }],
1056
+ 'unicorn/no-array-reverse': 'error',
1056
1057
  'unicorn/no-await-expression-member': 'error',
1057
1058
  'unicorn/no-console-spaces': 'error',
1058
1059
  'unicorn/no-document-cookie': 'error',
@@ -1086,6 +1087,7 @@ export default [
1086
1087
  'unicorn/no-unreadable-array-destructuring': 'error',
1087
1088
  'unicorn/no-unreadable-iife': 'error',
1088
1089
  'unicorn/no-unused-properties': 'error',
1090
+ 'unicorn/no-useless-error-capture-stack-trace': 'error',
1089
1091
  'unicorn/no-useless-fallback-in-spread': 'error',
1090
1092
  'unicorn/no-useless-promise-resolve-reject': 'error',
1091
1093
  'unicorn/no-useless-length-check': 'error',
@@ -1103,6 +1105,7 @@ export default [
1103
1105
  'unicorn/prefer-array-some': 'error',
1104
1106
  'unicorn/prefer-at': 'off', // @todo Disabled for now, since `at` is not supported by TypeScript type definitions yet.
1105
1107
  'unicorn/prefer-blob-reading-methods': 'off', // @todo Disabled for now, since it's only supported in Safari 14+. Activate in 2025
1108
+ 'unicorn/prefer-class-fields': 'error',
1106
1109
  'unicorn/prefer-code-point': 'error',
1107
1110
  'unicorn/prefer-date-now': 'error',
1108
1111
  'unicorn/prefer-default-parameters': 'error',
@@ -1149,6 +1152,7 @@ export default [
1149
1152
  'unicorn/prevent-abbreviations': ['error', { ignore: ['args', 'i', 'j', 'i18n', /[Rr]ef/u, /[Pp]arams/u, /[Pp]rops/u] }],
1150
1153
  'unicorn/relative-url-style': 'error',
1151
1154
  'unicorn/require-array-join-separator': 'error',
1155
+ 'unicorn/require-module-specifiers': 'error',
1152
1156
  'unicorn/require-number-to-fixed-digits-argument': 'error',
1153
1157
  'unicorn/require-post-message-target-origin': 'off', // False-positive with Workers which don't support a `targetOrigin`
1154
1158
  'unicorn/string-content': 'off', // Breaks code (e.g. imports with `...` in Next.js or GraphQL template strings),
@@ -45,6 +45,7 @@ export default [
45
45
  *
46
46
  * @see https://github.com/import-js/eslint-plugin-import
47
47
  */
48
+ 'import/enforce-node-protocol-usage': 'off', // Covered by unicorn/prefer-node-protocol
48
49
  'import/no-commonjs': 'off',
49
50
  'import/no-import-module-exports': 'error',
50
51
  'import/no-internal-modules': 'off',
@@ -82,6 +83,7 @@ export default [
82
83
  'n/no-unsupported-features/es-builtins': 'error',
83
84
  'n/no-unsupported-features/es-syntax': 'error',
84
85
  'n/no-unsupported-features/node-builtins': 'error',
86
+ 'n/no-top-level-await': 'off', // Conflicts with unicorn/prefer-await
85
87
  'n/prefer-global/buffer': 'error',
86
88
  'n/prefer-global/console': 'error',
87
89
  'n/prefer-global/process': 'error',
package/eslint/jest.mjs CHANGED
@@ -96,6 +96,7 @@ export default [
96
96
  'jest/prefer-hooks-on-top': 'error',
97
97
  'jest/prefer-comparison-matcher': 'error',
98
98
  'jest/prefer-each': 'error',
99
+ 'jest/prefer-ending-with-an-expect': 'error',
99
100
  'jest/prefer-equality-matcher': 'error',
100
101
  'jest/prefer-importing-jest-globals': 'error',
101
102
  'jest/prefer-jest-mocked': 'error',
package/eslint/react.mjs CHANGED
@@ -2,7 +2,6 @@
2
2
  * @file Settings for React code in TypeScript (TSX) files.
3
3
  */
4
4
 
5
- import stylisticJSXPlugin from '@stylistic/eslint-plugin-jsx';
6
5
  import reactPlugin from 'eslint-plugin-react';
7
6
  import * as reactHooksPlugin from 'eslint-plugin-react-hooks';
8
7
 
@@ -13,8 +12,7 @@ export default [
13
12
  {
14
13
  plugins: {
15
14
  'react-hooks': reactHooksPlugin,
16
- 'react': reactPlugin,
17
- '@stylistic/jsx': stylisticJSXPlugin
15
+ 'react': reactPlugin
18
16
  }
19
17
  },
20
18
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linter-bundle",
3
- "version": "7.6.0",
3
+ "version": "7.7.0",
4
4
  "type": "module",
5
5
  "description": "Ready-to use bundle of linting tools, containing configurations for ESLint, stylelint and markdownlint.",
6
6
  "keywords": [
@@ -24,7 +24,7 @@
24
24
  "lint": "lint.js"
25
25
  },
26
26
  "engines": {
27
- "node": "^20.9.0 || >=21.1.0"
27
+ "node": "^20.12.0 || ^22.0.0 || >=24.0.0"
28
28
  },
29
29
  "repository": {
30
30
  "type": "git",
@@ -42,34 +42,33 @@
42
42
  "_test-stylelint": "node ./test-stylelint.js"
43
43
  },
44
44
  "dependencies": {
45
- "@stylistic/eslint-plugin": "4.2.0",
46
- "@stylistic/eslint-plugin-jsx": "4.2.0",
47
- "eslint": "9.26.0",
45
+ "@stylistic/eslint-plugin": "5.2.2",
46
+ "eslint": "9.31.0",
48
47
  "eslint-formatter-unix": "8.40.0",
49
- "eslint-import-resolver-typescript": "4.3.4",
48
+ "eslint-import-resolver-typescript": "4.4.4",
50
49
  "eslint-import-resolver-webpack": "0.13.10",
51
50
  "eslint-plugin-eslint-comments": "3.2.0",
52
- "eslint-plugin-functional": "9.0.1",
53
- "eslint-plugin-import": "2.31.0",
54
- "eslint-plugin-jest": "28.11.0",
55
- "eslint-plugin-jsdoc": "50.6.17",
51
+ "eslint-plugin-functional": "9.0.2",
52
+ "eslint-plugin-import": "2.32.0",
53
+ "eslint-plugin-jest": "29.0.1",
54
+ "eslint-plugin-jsdoc": "51.4.1",
56
55
  "eslint-plugin-jsx-a11y": "6.10.2",
57
- "eslint-plugin-n": "17.18.0",
56
+ "eslint-plugin-n": "17.21.0",
58
57
  "eslint-plugin-promise": "7.2.1",
59
58
  "eslint-plugin-react": "7.37.5",
60
59
  "eslint-plugin-react-hooks": "5.2.0",
61
- "eslint-plugin-unicorn": "59.0.1",
62
- "globals": "16.1.0",
63
- "markdownlint-cli": "0.44.0",
60
+ "eslint-plugin-unicorn": "60.0.0",
61
+ "globals": "16.3.0",
62
+ "markdownlint-cli": "0.45.0",
64
63
  "micromatch": "4.0.8",
65
64
  "postcss-scss": "4.0.9",
66
- "stylelint": "16.19.1",
65
+ "stylelint": "16.22.0",
67
66
  "stylelint-declaration-block-no-ignored-properties": "2.8.0",
68
67
  "stylelint-high-performance-animation": "1.11.0",
69
68
  "stylelint-order": "7.0.0",
70
- "stylelint-scss": "6.12.0",
69
+ "stylelint-scss": "6.12.1",
71
70
  "stylelint-use-logical-spec": "5.0.1",
72
- "typescript-eslint": "8.32.1"
71
+ "typescript-eslint": "8.38.0"
73
72
  },
74
73
  "peerDependencies": {
75
74
  "@typescript-eslint/utils": "*",
@@ -79,7 +78,7 @@
79
78
  "devDependencies": {
80
79
  "@types/eslint": "9.6.1",
81
80
  "@types/micromatch": "4.0.9",
82
- "@types/node": "22.15.18",
81
+ "@types/node": "24.1.0",
83
82
  "stylelint-find-new-rules": "5.0.0",
84
83
  "typescript": "5.8.3"
85
84
  }
@@ -279,7 +279,12 @@ export default {
279
279
  'comment-word-disallowed-list': null,
280
280
  'container-name-pattern': (linterBundleConfig.css.patternPrefix ? `${linterBundleConfig.css.patternPrefix}-[a-z][a-zA-Z]+(-[a-z][a-zA-Z]+\\d*)+` : null),
281
281
  'custom-media-pattern': (linterBundleConfig.css.patternPrefix ? `${linterBundleConfig.css.patternPrefix}-[a-z][a-zA-Z]+(-[a-z][a-zA-Z]+\\d*)+` : null),
282
- 'custom-property-empty-line-before': null, // Empty lines between custom properties are optional
282
+ 'custom-property-empty-line-before': [
283
+ 'always',
284
+ {
285
+ ignore: ['after-custom-property']
286
+ }
287
+ ],
283
288
  'custom-property-no-missing-var-function': true,
284
289
  'custom-property-pattern': (linterBundleConfig.css.patternPrefix ? `${linterBundleConfig.css.patternPrefix}-[a-z][a-zA-Z]+(-[a-z][a-zA-Z]+\\d*)*` : null),
285
290
  'declaration-block-no-duplicate-custom-properties': true,
@@ -197,7 +197,7 @@ function getCheckBefore (valueNode) {
197
197
  function getCheckAfter (valueNode) {
198
198
  let after = '';
199
199
 
200
- for (const node of [...valueNode.nodes].reverse()) {
200
+ for (const node of [...valueNode.nodes].toReversed()) {
201
201
  if (node.type === 'comment') {
202
202
  continue;
203
203
  }
@@ -277,7 +277,7 @@ function fixAfterForAlways (valueNode, newline) {
277
277
  function fixAfterForNever (valueNode) {
278
278
  valueNode.after = '';
279
279
 
280
- for (const node of [...valueNode.nodes].reverse()) {
280
+ for (const node of [...valueNode.nodes].toReversed()) {
281
281
  if (node.type === 'comment') {
282
282
  continue;
283
283
  }
@@ -233,7 +233,7 @@ const rule = (primary, _secondaryOptions) => (root, result) => {
233
233
  * @returns {string}
234
234
  */
235
235
  function removeIndices (str, indices) {
236
- for (const index of indices.reverse()) {
236
+ for (const index of indices.toReversed()) {
237
237
  str = str.slice(0, index) + str.slice(index + 1);
238
238
  }
239
239
 
@@ -78,7 +78,7 @@ const rule = (primary, _secondaryOptions, context) => {
78
78
 
79
79
  if (fixData) {
80
80
  for (const [decl, commaIndices] of fixData.entries()) {
81
- for (const index of commaIndices.sort((a, b) => a - b).reverse()) {
81
+ for (const index of commaIndices.toSorted((a, b) => a - b).toReversed()) {
82
82
  const value = getDeclarationValue(decl);
83
83
  const valueIndex = index - declarationValueIndex(decl);
84
84
  const beforeValue = value.slice(0, valueIndex + 1);
@@ -1,6 +1,6 @@
1
1
  // @ts-nocheck
2
2
 
3
- import configurationError from 'stylelint/lib/utils/configurationError.mjs';
3
+ import { ConfigurationError } from 'stylelint/lib/utils/errors.mjs';
4
4
  import isSingleLineString from 'stylelint/lib/utils/isSingleLineString.mjs';
5
5
  import isWhitespace from 'stylelint/lib/utils/isWhitespace.mjs';
6
6
  import { assertFunction, isNullish } from 'stylelint/lib/utils/validateTypes.mjs';
@@ -144,7 +144,7 @@ export default function whitespaceChecker (targetWhitespace, expectation, messag
144
144
  rejectBefore(messages.rejectedBeforeMultiLine);
145
145
  break;
146
146
  default:
147
- throw configurationError(`Unknown expectation "${expectation}"`);
147
+ throw new ConfigurationError(`Unknown expectation "${expectation}"`);
148
148
  }
149
149
  }
150
150
 
@@ -191,7 +191,7 @@ export default function whitespaceChecker (targetWhitespace, expectation, messag
191
191
  rejectAfter(messages.rejectedAfterMultiLine);
192
192
  break;
193
193
  default:
194
- throw configurationError(`Unknown expectation "${expectation}"`);
194
+ throw new ConfigurationError(`Unknown expectation "${expectation}"`);
195
195
  }
196
196
  }
197
197
 
@@ -1,70 +0,0 @@
1
- /**
2
- * @file CommonJS loader for `linter-bundle-config.js`.
3
- *
4
- * This module has to be CommonJS as it is only used by `eslint` which does not support ESModules.
5
- *
6
- * This workaround is necessary to load async ESModules in sync CommonJS code.
7
- */
8
-
9
- const { Worker, isMainThread, parentPort } = require('node:worker_threads');
10
-
11
- if (isMainThread) {
12
- const worker = new Worker(__filename);
13
-
14
- const sizeSharedArrayBuffer = new SharedArrayBuffer(4);
15
- const sizeInt32 = new Int32Array(sizeSharedArrayBuffer);
16
-
17
- worker.postMessage({ sizeInt32 });
18
-
19
- if (Atomics.wait(sizeInt32, 0, 0, 10_000) !== 'ok') {
20
- throw new Error('No size received');
21
- }
22
-
23
- const dataSharedArrayBuffer = new SharedArrayBuffer((Math.ceil(sizeInt32[0] / 4) << 2));
24
- const dataInt32 = new Int32Array(dataSharedArrayBuffer);
25
-
26
- worker.postMessage({ dataInt32 });
27
-
28
- if (Atomics.wait(dataInt32, 0, 0, 250) !== 'ok') {
29
- throw new Error('No data received');
30
- }
31
-
32
- void worker.terminate();
33
-
34
- const textDecoder = new TextDecoder('utf8');
35
- const content = textDecoder.decode(new Uint8Array(dataSharedArrayBuffer).slice(0, sizeInt32[0]));
36
-
37
- // @ts-expect-error TypeScript complains about the ESModule import, but correctly resolves it and applies the type.
38
- /** @type {import('./linter-bundle-config.js')} */
39
- module.exports = JSON.parse(content);
40
- }
41
- else {
42
- /** @type {Uint8Array} */
43
- let content;
44
-
45
- /**
46
- * Handles requests from the main thread.
47
- *
48
- * @param {{ sizeInt32?: Int32Array; dataInt32?: Int32Array; }} data - Data received from the main thread
49
- * @returns {Promise<void>}
50
- */
51
- const onData = async (data) => {
52
- if (data.sizeInt32) {
53
- const json = JSON.stringify(await import('./linter-bundle-config.js'));
54
-
55
- const textEncoder = new TextEncoder();
56
-
57
- content = textEncoder.encode(json);
58
-
59
- Atomics.store(data.sizeInt32, 0, content.byteLength);
60
- Atomics.notify(data.sizeInt32, 0);
61
- }
62
- else if (data.dataInt32) {
63
- new Uint8Array(data.dataInt32.buffer).set(content);
64
-
65
- Atomics.notify(data.dataInt32, 0);
66
- }
67
- };
68
-
69
- parentPort?.on('message', onData);
70
- }