Skip to content

Commit 8e3271c

Browse files
committed
feat: add stylelint for css and scss linting
1 parent 3b4edc9 commit 8e3271c

File tree

5 files changed

+669
-16
lines changed

5 files changed

+669
-16
lines changed

.changeset/moody-donuts-push.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
'@frontendfixer/eslint-config-react': major
3+
---
4+
5+
## Add stylelint for css and scss files
6+
7+
### Features
8+
9+
- Extends stylelint config with [stylelint-config-standard](https://github.com/stylelint/stylelint-config-standard)
10+
- SCSS support with [stylelint-scss](https://github.com/stylelint-scss/stylelint-scss) and [postcss-scss](https://github.com/postcss/postcss-scss)
11+
- Convert all px value to rem using [stylelint-rem-over-px](https://github.com/a-tokyo/stylelint-rem-over-px)

.stylelintrc.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"plugins": ["stylelint-scss", "stylelint-rem-over-px"],
3+
"extends": [
4+
"stylelint-config-standard",
5+
"stylelint-config-standard-scss",
6+
"stylelint-config-css-modules",
7+
"stylelint-config-recess-order"
8+
],
9+
"rules": {
10+
"selector-class-pattern": null,
11+
"rem-over-px/rem-over-px": [
12+
true,
13+
{
14+
"ignore": ["1px", "2px", "3px", "border", "box-shadow", "filter"]
15+
}
16+
],
17+
"scss/at-rule-no-unknown": [
18+
true,
19+
{
20+
"ignoreAtRules": ["tailwind", "layer"]
21+
}
22+
]
23+
},
24+
"overrides": [
25+
{
26+
"files": ["*.scss", "**/*.scss"],
27+
"customSyntax": "postcss-scss"
28+
}
29+
]
30+
}

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ module.exports = {
2929
'plugin:jsx-a11y/recommended',
3030
'plugin:import/recommended',
3131
'airbnb',
32+
'stylelint',
3233
'prettier',
3334
'plugin:prettier/recommended',
3435
],

package.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"./rules/base.rules.js",
2929
"./rules/typescript.rules.js",
3030
"./.prettierrc",
31+
"./.stylelintrc.json",
3132
"./.prettierignore",
3233
"./tsconfig.json"
3334
],
@@ -54,6 +55,7 @@
5455
"eslint-config-airbnb": "^19.0.4",
5556
"eslint-config-airbnb-typescript": "^17.0.0",
5657
"eslint-config-prettier": "^8.8.0",
58+
"eslint-config-stylelint": "^19.0.0",
5759
"eslint-import-resolver-typescript": "^3.5.5",
5860
"eslint-plugin-html": "^7.1.0",
5961
"eslint-plugin-import": "^2.27.5",
@@ -62,14 +64,23 @@
6264
"eslint-plugin-react": "^7.32.2",
6365
"eslint-plugin-react-hooks": "^4.6.0",
6466
"eslint-plugin-react-refresh": "^0.4.1",
65-
"eslint-plugin-simple-import-sort": "^10.0.0"
67+
"eslint-plugin-simple-import-sort": "^10.0.0",
68+
"postcss": "^8.4.26",
69+
"postcss-scss": "^4.0.6",
70+
"stylelint-config-css-modules": "^4.3.0",
71+
"stylelint-config-recess-order": "^4.3.0",
72+
"stylelint-config-standard": "^34.0.0",
73+
"stylelint-config-standard-scss": "^10.0.0",
74+
"stylelint-rem-over-px": "^1.0.0",
75+
"stylelint-scss": "^5.0.1"
6676
},
6777
"devDependencies": {
6878
"@changesets/changelog-github": "^0.4.8",
6979
"@changesets/cli": "^2.26.2",
7080
"eslint": "^8.44.0",
7181
"prettier": "^2.8.8",
7282
"react": "^18.2.0",
83+
"stylelint": "^15.10.2",
7384
"typescript": "^5.1.6"
7485
},
7586
"config": {

0 commit comments

Comments
 (0)