@sonsu-lee/stylelint-config 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +37 -2
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +45 -0
- package/package.json +43 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sonsu Lee
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,38 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @sonsu-lee/stylelint-config
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Shared Stylelint config for CSS, CSS Modules, and Tailwind CSS v4. Use oxfmt for formatting.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
pnpm add -D stylelint @sonsu-lee/stylelint-config
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
In `stylelint.config.mjs`:
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
export default { extends: ['@sonsu-lee/stylelint-config'] };
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Run `pnpm exec stylelint '**/*.css'`.
|
|
18
|
+
|
|
19
|
+
## What it catches
|
|
20
|
+
|
|
21
|
+
- The browser ignores `colr: red` and `padding: 10pixels`. Stylelint reports the unknown property and unit.
|
|
22
|
+
- A later `margin: 0` resets an earlier `margin-top: 8px` in the same block. Stylelint reports the shorthand override.
|
|
23
|
+
- A misspelled `@tailwnd` is reported, while Tailwind CSS v4 directives such as `@theme` and `@apply` are allowed.
|
|
24
|
+
|
|
25
|
+
## Tailwind CSS v4
|
|
26
|
+
|
|
27
|
+
- Nested selectors and media queries are allowed inside `@utility` and `@custom-variant`. A top-level `&` is still reported.
|
|
28
|
+
- Stylelint skips the `@import` prelude check so Tailwind imports can use modifiers such as `prefix(tw) source(none)`. It skips value validation for declarations containing `--spacing()`, `--alpha()`, or `theme()`, and allows `theme()` in media queries.
|
|
29
|
+
- Stylelint treats declarations directly inside Tailwind at-rules such as `@variant` and `@utility` as descriptors. It does not check them for unknown properties or invalid values, so `colr: red` and `padding: 10pixels` are not reported there. Declarations under a nested selector are checked as ordinary CSS, so `tab-size: --value(integer)` passes directly inside `@utility` but is reported inside a nested `&:hover` rule.
|
|
30
|
+
- `color: --value(--color-*)` is still reported by `custom-property-no-missing-var-function` when the same file declares `--color-*` in `@theme`. The rule has no exception for Tailwind functions.
|
|
31
|
+
|
|
32
|
+
## CSS Modules
|
|
33
|
+
|
|
34
|
+
The preset allows `:global`, `:local`, `:export`, `:import()`, `composes`, and `@value` only in `*.module.css`. Properties in `:export` and `:import()` blocks may be arbitrary token names. If a token name is also a CSS property, Stylelint still validates its value against that property's CSS syntax.
|
|
35
|
+
|
|
36
|
+
Stylelint does not substitute local or imported `@value` tokens when it validates CSS declarations. For example, `@value accent: #246` is allowed, but `color: accent` is reported by `declaration-property-value-no-unknown`. The rule stays on so it can still catch typos in CSS values.
|
|
37
|
+
|
|
38
|
+
The preset extends `stylelint-config-recommended`. It does not configure property ordering or support SCSS.
|
package/dist/index.d.mts
ADDED
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
const tailwindAtRules = [
|
|
3
|
+
"theme",
|
|
4
|
+
"source",
|
|
5
|
+
"utility",
|
|
6
|
+
"variant",
|
|
7
|
+
"custom-variant",
|
|
8
|
+
"apply",
|
|
9
|
+
"reference",
|
|
10
|
+
"config",
|
|
11
|
+
"plugin"
|
|
12
|
+
];
|
|
13
|
+
const tailwindNestingAtRules = ["utility", "custom-variant"];
|
|
14
|
+
const config = {
|
|
15
|
+
extends: ["stylelint-config-recommended"],
|
|
16
|
+
rules: {
|
|
17
|
+
"at-rule-prelude-no-invalid": [true, { ignoreAtRules: [
|
|
18
|
+
"media",
|
|
19
|
+
"import",
|
|
20
|
+
"apply"
|
|
21
|
+
] }],
|
|
22
|
+
"at-rule-no-unknown": [true, { ignoreAtRules: tailwindAtRules }],
|
|
23
|
+
"nesting-selector-no-missing-scoping-root": [true, { ignoreAtRules: tailwindNestingAtRules }],
|
|
24
|
+
"no-invalid-position-declaration": [true, { ignoreAtRules: tailwindNestingAtRules }],
|
|
25
|
+
"declaration-property-value-no-unknown": [true, { ignoreProperties: { "/.*/": [/(?:^|[^\w-])(?:--spacing|--alpha|theme)\(/u] } }],
|
|
26
|
+
"media-query-no-invalid": [true, { ignoreFunctions: ["theme"] }]
|
|
27
|
+
},
|
|
28
|
+
overrides: [{
|
|
29
|
+
files: ["**/*.module.css"],
|
|
30
|
+
rules: {
|
|
31
|
+
"selector-pseudo-class-no-unknown": [true, { ignorePseudoClasses: [
|
|
32
|
+
"global",
|
|
33
|
+
"local",
|
|
34
|
+
"export",
|
|
35
|
+
"import"
|
|
36
|
+
] }],
|
|
37
|
+
"property-no-unknown": [true, {
|
|
38
|
+
ignoreProperties: ["composes"],
|
|
39
|
+
ignoreSelectors: [":export", /^:import\([\s\S]*\)$/u]
|
|
40
|
+
}],
|
|
41
|
+
"at-rule-no-unknown": [true, { ignoreAtRules: [...tailwindAtRules, "value"] }]
|
|
42
|
+
}
|
|
43
|
+
}]
|
|
44
|
+
};
|
|
45
|
+
export { config as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sonsu-lee/stylelint-config",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Stylelint preset for CSS, CSS Modules, and Tailwind CSS v4",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/sonsu-lee/style-guide.git",
|
|
9
|
+
"directory": "packages/stylelint-config"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
14
|
+
"type": "module",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.mts",
|
|
18
|
+
"default": "./dist/index.mjs"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"stylelint-config-recommended": "19.1.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@sonsu-lee/oxlint-config": "^0.1.0",
|
|
29
|
+
"@types/node": "24.19.2",
|
|
30
|
+
"oxlint": "1.90.0",
|
|
31
|
+
"oxlint-tsgolint": "7.0.2005",
|
|
32
|
+
"stylelint": "18.1.0",
|
|
33
|
+
"tsdown": "0.23.4",
|
|
34
|
+
"typescript": "7.0.2",
|
|
35
|
+
"vitest": "5.0.5"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"stylelint": "^18.0.0"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "tsdown",
|
|
42
|
+
"test": "vitest run",
|
|
43
|
+
"typecheck": "tsc",
|
|
44
|
+
"lint": "oxlint"
|
|
45
|
+
}
|
|
6
46
|
}
|