Search code examples
sassglobpackage.jsonstylelint

Lint multiple directories with stylelint


I'm trying to lint more than one directory at once with stylelint.

In my package.json file I have:

"scripts": {
  "lint": "stylelint 'pages/**/*.scss', 'global/components/**/*.scss' ; exit 0"
},

If I remove either 'pages/**/*.scss' or 'global/components/**/*.scss', I can lint one of the directories.

Is it possible to lint 2 at once?


Solution

  • Is it possible to lint 2 at once?

    Yes.

    stylelint expects a single glob pattern, but you can construct a glob pattern that matches more than one directory. For example:

    {global/components,pages}/**/*.scss
    

    And in the context of your example:

    "scripts": {
      "lint": "stylelint '{global/components,pages}/**/*.scss'; exit 0"
    },
    

    stylelint supports these glob features and you can test your glob patterns using globtester.com