Skip to content

Commit 6e3ed16

Browse files
authored
Replace deprecated sass-lint for stylelint (#12774)
* chore(deps): install stylelint for SCSS Signed-off-by: Mike Fiedler <[email protected]> * lint: add stylelint configuration Trying to match the existing `.sass-lint.yml` rules as much as we can. Signed-off-by: Mike Fiedler <[email protected]> * lint: address whitespace Fixed based on the stylelint rules. There's 65 remaining fixes if we choose to change enable: - at-rule-empty-line-before - declaration-empty-line-before Signed-off-by: Mike Fiedler <[email protected]> * lint: address pseudo selectors With `selector-pseudo-element-colon-notation` enabled, we double-colon pseudo selectors for visual specificity. Signed-off-by: Mike Fiedler <[email protected]> * lint: rename disables Signed-off-by: Mike Fiedler <[email protected]> * lint: handle shorthand properties Refs: https://stylelint.io/user-guide/rules/shorthand-property-no-redundant-values/ Signed-off-by: Mike Fiedler <[email protected]> * lint: simplify complex .not notation Refs: https://stylelint.io/user-guide/rules/selector-not-notation/ Signed-off-by: Mike Fiedler <[email protected]> * lint: handle color lints Solves: - alpha-value-notation: 5 - color-function-notation: 5 - color-hex-case: 3 - color-hex-length: 1 Signed-off-by: Mike Fiedler <[email protected]> * lint: handle various one-off cases - declaration-block-trailing-semicolon: 2 - font-family-name-quotes: 1 - length-zero-no-unit: 1 - number-leading-zero: 1 - property-no-vendor-prefix: 1 - value-keyword-case: 1 Signed-off-by: Mike Fiedler <[email protected]> * lint: remove duplicate selectors Introduced in #3397 Raises lint error for `no-duplicate-selectors`. - Remove duplication - Disable lint rule for the Pygments block, since it helps us visually organize our thoughts. Signed-off-by: Mike Fiedler <[email protected]> * refactor: replace my janky regex with plugin Instead of trying to decipher in the future how I came up with the selector pattern, use a plugin that implements the right selector syntaxes. We disable the inherited `selector-class-pattern` rule from `stylelint-config-standard`. Refs: stylelint/stylelint-config-standard#209 Signed-off-by: Mike Fiedler <[email protected]> * test: run stylelint instead of sass-lint Signed-off-by: Mike Fiedler <[email protected]> * chore: remove deprecated sass-lint Signed-off-by: Mike Fiedler <[email protected]> Signed-off-by: Mike Fiedler <[email protected]>
1 parent 528b925 commit 6e3ed16

37 files changed

+1840
-2159
lines changed

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.git/*
2+
.stylelintcache
23
node_modules
34
dev/*
45
**/*.pyc

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ tags
3535
*.sw*
3636

3737
.DS_Store
38+
.stylelintcache

.sass-lint.yml

Lines changed: 0 additions & 54 deletions
This file was deleted.

.stylelintrc.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"extends": [
3+
"stylelint-config-standard-scss"
4+
],
5+
"plugins": [
6+
"stylelint-selector-bem-pattern"
7+
],
8+
"ignoreFiles": [
9+
"warehouse/static/sass/tools/bourbon/**/*",
10+
"warehouse/static/sass/tools/neat/**/*",
11+
"warehouse/static/sass/resets/_boxsizing.scss",
12+
"warehouse/static/sass/resets/_reset.scss"
13+
],
14+
"reportDescriptionlessDisables": true,
15+
"reportInvalidScopeDisables": true,
16+
"reportNeedlessDisables": true,
17+
"rules": {
18+
"at-rule-empty-line-before": null,
19+
"comment-empty-line-before": [
20+
"always",
21+
{
22+
"ignoreComments": [
23+
"/rtl/"
24+
]
25+
}
26+
],
27+
"comment-whitespace-inside": null,
28+
"declaration-empty-line-before": null,
29+
"font-family-no-missing-generic-family-keyword": [
30+
true,
31+
{
32+
"ignoreFontFamilies": [
33+
"/^Font Awesome.*$/"
34+
]
35+
}
36+
],
37+
"max-empty-lines": 2,
38+
"max-line-length": [
39+
120,
40+
{
41+
"ignore": [
42+
"comments"
43+
]
44+
}
45+
],
46+
"no-descending-specificity": null,
47+
"plugin/selector-bem-pattern": {
48+
"preset": "bem"
49+
},
50+
"selector-class-pattern": null,
51+
"scss/dollar-variable-colon-space-after": "at-least-one-space",
52+
"scss/no-global-function-names": null
53+
}
54+
}

bin/static_lint

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ export LANG="${ENCODING:-en_US.UTF-8}"
1010

1111
# Actually run our tests.
1212
./node_modules/.bin/eslint 'warehouse/static/js/**' 'tests/frontend/**' --ignore-pattern 'warehouse/static/js/vendor/**'
13-
./node_modules/.bin/sass-lint --verbose
13+
npm run stylelint

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ services:
150150
- ./warehouse:/opt/warehouse/src/warehouse:z
151151
- ./webpack.config.js:/opt/warehouse/src/webpack.config.js:z
152152
- ./.babelrc:/opt/warehouse/src/.babelrc:z
153-
- ./.sass-lint.yml:/opt/warehouse/src/.sass-lint.yml:z
153+
- ./.stylelintrc.json:/opt/warehouse/src/.stylelintrc.json:z
154154
- ./tests/frontend:/opt/warehouse/src/tests/frontend:z
155155
- ./bin:/opt/warehouse/src/bin:z
156156

0 commit comments

Comments
 (0)