@kitschpatrol/stylelint-config 4.7.12 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +6279 -61
- package/dist/index.d.ts +21 -0
- package/dist/index.js +63 -0
- package/init/stylelint.config.js +3 -0
- package/license.txt +1 -1
- package/package.json +30 -22
- package/readme.md +158 -22
- package/init/.stylelintrc.cjs +0 -7
- package/stylelint.config.cjs +0 -43
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Config as StylelintConfig } from 'stylelint';
|
|
2
|
+
declare const sharedStylelintConfig: StylelintConfig;
|
|
3
|
+
/**
|
|
4
|
+
* **\@Kitschpatrol's Shared Stylelint Configuration**
|
|
5
|
+
* @see [@kitschpatrol/stylelint-config](https://github.com/kitschpatrol/shared-config/tree/main/packages/stylelint-config)
|
|
6
|
+
* @see [@kitschpatrol/shared-config](https://github.com/kitschpatrol/shared-config)
|
|
7
|
+
* @example
|
|
8
|
+
* ```js
|
|
9
|
+
* import { stylelintConfig } from '@kitschpatrol/stylelint-config'
|
|
10
|
+
*
|
|
11
|
+
* export default stylelintConfig({
|
|
12
|
+
* ignoreFiles: ['example.html'],
|
|
13
|
+
* rules: {
|
|
14
|
+
* 'alpha-value-notation': 'number',
|
|
15
|
+
* 'selector-class-pattern': null,
|
|
16
|
+
* },
|
|
17
|
+
* })
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function stylelintConfig(config?: StylelintConfig): StylelintConfig;
|
|
21
|
+
export default sharedStylelintConfig;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { propertyGroups } from 'stylelint-config-clean-order';
|
|
2
|
+
// export { commandDefinition } from './command.js'
|
|
3
|
+
const propertiesOrder = propertyGroups.map((properties) => ({
|
|
4
|
+
emptyLineBefore: 'never', // Don't add empty lines between order groups.
|
|
5
|
+
noEmptyLineBetween: true,
|
|
6
|
+
properties,
|
|
7
|
+
}));
|
|
8
|
+
const sharedStylelintConfig = {
|
|
9
|
+
extends: ['stylelint-config-standard', 'stylelint-config-clean-order', 'stylelint-config-html'],
|
|
10
|
+
overrides: [
|
|
11
|
+
{
|
|
12
|
+
// Not unusual to have empty style tags in an Astro template
|
|
13
|
+
files: ['*.astro'],
|
|
14
|
+
rules: {
|
|
15
|
+
'no-empty-source': null,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
rules: {
|
|
20
|
+
'color-hex-length': null,
|
|
21
|
+
'comment-empty-line-before': null,
|
|
22
|
+
'declaration-empty-line-before': null,
|
|
23
|
+
// 'at-rule-empty-line-before': 'never',
|
|
24
|
+
'order/properties-order': [
|
|
25
|
+
propertiesOrder,
|
|
26
|
+
{
|
|
27
|
+
severity: 'error',
|
|
28
|
+
unspecified: 'bottomAlphabetical',
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
'selector-class-pattern': null,
|
|
32
|
+
'selector-pseudo-class-no-unknown': [
|
|
33
|
+
true,
|
|
34
|
+
{
|
|
35
|
+
ignorePseudoClasses: ['global'],
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* **\@Kitschpatrol's Shared Stylelint Configuration**
|
|
42
|
+
* @see [@kitschpatrol/stylelint-config](https://github.com/kitschpatrol/shared-config/tree/main/packages/stylelint-config)
|
|
43
|
+
* @see [@kitschpatrol/shared-config](https://github.com/kitschpatrol/shared-config)
|
|
44
|
+
* @example
|
|
45
|
+
* ```js
|
|
46
|
+
* import { stylelintConfig } from '@kitschpatrol/stylelint-config'
|
|
47
|
+
*
|
|
48
|
+
* export default stylelintConfig({
|
|
49
|
+
* ignoreFiles: ['example.html'],
|
|
50
|
+
* rules: {
|
|
51
|
+
* 'alpha-value-notation': 'number',
|
|
52
|
+
* 'selector-class-pattern': null,
|
|
53
|
+
* },
|
|
54
|
+
* })
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export function stylelintConfig(config) {
|
|
58
|
+
return {
|
|
59
|
+
extends: '@kitschpatrol/stylelint-config',
|
|
60
|
+
...config,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export default sharedStylelintConfig;
|
package/license.txt
CHANGED
package/package.json
CHANGED
|
@@ -1,54 +1,62 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kitschpatrol/stylelint-config",
|
|
3
|
-
"version": "
|
|
4
|
-
"type": "module",
|
|
3
|
+
"version": "5.0.0",
|
|
5
4
|
"description": "Stylelint configuration for @kitschpatrol/shared-config.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"stylelint-config",
|
|
7
|
+
"stylelint",
|
|
8
|
+
"cli",
|
|
9
|
+
"kpi",
|
|
10
|
+
"kpi-stylelint"
|
|
11
|
+
],
|
|
12
|
+
"bugs": "https://github.com/kitschpatrol/shared-config/issues",
|
|
6
13
|
"repository": {
|
|
7
14
|
"type": "git",
|
|
8
15
|
"url": "git+https://github.com/kitschpatrol/shared-config/cli.git",
|
|
9
16
|
"directory": "packages/stylelint-config"
|
|
10
17
|
},
|
|
11
|
-
"
|
|
18
|
+
"license": "MIT",
|
|
12
19
|
"author": {
|
|
13
20
|
"name": "Eric Mika",
|
|
14
21
|
"email": "eric@ericmika.com",
|
|
15
22
|
"url": "https://ericmika.com"
|
|
16
23
|
},
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
|
|
24
|
+
"type": "module",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"import": "./dist/index.js",
|
|
28
|
+
"types": "./dist/index.d.ts"
|
|
29
|
+
}
|
|
21
30
|
},
|
|
31
|
+
"main": "dist/index.js",
|
|
32
|
+
"types": "dist/index.d.ts",
|
|
22
33
|
"bin": {
|
|
23
|
-
"stylelint
|
|
34
|
+
"kpi-stylelint": "bin/cli.js"
|
|
24
35
|
},
|
|
25
|
-
"main": "stylelint.config.cjs",
|
|
26
36
|
"files": [
|
|
27
37
|
"bin/*",
|
|
38
|
+
"dist/*",
|
|
28
39
|
"init/*"
|
|
29
40
|
],
|
|
30
|
-
"keywords": [
|
|
31
|
-
"stylelint-config",
|
|
32
|
-
"stylelint",
|
|
33
|
-
"cli"
|
|
34
|
-
],
|
|
35
|
-
"peerDependencies": {
|
|
36
|
-
"stylelint": "^16.10.0"
|
|
37
|
-
},
|
|
38
41
|
"dependencies": {
|
|
39
42
|
"@pinojs/json-colorizer": "^4.0.0",
|
|
40
43
|
"cosmiconfig": "^9.0.0",
|
|
41
|
-
"execa": "^
|
|
42
|
-
"fs-extra": "^11.
|
|
43
|
-
"stylelint
|
|
44
|
+
"execa": "^9.5.2",
|
|
45
|
+
"fs-extra": "^11.3.0",
|
|
46
|
+
"stylelint": "^16.14.1",
|
|
47
|
+
"stylelint-config-clean-order": "^7.0.0",
|
|
44
48
|
"stylelint-config-html": "^1.1.0",
|
|
45
|
-
"stylelint-config-standard": "^
|
|
49
|
+
"stylelint-config-standard": "^37.0.0"
|
|
50
|
+
},
|
|
51
|
+
"engines": {
|
|
52
|
+
"node": ">=22.0.0",
|
|
53
|
+
"pnpm": ">=10.0.0"
|
|
46
54
|
},
|
|
47
55
|
"publishConfig": {
|
|
48
56
|
"access": "public"
|
|
49
57
|
},
|
|
50
58
|
"scripts": {
|
|
51
|
-
"build": "../../scripts/build.ts
|
|
59
|
+
"build": "tsc && ../../scripts/build.ts",
|
|
52
60
|
"cli": "node ./bin/cli.js"
|
|
53
61
|
}
|
|
54
62
|
}
|
package/readme.md
CHANGED
|
@@ -21,9 +21,17 @@
|
|
|
21
21
|
|
|
22
22
|
## Overview
|
|
23
23
|
|
|
24
|
-
It's a shared [Stylelint](https://stylelint.io) config.
|
|
24
|
+
It's a shared [Stylelint](https://stylelint.io) config, plus a command-line tool `kpi-stylelint` to perform Stylelint-related project initialization, linting, and fixing.
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
<!-- recommendation -->
|
|
27
|
+
|
|
28
|
+
> [!Important]
|
|
29
|
+
>
|
|
30
|
+
> **You can use this package on its own, but it's recommended to use [`@kitschpatrol/shared-config`](https://www.npmjs.com/package/@kitschpatrol/shared-config) instead for a single-dependency and single-package approach to linting and fixing your project.**
|
|
31
|
+
>
|
|
32
|
+
> This package is included as a dependency in [`@kitschpatrol/shared-config`](https://www.npmjs.com/package/@kitschpatrol/shared-config), which also automatically invokes the command line functionality in this package via its `kpi` command
|
|
33
|
+
|
|
34
|
+
<!-- /recommendation -->
|
|
27
35
|
|
|
28
36
|
## Setup
|
|
29
37
|
|
|
@@ -32,7 +40,7 @@ To use just this Stylelint config in isolation:
|
|
|
32
40
|
1. Install the `.npmrc` in your project root. This is required for correct PNPM behavior:
|
|
33
41
|
|
|
34
42
|
```sh
|
|
35
|
-
pnpm dlx @kitschpatrol/repo-config
|
|
43
|
+
pnpm dlx @kitschpatrol/repo-config init
|
|
36
44
|
```
|
|
37
45
|
|
|
38
46
|
2. Add the package:
|
|
@@ -41,12 +49,20 @@ To use just this Stylelint config in isolation:
|
|
|
41
49
|
pnpm add -D @kitschpatrol/stylelint-config
|
|
42
50
|
```
|
|
43
51
|
|
|
44
|
-
3. Add the starter
|
|
52
|
+
3. Add the starter `stylelint.config.js` file to your project root, and add any customizations you'd like:
|
|
45
53
|
|
|
46
54
|
```sh
|
|
47
|
-
pnpm exec stylelint
|
|
55
|
+
pnpm exec kpi-stylelint init
|
|
48
56
|
```
|
|
49
57
|
|
|
58
|
+
## Rules
|
|
59
|
+
|
|
60
|
+
- [stylelint-config-recommended](https://github.com/stylelint/stylelint-config-recommended) _([Rules](https://github.com/stylelint/stylelint-config-recommended/blob/main/index.js))_
|
|
61
|
+
- [stylelint-config-standard](https://github.com/stylelint/stylelint-config-standard) _(Extends the above with [additional rules](https://github.com/stylelint/stylelint-config-standard/blob/main/index.js))_
|
|
62
|
+
- [stylelint-config-clean-order](https://github.com/kutsan/stylelint-config-clean-order)
|
|
63
|
+
- [stylelint-config-html](https://www.npmjs.com/package/stylelint-config-html) _(Parses HTML, XML, Vue, Svelte, Astro, and PHP files)_
|
|
64
|
+
- [Additional customizations](./src/index.ts)
|
|
65
|
+
|
|
50
66
|
## Usage
|
|
51
67
|
|
|
52
68
|
The Stylelint binary should be picked up automatically by VS Code plugins.
|
|
@@ -56,40 +72,160 @@ You can call it directly, or use the script bundled with the config.
|
|
|
56
72
|
Integrate with your `package.json` scripts as you see fit, for example:
|
|
57
73
|
|
|
58
74
|
```json
|
|
59
|
-
|
|
60
|
-
"
|
|
61
|
-
|
|
75
|
+
{
|
|
76
|
+
"scripts": {
|
|
77
|
+
"lint": "kpi-stylelint lint",
|
|
78
|
+
"fix": "kpi-stylelint fix"
|
|
79
|
+
}
|
|
62
80
|
}
|
|
63
81
|
```
|
|
64
82
|
|
|
83
|
+
### Configuration
|
|
84
|
+
|
|
85
|
+
To create a `stylelint.config.js` in your project root:
|
|
86
|
+
|
|
87
|
+
```sh
|
|
88
|
+
pnpm exec kpi-stylelint init
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
(Note that this will delete the `stylelint` property in your `package.json`!)
|
|
92
|
+
|
|
93
|
+
_Or_
|
|
94
|
+
|
|
95
|
+
To create a `stylelint` property in `package.json`:
|
|
96
|
+
|
|
97
|
+
```sh
|
|
98
|
+
pnpm exec kpi-stylelint init --location package
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
(Note that this will delete the `stylelint.config.js` file in your project root!)
|
|
102
|
+
|
|
103
|
+
#### Ignoring files
|
|
104
|
+
|
|
105
|
+
Ignores all files in `.gitignore` by default.
|
|
106
|
+
|
|
107
|
+
Additional tool-specific ignores may be added to the config via the [`ignoreFiles`](https://stylelint.io/user-guide/configure#ignorefiles) key.
|
|
108
|
+
|
|
109
|
+
#### Ignoring code
|
|
110
|
+
|
|
111
|
+
See [the Stylelint documentation](https://stylelint.io/user-guide/ignore-code).
|
|
112
|
+
|
|
113
|
+
Blocks:
|
|
114
|
+
|
|
115
|
+
`/* stylelint-disable */ ... /* stylelint-enable */`
|
|
116
|
+
|
|
117
|
+
Inline:
|
|
118
|
+
|
|
119
|
+
`/* stylelint-disable-line */`
|
|
120
|
+
|
|
121
|
+
Next line:
|
|
122
|
+
|
|
123
|
+
`/* stylelint-disable-next-line`
|
|
124
|
+
|
|
65
125
|
### CLI
|
|
66
126
|
|
|
67
127
|
<!-- cli-help -->
|
|
68
128
|
|
|
69
|
-
#### Command: `stylelint
|
|
129
|
+
#### Command: `kpi-stylelint`
|
|
130
|
+
|
|
131
|
+
Kitschpatrol's Stylelint shared configuration tools.
|
|
70
132
|
|
|
71
|
-
|
|
133
|
+
This section lists top-level commands for `kpi-stylelint`.
|
|
72
134
|
|
|
73
135
|
Usage:
|
|
74
136
|
|
|
75
137
|
```txt
|
|
76
|
-
stylelint
|
|
138
|
+
kpi-stylelint <command>
|
|
77
139
|
```
|
|
78
140
|
|
|
79
|
-
|
|
|
80
|
-
|
|
|
81
|
-
|
|
|
82
|
-
|
|
|
83
|
-
|
|
|
84
|
-
|
|
|
85
|
-
| `--help`<br>`-h` | | Print this help info. |
|
|
86
|
-
| `--version`<br>`-v` | | Print the package version. |
|
|
141
|
+
| Command | Argument | Description |
|
|
142
|
+
| -------------- | ----------- | -------------------------------------------------------------------------------------------------------------------- |
|
|
143
|
+
| `init` | | Initialize by copying starter config files to your project root or to your package.json file. |
|
|
144
|
+
| `lint` | `[files..]` | Lint your project with Stylelint. Matches files below the current working directory by default. |
|
|
145
|
+
| `fix` | `[files..]` | Fix your project with Stylelint. Matches files below the current working directory by default. |
|
|
146
|
+
| `print-config` | `[file]` | Print the effective Stylelint configuration. Package-scoped by default, file-scoped if a file argument is provided.. |
|
|
87
147
|
|
|
88
|
-
|
|
148
|
+
| Option | Description | Type |
|
|
149
|
+
| ------------------- | ------------------- | --------- |
|
|
150
|
+
| `--help`<br>`-h` | Show help | `boolean` |
|
|
151
|
+
| `--version`<br>`-v` | Show version number | `boolean` |
|
|
152
|
+
|
|
153
|
+
_See the sections below for more information on each subcommand._
|
|
89
154
|
|
|
90
|
-
|
|
155
|
+
#### Subcommand: `kpi-stylelint init`
|
|
91
156
|
|
|
92
|
-
|
|
157
|
+
Initialize by copying starter config files to your project root or to your package.json file.
|
|
158
|
+
|
|
159
|
+
Usage:
|
|
160
|
+
|
|
161
|
+
```txt
|
|
162
|
+
kpi-stylelint init
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
| Option | Description | Type | Default |
|
|
166
|
+
| ------------------- | ------------------- | -------------------- | -------- |
|
|
167
|
+
| `--location` | TK | `"file"` `"package"` | `"file"` |
|
|
168
|
+
| `--help`<br>`-h` | Show help | `boolean` | |
|
|
169
|
+
| `--version`<br>`-v` | Show version number | `boolean` | |
|
|
170
|
+
|
|
171
|
+
#### Subcommand: `kpi-stylelint lint`
|
|
172
|
+
|
|
173
|
+
Lint your project with Stylelint. Matches files below the current working directory by default.
|
|
174
|
+
|
|
175
|
+
Usage:
|
|
176
|
+
|
|
177
|
+
```txt
|
|
178
|
+
kpi-stylelint lint [files..]
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
| Positional Argument | Description | Type | Default |
|
|
182
|
+
| ------------------- | ------------------------------ | ------- | ---------------------------------------------------------- |
|
|
183
|
+
| `files` | Files or glob pattern to lint. | `array` | `"**/*.{css,scss,sass,svelte,html,astro,tsx,jsx,php,vue}"` |
|
|
184
|
+
|
|
185
|
+
| Option | Description | Type |
|
|
186
|
+
| ------------------- | ------------------- | --------- |
|
|
187
|
+
| `--help`<br>`-h` | Show help | `boolean` |
|
|
188
|
+
| `--version`<br>`-v` | Show version number | `boolean` |
|
|
189
|
+
|
|
190
|
+
#### Subcommand: `kpi-stylelint fix`
|
|
191
|
+
|
|
192
|
+
Fix your project with Stylelint. Matches files below the current working directory by default.
|
|
193
|
+
|
|
194
|
+
Usage:
|
|
195
|
+
|
|
196
|
+
```txt
|
|
197
|
+
kpi-stylelint fix [files..]
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
| Positional Argument | Description | Type | Default |
|
|
201
|
+
| ------------------- | ----------------------------- | ------- | ---------------------------------------------------------- |
|
|
202
|
+
| `files` | Files or glob pattern to fix. | `array` | `"**/*.{css,scss,sass,svelte,html,astro,tsx,jsx,php,vue}"` |
|
|
203
|
+
|
|
204
|
+
| Option | Description | Type |
|
|
205
|
+
| ------------------- | ------------------- | --------- |
|
|
206
|
+
| `--help`<br>`-h` | Show help | `boolean` |
|
|
207
|
+
| `--version`<br>`-v` | Show version number | `boolean` |
|
|
208
|
+
|
|
209
|
+
#### Subcommand: `kpi-stylelint print-config`
|
|
210
|
+
|
|
211
|
+
Print the effective Stylelint configuration. Package-scoped by default, file-scoped if a file argument is provided..
|
|
212
|
+
|
|
213
|
+
Usage:
|
|
214
|
+
|
|
215
|
+
```txt
|
|
216
|
+
kpi-stylelint print-config [file]
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
| Positional Argument | Description | Type |
|
|
220
|
+
| ------------------- | --------------------------- | -------- |
|
|
221
|
+
| `file` | File or glob pattern to TK. | `string` |
|
|
222
|
+
|
|
223
|
+
| Option | Description | Type |
|
|
224
|
+
| ------------------- | ------------------- | --------- |
|
|
225
|
+
| `--help`<br>`-h` | Show help | `boolean` |
|
|
226
|
+
| `--version`<br>`-v` | Show version number | `boolean` |
|
|
227
|
+
|
|
228
|
+
<!-- /cli-help -->
|
|
93
229
|
|
|
94
230
|
<!-- license -->
|
|
95
231
|
|
package/init/.stylelintrc.cjs
DELETED
package/stylelint.config.cjs
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/* eslint-disable perfectionist/sort-objects */
|
|
2
|
-
/* eslint-disable unicorn/no-null */
|
|
3
|
-
const { propertyGroups } = require('stylelint-config-clean-order')
|
|
4
|
-
|
|
5
|
-
const propertiesOrder = propertyGroups.map((properties) => ({
|
|
6
|
-
emptyLineBefore: 'never', // Don't add empty lines between order groups.
|
|
7
|
-
noEmptyLineBetween: true,
|
|
8
|
-
properties,
|
|
9
|
-
}))
|
|
10
|
-
|
|
11
|
-
/** @type {import("stylelint").Config} */
|
|
12
|
-
module.exports = {
|
|
13
|
-
extends: ['stylelint-config-standard', 'stylelint-config-clean-order', 'stylelint-config-html'],
|
|
14
|
-
rules: {
|
|
15
|
-
'color-hex-length': null,
|
|
16
|
-
'comment-empty-line-before': null,
|
|
17
|
-
'declaration-empty-line-before': null,
|
|
18
|
-
// 'at-rule-empty-line-before': 'never',
|
|
19
|
-
'order/properties-order': [
|
|
20
|
-
propertiesOrder,
|
|
21
|
-
{
|
|
22
|
-
severity: 'error',
|
|
23
|
-
unspecified: 'bottomAlphabetical',
|
|
24
|
-
},
|
|
25
|
-
],
|
|
26
|
-
'selector-class-pattern': null,
|
|
27
|
-
'selector-pseudo-class-no-unknown': [
|
|
28
|
-
true,
|
|
29
|
-
{
|
|
30
|
-
ignorePseudoClasses: ['global'],
|
|
31
|
-
},
|
|
32
|
-
],
|
|
33
|
-
},
|
|
34
|
-
overrides: [
|
|
35
|
-
{
|
|
36
|
-
// Not unusual to have empty style tags in an Astro template
|
|
37
|
-
files: ['*.astro'],
|
|
38
|
-
rules: {
|
|
39
|
-
'no-empty-source': null,
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
}
|