Restrict stylelint to only css and scss files
Asked Answered
T

1

9

I'm trying to configure stylelint to only lint my CSS and/or SCSS files. I'm extending stylelint-config-recommended but by default it seems to be processing loads of other files as well as the .css and .scss ones I want to lint.

Examples of files I don't want to include:

  • .js
  • .cshtml

Exmples output from the CLI

debug.log
 1:67  ×  Unknown word   CssSyntaxError

local.log
 21:21  ×  Missed semicolon   CssSyntaxError

package-lock.json
 3:21  ×  Missed semicolon   CssSyntaxError

package.json
 3:21  ×  Missed semicolon   CssSyntaxError

personal.json
 3:40  ×  Missed semicolon   CssSyntaxError

Program.cs
 1:1  ×  Unknown word   CssSyntaxError

README.md
 11:51  ×  Unclosed bracket   CssSyntaxError

reviewers.csproj
 1:1  ×  Unknown word   CssSyntaxError

reviewers.csproj.user
 1:1  ×  Unknown word   CssSyntaxError

reviewers.sln
 14:4  ×  Unknown word   CssSyntaxError

.stylelintrc

{
  "extends": "stylelint-config-recommended"
}

.stylelintignore

node_modules
bin
obj
*.js
*.map
Trapeze answered 28/5, 2018 at 10:19 Comment(0)
T
13

Looks like you can use a "exclusion" glob like this:

.stylelintignore

node_modules
bin
obj
*.*
!*.css
!*.scss
Trapeze answered 28/5, 2018 at 12:47 Comment(3)
Curious. !*.scss only works for me if I also include the *.* line. Do you happen to know why that is?Daubigny
'fraid not @DaubignyTrapeze
I have similar problem - when passing wrong file to styllint it gives error even file is in .stylelintignore node ./node_modules/.bin/stylelint dont-check-this-file.yml This is error I got when specify linter ignored file: Error: No files matching the pattern "/home/user/some-path/dont-check-this-file.yml" were found. at globby.then.filePaths (/home/user/some-path/node_modules/stylelint/lib/standalone.js:206:17) at process._tickCallback (internal/process/next_tick.js:68:7)Cuenca

© 2022 - 2024 — McMap. All rights reserved.