The Node.js® Website

refactor(stylelint): Enfore camelCase for CSS Selectors. (#5814)

* refactor(stylelint): update guidelines

* refactor(stylelint): update lintsragedrc

* Update .stylelintrc.mjs

Signed-off-by: Claudio W <cwunder@gnome.org>

* refactor(stylelint): only ignore old styles

* refactor(stylelint): add EOL

* meta: fix file formatting

---------

Signed-off-by: Claudio W <cwunder@gnome.org>
Co-authored-by: Claudio W <cwunder@gnome.org>
Co-authored-by: Claudio Wunder <cwunder@hubspot.com>

authored by Harkunwar Kochar Claudio W Claudio Wunder and committed by GitHub 467f42b7 ff81f931

+1 -4
.lintstagedrc.json
··· 1 1 { 2 2 "**/*.{mjs,ts,tsx,md,mdx}": ["eslint --fix", "prettier --check --write"], 3 - "**/*.{css,sass,scss}": [ 4 - "stylelint --config .stylelintrc.json", 5 - "prettier --write" 6 - ], 3 + "**/*.{css,sass,scss}": ["stylelint", "prettier --write"], 7 4 "**/*.{json,yml}": ["prettier --check --write"] 8 5 }
+3
.stylelintignore
··· 12 12 13 13 # Storybook 14 14 storybook-static 15 + 16 + # Old Styles 17 + styles/old
-20
.stylelintrc.json
··· 1 - { 2 - "extends": ["stylelint-config-recommended-scss"], 3 - "plugins": ["stylelint-order", "stylelint-selector-bem-pattern"], 4 - "rules": { 5 - "order/properties-alphabetical-order": true, 6 - "no-descending-specificity": null, 7 - "scss/at-extend-no-missing-placeholder": null, 8 - "scss/at-import-no-partial-leading-underscore": null, 9 - "selector-pseudo-class-no-unknown": [ 10 - true, 11 - { "ignorePseudoClasses": ["global"] } 12 - ], 13 - "scss/at-rule-no-unknown": [ 14 - true, 15 - { 16 - "ignoreAtRules": ["tailwind", "apply"] 17 - } 18 - ] 19 - } 20 - }
+24
.stylelintrc.mjs
··· 1 + // Enforces certain selectors to be only in camelCase notation 2 + // such as class names, for example 3 + const onlyAllowCamelCaseRule = [ 4 + /^(?:[a-z]+(?:[A-Z][a-z]*)*)$/, 5 + { message: s => `Expected '${s}' to be in camelCase` }, 6 + ]; 7 + 8 + export default { 9 + extends: ['stylelint-config-recommended-scss'], 10 + plugins: ['stylelint-order', 'stylelint-selector-bem-pattern'], 11 + rules: { 12 + 'order/properties-alphabetical-order': true, 13 + 'no-descending-specificity': null, 14 + 'scss/at-extend-no-missing-placeholder': null, 15 + 'scss/at-import-no-partial-leading-underscore': null, 16 + 'selector-class-pattern': onlyAllowCamelCaseRule, 17 + 'selector-id-pattern': onlyAllowCamelCaseRule, 18 + 'selector-pseudo-class-no-unknown': [ 19 + true, 20 + { ignorePseudoClasses: ['global'] }, 21 + ], 22 + 'scss/at-rule-no-unknown': [true, { ignoreAtRules: ['tailwind', 'apply'] }], 23 + }, 24 + };
+6 -5
components/Common/Badge/index.module.scss
··· 11 11 font-medium; 12 12 13 13 .icon { 14 - @apply w-4 h-4; 14 + @apply w-4 15 + h-4; 15 16 } 16 17 17 18 .badge { ··· 58 59 59 60 .icon { 60 61 @apply text-danger-500 61 - dark:text-danger-300; 62 + dark:text-danger-300; 62 63 } 63 64 64 65 .badge { 65 66 @apply border-danger-200 66 - dark:border-danger-600 67 - bg-danger-600; 67 + dark:border-danger-600 68 + bg-danger-600; 68 69 } 69 70 70 71 .message { 71 72 @apply text-danger-700 72 - dark:text-danger-300; 73 + dark:text-danger-300; 73 74 } 74 75 } 75 76
+2 -1
components/Common/Banner/index.module.scss
··· 14 14 } 15 15 16 16 svg { 17 - @apply h-4 w-4; 17 + @apply h-4 18 + w-4; 18 19 } 19 20 } 20 21
+1 -1
package.json
··· 24 24 "build": "cross-env NODE_NO_WARNINGS=1 next build", 25 25 "start": "cross-env NODE_NO_WARNINGS=1 next start", 26 26 "deploy": "cross-env NEXT_STATIC_EXPORT=true npm run build", 27 - "lint:js": "eslint \"**/*.{mjs,ts,tsx}\" --cache --cache-strategy content --cache-file .eslintjscache --report-unused-disable-directives", 27 + "lint:js": "eslint \"**/*.{mjs,ts,tsx}\" --cache --cache-strategy content --cache-file .eslintjscache", 28 28 "lint:md": "eslint \"**/*.md?(x)\" --cache --cache-strategy content --cache-file .eslintmdcache", 29 29 "lint:scss": "stylelint \"**/*.{css,sass,scss}\"", 30 30 "lint": "npm run lint:js && npm run lint:md && npm run lint:scss",
+6 -6
turbo.json
··· 70 70 "lint:scss": { 71 71 "inputs": [ 72 72 "{app,components,layouts,pages,styles}/**/*.{css,sass,scss}", 73 - ".stylelintrc.json", 73 + ".stylelintrc.mjs", 74 74 ".stylelintignore" 75 75 ] 76 76 }, ··· 84 84 "*.{md,mdx,ts,tsx,mjs,yml}", 85 85 ".eslintrc.json", 86 86 ".eslintignore", 87 - ".stylelintrc.json", 87 + ".stylelintrc.mjs", 88 88 ".stylelintignore", 89 89 ".prettierrc.json", 90 90 ".prettierignore", ··· 102 102 "*.{md,mdx,ts,tsx,mjs}", 103 103 ".eslintrc.json", 104 104 ".eslintignore", 105 - ".stylelintrc.json", 105 + ".stylelintrc.mjs", 106 106 ".stylelintignore", 107 107 ".prettierrc.json", 108 108 ".prettierignore", ··· 120 120 "*.{md,mdx,json,ts,tsx,mjs,yml}", 121 121 ".eslintrc.json", 122 122 ".eslintignore", 123 - ".stylelintrc.json", 123 + ".stylelintrc.mjs", 124 124 ".stylelintignore", 125 125 ".prettierrc.json", 126 126 ".prettierignore", ··· 139 139 "*.{md,mdx,json,ts,tsx,mjs,yml}", 140 140 ".eslintrc.json", 141 141 ".eslintignore", 142 - ".stylelintrc.json", 142 + ".stylelintrc.mjs", 143 143 ".stylelintignore", 144 144 ".prettierrc.json", 145 145 ".prettierignore", ··· 158 158 "*.{md,mdx,json,ts,tsx,mjs,yml}", 159 159 ".eslintrc.json", 160 160 ".eslintignore", 161 - ".stylelintrc.json", 161 + ".stylelintrc.mjs", 162 162 ".stylelintignore", 163 163 ".prettierrc.json", 164 164 ".prettierignore",