eslint-plugin-stylelint-2 1.0.9 → 1.0.10
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/docs/rules/getting-started.md +9 -122
- package/docs/rules/guides/benchmarks.md +27 -0
- package/docs/rules/guides/config-authoring.md +76 -0
- package/docs/rules/guides/faq.md +55 -0
- package/docs/rules/guides/getting-started.md +89 -0
- package/docs/rules/guides/intro.md +71 -0
- package/docs/rules/guides/stylelint-bridge.md +79 -0
- package/docs/rules/overview.md +9 -91
- package/docs/rules/presets/all.md +11 -1
- package/docs/rules/presets/configs.md +12 -2
- package/docs/rules/presets/configuration.md +2 -14
- package/docs/rules/presets/recommended.md +11 -1
- package/docs/rules/presets/stylelint-only.md +3 -6
- package/package.json +6 -6
|
@@ -1,130 +1,17 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: Getting Started
|
|
3
|
-
description:
|
|
2
|
+
title: Rules Getting Started (Legacy Route)
|
|
3
|
+
description: This legacy route has moved to the Guides getting started page.
|
|
4
|
+
unlisted: true
|
|
4
5
|
---
|
|
5
6
|
|
|
6
|
-
# Getting Started
|
|
7
|
+
# Rules Getting Started (Legacy Route)
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
This page has moved.
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
npm install --save-dev eslint-plugin-stylelint-2 eslint stylelint
|
|
12
|
-
```
|
|
11
|
+
Use the current guide entry:
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
- [Guides → Getting Started](./guides/getting-started.md)
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
import stylelint2 from "eslint-plugin-stylelint-2";
|
|
15
|
+
If you need bridge behavior details after setup, continue with:
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
...stylelint2.configs.recommended,
|
|
21
|
-
];
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## What `recommended` includes
|
|
25
|
-
|
|
26
|
-
`recommended` returns an array of flat config entries, not a single object.
|
|
27
|
-
|
|
28
|
-
It currently adds:
|
|
29
|
-
|
|
30
|
-
1. a CSS-targeted config that enables `stylelint-2/stylelint`
|
|
31
|
-
2. a config-file-targeted config that enables the Stylelint config authoring rules
|
|
32
|
-
|
|
33
|
-
## Stylelint bridge only
|
|
34
|
-
|
|
35
|
-
If you only want the Stylelint bridge for stylesheet files:
|
|
36
|
-
|
|
37
|
-
```ts
|
|
38
|
-
import stylelint2 from "eslint-plugin-stylelint-2";
|
|
39
|
-
|
|
40
|
-
export default [
|
|
41
|
-
stylelint2.configs.stylelintOnly,
|
|
42
|
-
];
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
## Stylelint config files only
|
|
46
|
-
|
|
47
|
-
If you only want the config-authoring rules and no stylesheet bridge:
|
|
48
|
-
|
|
49
|
-
```ts
|
|
50
|
-
import stylelint2 from "eslint-plugin-stylelint-2";
|
|
51
|
-
|
|
52
|
-
export default [
|
|
53
|
-
stylelint2.configs.configuration,
|
|
54
|
-
];
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
Legacy aliases remain supported:
|
|
58
|
-
|
|
59
|
-
- `stylelint2.configs.stylesheets` → `stylelint2.configs.stylelintOnly`
|
|
60
|
-
- `stylelint2.configs.configs` → `stylelint2.configs.configuration`
|
|
61
|
-
|
|
62
|
-
That preset currently enables:
|
|
63
|
-
|
|
64
|
-
- `stylelint-2/disallow-stylelint-allow-empty-input`
|
|
65
|
-
- `stylelint-2/disallow-stylelint-configuration-comment`
|
|
66
|
-
- `stylelint-2/disallow-stylelint-custom-syntax`
|
|
67
|
-
- `stylelint-2/disallow-stylelint-default-severity`
|
|
68
|
-
- `stylelint-2/disallow-stylelint-duplicate-extends`
|
|
69
|
-
- `stylelint-2/disallow-stylelint-duplicate-plugins`
|
|
70
|
-
- `stylelint-2/disallow-stylelint-duplicate-rule-option-values`
|
|
71
|
-
- `stylelint-2/disallow-stylelint-empty-rules-object`
|
|
72
|
-
- `stylelint-2/disallow-stylelint-ignore-disables`
|
|
73
|
-
- `stylelint-2/disallow-stylelint-ignore-files`
|
|
74
|
-
- `stylelint-2/disallow-stylelint-null-rule-config`
|
|
75
|
-
- `stylelint-2/disallow-stylelint-overrides-runtime-options`
|
|
76
|
-
- `stylelint-2/disallow-stylelint-processors`
|
|
77
|
-
- `stylelint-2/disallow-stylelint-relative-extends-paths`
|
|
78
|
-
- `stylelint-2/disallow-stylelint-relative-plugin-paths`
|
|
79
|
-
- `stylelint-2/prefer-stylelint-cache`
|
|
80
|
-
- `stylelint-2/prefer-stylelint-define-config`
|
|
81
|
-
- `stylelint-2/prefer-stylelint-extends-array`
|
|
82
|
-
- `stylelint-2/prefer-stylelint-fix`
|
|
83
|
-
- `stylelint-2/prefer-stylelint-formatter`
|
|
84
|
-
- `stylelint-2/prefer-stylelint-plugins-array`
|
|
85
|
-
- `stylelint-2/prefer-stylelint-report-descriptionless-disables`
|
|
86
|
-
- `stylelint-2/prefer-stylelint-report-invalid-scope-disables`
|
|
87
|
-
- `stylelint-2/prefer-stylelint-report-needless-disables`
|
|
88
|
-
- `stylelint-2/prefer-stylelint-report-unscoped-disables`
|
|
89
|
-
- `stylelint-2/require-stylelint-custom-syntax-in-overrides`
|
|
90
|
-
- `stylelint-2/require-stylelint-config-file-naming-convention`
|
|
91
|
-
- `stylelint-2/require-stylelint-extends-packages-installed`
|
|
92
|
-
- `stylelint-2/require-stylelint-overrides-configuration`
|
|
93
|
-
- `stylelint-2/require-stylelint-overrides-files-array`
|
|
94
|
-
- `stylelint-2/require-stylelint-overrides-files`
|
|
95
|
-
- `stylelint-2/require-stylelint-plugins-packages-installed`
|
|
96
|
-
- `stylelint-2/require-stylelint-report-disables`
|
|
97
|
-
- `stylelint-2/require-stylelint-rules-object`
|
|
98
|
-
- `stylelint-2/sort-stylelint-extends`
|
|
99
|
-
- `stylelint-2/sort-stylelint-plugins`
|
|
100
|
-
- `stylelint-2/sort-stylelint-rule-keys`
|
|
101
|
-
|
|
102
|
-
## Adding Stylelint options
|
|
103
|
-
|
|
104
|
-
Pass rule options when you need a custom syntax or an explicit config file:
|
|
105
|
-
|
|
106
|
-
```ts
|
|
107
|
-
import stylelint2 from "eslint-plugin-stylelint-2";
|
|
108
|
-
|
|
109
|
-
export default [
|
|
110
|
-
{
|
|
111
|
-
...stylelint2.configs.stylelintOnly,
|
|
112
|
-
rules: {
|
|
113
|
-
"stylelint-2/stylelint": [
|
|
114
|
-
"error",
|
|
115
|
-
{
|
|
116
|
-
configFile: "./stylelint.config.mjs",
|
|
117
|
-
customSyntax: "postcss-scss",
|
|
118
|
-
ignoreDisables: true,
|
|
119
|
-
},
|
|
120
|
-
],
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
];
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
## When to use ESLint + Stylelint together
|
|
127
|
-
|
|
128
|
-
Use this plugin when you want ESLint to be the single command that reports and fixes both JavaScript/TypeScript issues and stylesheet issues.
|
|
129
|
-
|
|
130
|
-
If your team already runs Stylelint separately and is happy with that split, this plugin may be unnecessary overhead.
|
|
17
|
+
- [Stylelint Bridge Guide](./guides/stylelint-bridge.md)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Benchmarks
|
|
3
|
+
description: Benchmark strategy for eslint-plugin-stylelint-2.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Benchmarks
|
|
7
|
+
|
|
8
|
+
The benchmark suite in this repository focuses on meaningful real-world workflows instead of toy snippets.
|
|
9
|
+
|
|
10
|
+
## Current scenarios
|
|
11
|
+
|
|
12
|
+
- valid stylesheet corpus
|
|
13
|
+
- invalid stylesheet corpus
|
|
14
|
+
- fix-enabled stylesheet corpus
|
|
15
|
+
- invalid config corpus
|
|
16
|
+
|
|
17
|
+
## Goal
|
|
18
|
+
|
|
19
|
+
The goal is to catch regressions in the Stylelint bridge path and the config-authoring rule path before they become editor-time annoyances.
|
|
20
|
+
|
|
21
|
+
## What is benchmarked today
|
|
22
|
+
|
|
23
|
+
- stylesheet reporting without fixes
|
|
24
|
+
- stylesheet reporting with fixes
|
|
25
|
+
- config-rule evaluation for invalid config files
|
|
26
|
+
|
|
27
|
+
These are the workloads most likely to matter during normal editor and CI usage.
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Config Authoring
|
|
3
|
+
description: Build predictable, maintainable stylelint config files with eslint-plugin-stylelint-2 rule enforcement.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Config Authoring
|
|
7
|
+
|
|
8
|
+
Bridge execution solves "how to run Stylelint from ESLint." Config authoring rules solve "how to keep Stylelint config files maintainable over time."
|
|
9
|
+
|
|
10
|
+
## Why config quality rules matter
|
|
11
|
+
|
|
12
|
+
In larger repositories, stylelint config drift usually appears as:
|
|
13
|
+
|
|
14
|
+
- duplicated `extends` / `plugins`
|
|
15
|
+
- inconsistent array ordering
|
|
16
|
+
- hidden relative path assumptions
|
|
17
|
+
- stale override blocks
|
|
18
|
+
|
|
19
|
+
The config rule set helps keep config files deterministic and review-friendly.
|
|
20
|
+
|
|
21
|
+
## Recommended baseline
|
|
22
|
+
|
|
23
|
+
Start with [`recommended`](../presets/recommended.md), then strengthen incrementally.
|
|
24
|
+
|
|
25
|
+
A practical progression:
|
|
26
|
+
|
|
27
|
+
1. Deduplication and shape rules (`require-*`, `disallow-*` basics)
|
|
28
|
+
2. Sorting rules for stable diffs
|
|
29
|
+
3. Environment-specific hardening (monorepo path/package checks)
|
|
30
|
+
|
|
31
|
+
## Authoring conventions that scale
|
|
32
|
+
|
|
33
|
+
### 1) Keep `extends` and `plugins` explicit
|
|
34
|
+
|
|
35
|
+
- Avoid implicit path behavior
|
|
36
|
+
- Prefer package-based references where possible
|
|
37
|
+
- Enforce package-install checks with dedicated rules
|
|
38
|
+
|
|
39
|
+
### 2) Keep arrays deterministic
|
|
40
|
+
|
|
41
|
+
Use sorting rules to minimize merge churn:
|
|
42
|
+
|
|
43
|
+
- [`sort-stylelint-extends`](../sort-stylelint-extends.md)
|
|
44
|
+
- [`sort-stylelint-plugins`](../sort-stylelint-plugins.md)
|
|
45
|
+
- [`sort-stylelint-rule-keys`](../sort-stylelint-rule-keys.md)
|
|
46
|
+
|
|
47
|
+
### 3) Treat overrides as policy, not exceptions
|
|
48
|
+
|
|
49
|
+
Enforce consistent override structure and file targeting:
|
|
50
|
+
|
|
51
|
+
- [`require-stylelint-overrides-configuration`](../require-stylelint-overrides-configuration.md)
|
|
52
|
+
- [`require-stylelint-overrides-files`](../require-stylelint-overrides-files.md)
|
|
53
|
+
- [`require-stylelint-overrides-files-array`](../require-stylelint-overrides-files-array.md)
|
|
54
|
+
|
|
55
|
+
### 4) Prevent legacy/deprecated patterns
|
|
56
|
+
|
|
57
|
+
Guard against obsolete or risky stylelint config patterns with `disallow-*` rules.
|
|
58
|
+
|
|
59
|
+
## Monorepo tips
|
|
60
|
+
|
|
61
|
+
- Keep `configBasedir` stable when invoking bridge rule options.
|
|
62
|
+
- Avoid relative extends/plugin path assumptions between packages.
|
|
63
|
+
- Validate package dependencies where stylelint config references plugins/presets.
|
|
64
|
+
|
|
65
|
+
## Migration strategy for existing repos
|
|
66
|
+
|
|
67
|
+
1. Enable config rules in warning mode first.
|
|
68
|
+
2. Apply autofixes and sorting.
|
|
69
|
+
3. Resolve remaining hard violations in batches.
|
|
70
|
+
4. Promote to error once baseline debt is cleared.
|
|
71
|
+
|
|
72
|
+
## Related docs
|
|
73
|
+
|
|
74
|
+
- Runtime bridge behavior: [Stylelint Bridge](./stylelint-bridge.md)
|
|
75
|
+
- Initial setup: [Getting Started](./getting-started.md)
|
|
76
|
+
- Full policy sets: [Preset Reference](../presets/index.md)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: FAQ
|
|
3
|
+
description: Answers to common questions about bridge behavior, presets, rollout, and troubleshooting.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# FAQ
|
|
7
|
+
|
|
8
|
+
## Do I still need the Stylelint CLI if I use this plugin?
|
|
9
|
+
|
|
10
|
+
Not necessarily.
|
|
11
|
+
|
|
12
|
+
If your goal is a unified lint pipeline, ESLint + `stylelint2/stylelint` is usually enough.
|
|
13
|
+
Keep a dedicated Stylelint CLI job only if you need separate formatter/output contracts.
|
|
14
|
+
|
|
15
|
+
## Which preset should I start with?
|
|
16
|
+
|
|
17
|
+
- Start with [`stylelintOnly`](../presets/stylelint-only.md) for minimal-risk adoption.
|
|
18
|
+
- Start with [`recommended`](../presets/recommended.md) if you want bridge + config quality enforcement from day one.
|
|
19
|
+
|
|
20
|
+
## Why am I seeing both ESLint and Stylelint errors for similar issues?
|
|
21
|
+
|
|
22
|
+
You may have overlapping policy between ESLint ecosystem rules and bridged Stylelint rules.
|
|
23
|
+
Audit overlap and choose one source of truth for each policy area.
|
|
24
|
+
|
|
25
|
+
## Can I use autofix safely?
|
|
26
|
+
|
|
27
|
+
In most repos, yes—start by running `eslint --fix` in a branch and reviewing the diff.
|
|
28
|
+
Then enforce in CI once results are stable.
|
|
29
|
+
|
|
30
|
+
## How do I lint files that require custom parsers/syntaxes?
|
|
31
|
+
|
|
32
|
+
Configure the [`stylelint` rule](../stylelint.md) with `customSyntax` (and related options) so Stylelint parses those files correctly.
|
|
33
|
+
|
|
34
|
+
## What if some packages in a monorepo resolve config differently?
|
|
35
|
+
|
|
36
|
+
Set `configBasedir` intentionally and avoid fragile relative paths in Stylelint config references.
|
|
37
|
+
Use package-install validation rules to catch missing dependencies early.
|
|
38
|
+
|
|
39
|
+
## Why do config authoring rules matter if my Stylelint config already works?
|
|
40
|
+
|
|
41
|
+
A config can "work" while still being brittle, duplicated, or hard to review.
|
|
42
|
+
Authoring rules reduce long-term churn and make diffs deterministic.
|
|
43
|
+
|
|
44
|
+
## What’s the best migration order for existing repos?
|
|
45
|
+
|
|
46
|
+
1. Enable one preset.
|
|
47
|
+
2. Run autofix.
|
|
48
|
+
3. Resolve high-value violations first.
|
|
49
|
+
4. Promote warnings to errors once baseline is clean.
|
|
50
|
+
|
|
51
|
+
## Where should I go next?
|
|
52
|
+
|
|
53
|
+
- Setup flow: [Getting Started](./getting-started.md)
|
|
54
|
+
- Bridge internals and behavior: [Stylelint Bridge](./stylelint-bridge.md)
|
|
55
|
+
- Config quality conventions: [Config Authoring](./config-authoring.md)
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Getting Started
|
|
3
|
+
description: Install eslint-plugin-stylelint-2, pick the right preset, and roll it out safely in CI/editor workflows.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Getting Started
|
|
7
|
+
|
|
8
|
+
This guide gets you from zero to a production-safe baseline quickly.
|
|
9
|
+
|
|
10
|
+
## Prerequisites
|
|
11
|
+
|
|
12
|
+
- ESLint with Flat Config
|
|
13
|
+
- Stylelint installed in the same project
|
|
14
|
+
- A stylelint config file (for example `stylelint.config.mjs`)
|
|
15
|
+
|
|
16
|
+
## Step 1: Install dependencies
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install --save-dev eslint-plugin-stylelint-2 stylelint
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Step 2: Start with one preset
|
|
23
|
+
|
|
24
|
+
Pick one adoption mode:
|
|
25
|
+
|
|
26
|
+
- **Bridge only** (just run Stylelint from ESLint): [`stylelintOnly`](../presets/stylelint-only.md)
|
|
27
|
+
- **Bridge + config quality** (recommended for teams): [`recommended`](../presets/recommended.md)
|
|
28
|
+
|
|
29
|
+
Example `eslint.config.mjs`:
|
|
30
|
+
|
|
31
|
+
```js
|
|
32
|
+
import stylelint2 from "eslint-plugin-stylelint-2";
|
|
33
|
+
|
|
34
|
+
export default [
|
|
35
|
+
stylelint2.configs.recommended,
|
|
36
|
+
{
|
|
37
|
+
rules: {
|
|
38
|
+
// Optional: tune bridge behavior here.
|
|
39
|
+
"stylelint2/stylelint": "error",
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Step 3: Run lint once and apply fixes
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npx eslint . --fix
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Review the PR diff and categorize findings:
|
|
52
|
+
|
|
53
|
+
1. **Safe autofixes** (accept immediately)
|
|
54
|
+
2. **Configuration cleanups** (plan staged rollout)
|
|
55
|
+
3. **Actual style violations** (fix or suppress with rationale)
|
|
56
|
+
|
|
57
|
+
## Step 4: Configure the bridge rule intentionally
|
|
58
|
+
|
|
59
|
+
If your project needs custom syntax or special file matching, tune the [`stylelint` rule](../stylelint.md).
|
|
60
|
+
|
|
61
|
+
Typical options include:
|
|
62
|
+
|
|
63
|
+
- `customSyntax`
|
|
64
|
+
- `configFile`
|
|
65
|
+
- `configBasedir`
|
|
66
|
+
- `quiet`
|
|
67
|
+
- `allowEmptyInput`
|
|
68
|
+
|
|
69
|
+
## Step 5: Roll out in phases
|
|
70
|
+
|
|
71
|
+
Recommended rollout model:
|
|
72
|
+
|
|
73
|
+
1. Enable preset + run in CI as warning-only (short period)
|
|
74
|
+
2. Resolve baseline issues
|
|
75
|
+
3. Switch to error-level enforcement
|
|
76
|
+
4. Add stricter config-authoring rules over time
|
|
77
|
+
|
|
78
|
+
## Common rollout mistakes
|
|
79
|
+
|
|
80
|
+
- **Enabling `all` immediately**: high noise and slower adoption
|
|
81
|
+
- **Mixing Stylelint CLI and ESLint bridge outputs in the same CI gate** without clear ownership
|
|
82
|
+
- **Skipping autofix pass before triage**
|
|
83
|
+
|
|
84
|
+
## Where to go next
|
|
85
|
+
|
|
86
|
+
- Architecture and behavior: [Stylelint Bridge](./stylelint-bridge.md)
|
|
87
|
+
- Team standards and config conventions: [Config Authoring](./config-authoring.md)
|
|
88
|
+
- Preset details: [Preset Reference](../presets/index.md)
|
|
89
|
+
- Common troubleshooting: [FAQ](./faq.md)
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Overview
|
|
3
|
+
description: What eslint-plugin-stylelint-2 does, how the rules docs are organized, and where to start for your use case.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Overview
|
|
7
|
+
|
|
8
|
+
`eslint-plugin-stylelint-2` is built for teams that want Stylelint and ESLint to cooperate cleanly.
|
|
9
|
+
|
|
10
|
+
1. **Bridge Stylelint into ESLint** so style diagnostics and autofixes can flow through your existing ESLint pipeline.
|
|
11
|
+
2. **Enforce maintainable Stylelint config authoring** so your Stylelint configuration stays predictable, reviewable, and automation-friendly.
|
|
12
|
+
|
|
13
|
+
If you only care about bridge behavior, start with:
|
|
14
|
+
|
|
15
|
+
- [`stylelint` rule](../stylelint.md)
|
|
16
|
+
- [`stylelintOnly` preset](../presets/stylelint-only.md)
|
|
17
|
+
|
|
18
|
+
If you also want strict configuration hygiene, start with:
|
|
19
|
+
|
|
20
|
+
- [`recommended` preset](../presets/recommended.md)
|
|
21
|
+
- then progressively adopt stricter config-focused rules from the main [rule catalog](../overview.md)
|
|
22
|
+
|
|
23
|
+
## How this rules documentation is organized
|
|
24
|
+
|
|
25
|
+
The Rules docs section is intentionally split by decision-making flow:
|
|
26
|
+
|
|
27
|
+
1. **Guides** (you are here) for adoption strategy and practical setup.
|
|
28
|
+
2. **Presets** for curated rule sets ([reference](../presets/index.md)).
|
|
29
|
+
3. **Rule catalog** for per-rule details and examples ([catalog](../overview.md)).
|
|
30
|
+
|
|
31
|
+
## Pick a path
|
|
32
|
+
|
|
33
|
+
### Path A — "Just run Stylelint from ESLint"
|
|
34
|
+
|
|
35
|
+
Use this if your main goal is unified lint execution in CI/editor:
|
|
36
|
+
|
|
37
|
+
1. Follow [Getting Started](./getting-started.md).
|
|
38
|
+
2. Enable [`stylelintOnly`](../presets/stylelint-only.md).
|
|
39
|
+
3. Tune the [`stylelint` rule options](../stylelint.md) if needed.
|
|
40
|
+
|
|
41
|
+
### Path B — "Also standardize config quality"
|
|
42
|
+
|
|
43
|
+
Use this if you want consistent stylelint config shape across repos:
|
|
44
|
+
|
|
45
|
+
1. Start with [`recommended`](../presets/recommended.md).
|
|
46
|
+
2. Review [Config Authoring](./config-authoring.md).
|
|
47
|
+
3. Tighten with additional rule-level policies from [Rule Catalog](../overview.md).
|
|
48
|
+
|
|
49
|
+
### Path C — "Need details before enabling"
|
|
50
|
+
|
|
51
|
+
If you are evaluating behavior or migration risk:
|
|
52
|
+
|
|
53
|
+
- Read [Stylelint Bridge](./stylelint-bridge.md).
|
|
54
|
+
- Skim [FAQ](./faq.md).
|
|
55
|
+
- Validate on a small target package first.
|
|
56
|
+
|
|
57
|
+
## Quick map
|
|
58
|
+
|
|
59
|
+
- [Getting Started](./getting-started.md)
|
|
60
|
+
- [Stylelint Bridge](./stylelint-bridge.md)
|
|
61
|
+
- [Config Authoring](./config-authoring.md)
|
|
62
|
+
- [FAQ](./faq.md)
|
|
63
|
+
- [Presets](../presets/index.md)
|
|
64
|
+
- [Rule Catalog](../overview.md)
|
|
65
|
+
|
|
66
|
+
## Recommended first steps (practical)
|
|
67
|
+
|
|
68
|
+
1. Enable one preset (`stylelintOnly` or `recommended`) and run lint once.
|
|
69
|
+
2. Apply autofixes and inspect diff quality in a PR.
|
|
70
|
+
3. Add config policy rules gradually (not all at once) to reduce noisy rollouts.
|
|
71
|
+
4. Lock in conventions via CI and editor integration.
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Stylelint Bridge
|
|
3
|
+
description: Understand how eslint-plugin-stylelint-2 executes Stylelint through ESLint and what that means for diagnostics, fixes, and CI.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Stylelint Bridge
|
|
7
|
+
|
|
8
|
+
The bridge is powered by the [`stylelint` rule](../stylelint.md). It runs Stylelint during ESLint execution and reports results as ESLint diagnostics.
|
|
9
|
+
|
|
10
|
+
## What the bridge gives you
|
|
11
|
+
|
|
12
|
+
- A single lint entrypoint (`eslint`) for JS/TS + style quality
|
|
13
|
+
- One diagnostics stream in editors and CI
|
|
14
|
+
- Unified autofix flow (`eslint --fix`) where safe
|
|
15
|
+
|
|
16
|
+
## How execution works
|
|
17
|
+
|
|
18
|
+
At a high level:
|
|
19
|
+
|
|
20
|
+
1. ESLint visits a supported file.
|
|
21
|
+
2. `stylelint2/stylelint` invokes Stylelint with your configured options.
|
|
22
|
+
3. Stylelint results are mapped to ESLint reports.
|
|
23
|
+
4. Autofixable issues are offered through ESLint fixers.
|
|
24
|
+
|
|
25
|
+
## What gets reported
|
|
26
|
+
|
|
27
|
+
The bridge can surface:
|
|
28
|
+
|
|
29
|
+
- Stylelint rule violations
|
|
30
|
+
- Stylelint parsing failures
|
|
31
|
+
- Invalid/unsupported Stylelint configuration details
|
|
32
|
+
- Deprecation and migration warnings (depending on Stylelint behavior)
|
|
33
|
+
|
|
34
|
+
## Fixing behavior
|
|
35
|
+
|
|
36
|
+
Use standard ESLint workflows:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npx eslint . --fix
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Practical advice:
|
|
43
|
+
|
|
44
|
+
- Prefer `--fix` first, then triage leftovers.
|
|
45
|
+
- Treat non-fixable findings as policy debt, not random noise.
|
|
46
|
+
- Keep bridge options explicit so behavior is deterministic across CI/local environments.
|
|
47
|
+
|
|
48
|
+
## Option tuning checklist
|
|
49
|
+
|
|
50
|
+
If behavior looks inconsistent, verify:
|
|
51
|
+
|
|
52
|
+
- `configFile` points to the intended Stylelint config
|
|
53
|
+
- `configBasedir` is stable in monorepos
|
|
54
|
+
- `customSyntax` is set for non-standard syntaxes
|
|
55
|
+
- `allowEmptyInput` and `quiet` match your expectations
|
|
56
|
+
|
|
57
|
+
See full option docs in [`stylelint` rule reference](../stylelint.md).
|
|
58
|
+
|
|
59
|
+
## Performance tips
|
|
60
|
+
|
|
61
|
+
- Scope lint targets intentionally (do not lint the whole repo blindly in every job).
|
|
62
|
+
- Cache ESLint in CI where possible.
|
|
63
|
+
- Start with [`stylelintOnly`](../presets/stylelint-only.md) if you need low-friction adoption.
|
|
64
|
+
- Add config-authoring rules after baseline bridge stability.
|
|
65
|
+
|
|
66
|
+
## When to keep Stylelint CLI separately
|
|
67
|
+
|
|
68
|
+
You might still keep a dedicated Stylelint CLI job when:
|
|
69
|
+
|
|
70
|
+
- You require Stylelint-specific formatter output in a separate pipeline stage.
|
|
71
|
+
- You need parity with existing non-ESLint tooling contracts.
|
|
72
|
+
|
|
73
|
+
If you do this, avoid duplicated failing signals in PR checks (assign one owner per policy area).
|
|
74
|
+
|
|
75
|
+
## Related guides
|
|
76
|
+
|
|
77
|
+
- Setup path: [Getting Started](./getting-started.md)
|
|
78
|
+
- Config quality standards: [Config Authoring](./config-authoring.md)
|
|
79
|
+
- Troubleshooting edge cases: [FAQ](./faq.md)
|
package/docs/rules/overview.md
CHANGED
|
@@ -1,99 +1,17 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: Overview
|
|
3
|
-
description:
|
|
2
|
+
title: Rules Overview (Legacy Route)
|
|
3
|
+
description: This legacy route has moved to the Guides overview page.
|
|
4
|
+
unlisted: true
|
|
4
5
|
---
|
|
5
6
|
|
|
6
|
-
#
|
|
7
|
+
# Rules Overview (Legacy Route)
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
This page has moved.
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
Use the current guide entry:
|
|
11
12
|
|
|
12
|
-
-
|
|
13
|
-
- disallow execution-only Stylelint config options that belong in the runner, not the shared config object
|
|
14
|
-
- disallow shared-config severity and file-ignore options that hide lint-policy changes globally
|
|
15
|
-
- standardize modern `stylelint-define-config` usage in Stylelint config modules
|
|
16
|
-
- require Stylelint config files to report disable comments that lack a reason
|
|
17
|
-
- require the full family of Stylelint disable-comment reporting safeguards in config files
|
|
13
|
+
- [Guides → Overview](./guides/intro.md)
|
|
18
14
|
|
|
19
|
-
|
|
15
|
+
For the full rules list, use:
|
|
20
16
|
|
|
21
|
-
|
|
22
|
-
npm install --save-dev eslint-plugin-stylelint-2 eslint stylelint
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## Quick start
|
|
26
|
-
|
|
27
|
-
```ts
|
|
28
|
-
import stylelint2 from "eslint-plugin-stylelint-2";
|
|
29
|
-
|
|
30
|
-
export default [
|
|
31
|
-
...stylelint2.configs.recommended,
|
|
32
|
-
];
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
`recommended` expands to two file-scoped flat config entries:
|
|
36
|
-
|
|
37
|
-
- one for CSS files using ESLint's `css/css` language
|
|
38
|
-
- one for Stylelint config files such as `stylelint.config.ts`
|
|
39
|
-
|
|
40
|
-
## Included presets
|
|
41
|
-
|
|
42
|
-
| Preset | Purpose |
|
|
43
|
-
| ----------------------------------------------------------------- | ------------------------------------------------------------- |
|
|
44
|
-
| [`stylelint2.configs.recommended`](./presets/recommended.md) | Stylesheet linting plus Stylelint config authoring guidance |
|
|
45
|
-
| [`stylelint2.configs.stylelintOnly`](./presets/stylelint-only.md) | Only run the Stylelint bridge workflow for stylesheet files |
|
|
46
|
-
| [`stylelint2.configs.configuration`](./presets/configuration.md) | Only lint Stylelint config modules, with no stylesheet bridge |
|
|
47
|
-
| [`stylelint2.configs.all`](./presets/all.md) | Enable every preset entry currently shipped by this plugin |
|
|
48
|
-
|
|
49
|
-
Legacy aliases remain supported:
|
|
50
|
-
|
|
51
|
-
- `stylelint2.configs.stylesheets` → `stylelint2.configs.stylelintOnly`
|
|
52
|
-
- `stylelint2.configs.configs` → `stylelint2.configs.configuration`
|
|
53
|
-
|
|
54
|
-
## Included rules
|
|
55
|
-
|
|
56
|
-
- [`stylelint`](./stylelint.md)
|
|
57
|
-
- [`disallow-stylelint-allow-empty-input`](./disallow-stylelint-allow-empty-input.md)
|
|
58
|
-
- [`disallow-stylelint-configuration-comment`](./disallow-stylelint-configuration-comment.md)
|
|
59
|
-
- [`disallow-stylelint-custom-syntax`](./disallow-stylelint-custom-syntax.md)
|
|
60
|
-
- [`disallow-stylelint-default-severity`](./disallow-stylelint-default-severity.md)
|
|
61
|
-
- [`disallow-stylelint-duplicate-extends`](./disallow-stylelint-duplicate-extends.md)
|
|
62
|
-
- [`disallow-stylelint-duplicate-plugins`](./disallow-stylelint-duplicate-plugins.md)
|
|
63
|
-
- [`disallow-stylelint-duplicate-rule-option-values`](./disallow-stylelint-duplicate-rule-option-values.md)
|
|
64
|
-
- [`disallow-stylelint-empty-rules-object`](./disallow-stylelint-empty-rules-object.md)
|
|
65
|
-
- [`disallow-stylelint-ignore-disables`](./disallow-stylelint-ignore-disables.md)
|
|
66
|
-
- [`disallow-stylelint-ignore-files`](./disallow-stylelint-ignore-files.md)
|
|
67
|
-
- [`disallow-stylelint-null-rule-config`](./disallow-stylelint-null-rule-config.md)
|
|
68
|
-
- [`disallow-stylelint-overrides-runtime-options`](./disallow-stylelint-overrides-runtime-options.md)
|
|
69
|
-
- [`disallow-stylelint-processors`](./disallow-stylelint-processors.md)
|
|
70
|
-
- [`disallow-stylelint-relative-extends-paths`](./disallow-stylelint-relative-extends-paths.md)
|
|
71
|
-
- [`disallow-stylelint-relative-plugin-paths`](./disallow-stylelint-relative-plugin-paths.md)
|
|
72
|
-
- [`prefer-stylelint-cache`](./prefer-stylelint-cache.md)
|
|
73
|
-
- [`prefer-stylelint-define-config`](./prefer-stylelint-define-config.md)
|
|
74
|
-
- [`prefer-stylelint-extends-array`](./prefer-stylelint-extends-array.md)
|
|
75
|
-
- [`prefer-stylelint-fix`](./prefer-stylelint-fix.md)
|
|
76
|
-
- [`prefer-stylelint-formatter`](./prefer-stylelint-formatter.md)
|
|
77
|
-
- [`prefer-stylelint-plugins-array`](./prefer-stylelint-plugins-array.md)
|
|
78
|
-
- [`prefer-stylelint-report-descriptionless-disables`](./prefer-stylelint-report-descriptionless-disables.md)
|
|
79
|
-
- [`prefer-stylelint-report-invalid-scope-disables`](./prefer-stylelint-report-invalid-scope-disables.md)
|
|
80
|
-
- [`prefer-stylelint-report-needless-disables`](./prefer-stylelint-report-needless-disables.md)
|
|
81
|
-
- [`prefer-stylelint-report-unscoped-disables`](./prefer-stylelint-report-unscoped-disables.md)
|
|
82
|
-
- [`require-stylelint-custom-syntax-in-overrides`](./require-stylelint-custom-syntax-in-overrides.md)
|
|
83
|
-
- [`require-stylelint-config-file-naming-convention`](./require-stylelint-config-file-naming-convention.md)
|
|
84
|
-
- [`require-stylelint-extends-packages-installed`](./require-stylelint-extends-packages-installed.md)
|
|
85
|
-
- [`require-stylelint-overrides-configuration`](./require-stylelint-overrides-configuration.md)
|
|
86
|
-
- [`require-stylelint-overrides-files-array`](./require-stylelint-overrides-files-array.md)
|
|
87
|
-
- [`require-stylelint-overrides-files`](./require-stylelint-overrides-files.md)
|
|
88
|
-
- [`require-stylelint-plugins-packages-installed`](./require-stylelint-plugins-packages-installed.md)
|
|
89
|
-
- [`require-stylelint-report-disables`](./require-stylelint-report-disables.md)
|
|
90
|
-
- [`require-stylelint-rules-object`](./require-stylelint-rules-object.md)
|
|
91
|
-
- [`sort-stylelint-extends`](./sort-stylelint-extends.md)
|
|
92
|
-
- [`sort-stylelint-plugins`](./sort-stylelint-plugins.md)
|
|
93
|
-
- [`sort-stylelint-rule-keys`](./sort-stylelint-rule-keys.md)
|
|
94
|
-
|
|
95
|
-
## Next steps
|
|
96
|
-
|
|
97
|
-
- Read [Getting Started](./getting-started.md) for copy-paste setup examples.
|
|
98
|
-
- Review [Presets](./presets/index.md) to pick the right rollout path.
|
|
99
|
-
- Open each rule page before enabling stricter adoption in a larger codebase.
|
|
17
|
+
- [Rule Catalog](./stylelint.md)
|
|
@@ -12,6 +12,16 @@ export default [
|
|
|
12
12
|
];
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
+
## What this preset includes
|
|
16
|
+
|
|
17
|
+
- The Stylelint bridge rule (`stylelint`)
|
|
18
|
+
- Configuration-authoring policy rules
|
|
19
|
+
- Opinionated operational policy rules (cache/formatter/fix/default-severity/reporting preferences)
|
|
20
|
+
|
|
21
|
+
## What this preset does not include
|
|
22
|
+
|
|
23
|
+
- Nothing from this plugin is excluded; this is the broadest preset.
|
|
24
|
+
|
|
15
25
|
## Related preset docs
|
|
16
26
|
|
|
17
27
|
- [Presets overview](./index.md)
|
|
@@ -19,7 +29,7 @@ export default [
|
|
|
19
29
|
- [Stylelint-only preset](./stylelint-only.md)
|
|
20
30
|
- [Configuration-only preset](./configuration.md)
|
|
21
31
|
|
|
22
|
-
##
|
|
32
|
+
## Rules in this preset
|
|
23
33
|
|
|
24
34
|
For the exhaustive generated rule matrix, see [Presets overview](./index.md).
|
|
25
35
|
|
|
@@ -16,12 +16,22 @@ export default [
|
|
|
16
16
|
];
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
##
|
|
19
|
+
## What this preset includes
|
|
20
|
+
|
|
21
|
+
- Legacy alias export for this plugin's preset surface (`stylelint2.configs.configs`)
|
|
22
|
+
- Same active rule set as [`recommended`](./recommended.md)
|
|
23
|
+
|
|
24
|
+
## What this preset does not include
|
|
25
|
+
|
|
26
|
+
- Additional rules beyond what `recommended` already enables
|
|
27
|
+
- Any behavior differences from `recommended` (it is an alias)
|
|
28
|
+
|
|
29
|
+
## Related preset docs
|
|
20
30
|
|
|
21
31
|
- [Configuration-only preset](./configuration.md)
|
|
22
32
|
- [Presets overview](./index.md)
|
|
23
33
|
|
|
24
|
-
##
|
|
34
|
+
## Rules in this preset
|
|
25
35
|
|
|
26
36
|
For the exhaustive generated rule matrix, see [Configuration-only preset](./configuration.md) and [Presets overview](./index.md).
|
|
27
37
|
|
|
@@ -18,19 +18,7 @@ export default [
|
|
|
18
18
|
|
|
19
19
|
## What this preset includes
|
|
20
20
|
|
|
21
|
-
-
|
|
22
|
-
- `stylelint-2/disallow-stylelint-default-severity`
|
|
23
|
-
- `stylelint-2/prefer-stylelint-fix`
|
|
24
|
-
- `stylelint-2/prefer-stylelint-formatter`
|
|
25
|
-
- `stylelint-2/disallow-stylelint-ignore-disables`
|
|
26
|
-
- `stylelint-2/disallow-stylelint-ignore-files`
|
|
27
|
-
- `stylelint-2/prefer-stylelint-define-config`
|
|
28
|
-
- `stylelint-2/prefer-stylelint-report-descriptionless-disables`
|
|
29
|
-
- `stylelint-2/prefer-stylelint-report-invalid-scope-disables`
|
|
30
|
-
- `stylelint-2/prefer-stylelint-report-needless-disables`
|
|
31
|
-
- `stylelint-2/prefer-stylelint-report-unscoped-disables`
|
|
32
|
-
- `stylelint-2/require-stylelint-overrides-configuration`
|
|
33
|
-
- `stylelint-2/require-stylelint-overrides-files-array`
|
|
21
|
+
Configuration-focused policy rules only. See the canonical rules table below for the exact preset contents.
|
|
34
22
|
|
|
35
23
|
## What this preset does not include
|
|
36
24
|
|
|
@@ -45,7 +33,7 @@ export default [
|
|
|
45
33
|
- [Stylelint-only preset](./stylelint-only.md)
|
|
46
34
|
- [All preset](./all.md)
|
|
47
35
|
|
|
48
|
-
##
|
|
36
|
+
## Rules in this preset
|
|
49
37
|
|
|
50
38
|
For the exhaustive generated rule matrix, see [Presets overview](./index.md).
|
|
51
39
|
|
|
@@ -19,6 +19,16 @@ export default [
|
|
|
19
19
|
];
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
+
## What this preset includes
|
|
23
|
+
|
|
24
|
+
- The Stylelint bridge rule (`stylelint`)
|
|
25
|
+
- High-signal configuration policy rules for common production usage
|
|
26
|
+
|
|
27
|
+
## What this preset does not include
|
|
28
|
+
|
|
29
|
+
- The full strict policy surface from [`all`](./all.md)
|
|
30
|
+
- Configuration-only mode semantics from [`configuration`](./configuration.md)
|
|
31
|
+
|
|
22
32
|
## Related preset docs
|
|
23
33
|
|
|
24
34
|
- [Presets overview](./index.md)
|
|
@@ -26,7 +36,7 @@ export default [
|
|
|
26
36
|
- [Configuration-only preset](./configuration.md)
|
|
27
37
|
- [All preset](./all.md)
|
|
28
38
|
|
|
29
|
-
##
|
|
39
|
+
## Rules in this preset
|
|
30
40
|
|
|
31
41
|
For the exhaustive generated rule matrix, see [Presets overview](./index.md).
|
|
32
42
|
|
|
@@ -18,15 +18,12 @@ export default [
|
|
|
18
18
|
|
|
19
19
|
## What this preset includes
|
|
20
20
|
|
|
21
|
-
- `stylelint-2/stylelint
|
|
22
|
-
- stylesheet files only (`**/*.css`)
|
|
23
|
-
- Stylelint edit info surfaced through `eslint --fix` when available
|
|
21
|
+
- The bridge rule only: [`stylelint`](https://nick2bad4u.github.io/eslint-plugin-stylelint-2/docs/rules/stylelint)
|
|
24
22
|
|
|
25
23
|
## What this preset does not include
|
|
26
24
|
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
- No disable-comment reporting checks for config files
|
|
25
|
+
- Configuration-authoring policy rules (`require-*`, `disallow-*`, `sort-*`)
|
|
26
|
+
- Operational policy rules like `prefer-stylelint-cache` and reporting preferences
|
|
30
27
|
|
|
31
28
|
## Related preset docs
|
|
32
29
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://www.schemastore.org/package.json",
|
|
3
3
|
"name": "eslint-plugin-stylelint-2",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.10",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "ESLint plugin that runs Stylelint through ESLint and adds Stylelint-specific authoring rules.",
|
|
7
7
|
"keywords": [
|
|
@@ -231,8 +231,8 @@
|
|
|
231
231
|
"@eslint/js": "^10.0.1",
|
|
232
232
|
"@eslint/json": "^1.2.0",
|
|
233
233
|
"@eslint/markdown": "^8.0.1",
|
|
234
|
-
"@html-eslint/eslint-plugin": "^0.
|
|
235
|
-
"@html-eslint/parser": "^0.
|
|
234
|
+
"@html-eslint/eslint-plugin": "^0.59.0",
|
|
235
|
+
"@html-eslint/parser": "^0.59.0",
|
|
236
236
|
"@microsoft/eslint-plugin-sdl": "^1.1.0",
|
|
237
237
|
"@microsoft/tsdoc-config": "^0.18.1",
|
|
238
238
|
"@secretlint/secretlint-rule-anthropic": "^11.5.0",
|
|
@@ -302,7 +302,7 @@
|
|
|
302
302
|
"eslint-plugin-etc": "^2.0.3",
|
|
303
303
|
"eslint-plugin-etc-misc": "^1.0.5",
|
|
304
304
|
"eslint-plugin-file-progress-2": "^3.4.4",
|
|
305
|
-
"eslint-plugin-github-actions-2": "^1.0.
|
|
305
|
+
"eslint-plugin-github-actions-2": "^1.0.6",
|
|
306
306
|
"eslint-plugin-html": "^8.1.4",
|
|
307
307
|
"eslint-plugin-immutable-2": "^1.0.7",
|
|
308
308
|
"eslint-plugin-import-x": "^4.16.2",
|
|
@@ -335,7 +335,7 @@
|
|
|
335
335
|
"eslint-plugin-testing-library": "^7.16.2",
|
|
336
336
|
"eslint-plugin-toml": "^1.3.1",
|
|
337
337
|
"eslint-plugin-tsdoc": "^0.5.2",
|
|
338
|
-
"eslint-plugin-tsdoc-require-2": "^1.0.
|
|
338
|
+
"eslint-plugin-tsdoc-require-2": "^1.0.9",
|
|
339
339
|
"eslint-plugin-undefined-css-classes": "^0.1.5",
|
|
340
340
|
"eslint-plugin-unicorn": "^64.0.0",
|
|
341
341
|
"eslint-plugin-unused-imports": "^4.4.1",
|
|
@@ -355,7 +355,7 @@
|
|
|
355
355
|
"madge": "^8.0.0",
|
|
356
356
|
"markdown-link-check": "^3.14.2",
|
|
357
357
|
"npm-check-updates": "^20.0.0",
|
|
358
|
-
"npm-package-json-lint": "^10.
|
|
358
|
+
"npm-package-json-lint": "^10.2.0",
|
|
359
359
|
"picocolors": "^1.1.1",
|
|
360
360
|
"postcss": "^8.5.8",
|
|
361
361
|
"postcss-assets": "^6.0.0",
|