linter-bundle 7.2.0 → 7.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/CHANGELOG.md +27 -2
  2. package/README.md +11 -11
  3. package/eslint/react.mjs +2 -1
  4. package/eslint/rules/enforce-logical-expression-parens.mjs +1 -1
  5. package/eslint/rules/enforce-ternary-parens.mjs +1 -1
  6. package/eslint/rules/ensure-lucide-import-consistency.mjs +1 -1
  7. package/eslint/rules/no-extra-spaces-in-generics.mjs +1 -1
  8. package/eslint/rules/no-ternary-return.mjs +1 -1
  9. package/eslint/rules/no-unnecessary-typeof.mjs +1 -1
  10. package/eslint/rules/restricted-filenames.mjs +6 -2
  11. package/package.json +5 -5
  12. package/stylelint/index.mjs +0 -2
  13. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/at-rule-name-case/index.mjs +5 -9
  14. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/at-rule-name-space-after/index.mjs +1 -1
  15. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/at-rule-semicolon-newline-after/index.mjs +12 -14
  16. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/atRuleNameSpaceChecker.mjs +2 -7
  17. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-closing-brace-empty-line-before/index.mjs +13 -16
  18. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-closing-brace-newline-after/index.mjs +22 -23
  19. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-closing-brace-newline-before/index.mjs +29 -30
  20. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-closing-brace-space-before/index.mjs +19 -20
  21. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-opening-brace-newline-after/index.mjs +40 -43
  22. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-opening-brace-space-after/index.mjs +19 -20
  23. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/block-opening-brace-space-before/index.mjs +14 -17
  24. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/color-hex-case/index.mjs +6 -9
  25. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-bang-space-after/index.mjs +1 -1
  26. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-bang-space-before/index.mjs +42 -43
  27. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-block-semicolon-newline-after/index.mjs +19 -20
  28. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-block-semicolon-space-after/index.mjs +15 -16
  29. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-block-semicolon-space-before/index.mjs +27 -28
  30. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-block-trailing-semicolon/index.mjs +6 -8
  31. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-colon-newline-after/index.mjs +17 -18
  32. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-colon-space-after/index.mjs +17 -18
  33. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declaration-colon-space-before/index.mjs +17 -18
  34. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declarationBangSpaceChecker.mjs +2 -5
  35. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/declarationColonSpaceChecker.mjs +2 -5
  36. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-comma-newline-after/index.mjs +8 -10
  37. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-comma-newline-before/index.mjs +8 -10
  38. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-comma-space-after/index.mjs +9 -11
  39. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-comma-space-before/index.mjs +9 -11
  40. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-max-empty-lines/index.mjs +23 -25
  41. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-parentheses-newline-inside/index.mjs +72 -57
  42. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-parentheses-space-inside/index.mjs +97 -72
  43. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/function-whitespace-after/index.mjs +10 -16
  44. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/functionCommaSpaceChecker.mjs +7 -9
  45. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/indentation/index.mjs +43 -49
  46. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/max-empty-lines/index.mjs +13 -8
  47. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/max-line-length/index.mjs +2 -2
  48. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-colon-space-after/index.mjs +9 -11
  49. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-colon-space-before/index.mjs +9 -11
  50. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-name-case/index.mjs +6 -9
  51. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-parentheses-space-inside/index.mjs +68 -27
  52. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-range-operator-space-after/index.mjs +23 -39
  53. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-feature-range-operator-space-before/index.mjs +6 -12
  54. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-query-list-comma-newline-after/index.mjs +8 -10
  55. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-query-list-comma-space-after/index.mjs +9 -11
  56. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/media-query-list-comma-space-before/index.mjs +9 -11
  57. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/mediaFeatureColonSpaceChecker.mjs +2 -1
  58. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/mediaQueryListCommaWhitespaceChecker.mjs +2 -5
  59. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/no-empty-first-line/index.mjs +14 -17
  60. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/no-eol-whitespace/index.mjs +6 -7
  61. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/no-extra-semicolons/index.mjs +45 -43
  62. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/no-missing-end-of-source-newline/index.mjs +5 -9
  63. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/number-leading-zero/index.mjs +24 -58
  64. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/number-no-trailing-zeros/index.mjs +8 -11
  65. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/property-case/index.mjs +5 -8
  66. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-attribute-brackets-space-inside/index.mjs +49 -45
  67. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-attribute-operator-space-after/index.mjs +52 -54
  68. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-attribute-operator-space-before/index.mjs +37 -39
  69. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-combinator-space-after/index.mjs +12 -14
  70. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-combinator-space-before/index.mjs +12 -14
  71. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-descendant-combinator-no-non-space/index.mjs +11 -14
  72. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-list-comma-newline-after/index.mjs +4 -7
  73. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-list-comma-newline-before/index.mjs +7 -9
  74. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-list-comma-space-after/index.mjs +8 -10
  75. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-list-comma-space-before/index.mjs +8 -10
  76. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-max-empty-lines/index.mjs +17 -17
  77. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-pseudo-class-case/index.mjs +39 -40
  78. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-pseudo-class-parentheses-space-inside/index.mjs +49 -44
  79. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selector-pseudo-element-case/index.mjs +5 -8
  80. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selectorAttributeOperatorSpaceChecker.mjs +6 -7
  81. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selectorCombinatorSpaceChecker.mjs +6 -7
  82. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/selectorListCommaWhitespaceChecker.mjs +2 -5
  83. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/string-quotes/index.mjs +51 -59
  84. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/unit-case/index.mjs +19 -21
  85. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/value-list-comma-newline-after/index.mjs +11 -13
  86. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/value-list-comma-space-after/index.mjs +12 -14
  87. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/value-list-comma-space-before/index.mjs +12 -14
  88. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/value-list-max-empty-lines/index.mjs +12 -12
  89. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/valueListCommaWhitespaceChecker.mjs +2 -1
  90. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/linebreaks/README.md +0 -21
  91. package/stylelint/plugins/stylelint-15.11.0-stylistic/rules/linebreaks/index.mjs +0 -133
package/CHANGELOG.md CHANGED
@@ -6,7 +6,30 @@ 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.1.2...HEAD)
9
+ [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v7.4.0...HEAD)
10
+
11
+ ## [7.4.0] - 2025-03-23
12
+
13
+ ### Changed
14
+
15
+ - [eslint] Updated `eslint` from `9.22.0` to `9.23.0`
16
+ - [eslint/react] Activated `allowExpressions` of the `@typescript-eslint/explicit-function-return-type`rule also for the React overrides
17
+
18
+ [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v7.3.0...v7.4.0)
19
+
20
+ ## [7.3.0] - 2025-03-20
21
+
22
+ ### Changed
23
+
24
+ - [eslint] Updated `eslint-import-resolver-typescript` from `4.2.0` to `4.2.2`
25
+ - [eslint] Updated `typescript-eslint` from `8.26.1` to `8.27.0`
26
+ - [stylelint] Refactored all mocked stylistic Stylelint rule, to get rid of the deprecated `context.fix`
27
+
28
+ ### Removed
29
+
30
+ - [stylelint] Removed the stylistic `linebreaks` plugin, as this can be achieved using the `.editorconfig` file
31
+
32
+ [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v7.2.0...v7.3.0)
10
33
 
11
34
  ## [7.2.0] - 2025-03-18
12
35
 
@@ -21,7 +44,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
21
44
 
22
45
  ### Added
23
46
 
24
- - Re-added fixers of the mocked stylistic Stylelint rule.
47
+ - [stylelint] Re-added fixers of the mocked stylistic Stylelint rule.
48
+
49
+ [Show all code changes](https://github.com/jens-duttke/linter-bundle/compare/v7.1.2...v7.2.0)
25
50
 
26
51
  ## [7.1.2] - 2025-03-15
27
52
 
package/README.md CHANGED
@@ -58,7 +58,7 @@ Beside that, the following additional rules are part of this bundle:
58
58
  - [stylelint-selector-tag-no-without-class](https://www.npmjs.com/package/stylelint-selector-tag-no-without-class) (Forked version)
59
59
  - [stylelint-use-logical-spec](https://www.npmjs.com/package/stylelint-use-logical-spec)
60
60
 
61
- Beside that [73 stylistic rules](https://github.com/jens-duttke/linter-bundle/tree/main/stylelint/plugins/stylelint-15.11.0-stylistic/rules) has been forked from `stylelint@15.11.0`, which have been removed in `stylelint@16.0.0`, are part of this bundle.
61
+ Beside that [72 stylistic rules](https://github.com/jens-duttke/linter-bundle/tree/main/stylelint/plugins/stylelint-15.11.0-stylistic/rules) has been forked from `stylelint@15.11.0`, which have been removed in `stylelint@16.0.0`, are part of this bundle.
62
62
 
63
63
  ### Previously used, but now unmaintained plugins
64
64
 
@@ -93,16 +93,16 @@ npm install linter-bundle --save-dev
93
93
  #### eslint.config.mjs
94
94
 
95
95
  ```js
96
- import gatsbyConfig from './eslint/gatsby.mjs';
97
- import javascriptConfig from './eslint/javascript.mjs';
98
- // import javascriptLazyConfig from './eslint/javascript-lazy.mjs';
99
- import jestConfig from './eslint/jest.mjs';
100
- import jsdocConfig from './eslint/jsdoc.mjs';
101
- import reactConfig from './eslint/react.mjs';
102
- import storybookConfig from './eslint/storybook.mjs';
103
- import typeDeclarationsConfig from './eslint/type-declarations.mjs';
104
- import workerConfig from './eslint/worker.mjs';
105
- import eslintConfig from './eslint.mjs';
96
+ import gatsbyConfig from 'linter-bundle/eslint/gatsby.mjs';
97
+ import javascriptConfig from 'linter-bundle/eslint/javascript.mjs';
98
+ // import javascriptLazyConfig from 'linter-bundle/eslint/javascript-lazy.mjs';
99
+ import jestConfig from 'linter-bundle/eslint/jest.mjs';
100
+ import jsdocConfig from 'linter-bundle/eslint/jsdoc.mjs';
101
+ import reactConfig from 'linter-bundle/eslint/react.mjs';
102
+ import storybookConfig from 'linter-bundle/eslint/storybook.mjs';
103
+ import typeDeclarationsConfig from 'linter-bundle/eslint/type-declarations.mjs';
104
+ import workerConfig from 'linter-bundle/eslint/worker.mjs';
105
+ import eslintConfig from 'linter-bundle/eslint.mjs';
106
106
 
107
107
  export default [
108
108
  ...eslintConfig,
package/eslint/react.mjs CHANGED
@@ -42,7 +42,8 @@ export default [
42
42
  'getSnapshotBeforeUpdate',
43
43
  'render',
44
44
  'shouldComponentUpdate'
45
- ]
45
+ ],
46
+ allowExpressions: true
46
47
  }],
47
48
  '@typescript-eslint/no-empty-object-type': ['error', { // Empty interfaces for Component props should be allowed to make it directly visible, that a component has no props.
48
49
  allowWithName: 'Props$'
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @file ESLint rule which ensures logical operations are wrapped in parentheses.
2
+ * @file ESLint rule that ensures logical operations are wrapped in parentheses.
3
3
  */
4
4
 
5
5
  import { isParenthesized } from './helper/is-parenthesized.mjs';
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @file ESLint rule which ensures ternary expressions are wrapped in parentheses.
2
+ * @file ESLint rule that ensures ternary expressions are wrapped in parentheses.
3
3
  */
4
4
 
5
5
  import { isParenthesized } from './helper/is-parenthesized.mjs';
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @file ESLint rule which enforces using Lucide prefix for lucide-react imports and their usage.
2
+ * @file ESLint rule that enforces using Lucide prefix for lucide-react imports and their usage.
3
3
  */
4
4
 
5
5
  import { AST_NODE_TYPES } from '@typescript-eslint/utils';
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @file ESLint rule which disallows spaces after '<' and before '>' in TypeScript generics.
2
+ * @file ESLint rule that disallows spaces after '<' and before '>' in TypeScript generics.
3
3
  */
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @file ESLint rule which disallows ternary expressions as return values for better readability.
2
+ * @file ESLint rule that disallows ternary expressions as return values for better readability.
3
3
  */
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  /**
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.
2
+ * @file ESLint rule that 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
5
  /** @typedef {ts.Type & { intrinsicName?: string; types?: ts.Type[]; objectFlags?: ts.ObjectFlags; }} Type */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @file ESLint rule which ensures that only files which match given glob patterns are part of your project.
2
+ * @file ESLint rule that ensures that only files which match given glob patterns are part of your project.
3
3
  */
4
4
 
5
5
  import path from 'node:path';
@@ -54,8 +54,12 @@ export default {
54
54
  },
55
55
  create: (context) => {
56
56
  const filePath = context.filename;
57
+
58
+ // The type is ensured by `meta.schema`
59
+ const contextOptions = /** @type {{ basePath: string, allowed?: string[]; disallowed?: string[]; }[]} */(context.options);
60
+
57
61
  /** @type {{ basePath: string, allowed?: string[]; disallowed?: string[]; }[]} */
58
- const options = (linterBundleConfig?.files?.restrictions ? [...linterBundleConfig.files.restrictions, ...context.options] : context.options);
62
+ const options = (linterBundleConfig?.files?.restrictions ? [...linterBundleConfig.files.restrictions, ...contextOptions] : contextOptions);
59
63
 
60
64
  for (const { basePath, allowed, disallowed } of options) {
61
65
  const normalizedName = path.relative(path.join(process.cwd(), basePath), filePath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linter-bundle",
3
- "version": "7.2.0",
3
+ "version": "7.4.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": [
@@ -43,9 +43,9 @@
43
43
  "dependencies": {
44
44
  "@stylistic/eslint-plugin": "4.2.0",
45
45
  "@stylistic/eslint-plugin-jsx": "4.2.0",
46
- "eslint": "9.22.0",
46
+ "eslint": "9.23.0",
47
47
  "eslint-formatter-unix": "8.40.0",
48
- "eslint-import-resolver-typescript": "4.2.0",
48
+ "eslint-import-resolver-typescript": "4.2.2",
49
49
  "eslint-import-resolver-webpack": "0.13.10",
50
50
  "eslint-plugin-eslint-comments": "3.2.0",
51
51
  "eslint-plugin-functional": "9.0.1",
@@ -68,7 +68,7 @@
68
68
  "stylelint-order": "6.0.4",
69
69
  "stylelint-scss": "6.11.1",
70
70
  "stylelint-use-logical-spec": "5.0.1",
71
- "typescript-eslint": "8.26.1"
71
+ "typescript-eslint": "8.27.0"
72
72
  },
73
73
  "peerDependencies": {
74
74
  "@typescript-eslint/utils": "*",
@@ -78,7 +78,7 @@
78
78
  "devDependencies": {
79
79
  "@types/eslint": "9.6.1",
80
80
  "@types/micromatch": "4.0.9",
81
- "@types/node": "22.13.10",
81
+ "@types/node": "22.13.11",
82
82
  "stylelint-find-new-rules": "5.0.0",
83
83
  "typescript": "5.8.2"
84
84
  }
@@ -49,7 +49,6 @@ export default {
49
49
  await import('./plugins/stylelint-15.11.0-stylistic/rules/function-parentheses-space-inside/index.mjs'),
50
50
  await import('./plugins/stylelint-15.11.0-stylistic/rules/function-whitespace-after/index.mjs'),
51
51
  await import('./plugins/stylelint-15.11.0-stylistic/rules/indentation/index.mjs'),
52
- await import('./plugins/stylelint-15.11.0-stylistic/rules/linebreaks/index.mjs'),
53
52
  await import('./plugins/stylelint-15.11.0-stylistic/rules/max-empty-lines/index.mjs'),
54
53
  await import('./plugins/stylelint-15.11.0-stylistic/rules/max-line-length/index.mjs'),
55
54
  await import('./plugins/stylelint-15.11.0-stylistic/rules/media-feature-colon-space-after/index.mjs'),
@@ -395,7 +394,6 @@ export default {
395
394
  'plugin/function-parentheses-space-inside': 'never-single-line',
396
395
  'plugin/function-whitespace-after': 'always',
397
396
  'plugin/indentation': 'tab',
398
- 'plugin/linebreaks': 'unix',
399
397
  'plugin/max-empty-lines': 1,
400
398
  'plugin/max-line-length': 160,
401
399
  'plugin/media-feature-colon-space-after': 'always',
@@ -19,7 +19,7 @@ const meta = {
19
19
  };
20
20
 
21
21
  /** @type {import('stylelint').Rule} */
22
- const rule = (primary, _secondary, context) => (root, result) => {
22
+ const rule = (primary, _secondary) => (root, result) => {
23
23
  const validOptions = validateOptions(result, ruleName, {
24
24
  actual: primary,
25
25
  possible: ['lower', 'upper']
@@ -38,24 +38,20 @@ const rule = (primary, _secondary, context) => (root, result) => {
38
38
  }
39
39
 
40
40
  const name = atRule.name;
41
-
42
41
  const expectedName = expectation === 'lower' ? name.toLowerCase() : name.toUpperCase();
43
42
 
44
43
  if (name === expectedName) {
45
44
  return;
46
45
  }
47
46
 
48
- if (context.fix) {
49
- atRule.name = expectedName;
50
-
51
- return;
52
- }
53
-
54
47
  report({
55
48
  message: messages.expected(name, expectedName),
56
49
  node: atRule,
57
50
  ruleName,
58
- result
51
+ result,
52
+ fix: () => {
53
+ atRule.name = expectedName;
54
+ }
59
55
  });
60
56
  });
61
57
  };
@@ -20,7 +20,7 @@ const meta = {
20
20
  };
21
21
 
22
22
  /** @type {import('stylelint').Rule} */
23
- const rule = (primary, _secondary, context) => {
23
+ const rule = (primary, _secondary) => {
24
24
  const checker = whitespaceChecker('space', primary, messages);
25
25
 
26
26
  return (root, result) => {
@@ -24,7 +24,7 @@ const meta = {
24
24
  };
25
25
 
26
26
  /** @type {import('stylelint').Rule} */
27
- const rule = (primary, _secondary, context) => {
27
+ const rule = (primary, _secondary) => {
28
28
  const checker = whitespaceChecker('newline', primary, messages);
29
29
 
30
30
  return (root, result) => {
@@ -63,19 +63,17 @@ const rule = (primary, _secondary, context) => {
63
63
  source: rawNodeString(nodeToCheck),
64
64
  index: -1,
65
65
  err: (message) => {
66
- if (context.fix) {
67
- nodeToCheck.raws.before = context.newline + nodeToCheck.raws.before;
68
- }
69
- else {
70
- report({
71
- message,
72
- node: atRule,
73
- index: atRule.toString().length + 1,
74
- endIndex: atRule.toString().length + 1,
75
- result,
76
- ruleName
77
- });
78
- }
66
+ report({
67
+ message,
68
+ node: atRule,
69
+ index: atRule.toString().length + 1,
70
+ endIndex: atRule.toString().length + 1,
71
+ result,
72
+ ruleName,
73
+ fix: () => {
74
+ nodeToCheck.raws.before = '\n' + nodeToCheck.raws.before;
75
+ }
76
+ });
79
77
  }
80
78
  });
81
79
  });
@@ -36,19 +36,14 @@ export default function atRuleNameSpaceChecker (options) {
36
36
  source,
37
37
  index,
38
38
  err: (m) => {
39
- if (options.fix) {
40
- options.fix(node);
41
-
42
- return;
43
- }
44
-
45
39
  report({
46
40
  message: m,
47
41
  node,
48
42
  index,
49
43
  endIndex: index,
50
44
  result: options.result,
51
- ruleName: options.checkedRuleName
45
+ ruleName: options.checkedRuleName,
46
+ fix: (options.fix ? () => options.fix(node) : undefined)
52
47
  });
53
48
  },
54
49
  errTarget: `@${node.name}`
@@ -97,21 +97,6 @@ const rule = (primary, secondaryOptions, context) => (root, result) => {
97
97
  return;
98
98
  }
99
99
 
100
- if (context.fix) {
101
- const { newline } = context;
102
-
103
- if (typeof newline !== 'string') { return; }
104
-
105
- if (expectEmptyLineBefore) {
106
- addEmptyLineAfter(statement, newline);
107
- }
108
- else {
109
- removeEmptyLinesAfter(statement, newline);
110
- }
111
-
112
- return;
113
- }
114
-
115
100
  const message = expectEmptyLineBefore ? messages.expected : messages.rejected;
116
101
 
117
102
  report({
@@ -120,7 +105,19 @@ const rule = (primary, secondaryOptions, context) => (root, result) => {
120
105
  ruleName,
121
106
  node: statement,
122
107
  index,
123
- endIndex: index
108
+ endIndex: index,
109
+ fix: () => {
110
+ const { newline } = context;
111
+
112
+ if (typeof newline !== 'string') { return; }
113
+
114
+ if (expectEmptyLineBefore) {
115
+ addEmptyLineAfter(statement, newline);
116
+ }
117
+ else {
118
+ removeEmptyLinesAfter(statement, newline);
119
+ }
120
+ }
124
121
  });
125
122
  }
126
123
  };
@@ -112,36 +112,35 @@ const rule = (primary, secondaryOptions, context) => {
112
112
  index: -1,
113
113
  lineCheckStr: blockString(statement),
114
114
  err: (message) => {
115
- if (context.fix) {
116
- const nodeToCheckRaws = nodeToCheck.raws;
115
+ report({
116
+ message,
117
+ node: statement,
118
+ index: reportIndex,
119
+ endIndex: reportIndex,
120
+ result,
121
+ ruleName,
122
+ fix: () => {
123
+ const nodeToCheckRaws = nodeToCheck.raws;
117
124
 
118
- if (typeof nodeToCheckRaws.before !== 'string') { return; }
125
+ if (typeof nodeToCheckRaws.before !== 'string') { return; }
119
126
 
120
- if (primary.startsWith('always')) {
121
- const index = nodeToCheckRaws.before.search(/\r?\n/);
127
+ if (primary.startsWith('always')) {
128
+ const index = nodeToCheckRaws.before.search(/\r?\n/);
122
129
 
123
- nodeToCheckRaws.before =
124
- index >= 0 ?
125
- nodeToCheckRaws.before.slice(index)
126
- : context.newline + nodeToCheckRaws.before;
130
+ nodeToCheckRaws.before =
131
+ index >= 0 ?
132
+ nodeToCheckRaws.before.slice(index)
133
+ : context.newline + nodeToCheckRaws.before;
127
134
 
128
- return;
129
- }
135
+ return;
136
+ }
130
137
 
131
- if (primary.startsWith('never')) {
132
- nodeToCheckRaws.before = '';
138
+ if (primary.startsWith('never')) {
139
+ nodeToCheckRaws.before = '';
133
140
 
134
- return;
141
+ return;
142
+ }
135
143
  }
136
- }
137
-
138
- report({
139
- message,
140
- node: statement,
141
- index: reportIndex,
142
- endIndex: reportIndex,
143
- result,
144
- ruleName
145
144
  });
146
145
  }
147
146
  });
@@ -86,36 +86,6 @@ const rule = (primary, _secondaryOptions, context) => (root, result) => {
86
86
  * @param {string} message
87
87
  */
88
88
  function complain (message) {
89
- if (context.fix) {
90
- const statementRaws = statement.raws;
91
-
92
- if (typeof statementRaws.after !== 'string') { return; }
93
-
94
- if (primary.startsWith('always')) {
95
- const firstWhitespaceIndex = statementRaws.after.search(/\s/);
96
- const newlineBefore =
97
- firstWhitespaceIndex >= 0 ?
98
- statementRaws.after.slice(0, firstWhitespaceIndex)
99
- : statementRaws.after;
100
- const newlineAfter =
101
- firstWhitespaceIndex >= 0 ? statementRaws.after.slice(firstWhitespaceIndex) : '';
102
- const newlineIndex = newlineAfter.search(/\r?\n/);
103
-
104
- statementRaws.after =
105
- newlineIndex >= 0 ?
106
- newlineBefore + newlineAfter.slice(newlineIndex)
107
- : newlineBefore + context.newline + newlineAfter;
108
-
109
- return;
110
- }
111
-
112
- if (primary === 'never-multi-line') {
113
- statementRaws.after = statementRaws.after.replace(/\s/g, '');
114
-
115
- return;
116
- }
117
- }
118
-
119
89
  report({
120
90
  message,
121
91
  result,
@@ -123,6 +93,35 @@ const rule = (primary, _secondaryOptions, context) => (root, result) => {
123
93
  node: statement,
124
94
  index,
125
95
  endIndex: index,
96
+ fix: () => {
97
+ const statementRaws = statement.raws;
98
+
99
+ if (typeof statementRaws.after !== 'string') { return; }
100
+
101
+ if (primary.startsWith('always')) {
102
+ const firstWhitespaceIndex = statementRaws.after.search(/\s/);
103
+ const newlineBefore =
104
+ firstWhitespaceIndex >= 0 ?
105
+ statementRaws.after.slice(0, firstWhitespaceIndex)
106
+ : statementRaws.after;
107
+ const newlineAfter =
108
+ firstWhitespaceIndex >= 0 ? statementRaws.after.slice(firstWhitespaceIndex) : '';
109
+ const newlineIndex = newlineAfter.search(/\r?\n/);
110
+
111
+ statementRaws.after =
112
+ newlineIndex >= 0 ?
113
+ newlineBefore + newlineAfter.slice(newlineIndex)
114
+ : newlineBefore + context.newline + newlineAfter;
115
+
116
+ return;
117
+ }
118
+
119
+ if (primary === 'never-multi-line') {
120
+ statementRaws.after = statementRaws.after.replace(/\s/g, '');
121
+
122
+ return;
123
+ }
124
+ }
126
125
  });
127
126
  }
128
127
  }
@@ -28,7 +28,7 @@ const meta = {
28
28
  };
29
29
 
30
30
  /** @type {import('stylelint').Rule} */
31
- const rule = (primary, _secondaryOptions, context) => {
31
+ const rule = (primary, _secondaryOptions) => {
32
32
  const checker = whitespaceChecker('space', primary, messages);
33
33
 
34
34
  return (root, result) => {
@@ -74,31 +74,30 @@ const rule = (primary, _secondaryOptions, context) => {
74
74
  source,
75
75
  index: source.length - 1,
76
76
  err: (message) => {
77
- if (context.fix) {
78
- const statementRaws = statement.raws;
79
-
80
- if (typeof statementRaws.after !== 'string') { return; }
81
-
82
- if (primary.startsWith('always')) {
83
- statementRaws.after = statementRaws.after.replace(/\s*$/, ' ');
84
-
85
- return;
86
- }
87
-
88
- if (primary.startsWith('never')) {
89
- statementRaws.after = statementRaws.after.replace(/\s*$/, '');
90
-
91
- return;
92
- }
93
- }
94
-
95
77
  report({
96
78
  message,
97
79
  node: statement,
98
80
  index,
99
81
  endIndex: index,
100
82
  result,
101
- ruleName
83
+ ruleName,
84
+ fix: () => {
85
+ const statementRaws = statement.raws;
86
+
87
+ if (typeof statementRaws.after !== 'string') { return; }
88
+
89
+ if (primary.startsWith('always')) {
90
+ statementRaws.after = statementRaws.after.replace(/\s*$/, ' ');
91
+
92
+ return;
93
+ }
94
+
95
+ if (primary.startsWith('never')) {
96
+ statementRaws.after = statementRaws.after.replace(/\s*$/, '');
97
+
98
+ return;
99
+ }
100
+ }
102
101
  });
103
102
  }
104
103
  });
@@ -108,65 +108,62 @@ const rule = (primary, secondaryOptions, context) => {
108
108
  index: -1,
109
109
  lineCheckStr: blockString(statement),
110
110
  err: (m) => {
111
- if (context.fix) {
112
- const nodeToCheckRaws = nodeToCheck.raws;
113
-
114
- if (typeof nodeToCheckRaws.before !== 'string') { return; }
111
+ report({
112
+ message: m,
113
+ node: statement,
114
+ index: beforeBlockString(statement, { noRawBefore: true }).length + 1,
115
+ endIndex: beforeBlockString(statement, { noRawBefore: true }).length + 1,
116
+ result,
117
+ ruleName,
118
+ fix: () => {
119
+ const nodeToCheckRaws = nodeToCheck.raws;
115
120
 
116
- if (primary.startsWith('always')) {
117
- const index = nodeToCheckRaws.before.search(/\r?\n/);
121
+ if (typeof nodeToCheckRaws.before !== 'string') { return; }
118
122
 
119
- nodeToCheckRaws.before =
120
- index >= 0 ?
121
- nodeToCheckRaws.before.slice(index)
122
- : context.newline + nodeToCheckRaws.before;
123
+ if (primary.startsWith('always')) {
124
+ const index = nodeToCheckRaws.before.search(/\r?\n/);
123
125
 
124
- backupCommentNextBefores.delete(nodeToCheck);
126
+ nodeToCheckRaws.before =
127
+ index >= 0 ?
128
+ nodeToCheckRaws.before.slice(index)
129
+ : context.newline + nodeToCheckRaws.before;
125
130
 
126
- return;
127
- }
131
+ backupCommentNextBefores.delete(nodeToCheck);
128
132
 
129
- if (primary === 'never-multi-line') {
130
- // Restore the `before` of the node next to the comment node.
131
- for (const [node, before] of backupCommentNextBefores.entries()) {
132
- node.raws.before = before;
133
+ return;
133
134
  }
134
135
 
135
- backupCommentNextBefores.clear();
136
+ if (primary === 'never-multi-line') {
137
+ // Restore the `before` of the node next to the comment node.
138
+ for (const [node, before] of backupCommentNextBefores.entries()) {
139
+ node.raws.before = before;
140
+ }
136
141
 
137
- // Fix
138
- const reNewLine = /\r?\n/;
139
- let fixTarget = statement.first;
142
+ backupCommentNextBefores.clear();
140
143
 
141
- while (fixTarget) {
142
- const fixTargetRaws = fixTarget.raws;
144
+ // Fix
145
+ const reNewLine = /\r?\n/;
146
+ let fixTarget = statement.first;
143
147
 
144
- if (typeof fixTargetRaws.before !== 'string') { continue; }
148
+ while (fixTarget) {
149
+ const fixTargetRaws = fixTarget.raws;
145
150
 
146
- if (reNewLine.test(fixTargetRaws.before || '')) {
147
- fixTargetRaws.before = fixTargetRaws.before.replace(/\r?\n/g, '');
148
- }
151
+ if (typeof fixTargetRaws.before !== 'string') { continue; }
149
152
 
150
- if (fixTarget.type !== 'comment') {
151
- break;
152
- }
153
+ if (reNewLine.test(fixTargetRaws.before || '')) {
154
+ fixTargetRaws.before = fixTargetRaws.before.replace(/\r?\n/g, '');
155
+ }
153
156
 
154
- fixTarget = fixTarget.next();
155
- }
157
+ if (fixTarget.type !== 'comment') {
158
+ break;
159
+ }
156
160
 
157
- nodeToCheckRaws.before = '';
161
+ fixTarget = fixTarget.next();
162
+ }
158
163
 
159
- return;
164
+ nodeToCheckRaws.before = '';
165
+ }
160
166
  }
161
- }
162
-
163
- report({
164
- message: m,
165
- node: statement,
166
- index: beforeBlockString(statement, { noRawBefore: true }).length + 1,
167
- endIndex: beforeBlockString(statement, { noRawBefore: true }).length + 1,
168
- result,
169
- ruleName
170
167
  });
171
168
  }
172
169
  });