@haltcase/style 6.1.0 → 6.2.0-canary.2
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/package.json +19 -2
- package/readme.md +42 -0
- package/stylelint/_base.js +47 -0
- package/stylelint/index.js +21 -0
- package/stylelint/modules.js +25 -0
- package/stylelint/standard.js +7 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haltcase/style",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.0-canary.2",
|
|
4
4
|
"description": "haltcase's web ecosystem style guide & configurations",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -30,6 +30,9 @@
|
|
|
30
30
|
"./eslint/react": "./eslint/react.js",
|
|
31
31
|
"./eslint/typescript": "./eslint/typescript.js",
|
|
32
32
|
"./prettier": "./prettier/index.js",
|
|
33
|
+
"./stylelint": "./stylelint/index.js",
|
|
34
|
+
"./stylelint/modules": "./stylelint/modules.js",
|
|
35
|
+
"./stylelint/standard": "./stylelint/standard.js",
|
|
33
36
|
"./typescript/base": "./typescript/tsconfig.base.json",
|
|
34
37
|
"./typescript/bundler": "./typescript/tsconfig.bundler.json",
|
|
35
38
|
"./typescript/next": "./typescript/tsconfig.next.json",
|
|
@@ -41,6 +44,7 @@
|
|
|
41
44
|
"files": [
|
|
42
45
|
"eslint",
|
|
43
46
|
"prettier",
|
|
47
|
+
"stylelint",
|
|
44
48
|
"typescript",
|
|
45
49
|
"astro",
|
|
46
50
|
"next"
|
|
@@ -57,6 +61,9 @@
|
|
|
57
61
|
"*.{js,jsx,ts,tsx,css,yml,yaml}": "pnpm prettier --write"
|
|
58
62
|
},
|
|
59
63
|
"prettier": "./prettier",
|
|
64
|
+
"stylelint": {
|
|
65
|
+
"extends": "./stylelint/index.js"
|
|
66
|
+
},
|
|
60
67
|
"dependencies": {
|
|
61
68
|
"@babel/core": "^7.23.2",
|
|
62
69
|
"@babel/eslint-parser": "^7.22.15",
|
|
@@ -77,8 +84,13 @@
|
|
|
77
84
|
"eslint-plugin-testing-library": "^6.1.0",
|
|
78
85
|
"eslint-plugin-tsdoc": "^0.2.17",
|
|
79
86
|
"eslint-plugin-unicorn": "^48.0.1",
|
|
87
|
+
"postcss-html": "^1.6.0",
|
|
80
88
|
"prettier-plugin-astro": "^0.12.1",
|
|
81
|
-
"prettier-plugin-packagejson": "^2.4.6"
|
|
89
|
+
"prettier-plugin-packagejson": "^2.4.6",
|
|
90
|
+
"stylelint-config-clean-order": "^5.4.1",
|
|
91
|
+
"stylelint-config-html": "^1.1.0",
|
|
92
|
+
"stylelint-config-standard": "^36.0.0",
|
|
93
|
+
"stylelint-define-config": "^1.2.0"
|
|
82
94
|
},
|
|
83
95
|
"devDependencies": {
|
|
84
96
|
"@actions/core": "^1.10.1",
|
|
@@ -94,12 +106,14 @@
|
|
|
94
106
|
"lint-staged": "^15.0.2",
|
|
95
107
|
"prettier": "^3.0.3",
|
|
96
108
|
"semantic-release": "^22.0.5",
|
|
109
|
+
"stylelint": "^16.3.1",
|
|
97
110
|
"typescript": "^5.2.2"
|
|
98
111
|
},
|
|
99
112
|
"peerDependencies": {
|
|
100
113
|
"@next/eslint-plugin-next": ">=13.3.0 <15",
|
|
101
114
|
"eslint": ">=8.40.0 <9",
|
|
102
115
|
"prettier": ">=3.0.0 <4",
|
|
116
|
+
"stylelint": ">=16.3.1 <17",
|
|
103
117
|
"typescript": ">=5.0.0 <6"
|
|
104
118
|
},
|
|
105
119
|
"peerDependenciesMeta": {
|
|
@@ -115,6 +129,9 @@
|
|
|
115
129
|
"prettier": {
|
|
116
130
|
"optional": true
|
|
117
131
|
},
|
|
132
|
+
"stylelint": {
|
|
133
|
+
"optional": true
|
|
134
|
+
},
|
|
118
135
|
"typescript": {
|
|
119
136
|
"optional": true
|
|
120
137
|
}
|
package/readme.md
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
- [Prettier](#prettier)
|
|
6
6
|
- [ESLint](#eslint)
|
|
7
7
|
- [TypeScript](#typescript)
|
|
8
|
+
- [Stylelint](#stylelint)
|
|
8
9
|
|
|
9
10
|
> This package originated from [Vercel's style guide](https://github.com/vercel/style-guide).
|
|
10
11
|
|
|
@@ -224,6 +225,47 @@ You could also combine them with an `extends` array in [Typescript 5+](https://d
|
|
|
224
225
|
> [!TIP]
|
|
225
226
|
> Run `tsc --showConfig` to see the result of the combined configs.
|
|
226
227
|
|
|
228
|
+
### Stylelint
|
|
229
|
+
|
|
230
|
+
To format and check CSS with Stylelint, install the `stylelint` package and
|
|
231
|
+
set your configuration to extend from `@haltcase/style/stylelint`.
|
|
232
|
+
|
|
233
|
+
> [!NOTE]
|
|
234
|
+
> Stylelint is a peer dependency you'll need to install
|
|
235
|
+
> at the root of your project.
|
|
236
|
+
>
|
|
237
|
+
> See: https://stylelint.io/user-guide/get-started
|
|
238
|
+
|
|
239
|
+
Add the following in `package.json`:
|
|
240
|
+
|
|
241
|
+
```json
|
|
242
|
+
{
|
|
243
|
+
"stylelint": {
|
|
244
|
+
"extends": "@haltcase/style/stylelint"
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
> [!TIP]
|
|
250
|
+
> See the [Stylelint documentation](https://stylelint.io/user-guide/configure)
|
|
251
|
+
> for other configuration options.
|
|
252
|
+
|
|
253
|
+
#### Stylelint configs
|
|
254
|
+
|
|
255
|
+
There are several configs you can extend from. The default config does not
|
|
256
|
+
enforce a specific naming convention for classes, IDs, etc. This is intended
|
|
257
|
+
to allow flexibility between conventional CSS, where `kebab-case` is standard,
|
|
258
|
+
and CSS Modules or CSS-in-JS, where `camelCase` is more common.
|
|
259
|
+
|
|
260
|
+
There are alternate entry points if you would like to enforce a specific naming
|
|
261
|
+
convention: `standard` for kebab case and `modules` for camel case.
|
|
262
|
+
|
|
263
|
+
| Name | Description |
|
|
264
|
+
| ------------------------------------ | --------------------------------------------------- |
|
|
265
|
+
| `@haltcase/style/stylelint` | Do not enforce a naming convention for identifiers. |
|
|
266
|
+
| `@haltcase/style/stylelint/modules` | Enforce `camelCase` identifiers. |
|
|
267
|
+
| `@haltcase/style/stylelint/standard` | Enforce conventional `kebab-case` identifiers. |
|
|
268
|
+
|
|
227
269
|
## contributing
|
|
228
270
|
|
|
229
271
|
Please read our [contributing](https://github.com/haltcase/style/blob/main/CONTRIBUTING.md)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const defineConfig = require("stylelint-define-config").defineConfig;
|
|
6
|
+
|
|
7
|
+
module.exports = defineConfig({
|
|
8
|
+
extends: [
|
|
9
|
+
"stylelint-config-standard",
|
|
10
|
+
"stylelint-config-html",
|
|
11
|
+
"stylelint-config-clean-order"
|
|
12
|
+
],
|
|
13
|
+
rules: {
|
|
14
|
+
"at-rule-empty-line-before": [
|
|
15
|
+
"always",
|
|
16
|
+
{
|
|
17
|
+
except: ["blockless-after-same-name-blockless", "first-nested"],
|
|
18
|
+
ignore: ["after-comment"]
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"custom-property-empty-line-before": [
|
|
22
|
+
"always",
|
|
23
|
+
{
|
|
24
|
+
except: ["after-custom-property"],
|
|
25
|
+
ignore: ["after-comment", "first-nested", "inside-single-line-block"]
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"declaration-empty-line-before": [
|
|
29
|
+
"always",
|
|
30
|
+
{
|
|
31
|
+
except: ["first-nested"],
|
|
32
|
+
ignore: [
|
|
33
|
+
"after-comment",
|
|
34
|
+
"after-declaration",
|
|
35
|
+
"inside-single-line-block"
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
"rule-empty-line-before": [
|
|
40
|
+
"always-multi-line",
|
|
41
|
+
{
|
|
42
|
+
except: ["first-nested"],
|
|
43
|
+
ignore: ["after-comment"]
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const defineConfig = require("stylelint-define-config").defineConfig;
|
|
6
|
+
|
|
7
|
+
const base = require("./_base.js");
|
|
8
|
+
|
|
9
|
+
module.exports = defineConfig({
|
|
10
|
+
...base,
|
|
11
|
+
|
|
12
|
+
rules: {
|
|
13
|
+
...base.rules,
|
|
14
|
+
|
|
15
|
+
// disable identifier casing rules
|
|
16
|
+
"custom-media-pattern": null,
|
|
17
|
+
"custom-property-pattern": null,
|
|
18
|
+
"keyframes-name-pattern": null,
|
|
19
|
+
"selector-class-pattern": null
|
|
20
|
+
}
|
|
21
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
const defineConfig = require("stylelint-define-config").defineConfig;
|
|
6
|
+
|
|
7
|
+
const base = require("./_base.js");
|
|
8
|
+
|
|
9
|
+
const camelCaseRegex = /^(?<=^|[^A-Z_a-z])_*[a-z]+[A-Z_a-z]*$/;
|
|
10
|
+
|
|
11
|
+
module.exports = defineConfig({
|
|
12
|
+
...base,
|
|
13
|
+
|
|
14
|
+
rules: {
|
|
15
|
+
...base.rules,
|
|
16
|
+
|
|
17
|
+
"custom-media-pattern": camelCaseRegex,
|
|
18
|
+
|
|
19
|
+
// custom properties (variables) should still be kebab-case
|
|
20
|
+
// "custom-property-pattern": camelCaseRegex,
|
|
21
|
+
|
|
22
|
+
"keyframes-name-pattern": camelCaseRegex,
|
|
23
|
+
"selector-class-pattern": camelCaseRegex
|
|
24
|
+
}
|
|
25
|
+
});
|