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
goofballLogic
  • 37,883
  • 8
  • 44
  • 62

1 Answers1

13

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

.stylelintignore

node_modules
bin
obj
*.*
!*.css
!*.scss
goofballLogic
  • 37,883
  • 8
  • 44
  • 62
  • 1
    Curious. `!*.scss` only works for me if I also include the `*.*` line. Do you happen to know why that is? – mikkelrd Aug 13 '18 at 14:30
  • 'fraid not @mikkelrd – goofballLogic Aug 15 '18 at 12:02
  • 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)` – Lauris Kuznecovs Aug 14 '19 at 07:02