linter-bundle 6.2.2 → 7.0.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.
Files changed (144) hide show
  1. package/.linter-bundle.js +27 -17
  2. package/.linter-bundle.schema.json +45 -0
  3. package/CHANGELOG.md +149 -4
  4. package/README.md +60 -63
  5. package/eslint/gatsby.mjs +95 -0
  6. package/eslint/index.mjs +1127 -0
  7. package/eslint/javascript-lazy.mjs +24 -0
  8. package/eslint/javascript.mjs +126 -0
  9. package/eslint/jest.mjs +172 -0
  10. package/eslint/jsdoc.mjs +103 -0
  11. package/eslint/react.mjs +232 -0
  12. package/eslint/rules/no-unnecessary-typeof.md +1 -1
  13. package/eslint/rules/{no-unnecessary-typeof.js → no-unnecessary-typeof.mjs} +9 -11
  14. package/eslint/rules/restricted-filenames.md +4 -4
  15. package/eslint/rules/{restricted-filenames.js → restricted-filenames.mjs} +7 -6
  16. package/eslint/storybook.mjs +42 -0
  17. package/eslint/type-declarations.mjs +49 -0
  18. package/eslint/{overrides-worker.cjs → worker.mjs} +12 -14
  19. package/eslint.mjs +5 -0
  20. package/files/index.js +3 -3
  21. package/helper/{ensure-type.cjs → ensure-type.mjs} +1 -5
  22. package/helper/get-outdated-dependencies.js +4 -4
  23. package/helper/get-outdated-overrides.js +2 -2
  24. package/helper/get-stylelint-path.js +4 -3
  25. package/helper/is-npm-or-yarn.js +2 -2
  26. package/helper/linter-bundle-config.d.ts +24 -0
  27. package/helper/linter-bundle-config.js +9 -14
  28. package/helper/run-process.js +1 -1
  29. package/lint.js +21 -16
  30. package/package.json +31 -29
  31. package/stylelint/index.mjs +1111 -0
  32. package/stylelint/plugins/stylelint-15.11.0-stylistic/html-tags/{index.cjs → index.mjs} +1 -1
  33. package/stylelint/plugins/stylelint-15.11.0-stylistic/reference/{selectors.cjs → selectors.mjs} +15 -31
  34. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/at-rule-name-case/{index.cjs → index.mjs} +6 -12
  35. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/at-rule-name-space-after/{index.cjs → index.mjs} +11 -13
  36. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/at-rule-semicolon-newline-after/{index.cjs → index.mjs} +18 -22
  37. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/at-rule-semicolon-space-before/{index.cjs → index.mjs} +10 -9
  38. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/{atRuleNameSpaceChecker.cjs → atRuleNameSpaceChecker.mjs} +4 -3
  39. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-closing-brace-empty-line-before/{index.cjs → index.mjs} +16 -30
  40. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-closing-brace-newline-after/{index.cjs → index.mjs} +13 -35
  41. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-closing-brace-newline-before/{index.cjs → index.mjs} +11 -40
  42. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-closing-brace-space-before/{index.cjs → index.mjs} +10 -27
  43. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-opening-brace-newline-after/{index.cjs → index.mjs} +14 -65
  44. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-opening-brace-space-after/{index.cjs → index.mjs} +13 -30
  45. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-opening-brace-space-before/{index.cjs → index.mjs} +14 -27
  46. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/color-hex-case/{index.cjs → index.mjs} +10 -16
  47. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-bang-space-after/index.mjs +93 -0
  48. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-bang-space-before/{index.cjs → index.mjs} +11 -12
  49. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-block-semicolon-newline-after/{index.cjs → index.mjs} +11 -29
  50. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-block-semicolon-newline-before/{index.cjs → index.mjs} +9 -8
  51. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-block-semicolon-space-after/{index.cjs → index.mjs} +10 -23
  52. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-block-semicolon-space-before/{index.cjs → index.mjs} +11 -36
  53. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-block-trailing-semicolon/{index.cjs → index.mjs} +9 -27
  54. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-colon-newline-after/{index.cjs → index.mjs} +9 -25
  55. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-colon-space-after/{index.cjs → index.mjs} +8 -9
  56. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-colon-space-before/{index.cjs → index.mjs} +8 -9
  57. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/{declarationBangSpaceChecker.cjs → declarationBangSpaceChecker.mjs} +5 -4
  58. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/{declarationColonSpaceChecker.cjs → declarationColonSpaceChecker.mjs} +5 -4
  59. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/{findMediaOperator.cjs → findMediaOperator.mjs} +2 -2
  60. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-comma-newline-after/{index.cjs → index.mjs} +8 -9
  61. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-comma-newline-before/{index.cjs → index.mjs} +8 -9
  62. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-comma-space-after/{index.cjs → index.mjs} +8 -9
  63. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-comma-space-before/{index.cjs → index.mjs} +8 -9
  64. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-max-empty-lines/{index.cjs → index.mjs} +19 -39
  65. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-parentheses-newline-inside/{index.cjs → index.mjs} +19 -54
  66. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-parentheses-space-inside/{index.cjs → index.mjs} +21 -68
  67. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-whitespace-after/{index.cjs → index.mjs} +16 -31
  68. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/{functionCommaSpaceChecker.cjs → functionCommaSpaceChecker.mjs} +8 -7
  69. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/{functionCommaSpaceFix.cjs → functionCommaSpaceFix.mjs} +1 -1
  70. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/indentation/{index.cjs → index.mjs} +39 -64
  71. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/linebreaks/{index.cjs → index.mjs} +15 -44
  72. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/max-empty-lines/{index.cjs → index.mjs} +10 -49
  73. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/max-line-length/{index.cjs → index.mjs} +10 -9
  74. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-colon-space-after/{index.cjs → index.mjs} +8 -9
  75. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-colon-space-before/{index.cjs → index.mjs} +8 -9
  76. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-name-case/{index.cjs → index.mjs} +9 -16
  77. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-parentheses-space-inside/{index.cjs → index.mjs} +8 -21
  78. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-range-operator-space-after/{index.cjs → index.mjs} +10 -11
  79. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-range-operator-space-before/{index.cjs → index.mjs} +10 -11
  80. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-query-list-comma-newline-after/{index.cjs → index.mjs} +8 -9
  81. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-query-list-comma-newline-before/{index.cjs → index.mjs} +6 -6
  82. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-query-list-comma-space-after/{index.cjs → index.mjs} +8 -9
  83. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-query-list-comma-space-before/{index.cjs → index.mjs} +8 -9
  84. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/{mediaFeatureColonSpaceChecker.cjs → mediaFeatureColonSpaceChecker.mjs} +5 -4
  85. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/{mediaQueryListCommaWhitespaceChecker.cjs → mediaQueryListCommaWhitespaceChecker.mjs} +6 -5
  86. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/no-empty-first-line/{index.cjs → index.mjs} +6 -20
  87. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/no-eol-whitespace/{index.cjs → index.mjs} +13 -16
  88. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/no-extra-semicolons/{index.cjs → index.mjs} +10 -33
  89. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/no-missing-end-of-source-newline/{index.cjs → index.mjs} +7 -13
  90. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/number-leading-zero/{index.cjs → index.mjs} +13 -31
  91. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/number-no-trailing-zeros/{index.cjs → index.mjs} +9 -18
  92. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/property-case/{index.cjs → index.mjs} +10 -16
  93. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-attribute-brackets-space-inside/{index.cjs → index.mjs} +9 -36
  94. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-attribute-operator-space-after/{index.cjs → index.mjs} +7 -8
  95. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-attribute-operator-space-before/{index.cjs → index.mjs} +7 -8
  96. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-combinator-space-after/{index.cjs → index.mjs} +7 -8
  97. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-combinator-space-before/{index.cjs → index.mjs} +7 -8
  98. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-descendant-combinator-no-non-space/{index.cjs → index.mjs} +9 -20
  99. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-list-comma-newline-after/{index.cjs → index.mjs} +9 -14
  100. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-list-comma-newline-before/{index.cjs → index.mjs} +7 -8
  101. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-list-comma-space-after/{index.cjs → index.mjs} +7 -8
  102. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-list-comma-space-before/{index.cjs → index.mjs} +7 -8
  103. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-max-empty-lines/{index.cjs → index.mjs} +10 -21
  104. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-pseudo-class-case/{index.cjs → index.mjs} +10 -24
  105. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-pseudo-class-parentheses-space-inside/{index.cjs → index.mjs} +12 -35
  106. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-pseudo-element-case/{index.cjs → index.mjs} +10 -15
  107. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/{selectorAttributeOperatorSpaceChecker.cjs → selectorAttributeOperatorSpaceChecker.mjs} +6 -5
  108. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/{selectorCombinatorSpaceChecker.cjs → selectorCombinatorSpaceChecker.mjs} +12 -11
  109. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/{selectorListCommaWhitespaceChecker.cjs → selectorListCommaWhitespaceChecker.mjs} +5 -4
  110. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/string-quotes/{index.cjs → index.mjs} +43 -65
  111. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/unicode-bom/{index.cjs → index.mjs} +5 -5
  112. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/unit-case/{index.cjs → index.mjs} +17 -34
  113. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/value-list-comma-newline-after/{index.cjs → index.mjs} +11 -12
  114. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/value-list-comma-newline-before/{index.cjs → index.mjs} +6 -6
  115. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/value-list-comma-space-after/{index.cjs → index.mjs} +10 -11
  116. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/value-list-comma-space-before/{index.cjs → index.mjs} +10 -11
  117. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/value-list-max-empty-lines/{index.cjs → index.mjs} +12 -18
  118. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/{valueListCommaWhitespaceChecker.cjs → valueListCommaWhitespaceChecker.mjs} +6 -5
  119. package/stylelint/plugins/stylelint-15.11.0-stylistic/style-search/{index.cjs → index.mjs} +1 -1
  120. package/stylelint/plugins/stylelint-15.11.0-stylistic/utils/{addEmptyLineAfter.cjs → addEmptyLineAfter.mjs} +1 -1
  121. package/stylelint/plugins/stylelint-15.11.0-stylistic/utils/{hasEmptyBlock.cjs → hasEmptyBlock.mjs} +2 -2
  122. package/stylelint/plugins/stylelint-15.11.0-stylistic/utils/{nextNonCommentNode.cjs → nextNonCommentNode.mjs} +1 -1
  123. package/stylelint/plugins/stylelint-15.11.0-stylistic/utils/{removeEmptyLinesAfter.cjs → removeEmptyLinesAfter.mjs} +1 -1
  124. package/stylelint/plugins/stylelint-15.11.0-stylistic/utils/transformSelector.mjs +19 -0
  125. package/stylelint/plugins/stylelint-15.11.0-stylistic/utils/{whitespaceChecker.cjs → whitespaceChecker.mjs} +5 -5
  126. package/stylelint/plugins/stylelint-selector-no-empty.js +2 -0
  127. package/stylelint/plugins/stylelint-selector-tag-no-without-class.js +2 -2
  128. package/stylelint.mjs +6 -0
  129. package/TODO.md +0 -58
  130. package/eslint/index.cjs +0 -1065
  131. package/eslint/overrides-gatsby.cjs +0 -108
  132. package/eslint/overrides-javascript-lazy.cjs +0 -27
  133. package/eslint/overrides-javascript.cjs +0 -121
  134. package/eslint/overrides-jest.cjs +0 -144
  135. package/eslint/overrides-jsdoc.cjs +0 -94
  136. package/eslint/overrides-react.cjs +0 -220
  137. package/eslint/overrides-storybook.cjs +0 -44
  138. package/eslint/overrides-type-declarations.cjs +0 -51
  139. package/eslint/rules/no-global-undefined-check.js +0 -85
  140. package/eslint/rules/no-global-undefined-check.md +0 -34
  141. package/eslint.cjs +0 -5
  142. package/stylelint/index.cjs +0 -1104
  143. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-bang-space-after/index.cjs +0 -95
  144. package/stylelint.cjs +0 -5
@@ -2,31 +2,29 @@
2
2
  * @file ESLint rule which ensures that a `typeof` operant has more than one type in TypeScript, to prevent unnecessary checks of types at runtime.
3
3
  */
4
4
 
5
- /* eslint-disable unicorn/prefer-module -- For ESLint, we still need to rely on CommonJS modules */
6
-
7
5
  /** @typedef {ts.Type & { intrinsicName?: string; types?: ts.Type[]; objectFlags?: ts.ObjectFlags; }} Type */
8
6
 
9
- const ts = require('typescript');
7
+ import * as ts from 'typescript';
10
8
 
11
- const { ESLintUtils } = require('@typescript-eslint/utils');
9
+ import { ESLintUtils } from '@typescript-eslint/utils';
12
10
 
13
- /**
14
- * @type {import('eslint').Rule.RuleModule}
15
- */
16
- module.exports = {
11
+ export default {
17
12
  meta: {
13
+ type: 'problem',
18
14
  docs: {
19
15
  description: 'If a `typeof` operant has only one type in TypeScript, it\'s unnecessary to check it\'s type at runtime.',
20
- recommended: true
16
+ recommended: true,
17
+ requiresTypeChecking: true
21
18
  },
22
19
  messages: {
23
20
  text: 'Unnecessary `typeof`, because the only possible type of {{ variableName }} is `{{ typeName }}`.'
24
21
  }
25
22
  },
23
+
26
24
  /**
27
25
  * Create a new rule.
28
26
  *
29
- * @param {Readonly<import('@typescript-eslint/utils/ts-eslint').RuleContext<'text', []>>} context - RuleContext of @typescript-eslint instead of ESlint
27
+ * @param {import('@typescript-eslint/utils/ts-eslint').RuleContext<any, any>} context - RuleContext of @typescript-eslint instead of ESlint
30
28
  * @returns {import('@typescript-eslint/utils/ts-eslint').RuleListener} RuleListener of @typescript-eslint, instead of ESlint
31
29
  */
32
30
  create (context) {
@@ -136,7 +134,7 @@ function getTypeString (checker, type) {
136
134
  * @returns {boolean} Returns `true` if the type is either `any` or `unknown`, or an object which is based on `unknown`
137
135
  */
138
136
  function isAnyOrUnknown (type) {
139
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- `symbol` on Object is `undefined` for `Omit<unknown, 'undefined'>`
137
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- @todo I've seen `symbol` to be undefined. Is that an issue in the TypeScript type definition?
140
138
  return (type.flags === ts.TypeFlags.Any || type.flags === ts.TypeFlags.Unknown || (type.flags === ts.TypeFlags.Object && type.symbol === undefined));
141
139
  }
142
140
 
@@ -7,7 +7,7 @@ In projects in which several developers or even teams work together, it is impor
7
7
  Example configuration for this rule:
8
8
 
9
9
  ```js
10
- 'restricted-filenames': ['error', {
10
+ 'linter-bundle/restricted-filenames': ['error', {
11
11
  basePath: './src',
12
12
  allowed: [
13
13
  'components/**/index.tsx',
@@ -64,7 +64,7 @@ If both are set, `disallowed` wins over `allowed` and all unspecified files are
64
64
 
65
65
  Instead of defining the same complex patterns over and over again, e.g. for casing, you can write them into a variable and use them within the pattern, for example by using template strings.
66
66
 
67
- Example of `.eslintrc.cjs`:
67
+ Example of `eslint.config.mjs`:
68
68
 
69
69
  ```js
70
70
  const snippets = {
@@ -77,9 +77,9 @@ const snippets = {
77
77
  pascalCase: '[A-Z]*([a-zA-Z0-9])'
78
78
  };
79
79
 
80
- module.exports = {
80
+ export default {
81
81
  rules: {
82
- 'restricted-filenames': ['error', {
82
+ 'linter-bundle/restricted-filenames': ['error', {
83
83
  basePath: './src',
84
84
  allowed: [
85
85
  `components/${snippets.pascalCase}/index.tsx`,
@@ -2,19 +2,20 @@
2
2
  * @file ESLint rule which ensures that only files which match given glob patterns are part of your project.
3
3
  */
4
4
 
5
- /* eslint-disable unicorn/prefer-module -- For ESLint, we still need to rely on CommonJS modules */
5
+ import path from 'node:path';
6
6
 
7
- const path = require('node:path');
7
+ import micromatch from 'micromatch';
8
8
 
9
- const micromatch = require('micromatch');
9
+ // eslint-disable-next-line n/no-process-env -- If the ESLint sub-process is running from within the linter-bundle, we make use of its configuration.
10
+ const isInLinterBundle = !process.env['LINTER_BUNDLE'];
10
11
 
11
- // eslint-disable-next-line n/no-process-env -- Only merge the linter-bundle config, if the linting is not started by the linter-bundle CLI tool (e.g. if ESlint is running separately in VSCode), to get warnings shown there too
12
- const linterBundleConfig = (!process.env['LINTER_BUNDLE'] ? require('../../helper/linter-bundle-config.cjs').linterBundleConfig : undefined);
12
+ // eslint-disable-next-line n/no-unpublished-import -- @todo Is that a false-positive?
13
+ const { linterBundleConfig } = (isInLinterBundle ? await import('../../helper/linter-bundle-config.js') : {});
13
14
 
14
15
  /**
15
16
  * @type {import('eslint').Rule.RuleModule}
16
17
  */
17
- module.exports = {
18
+ export default {
18
19
  meta: {
19
20
  docs: {
20
21
  description: 'Restrict file and path names with given glob patterns.',
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @file Settings for Storybook configuration and stories.
3
+ */
4
+
5
+ export default [
6
+ {
7
+ files: ['**/*.stories.[jt]s?(x)'],
8
+ rules: {
9
+ /**
10
+ * eslint-plugin-import
11
+ *
12
+ * @see https://github.com/import-js/eslint-plugin-import
13
+ */
14
+ 'import/no-default-export': 'off'
15
+ }
16
+ },
17
+ {
18
+ files: ['.storybook/main.ts'],
19
+ rules: {
20
+ /**
21
+ * eslint-plugin-import
22
+ *
23
+ * @see https://github.com/import-js/eslint-plugin-import
24
+ */
25
+ 'import/no-nodejs-modules': 'off'
26
+ }
27
+ },
28
+ {
29
+ files: ['.storybook/preview.{js,cjs,mjs,jsx,ts,cts,mts,tsx}'],
30
+ rules: {
31
+ /**
32
+ * eslint
33
+ *
34
+ * @see https://eslint.org/docs/rules/
35
+ */
36
+ 'no-underscore-dangle': ['error', {
37
+ allow: ['__BASE_PATH__', '___loader', '___navigate'],
38
+ allowAfterThis: true
39
+ }]
40
+ }
41
+ }
42
+ ];
@@ -0,0 +1,49 @@
1
+ /**
2
+ * @file Settings for TypeScript type definition files.
3
+ */
4
+
5
+ export default [
6
+ {
7
+ files: ['**/*.d.ts'],
8
+ rules: {
9
+ /**
10
+ * eslint
11
+ *
12
+ * @see https://eslint.org/docs/rules/
13
+ */
14
+ 'max-classes-per-file': 'off',
15
+ 'one-var': 'off',
16
+
17
+ /**
18
+ * eslint-plugin-import
19
+ *
20
+ * @see https://github.com/import-js/eslint-plugin-import
21
+ */
22
+ 'import/no-default-export': 'off',
23
+ 'import/no-unused-modules': 'off',
24
+
25
+ /**
26
+ * eslint-plugin-unicorn
27
+ *
28
+ * @see https://github.com/sindresorhus/eslint-plugin-unicorn
29
+ */
30
+ 'unicorn/filename-case': ['off', { // Disabled in favour of the linter-bundle `files` task
31
+ cases: {
32
+ kebabCase: true,
33
+ pascalCase: true
34
+ }
35
+ }]
36
+ }
37
+ },
38
+ {
39
+ files: ['**/*.scss.d.ts'],
40
+ rules: {
41
+ /**
42
+ * eslint
43
+ *
44
+ * @see https://eslint.org/docs/rules/
45
+ */
46
+ 'linebreak-style': 'off' // Ignore for automatically generated .scss.d.ts files, since that does not affect the project.
47
+ }
48
+ }
49
+ ];
@@ -8,18 +8,16 @@
8
8
  * export default undefined as unknown as WebpackWorker;
9
9
  */
10
10
 
11
- module.exports = {
12
- overrides: [
13
- {
14
- files: ['*.worker.ts'],
15
- rules: {
16
- /**
17
- * eslint-plugin-import
18
- *
19
- * @see https://github.com/import-js/eslint-plugin-import
20
- */
21
- 'import/no-default-export': 'off'
22
- }
11
+ export default [
12
+ {
13
+ files: ['**/*.worker.ts'],
14
+ rules: {
15
+ /**
16
+ * eslint-plugin-import
17
+ *
18
+ * @see https://github.com/import-js/eslint-plugin-import
19
+ */
20
+ 'import/no-default-export': 'off'
23
21
  }
24
- ]
25
- };
22
+ }
23
+ ];
package/eslint.mjs ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @file Wrapper which allows to extend "linter-bundle/eslint.mjs" instead of "linter-bundle/eslint/index.mjs".
3
+ */
4
+
5
+ export { default } from './eslint/index.mjs';
package/files/index.js CHANGED
@@ -2,8 +2,8 @@
2
2
  * @file Ensures that only files which match given glob patterns are part of the project.
3
3
  */
4
4
 
5
- import * as fs from 'node:fs';
6
- import * as path from 'node:path';
5
+ import fs from 'node:fs';
6
+ import path from 'node:path';
7
7
 
8
8
  import micromatch from 'micromatch';
9
9
 
@@ -43,7 +43,7 @@ if (Array.isArray(restrictions)) {
43
43
  }
44
44
  }
45
45
 
46
- return;
46
+ return undefined;
47
47
  };
48
48
 
49
49
  for (const { basePath, allowed, disallowed } of restrictions) {
@@ -12,11 +12,7 @@
12
12
  * @param {T} value - The value which should be checked
13
13
  * @returns {T extends Array<any> ? T : []} Either the input array, or an empty array, if the input array is not an array
14
14
  */
15
- function array (value) {
15
+ export function array (value) {
16
16
  // @ts-expect-error -- Right now the type definition of `Array.isArray()` is incorrect since it uses `arg is any[]` instead of the correct type of `arg`.
17
17
  return (Array.isArray(value) ? value : []);
18
18
  }
19
-
20
- module.exports = {
21
- array
22
- };
@@ -5,8 +5,8 @@
5
5
  * @see https://classic.yarnpkg.com/en/docs/selective-version-resolutions/
6
6
  */
7
7
 
8
- import * as fs from 'node:fs/promises';
9
- import * as path from 'node:path';
8
+ import fs from 'node:fs/promises';
9
+ import path from 'node:path';
10
10
  import { fileURLToPath } from 'node:url';
11
11
 
12
12
  const dirname = path.dirname(fileURLToPath(import.meta.url));
@@ -30,7 +30,7 @@ export async function getOutdatedDependencies () {
30
30
  }
31
31
  catch {
32
32
  // If the file does not exist, we ignore it, because in this case it's most likely a linter-bundle-only dependency.
33
- return;
33
+ return undefined;
34
34
  }
35
35
 
36
36
  if (dependencyPackageJson.version !== expectedVersion) {
@@ -41,7 +41,7 @@ export async function getOutdatedDependencies () {
41
41
  };
42
42
  }
43
43
 
44
- return;
44
+ return undefined;
45
45
  }));
46
46
 
47
47
  return /** @type {Dependency[]} */(outdatedDependencies.filter((dependency) => dependency !== undefined));
@@ -5,8 +5,8 @@
5
5
  * @see https://classic.yarnpkg.com/en/docs/selective-version-resolutions/
6
6
  */
7
7
 
8
- import * as fs from 'node:fs/promises';
9
- import * as path from 'node:path';
8
+ import fs from 'node:fs/promises';
9
+ import path from 'node:path';
10
10
  import { fileURLToPath } from 'node:url';
11
11
 
12
12
  const dirname = path.dirname(fileURLToPath(import.meta.url));
@@ -2,9 +2,9 @@
2
2
  * @file Returns the path to the Stylelint CLI script.
3
3
  */
4
4
 
5
- import * as fs from 'node:fs/promises';
5
+ import fs from 'node:fs/promises';
6
6
  import { createRequire } from 'node:module';
7
- import * as path from 'node:path';
7
+ import path from 'node:path';
8
8
 
9
9
  const require = createRequire(import.meta.url);
10
10
 
@@ -17,11 +17,12 @@ const require = createRequire(import.meta.url);
17
17
  export async function getStylelintPath () {
18
18
  const stylelintLibPath = path.dirname(require.resolve('stylelint'));
19
19
 
20
- for await (const stylelintBinPath of [
20
+ for (const stylelintBinPath of [
21
21
  path.join(stylelintLibPath, '../bin/stylelint.mjs'),
22
22
  path.join(stylelintLibPath, '../bin/stylelint.js')
23
23
  ]) {
24
24
  try {
25
+ // eslint-disable-next-line no-await-in-loop -- As we return from the method on the first file which exist, we cannot run the promises in parallel.
25
26
  const stat = await fs.stat(stylelintBinPath);
26
27
 
27
28
  if (stat.isFile()) {
@@ -2,8 +2,8 @@
2
2
  * @file Check if the project is using npm or yarn by checking the existence of a `package-lock.json` or a `yarn.lock`.
3
3
  */
4
4
 
5
- import * as fs from 'node:fs/promises';
6
- import * as path from 'node:path';
5
+ import fs from 'node:fs/promises';
6
+ import path from 'node:path';
7
7
 
8
8
  /**
9
9
  * Returns if the project is using npm or yarn.
@@ -2,6 +2,29 @@
2
2
  * @file Type definition of `.linter-bundle.js` configuration.
3
3
  */
4
4
 
5
+ interface NamingConventionOption {
6
+ // format options
7
+ format: ('camelCase' | 'strictCamelCase' | 'PascalCase' | 'StrictPascalCase' | 'snake_case' | 'UPPER_CASE')[] | null;
8
+ custom?: {
9
+ regex: string;
10
+ match: boolean;
11
+ };
12
+ leadingUnderscore?: 'forbid' | 'require' | 'requireDouble' | 'allow' | 'allowDouble' | 'allowSingleOrDouble';
13
+ trailingUnderscore?: 'forbid' | 'require' | 'requireDouble' | 'allow' | 'allowDouble' | 'allowSingleOrDouble';
14
+ prefix?: string[];
15
+ suffix?: string[];
16
+
17
+ // selector options
18
+ selector: string | string[];
19
+ filter?: string | {
20
+ regex: string;
21
+ match: boolean;
22
+ };
23
+ // the allowed values for these are dependent on the selector - see below
24
+ modifiers?: string[];
25
+ types?: string[];
26
+ }
27
+
5
28
  export interface LinterBundleConfig {
6
29
  verbose?: boolean;
7
30
  timing?: boolean;
@@ -27,6 +50,7 @@ export interface LinterBundleConfig {
27
50
  'no-restricted-properties'?: { additionalRestrictions?: { object: string; property: string; message: string; }[]; };
28
51
  'no-restricted-syntax'?: { additionalRestrictions?: { selector: string; message: string; }[]; };
29
52
  'import/order'?: { additionalExternalPatterns?: string[]; };
53
+ '@typescript-eslint/naming-convention'?: { additionalOptions?: NamingConventionOption[]; };
30
54
  };
31
55
  react?: {
32
56
  'react/forbid-component-props'?: { allowClassNameFor?: string[]; allowStyleFor?: string[]; };
@@ -2,8 +2,8 @@
2
2
  * @file Returns the `.linter-bundle.js` configuration result.
3
3
  */
4
4
 
5
- import * as fs from 'node:fs/promises';
6
- import * as path from 'node:path';
5
+ import fs from 'node:fs/promises';
6
+ import path from 'node:path';
7
7
 
8
8
  export const linterBundleConfig = (
9
9
  await loadConfig('.linter-bundle.json') ??
@@ -23,7 +23,7 @@ async function loadConfig (fileName) {
23
23
  const filePath = path.join(process.cwd(), fileName);
24
24
 
25
25
  if (!await fs.access(filePath, fs.constants.F_OK).then(() => true).catch(() => false)) {
26
- return;
26
+ return undefined;
27
27
  }
28
28
 
29
29
  try {
@@ -33,9 +33,11 @@ async function loadConfig (fileName) {
33
33
  return JSON.parse(content);
34
34
  }
35
35
 
36
- const fileUri = path.join('file://', filePath);
36
+ const fileUrl = new URL('file:');
37
37
 
38
- const config = await import(fileUri);
38
+ fileUrl.pathname = filePath;
39
+
40
+ const config = await import(fileUrl.toString());
39
41
 
40
42
  if ('default' in config) {
41
43
  return config.default;
@@ -44,15 +46,8 @@ async function loadConfig (fileName) {
44
46
  return config;
45
47
  }
46
48
  catch (error) {
47
- process.stderr.write(`Error reading ${filePath}\n`);
48
-
49
- if (error instanceof Error) {
50
- process.stderr.write(`${error.stack}\n`);
51
- }
52
- else {
53
- process.stderr.write(`${error}\n`);
54
- }
49
+ process.stderr.write(`Error reading ${filePath}\n${error}\n`);
55
50
  }
56
51
 
57
- return;
52
+ return undefined;
58
53
  }
@@ -28,7 +28,7 @@ export async function runProcess (command, options) {
28
28
  const lintingProcess = childProcess.exec(command, {
29
29
  ...options,
30
30
  env: {
31
- // eslint-disable-next-line n/no-process-env -- We need to access `process.env`, because this is the default value if `env` is not set.
31
+ // eslint-disable-next-line n/no-process-env -- Pass all environment variables to the child process
32
32
  ...process.env,
33
33
  ...options?.env,
34
34
  LINTER_BUNDLE: '1'
package/lint.js CHANGED
@@ -5,8 +5,8 @@
5
5
  */
6
6
 
7
7
  import { createRequire } from 'node:module';
8
- import * as path from 'node:path';
9
- import * as tty from 'node:tty';
8
+ import path from 'node:path';
9
+ import tty from 'node:tty';
10
10
  import { fileURLToPath } from 'node:url';
11
11
 
12
12
  import micromatch from 'micromatch';
@@ -22,12 +22,14 @@ import { runProcess } from './helper/run-process.js';
22
22
  const require = createRequire(import.meta.url);
23
23
  const dirname = path.dirname(fileURLToPath(import.meta.url));
24
24
 
25
- /** @typedef {'files' | 'tsc' | 'ts' | 'sass' | 'md' | 'audit'} TaskNames */
26
- /** @typedef {Partial<Record<string, (string | boolean)[]>>} TaskConfig */
27
- /** @typedef {import('./helper/run-process.js').ProcessResult} ProcessResult */
28
- /** @typedef {{ taskName: TaskNames; taskConfig: TaskConfig; }} TaskNameAndConfig */
29
- /** @typedef {TaskNameAndConfig & { command: string; options?: import('child_process').ExecOptions; }} TaskSetup */
30
- /** @typedef {{ jobTitle: string; taskSetup: TaskSetup; job: Promise<ProcessResult>; }} Job */
25
+ /**
26
+ * @typedef {'files' | 'tsc' | 'ts' | 'sass' | 'md' | 'audit'} TaskNames
27
+ * @typedef {Partial<Record<string, (string | boolean)[]>>} TaskConfig
28
+ * @typedef {import('./helper/run-process.js').ProcessResult} ProcessResult
29
+ * @typedef {{ taskName: TaskNames; taskConfig: TaskConfig; }} TaskNameAndConfig
30
+ * @typedef {TaskNameAndConfig & { command: string; options?: import('child_process').ExecOptions; }} TaskSetup
31
+ * @typedef {{ jobTitle: string; taskSetup: TaskSetup; job: Promise<ProcessResult>; }} Job
32
+ */
31
33
 
32
34
  const isTerminal = tty.isatty(1);
33
35
 
@@ -104,7 +106,7 @@ await (async () => {
104
106
  showTimingForAllJobs = false;
105
107
  }
106
108
 
107
- if (process.exitCode === undefined || code > process.exitCode) {
109
+ if (process.exitCode === undefined || code > Number.parseInt(String(process.exitCode), 10)) {
108
110
  process.exitCode = code;
109
111
  }
110
112
  }
@@ -199,14 +201,12 @@ async function runESLintTask (taskName, taskConfig) {
199
201
  `"${path.join(path.dirname(require.resolve('eslint')), '../bin/eslint.js')}"`,
200
202
  includes,
201
203
  newTaskConfig.exclude?.map((exclude) => `--ignore-pattern ${exclude}`).join(' '),
202
- `--rulesdir "${path.resolve(dirname, './eslint/rules/')}"`,
203
- '--format unix',
204
- `--resolve-plugins-relative-to "${dirname}"`
204
+ '--format unix'
205
205
  ].filter((argument) => Boolean(argument)).join(' '),
206
206
  taskConfig: newTaskConfig,
207
207
  options: {
208
208
  env: {
209
- TIMING: '10', // Show timing information about the 10 slowest rules
209
+ TIMING: (getConfigValue(taskName, taskConfig, 'timing')?.[0] ? '10' : undefined), // Show timing information about the 10 slowest rules
210
210
  TSCONFIG: (typeof newTaskConfig.tsconfig?.[0] === 'string' ? newTaskConfig.tsconfig[0] : undefined)
211
211
  }
212
212
  }
@@ -253,7 +253,12 @@ async function runStylelintTask (taskName, taskConfig) {
253
253
  (newTaskConfig.verbose?.[0] ? '--verbose' : undefined),
254
254
  '--formatter unix'
255
255
 
256
- ].filter((argument) => Boolean(argument)).join(' ')
256
+ ].filter((argument) => Boolean(argument)).join(' '),
257
+ options: {
258
+ env: {
259
+ TIMING: (getConfigValue(taskName, taskConfig, 'timing')?.[0] ? '10' : undefined) // Show timing information about the 10 slowest rules
260
+ }
261
+ }
257
262
  });
258
263
  }
259
264
 
@@ -312,7 +317,7 @@ async function runAuditTask (taskName, taskConfig) {
312
317
  'npx',
313
318
  '--yes',
314
319
  '--',
315
- 'better-npm-audit@3.7.3',
320
+ 'better-npm-audit@3.11.0',
316
321
  'audit',
317
322
  `-l ${newTaskConfig.minSeverity?.[0] ?? 'moderate'}`,
318
323
  '-p',
@@ -596,5 +601,5 @@ function getConfigValue (taskName, taskConfig, optionName) {
596
601
  }
597
602
  }
598
603
 
599
- return;
604
+ return undefined;
600
605
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linter-bundle",
3
- "version": "6.2.2",
3
+ "version": "7.0.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": [
@@ -23,7 +23,7 @@
23
23
  "lint": "lint.js"
24
24
  },
25
25
  "engines": {
26
- "node": ">=18.12.0"
26
+ "node": "^20.9.0 || >=21.1.0"
27
27
  },
28
28
  "repository": {
29
29
  "type": "git",
@@ -37,46 +37,48 @@
37
37
  "preversion": "npm run check-outdated && npm run lint",
38
38
  "postversion": "git push && git push --tags && npm publish",
39
39
  "check-outdated": "npx --yes -- check-outdated --ignore-pre-releases",
40
- "_stylelint-find-rules": "stylelint-find-new-rules ./stylelint/index.cjs",
40
+ "_stylelint-find-rules": "stylelint-find-new-rules ./stylelint/index.mjs",
41
41
  "_test-stylelint": "node ./test-stylelint.js"
42
42
  },
43
43
  "dependencies": {
44
- "@typescript-eslint/eslint-plugin": "6.19.1",
45
- "@typescript-eslint/parser": "6.19.1",
46
- "@typescript-eslint/utils": "6.19.1",
47
- "eslint": "8.56.0",
48
- "eslint-import-resolver-typescript": "3.6.1",
49
- "eslint-import-resolver-webpack": "0.13.8",
44
+ "@stylistic/eslint-plugin": "4.2.0",
45
+ "@stylistic/eslint-plugin-jsx": "4.2.0",
46
+ "eslint": "9.22.0",
47
+ "eslint-formatter-unix": "8.40.0",
48
+ "eslint-import-resolver-typescript": "3.8.4",
49
+ "eslint-import-resolver-webpack": "0.13.10",
50
50
  "eslint-plugin-eslint-comments": "3.2.0",
51
- "eslint-plugin-functional": "6.0.0",
52
- "eslint-plugin-import": "2.29.1",
53
- "eslint-plugin-jest": "27.6.3",
54
- "eslint-plugin-jsdoc": "48.0.3",
55
- "eslint-plugin-jsx-a11y": "6.8.0",
56
- "eslint-plugin-n": "16.6.2",
57
- "eslint-plugin-promise": "6.1.1",
58
- "eslint-plugin-react": "7.33.2",
59
- "eslint-plugin-react-hooks": "4.6.0",
60
- "eslint-plugin-unicorn": "50.0.1",
61
- "markdownlint-cli": "0.38.0",
62
- "micromatch": "4.0.5",
51
+ "eslint-plugin-functional": "9.0.1",
52
+ "eslint-plugin-import": "2.31.0",
53
+ "eslint-plugin-jest": "28.11.0",
54
+ "eslint-plugin-jsdoc": "50.6.6",
55
+ "eslint-plugin-jsx-a11y": "6.10.2",
56
+ "eslint-plugin-n": "17.16.2",
57
+ "eslint-plugin-promise": "7.2.1",
58
+ "eslint-plugin-react": "7.37.4",
59
+ "eslint-plugin-react-hooks": "5.2.0",
60
+ "eslint-plugin-unicorn": "57.0.0",
61
+ "globals": "16.0.0",
62
+ "markdownlint-cli": "0.44.0",
63
+ "micromatch": "4.0.8",
63
64
  "postcss-scss": "4.0.9",
64
- "stylelint": "16.2.0",
65
+ "stylelint": "16.15.0",
65
66
  "stylelint-declaration-block-no-ignored-properties": "2.8.0",
66
- "stylelint-high-performance-animation": "1.10.0",
67
+ "stylelint-high-performance-animation": "1.11.0",
67
68
  "stylelint-order": "6.0.4",
68
- "stylelint-scss": "6.1.0",
69
- "stylelint-use-logical-spec": "5.0.1"
69
+ "stylelint-scss": "6.11.1",
70
+ "stylelint-use-logical-spec": "5.0.1",
71
+ "typescript-eslint": "8.26.1"
70
72
  },
71
73
  "peerDependencies": {
72
74
  "postcss-value-parser": "*",
73
75
  "typescript": ">=4.0.0"
74
76
  },
75
77
  "devDependencies": {
76
- "@types/eslint": "8.56.2",
77
- "@types/micromatch": "4.0.6",
78
- "@types/node": "20.11.6",
78
+ "@types/eslint": "9.6.1",
79
+ "@types/micromatch": "4.0.9",
80
+ "@types/node": "22.13.10",
79
81
  "stylelint-find-new-rules": "5.0.0",
80
- "typescript": "5.3.3"
82
+ "typescript": "5.8.2"
81
83
  }
82
84
  }