Vinnie James
Vinnie James

Reputation: 6062

Stylelint failing silently as npm script

I'm setting up stylelint for a project, everything works as expected when run from the cli:

$ stylelint 'css/**/*.css' --fix

css/style.css
 20:18  ×  Expected newline after ":" with a multi-line declaration declaration-colon-newline-after
...
...

However, when run as an npm script no output appears (beyond logging the command) and the errors seem to be ignored:

$ npm run stylelint

> project lint:css path/project
> stylelint 'css/**/*.css' --fix    

package.json

  "scripts": {
    ...
    "stylelint": "stylelint 'css/**/*.css' --fix"
  },

Any idea how to get the console output AND exit on errors when stylelint is run as an npm script?

Upvotes: 6

Views: 2482

Answers (2)

sn3p
sn3p

Reputation: 746

Seems like appending ; exit 0 also does the trick:

"stylelint": "stylelint 'css/**/*.css' --fix; exit 0"

Upvotes: 0

Vinnie James
Vinnie James

Reputation: 6062

The issue turned out to be the quotes around the globstar pattern. Most other scripts allow you to wrap the globstar in single quotes ', however stylelint seems to require escaped double quotes:

"stylelint": "stylelint \"src/**/*.css\" --fix"

Upvotes: 10

Related Questions