eslint-plugin-stylelint-2 1.0.9
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 +329 -0
- package/LICENSE +21 -0
- package/README.md +174 -0
- package/dist/_internal/rule-docs-url.d.ts +15 -0
- package/dist/_internal/rule-docs-url.d.ts.map +1 -0
- package/dist/_internal/rule-docs-url.js +15 -0
- package/dist/_internal/rule-docs-url.js.map +1 -0
- package/dist/_internal/rules-registry.d.ts +88 -0
- package/dist/_internal/rules-registry.d.ts.map +1 -0
- package/dist/_internal/rules-registry.js +85 -0
- package/dist/_internal/rules-registry.js.map +1 -0
- package/dist/_internal/stylelint-config-boolean-option-rule.d.ts +17 -0
- package/dist/_internal/stylelint-config-boolean-option-rule.d.ts.map +1 -0
- package/dist/_internal/stylelint-config-boolean-option-rule.js +90 -0
- package/dist/_internal/stylelint-config-boolean-option-rule.js.map +1 -0
- package/dist/_internal/stylelint-config-disallowed-option-rule.d.ts +16 -0
- package/dist/_internal/stylelint-config-disallowed-option-rule.d.ts.map +1 -0
- package/dist/_internal/stylelint-config-disallowed-option-rule.js +48 -0
- package/dist/_internal/stylelint-config-disallowed-option-rule.js.map +1 -0
- package/dist/_internal/stylelint-config-object.d.ts +62 -0
- package/dist/_internal/stylelint-config-object.d.ts.map +1 -0
- package/dist/_internal/stylelint-config-object.js +114 -0
- package/dist/_internal/stylelint-config-object.js.map +1 -0
- package/dist/_internal/stylelint-config-package-option-rule.d.ts +12 -0
- package/dist/_internal/stylelint-config-package-option-rule.d.ts.map +1 -0
- package/dist/_internal/stylelint-config-package-option-rule.js +66 -0
- package/dist/_internal/stylelint-config-package-option-rule.js.map +1 -0
- package/dist/_internal/stylelint-config-rules-object.d.ts +23 -0
- package/dist/_internal/stylelint-config-rules-object.d.ts.map +1 -0
- package/dist/_internal/stylelint-config-rules-object.js +47 -0
- package/dist/_internal/stylelint-config-rules-object.js.map +1 -0
- package/dist/_internal/stylelint-config-string-array-option-rule.d.ts +27 -0
- package/dist/_internal/stylelint-config-string-array-option-rule.d.ts.map +1 -0
- package/dist/_internal/stylelint-config-string-array-option-rule.js +234 -0
- package/dist/_internal/stylelint-config-string-array-option-rule.js.map +1 -0
- package/dist/_internal/stylelint-config-string-array-option.d.ts +32 -0
- package/dist/_internal/stylelint-config-string-array-option.d.ts.map +1 -0
- package/dist/_internal/stylelint-config-string-array-option.js +55 -0
- package/dist/_internal/stylelint-config-string-array-option.js.map +1 -0
- package/dist/_internal/stylelint-package-dependencies.d.ts +18 -0
- package/dist/_internal/stylelint-package-dependencies.d.ts.map +1 -0
- package/dist/_internal/stylelint-package-dependencies.js +107 -0
- package/dist/_internal/stylelint-package-dependencies.js.map +1 -0
- package/dist/_internal/stylelint-runner.d.ts +4 -0
- package/dist/_internal/stylelint-runner.d.ts.map +1 -0
- package/dist/_internal/stylelint-runner.js +93 -0
- package/dist/_internal/stylelint-runner.js.map +1 -0
- package/dist/_internal/stylelint-worker-types.d.ts +70 -0
- package/dist/_internal/stylelint-worker-types.d.ts.map +1 -0
- package/dist/_internal/stylelint-worker-types.js +2 -0
- package/dist/_internal/stylelint-worker-types.js.map +1 -0
- package/dist/_internal/stylelint-worker.d.ts +2 -0
- package/dist/_internal/stylelint-worker.d.ts.map +1 -0
- package/dist/_internal/stylelint-worker.js +113 -0
- package/dist/_internal/stylelint-worker.js.map +1 -0
- package/dist/_internal/stylelint2-config-references.d.ts +32 -0
- package/dist/_internal/stylelint2-config-references.d.ts.map +1 -0
- package/dist/_internal/stylelint2-config-references.js +65 -0
- package/dist/_internal/stylelint2-config-references.js.map +1 -0
- package/dist/_internal/typed-rule.d.ts +42 -0
- package/dist/_internal/typed-rule.d.ts.map +1 -0
- package/dist/_internal/typed-rule.js +53 -0
- package/dist/_internal/typed-rule.js.map +1 -0
- package/dist/plugin.cjs +1 -0
- package/dist/plugin.d.cts +10 -0
- package/dist/plugin.d.ts +36 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +183 -0
- package/dist/plugin.js.map +1 -0
- package/dist/rules/disallow-stylelint-allow-empty-input.d.ts +9 -0
- package/dist/rules/disallow-stylelint-allow-empty-input.d.ts.map +1 -0
- package/dist/rules/disallow-stylelint-allow-empty-input.js +29 -0
- package/dist/rules/disallow-stylelint-allow-empty-input.js.map +1 -0
- package/dist/rules/disallow-stylelint-configuration-comment.d.ts +9 -0
- package/dist/rules/disallow-stylelint-configuration-comment.d.ts.map +1 -0
- package/dist/rules/disallow-stylelint-configuration-comment.js +29 -0
- package/dist/rules/disallow-stylelint-configuration-comment.js.map +1 -0
- package/dist/rules/disallow-stylelint-custom-syntax.d.ts +12 -0
- package/dist/rules/disallow-stylelint-custom-syntax.d.ts.map +1 -0
- package/dist/rules/disallow-stylelint-custom-syntax.js +32 -0
- package/dist/rules/disallow-stylelint-custom-syntax.js.map +1 -0
- package/dist/rules/disallow-stylelint-default-severity.d.ts +9 -0
- package/dist/rules/disallow-stylelint-default-severity.d.ts.map +1 -0
- package/dist/rules/disallow-stylelint-default-severity.js +28 -0
- package/dist/rules/disallow-stylelint-default-severity.js.map +1 -0
- package/dist/rules/disallow-stylelint-duplicate-extends.d.ts +9 -0
- package/dist/rules/disallow-stylelint-duplicate-extends.d.ts.map +1 -0
- package/dist/rules/disallow-stylelint-duplicate-extends.js +29 -0
- package/dist/rules/disallow-stylelint-duplicate-extends.js.map +1 -0
- package/dist/rules/disallow-stylelint-duplicate-plugins.d.ts +9 -0
- package/dist/rules/disallow-stylelint-duplicate-plugins.d.ts.map +1 -0
- package/dist/rules/disallow-stylelint-duplicate-plugins.js +29 -0
- package/dist/rules/disallow-stylelint-duplicate-plugins.js.map +1 -0
- package/dist/rules/disallow-stylelint-duplicate-rule-option-values.d.ts +10 -0
- package/dist/rules/disallow-stylelint-duplicate-rule-option-values.d.ts.map +1 -0
- package/dist/rules/disallow-stylelint-duplicate-rule-option-values.js +171 -0
- package/dist/rules/disallow-stylelint-duplicate-rule-option-values.js.map +1 -0
- package/dist/rules/disallow-stylelint-empty-rules-object.d.ts +7 -0
- package/dist/rules/disallow-stylelint-empty-rules-object.d.ts.map +1 -0
- package/dist/rules/disallow-stylelint-empty-rules-object.js +65 -0
- package/dist/rules/disallow-stylelint-empty-rules-object.js.map +1 -0
- package/dist/rules/disallow-stylelint-ignore-disables.d.ts +9 -0
- package/dist/rules/disallow-stylelint-ignore-disables.d.ts.map +1 -0
- package/dist/rules/disallow-stylelint-ignore-disables.js +28 -0
- package/dist/rules/disallow-stylelint-ignore-disables.js.map +1 -0
- package/dist/rules/disallow-stylelint-ignore-files.d.ts +9 -0
- package/dist/rules/disallow-stylelint-ignore-files.d.ts.map +1 -0
- package/dist/rules/disallow-stylelint-ignore-files.js +28 -0
- package/dist/rules/disallow-stylelint-ignore-files.js.map +1 -0
- package/dist/rules/disallow-stylelint-null-rule-config.d.ts +7 -0
- package/dist/rules/disallow-stylelint-null-rule-config.d.ts.map +1 -0
- package/dist/rules/disallow-stylelint-null-rule-config.js +86 -0
- package/dist/rules/disallow-stylelint-null-rule-config.js.map +1 -0
- package/dist/rules/disallow-stylelint-overrides-runtime-options.d.ts +7 -0
- package/dist/rules/disallow-stylelint-overrides-runtime-options.d.ts.map +1 -0
- package/dist/rules/disallow-stylelint-overrides-runtime-options.js +124 -0
- package/dist/rules/disallow-stylelint-overrides-runtime-options.js.map +1 -0
- package/dist/rules/disallow-stylelint-processors.d.ts +9 -0
- package/dist/rules/disallow-stylelint-processors.d.ts.map +1 -0
- package/dist/rules/disallow-stylelint-processors.js +29 -0
- package/dist/rules/disallow-stylelint-processors.js.map +1 -0
- package/dist/rules/disallow-stylelint-relative-extends-paths.d.ts +9 -0
- package/dist/rules/disallow-stylelint-relative-extends-paths.d.ts.map +1 -0
- package/dist/rules/disallow-stylelint-relative-extends-paths.js +28 -0
- package/dist/rules/disallow-stylelint-relative-extends-paths.js.map +1 -0
- package/dist/rules/disallow-stylelint-relative-plugin-paths.d.ts +9 -0
- package/dist/rules/disallow-stylelint-relative-plugin-paths.d.ts.map +1 -0
- package/dist/rules/disallow-stylelint-relative-plugin-paths.js +28 -0
- package/dist/rules/disallow-stylelint-relative-plugin-paths.js.map +1 -0
- package/dist/rules/prefer-stylelint-cache.d.ts +9 -0
- package/dist/rules/prefer-stylelint-cache.d.ts.map +1 -0
- package/dist/rules/prefer-stylelint-cache.js +28 -0
- package/dist/rules/prefer-stylelint-cache.js.map +1 -0
- package/dist/rules/prefer-stylelint-define-config.d.ts +7 -0
- package/dist/rules/prefer-stylelint-define-config.d.ts.map +1 -0
- package/dist/rules/prefer-stylelint-define-config.js +82 -0
- package/dist/rules/prefer-stylelint-define-config.js.map +1 -0
- package/dist/rules/prefer-stylelint-extends-array.d.ts +9 -0
- package/dist/rules/prefer-stylelint-extends-array.d.ts.map +1 -0
- package/dist/rules/prefer-stylelint-extends-array.js +29 -0
- package/dist/rules/prefer-stylelint-extends-array.js.map +1 -0
- package/dist/rules/prefer-stylelint-fix.d.ts +7 -0
- package/dist/rules/prefer-stylelint-fix.d.ts.map +1 -0
- package/dist/rules/prefer-stylelint-fix.js +90 -0
- package/dist/rules/prefer-stylelint-fix.js.map +1 -0
- package/dist/rules/prefer-stylelint-formatter.d.ts +10 -0
- package/dist/rules/prefer-stylelint-formatter.d.ts.map +1 -0
- package/dist/rules/prefer-stylelint-formatter.js +77 -0
- package/dist/rules/prefer-stylelint-formatter.js.map +1 -0
- package/dist/rules/prefer-stylelint-plugins-array.d.ts +9 -0
- package/dist/rules/prefer-stylelint-plugins-array.d.ts.map +1 -0
- package/dist/rules/prefer-stylelint-plugins-array.js +29 -0
- package/dist/rules/prefer-stylelint-plugins-array.js.map +1 -0
- package/dist/rules/prefer-stylelint-report-descriptionless-disables.d.ts +12 -0
- package/dist/rules/prefer-stylelint-report-descriptionless-disables.d.ts.map +1 -0
- package/dist/rules/prefer-stylelint-report-descriptionless-disables.js +32 -0
- package/dist/rules/prefer-stylelint-report-descriptionless-disables.js.map +1 -0
- package/dist/rules/prefer-stylelint-report-invalid-scope-disables.d.ts +12 -0
- package/dist/rules/prefer-stylelint-report-invalid-scope-disables.d.ts.map +1 -0
- package/dist/rules/prefer-stylelint-report-invalid-scope-disables.js +32 -0
- package/dist/rules/prefer-stylelint-report-invalid-scope-disables.js.map +1 -0
- package/dist/rules/prefer-stylelint-report-needless-disables.d.ts +9 -0
- package/dist/rules/prefer-stylelint-report-needless-disables.d.ts.map +1 -0
- package/dist/rules/prefer-stylelint-report-needless-disables.js +29 -0
- package/dist/rules/prefer-stylelint-report-needless-disables.js.map +1 -0
- package/dist/rules/prefer-stylelint-report-unscoped-disables.d.ts +9 -0
- package/dist/rules/prefer-stylelint-report-unscoped-disables.d.ts.map +1 -0
- package/dist/rules/prefer-stylelint-report-unscoped-disables.js +29 -0
- package/dist/rules/prefer-stylelint-report-unscoped-disables.js.map +1 -0
- package/dist/rules/require-stylelint-config-file-naming-convention.d.ts +13 -0
- package/dist/rules/require-stylelint-config-file-naming-convention.d.ts.map +1 -0
- package/dist/rules/require-stylelint-config-file-naming-convention.js +58 -0
- package/dist/rules/require-stylelint-config-file-naming-convention.js.map +1 -0
- package/dist/rules/require-stylelint-custom-syntax-in-overrides.d.ts +7 -0
- package/dist/rules/require-stylelint-custom-syntax-in-overrides.d.ts.map +1 -0
- package/dist/rules/require-stylelint-custom-syntax-in-overrides.js +100 -0
- package/dist/rules/require-stylelint-custom-syntax-in-overrides.js.map +1 -0
- package/dist/rules/require-stylelint-extends-packages-installed.d.ts +12 -0
- package/dist/rules/require-stylelint-extends-packages-installed.d.ts.map +1 -0
- package/dist/rules/require-stylelint-extends-packages-installed.js +31 -0
- package/dist/rules/require-stylelint-extends-packages-installed.js.map +1 -0
- package/dist/rules/require-stylelint-overrides-configuration.d.ts +7 -0
- package/dist/rules/require-stylelint-overrides-configuration.d.ts.map +1 -0
- package/dist/rules/require-stylelint-overrides-configuration.js +100 -0
- package/dist/rules/require-stylelint-overrides-configuration.js.map +1 -0
- package/dist/rules/require-stylelint-overrides-files-array.d.ts +7 -0
- package/dist/rules/require-stylelint-overrides-files-array.d.ts.map +1 -0
- package/dist/rules/require-stylelint-overrides-files-array.js +99 -0
- package/dist/rules/require-stylelint-overrides-files-array.js.map +1 -0
- package/dist/rules/require-stylelint-overrides-files.d.ts +7 -0
- package/dist/rules/require-stylelint-overrides-files.d.ts.map +1 -0
- package/dist/rules/require-stylelint-overrides-files.js +104 -0
- package/dist/rules/require-stylelint-overrides-files.js.map +1 -0
- package/dist/rules/require-stylelint-plugins-packages-installed.d.ts +12 -0
- package/dist/rules/require-stylelint-plugins-packages-installed.d.ts.map +1 -0
- package/dist/rules/require-stylelint-plugins-packages-installed.js +31 -0
- package/dist/rules/require-stylelint-plugins-packages-installed.js.map +1 -0
- package/dist/rules/require-stylelint-report-disables.d.ts +9 -0
- package/dist/rules/require-stylelint-report-disables.d.ts.map +1 -0
- package/dist/rules/require-stylelint-report-disables.js +29 -0
- package/dist/rules/require-stylelint-report-disables.js.map +1 -0
- package/dist/rules/require-stylelint-rules-object.d.ts +7 -0
- package/dist/rules/require-stylelint-rules-object.d.ts.map +1 -0
- package/dist/rules/require-stylelint-rules-object.js +65 -0
- package/dist/rules/require-stylelint-rules-object.js.map +1 -0
- package/dist/rules/sort-stylelint-extends.d.ts +9 -0
- package/dist/rules/sort-stylelint-extends.d.ts.map +1 -0
- package/dist/rules/sort-stylelint-extends.js +28 -0
- package/dist/rules/sort-stylelint-extends.js.map +1 -0
- package/dist/rules/sort-stylelint-plugins.d.ts +9 -0
- package/dist/rules/sort-stylelint-plugins.d.ts.map +1 -0
- package/dist/rules/sort-stylelint-plugins.js +28 -0
- package/dist/rules/sort-stylelint-plugins.js.map +1 -0
- package/dist/rules/sort-stylelint-rule-keys.d.ts +7 -0
- package/dist/rules/sort-stylelint-rule-keys.d.ts.map +1 -0
- package/dist/rules/sort-stylelint-rule-keys.js +129 -0
- package/dist/rules/sort-stylelint-rule-keys.js.map +1 -0
- package/dist/rules/stylelint.d.ts +15 -0
- package/dist/rules/stylelint.d.ts.map +1 -0
- package/dist/rules/stylelint.js +157 -0
- package/dist/rules/stylelint.js.map +1 -0
- package/docs/rules/disallow-stylelint-allow-empty-input.md +62 -0
- package/docs/rules/disallow-stylelint-configuration-comment.md +62 -0
- package/docs/rules/disallow-stylelint-custom-syntax.md +70 -0
- package/docs/rules/disallow-stylelint-default-severity.md +77 -0
- package/docs/rules/disallow-stylelint-duplicate-extends.md +61 -0
- package/docs/rules/disallow-stylelint-duplicate-plugins.md +61 -0
- package/docs/rules/disallow-stylelint-duplicate-rule-option-values.md +73 -0
- package/docs/rules/disallow-stylelint-empty-rules-object.md +62 -0
- package/docs/rules/disallow-stylelint-ignore-disables.md +78 -0
- package/docs/rules/disallow-stylelint-ignore-files.md +78 -0
- package/docs/rules/disallow-stylelint-null-rule-config.md +63 -0
- package/docs/rules/disallow-stylelint-overrides-runtime-options.md +82 -0
- package/docs/rules/disallow-stylelint-processors.md +62 -0
- package/docs/rules/disallow-stylelint-relative-extends-paths.md +61 -0
- package/docs/rules/disallow-stylelint-relative-plugin-paths.md +61 -0
- package/docs/rules/getting-started.md +130 -0
- package/docs/rules/overview.md +99 -0
- package/docs/rules/prefer-stylelint-cache.md +79 -0
- package/docs/rules/prefer-stylelint-define-config.md +90 -0
- package/docs/rules/prefer-stylelint-extends-array.md +61 -0
- package/docs/rules/prefer-stylelint-fix.md +79 -0
- package/docs/rules/prefer-stylelint-formatter.md +80 -0
- package/docs/rules/prefer-stylelint-plugins-array.md +61 -0
- package/docs/rules/prefer-stylelint-report-descriptionless-disables.md +85 -0
- package/docs/rules/prefer-stylelint-report-invalid-scope-disables.md +83 -0
- package/docs/rules/prefer-stylelint-report-needless-disables.md +83 -0
- package/docs/rules/prefer-stylelint-report-unscoped-disables.md +83 -0
- package/docs/rules/presets/all.md +39 -0
- package/docs/rules/presets/configs.md +40 -0
- package/docs/rules/presets/configuration.md +64 -0
- package/docs/rules/presets/index.md +82 -0
- package/docs/rules/presets/recommended.md +40 -0
- package/docs/rules/presets/stylelint-only.md +42 -0
- package/docs/rules/require-stylelint-config-file-naming-convention.md +61 -0
- package/docs/rules/require-stylelint-custom-syntax-in-overrides.md +77 -0
- package/docs/rules/require-stylelint-extends-packages-installed.md +61 -0
- package/docs/rules/require-stylelint-overrides-configuration.md +80 -0
- package/docs/rules/require-stylelint-overrides-files-array.md +78 -0
- package/docs/rules/require-stylelint-overrides-files.md +83 -0
- package/docs/rules/require-stylelint-plugins-packages-installed.md +61 -0
- package/docs/rules/require-stylelint-report-disables.md +67 -0
- package/docs/rules/require-stylelint-rules-object.md +61 -0
- package/docs/rules/sort-stylelint-extends.md +61 -0
- package/docs/rules/sort-stylelint-plugins.md +61 -0
- package/docs/rules/sort-stylelint-rule-keys.md +65 -0
- package/docs/rules/stylelint.md +100 -0
- package/package.json +577 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { getExportedStylelintConfigObject, isStylelintConfigFile, } from "../_internal/stylelint-config-object.js";
|
|
2
|
+
import { getTopLevelRuleEntries, getTopLevelRulesObject, } from "../_internal/stylelint-config-rules-object.js";
|
|
3
|
+
import { createTypedRule, toRuleListener } from "../_internal/typed-rule.js";
|
|
4
|
+
const getRuleName = (property) => {
|
|
5
|
+
const propertyKey = property.key;
|
|
6
|
+
if (propertyKey.type === "Identifier") {
|
|
7
|
+
return propertyKey.name;
|
|
8
|
+
}
|
|
9
|
+
if (propertyKey.type === "Literal" &&
|
|
10
|
+
typeof propertyKey.value === "string") {
|
|
11
|
+
return propertyKey.value;
|
|
12
|
+
}
|
|
13
|
+
return undefined;
|
|
14
|
+
};
|
|
15
|
+
const isAlreadySorted = (properties) => {
|
|
16
|
+
let previousRuleName = "";
|
|
17
|
+
for (const property of properties) {
|
|
18
|
+
const ruleName = getRuleName(property);
|
|
19
|
+
if (ruleName === undefined) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
if (ruleName.localeCompare(previousRuleName) < 0) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
previousRuleName = ruleName;
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
};
|
|
29
|
+
const canSafelyFixSorting = (sourceCode, properties) => {
|
|
30
|
+
for (const property of properties) {
|
|
31
|
+
if (property.computed || property.kind !== "init") {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
if (getRuleName(property) === undefined) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
if (sourceCode.getCommentsBefore(property).length > 0) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
if (sourceCode.getCommentsAfter(property).length > 0) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return true;
|
|
45
|
+
};
|
|
46
|
+
const getSortedPropertyText = (sourceCode, properties) => {
|
|
47
|
+
const sortedProperties = [...properties];
|
|
48
|
+
sortedProperties.sort((left, right) => {
|
|
49
|
+
const leftRuleName = getRuleName(left) ?? "";
|
|
50
|
+
const rightRuleName = getRuleName(right) ?? "";
|
|
51
|
+
return leftRuleName.localeCompare(rightRuleName);
|
|
52
|
+
});
|
|
53
|
+
const indentation = " ".repeat(properties[0]?.loc.start.column ?? 0);
|
|
54
|
+
return sortedProperties
|
|
55
|
+
.map((property) => sourceCode.getText(property))
|
|
56
|
+
.join(`,\n${indentation}`);
|
|
57
|
+
};
|
|
58
|
+
/** Rule module that enforces lexical ordering of top-level Stylelint rule keys. */
|
|
59
|
+
const sortStylelintRuleKeysRule = createTypedRule({
|
|
60
|
+
create(context) {
|
|
61
|
+
if (!isStylelintConfigFile(context.physicalFilename)) {
|
|
62
|
+
return {};
|
|
63
|
+
}
|
|
64
|
+
const sourceCode = context.sourceCode;
|
|
65
|
+
return toRuleListener({
|
|
66
|
+
ExportDefaultDeclaration(node) {
|
|
67
|
+
if (node === null || typeof node !== "object") {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const exportDefaultNode = node;
|
|
71
|
+
const configObject = getExportedStylelintConfigObject(exportDefaultNode.declaration);
|
|
72
|
+
if (configObject === undefined) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const rulesObject = getTopLevelRulesObject(configObject);
|
|
76
|
+
if (rulesObject === undefined) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const ruleEntries = getTopLevelRuleEntries(rulesObject);
|
|
80
|
+
if (ruleEntries.length < 2 ||
|
|
81
|
+
isAlreadySorted(ruleEntries)) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
context.report({
|
|
85
|
+
fix(fixer) {
|
|
86
|
+
if (!canSafelyFixSorting(sourceCode, ruleEntries)) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
const firstRuleEntry = ruleEntries[0];
|
|
90
|
+
const lastRuleEntry = ruleEntries.at(-1);
|
|
91
|
+
if (firstRuleEntry === undefined ||
|
|
92
|
+
lastRuleEntry === undefined) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
return fixer.replaceTextRange([
|
|
96
|
+
firstRuleEntry.range[0],
|
|
97
|
+
lastRuleEntry.range[1],
|
|
98
|
+
], getSortedPropertyText(sourceCode, ruleEntries));
|
|
99
|
+
},
|
|
100
|
+
messageId: "sortRuleKeys",
|
|
101
|
+
node: rulesObject,
|
|
102
|
+
});
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
},
|
|
106
|
+
meta: {
|
|
107
|
+
deprecated: false,
|
|
108
|
+
docs: {
|
|
109
|
+
configs: [
|
|
110
|
+
"stylelint2.configs.recommended",
|
|
111
|
+
"stylelint2.configs.configuration",
|
|
112
|
+
"stylelint2.configs.all",
|
|
113
|
+
],
|
|
114
|
+
description: "enforce sorted top-level Stylelint rule keys in shared config files.",
|
|
115
|
+
recommended: true,
|
|
116
|
+
requiresTypeChecking: false,
|
|
117
|
+
url: "https://nick2bad4u.github.io/eslint-plugin-stylelint-2/docs/rules/sort-stylelint-rule-keys",
|
|
118
|
+
},
|
|
119
|
+
fixable: "code",
|
|
120
|
+
messages: {
|
|
121
|
+
sortRuleKeys: "Sort top-level Stylelint `rules` keys for deterministic diffs and consistent review order.",
|
|
122
|
+
},
|
|
123
|
+
schema: [],
|
|
124
|
+
type: "suggestion",
|
|
125
|
+
},
|
|
126
|
+
name: "sort-stylelint-rule-keys",
|
|
127
|
+
});
|
|
128
|
+
export default sortStylelintRuleKeysRule;
|
|
129
|
+
//# sourceMappingURL=sort-stylelint-rule-keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sort-stylelint-rule-keys.js","sourceRoot":"","sources":["../../src/rules/sort-stylelint-rule-keys.ts"],"names":[],"mappings":"AAQA,OAAO,EACH,gCAAgC,EAChC,qBAAqB,GACxB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EACH,sBAAsB,EACtB,sBAAsB,GACzB,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAK7E,MAAM,WAAW,GAAG,CAChB,QAAqC,EACnB,EAAE;IACpB,MAAM,WAAW,GAAG,QAAQ,CAAC,GAAG,CAAC;IAEjC,IAAI,WAAW,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;QACpC,OAAO,WAAW,CAAC,IAAI,CAAC;IAC5B,CAAC;IAED,IACI,WAAW,CAAC,IAAI,KAAK,SAAS;QAC9B,OAAO,WAAW,CAAC,KAAK,KAAK,QAAQ,EACvC,CAAC;QACC,OAAO,WAAW,CAAC,KAAK,CAAC;IAC7B,CAAC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG,CACpB,UAAkD,EAC3C,EAAE;IACT,IAAI,gBAAgB,GAAG,EAAE,CAAC;IAE1B,KAAK,MAAM,QAAQ,IAAI,UAAU,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;QAEvC,IAAI,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ageIds = "stylelintConfigWarning" | "stylelintParseError" | "stylelintProblem";
|
|
3
|
+
type Options = readonly [StylelintRuleOption?];
|
|
4
|
+
type StylelintRuleOption = Readonly<{
|
|
5
|
+
allowEmptyInput?: boolean;
|
|
6
|
+
configBasedir?: string;
|
|
7
|
+
configFile?: string;
|
|
8
|
+
customSyntax?: string;
|
|
9
|
+
ignoreDisables?: boolean;
|
|
10
|
+
quiet?: boolean;
|
|
11
|
+
}>;
|
|
12
|
+
/** Rule module that bridges Stylelint diagnostics into ESLint. */
|
|
13
|
+
declare const stylelintRule: RuleModuleWithDocs<MessageIds, Options>;
|
|
14
|
+
export default stylelintRule;
|
|
15
|
+
//# sourceMappingURL=stylelint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stylelint.d.ts","sourceRoot":"","sources":["../../src/rules/stylelint.ts"],"names":[],"mappings":"AAOA,OAAO,EAGH,KAAK,kBAAkB,EAE1B,MAAM,4BAA4B,CAAC;AAEpC,KAAK,UAAU,GACT,wBAAwB,GACxB,qBAAqB,GACrB,kBAAkB,CAAC;AAEzB,KAAK,OAAO,GAAG,SAAS,CAAC,mBAAmB,CAAC,CAAC,CAAC;AAO/C,KAAK,mBAAmB,GAAG,QAAQ,CAAC;IAChC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC,CAAC;AAoBH,kEAAkE;AAClE,QAAA,MAAM,aAAa,EAAE,kBAAkB,CAAC,UAAU,EAAE,OAAO,CAmKzD,CAAC;AAEH,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { runStylelintSynchronously } from "../_internal/stylelint-runner.js";
|
|
2
|
+
import { createTypedRule, replaceTextRange, toRuleListener, } from "../_internal/typed-rule.js";
|
|
3
|
+
const toEslintLoc = (problem) => ({
|
|
4
|
+
end: {
|
|
5
|
+
column: Math.max((problem.endColumn ?? problem.column + 1) - 1, 0),
|
|
6
|
+
line: problem.endLine ?? problem.line,
|
|
7
|
+
},
|
|
8
|
+
start: {
|
|
9
|
+
column: Math.max(problem.column - 1, 0),
|
|
10
|
+
line: problem.line,
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
/** Rule module that bridges Stylelint diagnostics into ESLint. */
|
|
14
|
+
const stylelintRule = createTypedRule({
|
|
15
|
+
create(context, [rawOptions = {}]) {
|
|
16
|
+
return toRuleListener({
|
|
17
|
+
StyleSheet() {
|
|
18
|
+
const sourceCode = context.sourceCode;
|
|
19
|
+
const lintResult = runStylelintSynchronously({
|
|
20
|
+
code: sourceCode.text,
|
|
21
|
+
codeFilename: context.physicalFilename,
|
|
22
|
+
cwd: context.cwd,
|
|
23
|
+
...(rawOptions.allowEmptyInput === undefined
|
|
24
|
+
? {}
|
|
25
|
+
: { allowEmptyInput: rawOptions.allowEmptyInput }),
|
|
26
|
+
...(rawOptions.configBasedir === undefined
|
|
27
|
+
? {}
|
|
28
|
+
: { configBasedir: rawOptions.configBasedir }),
|
|
29
|
+
...(rawOptions.configFile === undefined
|
|
30
|
+
? {}
|
|
31
|
+
: { configFile: rawOptions.configFile }),
|
|
32
|
+
...(rawOptions.customSyntax === undefined
|
|
33
|
+
? {}
|
|
34
|
+
: { customSyntax: rawOptions.customSyntax }),
|
|
35
|
+
...(rawOptions.ignoreDisables === undefined
|
|
36
|
+
? {}
|
|
37
|
+
: { ignoreDisables: rawOptions.ignoreDisables }),
|
|
38
|
+
...(rawOptions.quiet === undefined
|
|
39
|
+
? {}
|
|
40
|
+
: { quiet: rawOptions.quiet }),
|
|
41
|
+
});
|
|
42
|
+
const reportNode = sourceCode.ast;
|
|
43
|
+
for (const parseError of lintResult.parseErrors) {
|
|
44
|
+
context.report({
|
|
45
|
+
data: {
|
|
46
|
+
message: parseError.message,
|
|
47
|
+
},
|
|
48
|
+
loc: toEslintLoc(parseError),
|
|
49
|
+
messageId: "stylelintParseError",
|
|
50
|
+
node: reportNode,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
for (const warning of lintResult.warnings) {
|
|
54
|
+
const fixData = warning.fix;
|
|
55
|
+
context.report({
|
|
56
|
+
data: {
|
|
57
|
+
rule: warning.rule,
|
|
58
|
+
text: warning.text,
|
|
59
|
+
},
|
|
60
|
+
loc: toEslintLoc(warning),
|
|
61
|
+
messageId: "stylelintProblem",
|
|
62
|
+
node: reportNode,
|
|
63
|
+
...(fixData === undefined
|
|
64
|
+
? {}
|
|
65
|
+
: {
|
|
66
|
+
fix: (fixer) => replaceTextRange(fixer, fixData.range, fixData.text),
|
|
67
|
+
}),
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
for (const invalidOptionWarning of lintResult.invalidOptionWarnings) {
|
|
71
|
+
context.report({
|
|
72
|
+
data: {
|
|
73
|
+
message: invalidOptionWarning,
|
|
74
|
+
},
|
|
75
|
+
loc: {
|
|
76
|
+
end: { column: 0, line: 1 },
|
|
77
|
+
start: { column: 0, line: 1 },
|
|
78
|
+
},
|
|
79
|
+
messageId: "stylelintConfigWarning",
|
|
80
|
+
node: reportNode,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
for (const deprecation of lintResult.deprecations) {
|
|
84
|
+
context.report({
|
|
85
|
+
data: {
|
|
86
|
+
message: deprecation,
|
|
87
|
+
},
|
|
88
|
+
loc: {
|
|
89
|
+
end: { column: 0, line: 1 },
|
|
90
|
+
start: { column: 0, line: 1 },
|
|
91
|
+
},
|
|
92
|
+
messageId: "stylelintConfigWarning",
|
|
93
|
+
node: reportNode,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
},
|
|
99
|
+
meta: {
|
|
100
|
+
defaultOptions: [{}],
|
|
101
|
+
deprecated: false,
|
|
102
|
+
docs: {
|
|
103
|
+
configs: [
|
|
104
|
+
"stylelint2.configs.recommended",
|
|
105
|
+
"stylelint2.configs.stylelintOnly",
|
|
106
|
+
"stylelint2.configs.all",
|
|
107
|
+
],
|
|
108
|
+
description: "enforce running Stylelint against CSS files from ESLint and surface Stylelint autofixes through ESLint's fixer pipeline.",
|
|
109
|
+
recommended: true,
|
|
110
|
+
requiresTypeChecking: false,
|
|
111
|
+
url: "https://nick2bad4u.github.io/eslint-plugin-stylelint-2/docs/rules/stylelint",
|
|
112
|
+
},
|
|
113
|
+
fixable: "code",
|
|
114
|
+
messages: {
|
|
115
|
+
stylelintConfigWarning: "Stylelint configuration warning: {{message}}",
|
|
116
|
+
stylelintParseError: "Stylelint parse error: {{message}}",
|
|
117
|
+
stylelintProblem: "Stylelint ({{rule}}): {{text}}",
|
|
118
|
+
},
|
|
119
|
+
schema: [
|
|
120
|
+
{
|
|
121
|
+
additionalProperties: false,
|
|
122
|
+
description: "Optional Stylelint bridge settings forwarded to the Stylelint Node API.",
|
|
123
|
+
properties: {
|
|
124
|
+
allowEmptyInput: {
|
|
125
|
+
description: "Allow empty input when forwarding the file to Stylelint.",
|
|
126
|
+
type: "boolean",
|
|
127
|
+
},
|
|
128
|
+
configBasedir: {
|
|
129
|
+
description: "Base directory used when resolving relative paths from the chosen Stylelint config.",
|
|
130
|
+
type: "string",
|
|
131
|
+
},
|
|
132
|
+
configFile: {
|
|
133
|
+
description: "Explicit Stylelint config file path to use instead of normal config discovery.",
|
|
134
|
+
type: "string",
|
|
135
|
+
},
|
|
136
|
+
customSyntax: {
|
|
137
|
+
description: "Optional Stylelint custom syntax package name.",
|
|
138
|
+
type: "string",
|
|
139
|
+
},
|
|
140
|
+
ignoreDisables: {
|
|
141
|
+
description: "Ignore Stylelint disable comments while linting the file.",
|
|
142
|
+
type: "boolean",
|
|
143
|
+
},
|
|
144
|
+
quiet: {
|
|
145
|
+
description: "Suppress warning-level Stylelint messages.",
|
|
146
|
+
type: "boolean",
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
type: "object",
|
|
150
|
+
},
|
|
151
|
+
],
|
|
152
|
+
type: "layout",
|
|
153
|
+
},
|
|
154
|
+
name: "stylelint",
|
|
155
|
+
});
|
|
156
|
+
export default stylelintRule;
|
|
157
|
+
//# sourceMappingURL=stylelint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stylelint.js","sourceRoot":"","sources":["../../src/rules/stylelint.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EACH,eAAe,EACf,gBAAgB,EAEhB,cAAc,GACjB,MAAM,4BAA4B,CAAC;AAuBpC,MAAM,WAAW,GAAG,CAChB,OAKE,EACY,EAAE,CAAC,CAAC;IAClB,GAAG,EAAE;QACD,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAClE,IAAI,EAAE,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI;KACxC;IACD,KAAK,EAAE;QACH,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,CAAC;QACvC,IAAI,EAAE,OAAO,CAAC,IAAI;KACrB;CACJ,CAAC,CAAC;AAEH,kEAAkE;AAClE,MAAM,aAAa,GAA4C,eAAe,CAG5E;IACE,MAAM,CAAC,OAAO,EAAE,CAAC,UAAU,GAAG,EAAE,CAAC;QAC7B,OAAO,cAAc,CAAC;YAClB,UAAU;gBACN,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;gBACtC,MAAM,UAAU,GAAG,yBAAyB,CAAC;oBACzC,IAAI,EAAE,UAAU,CAAC,IAAI;oBACrB,YAAY,EAAE,OAAO,CAAC,gBAAgB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AAQ;KACjB;IACD,IAAI,EAAE,WAAW;CACpB,CAAC,CAAC;AAEH,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# disallow-stylelint-allow-empty-input
|
|
2
|
+
|
|
3
|
+
Disallow configuring Stylelint's top-level `allowEmptyInput` option inside authored Stylelint config files.
|
|
4
|
+
|
|
5
|
+
## Targeted pattern scope
|
|
6
|
+
|
|
7
|
+
This rule targets Stylelint config modules such as `stylelint.config.ts`, `stylelint.config.mjs`, and `.stylelintrc.js`.
|
|
8
|
+
|
|
9
|
+
It focuses on top-level exported config objects, including configs wrapped in `defineConfig(...)`.
|
|
10
|
+
|
|
11
|
+
## What this rule reports
|
|
12
|
+
|
|
13
|
+
This rule reports Stylelint config objects that include a top-level `allowEmptyInput` property.
|
|
14
|
+
|
|
15
|
+
## Why this rule exists
|
|
16
|
+
|
|
17
|
+
`allowEmptyInput` changes runtime behavior for file discovery and no-op lint runs. That policy is an execution concern and should be controlled at invocation level, not embedded in shared config state.
|
|
18
|
+
|
|
19
|
+
## ❌ Incorrect
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
export default {
|
|
23
|
+
allowEmptyInput: true,
|
|
24
|
+
rules: {},
|
|
25
|
+
};
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## ✅ Correct
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
export default {
|
|
32
|
+
rules: {},
|
|
33
|
+
};
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Behavior and migration notes
|
|
37
|
+
|
|
38
|
+
- This rule removes the top-level `allowEmptyInput` property.
|
|
39
|
+
- It preserves the rest of the config object.
|
|
40
|
+
- Prefer explicit file globs and task-level invocation behavior for empty-input handling.
|
|
41
|
+
|
|
42
|
+
## ESLint flat config example
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import stylelint2 from "eslint-plugin-stylelint-2";
|
|
46
|
+
|
|
47
|
+
export default [stylelint2.configs.configuration];
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## When not to use it
|
|
51
|
+
|
|
52
|
+
Do not use this rule if your team intentionally enforces one shared `allowEmptyInput` policy in committed Stylelint config files.
|
|
53
|
+
|
|
54
|
+
## Package documentation
|
|
55
|
+
|
|
56
|
+
Stylelint package documentation:
|
|
57
|
+
|
|
58
|
+
> **Rule catalog ID:** R013
|
|
59
|
+
|
|
60
|
+
## Further reading
|
|
61
|
+
|
|
62
|
+
- [Stylelint configuring guide](https://stylelint.io/user-guide/configure/#allowemptyinput)
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# disallow-stylelint-configuration-comment
|
|
2
|
+
|
|
3
|
+
Disallow configuring Stylelint's top-level `configurationComment` option inside authored Stylelint config files.
|
|
4
|
+
|
|
5
|
+
## Targeted pattern scope
|
|
6
|
+
|
|
7
|
+
This rule targets Stylelint config modules such as `stylelint.config.ts`, `stylelint.config.mjs`, and `.stylelintrc.js`.
|
|
8
|
+
|
|
9
|
+
It focuses on top-level exported config objects, including configs wrapped in `defineConfig(...)`.
|
|
10
|
+
|
|
11
|
+
## What this rule reports
|
|
12
|
+
|
|
13
|
+
This rule reports Stylelint config objects that include a top-level `configurationComment` property.
|
|
14
|
+
|
|
15
|
+
## Why this rule exists
|
|
16
|
+
|
|
17
|
+
`configurationComment` changes how in-source configuration comments are interpreted. In shared configs, overriding this can create hard-to-debug behavior differences across repositories and tooling.
|
|
18
|
+
|
|
19
|
+
## ❌ Incorrect
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
export default {
|
|
23
|
+
configurationComment: "stylelint-enable",
|
|
24
|
+
rules: {},
|
|
25
|
+
};
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## ✅ Correct
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
export default {
|
|
32
|
+
rules: {},
|
|
33
|
+
};
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Behavior and migration notes
|
|
37
|
+
|
|
38
|
+
- This rule removes top-level `configurationComment`.
|
|
39
|
+
- It preserves the rest of the config object.
|
|
40
|
+
- Keep configuration-comment behavior aligned with Stylelint defaults unless there is a strict organization-wide policy.
|
|
41
|
+
|
|
42
|
+
## ESLint flat config example
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import stylelint2 from "eslint-plugin-stylelint-2";
|
|
46
|
+
|
|
47
|
+
export default [stylelint2.configs.configuration];
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## When not to use it
|
|
51
|
+
|
|
52
|
+
Do not use this rule if your organization explicitly standardizes a non-default Stylelint configuration comment token.
|
|
53
|
+
|
|
54
|
+
## Package documentation
|
|
55
|
+
|
|
56
|
+
Stylelint package documentation:
|
|
57
|
+
|
|
58
|
+
> **Rule catalog ID:** R016
|
|
59
|
+
|
|
60
|
+
## Further reading
|
|
61
|
+
|
|
62
|
+
- [Stylelint configuration comments](https://stylelint.io/user-guide/ignore-code/)
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# disallow-stylelint-custom-syntax
|
|
2
|
+
|
|
3
|
+
Disallow configuring Stylelint's top-level `customSyntax` option inside authored Stylelint config files.
|
|
4
|
+
|
|
5
|
+
## Targeted pattern scope
|
|
6
|
+
|
|
7
|
+
This rule targets Stylelint config modules such as `stylelint.config.ts`, `stylelint.config.mjs`, and `.stylelintrc.js`.
|
|
8
|
+
|
|
9
|
+
It focuses on top-level exported config objects, including configs wrapped in `defineConfig(...)`.
|
|
10
|
+
|
|
11
|
+
## What this rule reports
|
|
12
|
+
|
|
13
|
+
This rule reports Stylelint config objects that include a top-level `customSyntax` property.
|
|
14
|
+
|
|
15
|
+
## Why this rule exists
|
|
16
|
+
|
|
17
|
+
Top-level `customSyntax` applies globally and can accidentally affect unrelated file types. Syntax selection is safer when scoped to `overrides` entries with explicit `files` matchers.
|
|
18
|
+
|
|
19
|
+
## ❌ Incorrect
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
export default {
|
|
23
|
+
customSyntax: "postcss-scss",
|
|
24
|
+
rules: {},
|
|
25
|
+
};
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## ✅ Correct
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
export default {
|
|
32
|
+
overrides: [
|
|
33
|
+
{
|
|
34
|
+
customSyntax: "postcss-scss",
|
|
35
|
+
files: ["**/*.scss"],
|
|
36
|
+
rules: {},
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
rules: {},
|
|
40
|
+
};
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Behavior and migration notes
|
|
44
|
+
|
|
45
|
+
- This rule removes top-level `customSyntax`.
|
|
46
|
+
- It preserves the rest of the config object.
|
|
47
|
+
- Move syntax declarations into override entries that include explicit file patterns.
|
|
48
|
+
|
|
49
|
+
## ESLint flat config example
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import stylelint2 from "eslint-plugin-stylelint-2";
|
|
53
|
+
|
|
54
|
+
export default [stylelint2.configs.configuration];
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## When not to use it
|
|
58
|
+
|
|
59
|
+
Do not use this rule if your repository intentionally uses one global syntax parser for every linted file.
|
|
60
|
+
|
|
61
|
+
## Package documentation
|
|
62
|
+
|
|
63
|
+
Stylelint package documentation:
|
|
64
|
+
|
|
65
|
+
> **Rule catalog ID:** R014
|
|
66
|
+
|
|
67
|
+
## Further reading
|
|
68
|
+
|
|
69
|
+
- [Stylelint customSyntax](https://stylelint.io/user-guide/configure/#customsyntax)
|
|
70
|
+
- [Stylelint overrides](https://stylelint.io/user-guide/configure/#overrides)
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# disallow-stylelint-default-severity
|
|
2
|
+
|
|
3
|
+
Disallow configuring Stylelint's top-level `defaultSeverity` option inside authored Stylelint config files.
|
|
4
|
+
|
|
5
|
+
## Targeted pattern scope
|
|
6
|
+
|
|
7
|
+
This rule targets Stylelint config modules such as `stylelint.config.ts`, `stylelint.config.mjs`, and `.stylelintrc.js`.
|
|
8
|
+
|
|
9
|
+
It focuses on top-level exported config objects, including configs wrapped in `defineConfig(...)`.
|
|
10
|
+
|
|
11
|
+
## What this rule reports
|
|
12
|
+
|
|
13
|
+
This rule reports Stylelint config objects that include a top-level `defaultSeverity` property.
|
|
14
|
+
|
|
15
|
+
## Why this rule exists
|
|
16
|
+
|
|
17
|
+
`defaultSeverity` applies a global warning/error policy across rules. In an ESLint-first workflow, that global Stylelint severity layer can conflict with the severity contract already defined at the ESLint rule boundary.
|
|
18
|
+
|
|
19
|
+
Keeping severity explicit per Stylelint rule (or enforced at the ESLint config layer) makes review outcomes easier to reason about and avoids hidden global severity drift.
|
|
20
|
+
|
|
21
|
+
## ❌ Incorrect
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
export default {
|
|
25
|
+
defaultSeverity: "warning",
|
|
26
|
+
rules: {},
|
|
27
|
+
};
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## ✅ Correct
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
export default {
|
|
34
|
+
rules: {},
|
|
35
|
+
};
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Behavior and migration notes
|
|
39
|
+
|
|
40
|
+
- This rule removes the top-level `defaultSeverity` property.
|
|
41
|
+
- It preserves the rest of the config object.
|
|
42
|
+
- If you need warning/error policy differences, keep them explicit in rule-level secondary options or the ESLint config that enables this plugin.
|
|
43
|
+
|
|
44
|
+
## Additional examples
|
|
45
|
+
|
|
46
|
+
### ✅ Correct — severity stays local to a rule
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
export default {
|
|
50
|
+
rules: {
|
|
51
|
+
"number-max-precision": [2, { severity: "warning" }],
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## ESLint flat config example
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import stylelint2 from "eslint-plugin-stylelint-2";
|
|
60
|
+
|
|
61
|
+
export default [stylelint2.configs.configuration];
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## When not to use it
|
|
65
|
+
|
|
66
|
+
Do not use this rule if your team intentionally enforces one global Stylelint default severity in committed config and accepts that policy being coupled to shared config files.
|
|
67
|
+
|
|
68
|
+
## Package documentation
|
|
69
|
+
|
|
70
|
+
Stylelint package documentation:
|
|
71
|
+
|
|
72
|
+
> **Rule catalog ID:** R009
|
|
73
|
+
|
|
74
|
+
## Further reading
|
|
75
|
+
|
|
76
|
+
- [Stylelint configuring guide](https://stylelint.io/user-guide/configure/#defaultseverity)
|
|
77
|
+
- [Stylelint severity option](https://stylelint.io/user-guide/configure/#severity)
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# disallow-stylelint-duplicate-extends
|
|
2
|
+
|
|
3
|
+
Disallow duplicate entries in top-level Stylelint `extends` declarations.
|
|
4
|
+
|
|
5
|
+
## Targeted pattern scope
|
|
6
|
+
|
|
7
|
+
This rule targets Stylelint config modules such as `stylelint.config.ts`, `stylelint.config.mjs`, and `.stylelintrc.js`.
|
|
8
|
+
|
|
9
|
+
It focuses on top-level exported config objects, including configs wrapped in `defineConfig(...)`.
|
|
10
|
+
|
|
11
|
+
## What this rule reports
|
|
12
|
+
|
|
13
|
+
Reports duplicate string entries in top-level `extends` arrays.
|
|
14
|
+
|
|
15
|
+
## Why this rule exists
|
|
16
|
+
|
|
17
|
+
Duplicate shared-config layers add noise and can obscure real config intent.
|
|
18
|
+
|
|
19
|
+
## ❌ Incorrect
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
export default {
|
|
23
|
+
extends: ["stylelint-config-standard", "stylelint-config-standard"],
|
|
24
|
+
rules: {},
|
|
25
|
+
};
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## ✅ Correct
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
export default {
|
|
32
|
+
extends: ["stylelint-config-standard"],
|
|
33
|
+
rules: {},
|
|
34
|
+
};
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Behavior and migration notes
|
|
38
|
+
|
|
39
|
+
This rule auto-fixes by keeping the first occurrence of each entry.
|
|
40
|
+
|
|
41
|
+
## ESLint flat config example
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import stylelint2 from "eslint-plugin-stylelint-2";
|
|
45
|
+
|
|
46
|
+
export default [stylelint2.configs.configuration];
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## When not to use it
|
|
50
|
+
|
|
51
|
+
Do not use this rule if your repository intentionally keeps duplicate entries for generated tooling compatibility.
|
|
52
|
+
|
|
53
|
+
## Package documentation
|
|
54
|
+
|
|
55
|
+
Stylelint package documentation:
|
|
56
|
+
|
|
57
|
+
> **Rule catalog ID:** R023
|
|
58
|
+
|
|
59
|
+
## Further reading
|
|
60
|
+
|
|
61
|
+
- [Stylelint extends](https://stylelint.io/user-guide/configure/#extends)
|