I have stylelint installed in my project, and I’ve configured its configuration.
I added a script to run this linter on my src
folder.
For some reason, the linter scans only one folder.
Here is my configuration file stylelint.config.js:
module.exports = { extends: [ 'stylelint-config-standard-scss', 'stylelint-config-prettier-scss', 'stylelint-config-recess-order', ], plugins: ['stylelint-scss', 'stylelint-order'], rules: { 'selector-class-pattern': [ '^[a-z][A-Za-z0-9]*((--([a-z][A-Za-z0-9]*)(__([a-z][A-Za-z0-9]*))?)|(__([a-z][A-Za-z0-9]*)(--([a-z][A-Za-z0-9]*))?))?$', { resolveNestedSelectors: true, message: 'Expected class selector to be camel case' }, ], 'value-no-vendor-prefix': null, 'selector-id-pattern': null, 'scss/at-import-partial-extension': null, }, };
This is the script: "stylelint": "stylelint --f verbose src/**/*.scss",
My src folder has a lot of .scss files. But this script only scans 2 files for some reason.
$ stylelint --f verbose src/**/*.scss 2 sources checked /Users/amir/Desktop/Development/Vinyl projects/LandingPag-REAL/src/styles/custom.scss /Users/amir/Desktop/Development/Vinyl projects/LandingPag-REAL/src/styles/variables.scss 0 problems found ✨ Done in 0.79s.
Why would it ignores all other files? I don’t have some “ignore” configuration file.
NOTE: It worked on Windows perfect (didn’t skip), on Mac it skips almost the entire src file
Also when I change the script to run stylelint ... **/*.scss
it does work
Advertisement
Answer
You need to quote your input glob, otherwise the shell (which differs on Windows and Mac) will interpret it rather than Stylelint itself.
If you’re only targeting *nix, you can use single quotes:
"stylelint": "stylelint --f verbose 'src/**/*.scss'",
For cross-platform use escaped double quotes:
"stylelint": "stylelint --f verbose "src/**/*.scss"",
Incidentally, you:
- can remove the
plugins
property as both plugins are bundled in their respective configs - should put the prettier config last so that it overrides everything before
{ "extends": [ "stylelint-config-standard-scss", "stylelint-config-recess-order", "stylelint-config-prettier-scss" ], "rules": { "selector-class-pattern": [ "^[a-z][A-Za-z0-9]*((--([a-z][A-Za-z0-9]*)(__([a-z][A-Za-z0-9]*))?)|(__([a-z][A-Za-z0-9]*)(--([a-z][A-Za-z0-9]*))?))?$", { "resolveNestedSelectors": true, "message": "Expected class selector to be camel case" } ], "value-no-vendor-prefix": null, "selector-id-pattern": null, "scss/at-import-partial-extension": null } }