Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restrict stylelint to only css and scss files

Tags:

css

stylelint

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
like image 968
goofballLogic Avatar asked May 28 '18 10:05

goofballLogic


People also ask

Can CSS and SCSS be used together?

You can have both but you have to set your style extension to SASS or CSS only. Show activity on this post. I would recommend you change the styleExt to scss and your css files to scss because scss is a superset of css.

Does Stylelint work with SCSS?

Stylelint by itself supports SCSS syntax very well (as well as other preprocessors' syntaxes). Moreover, it introduces some specific rules that can be used to lint SCSS, e.g. to limit. Yet stylelint is in general focused on standard CSS. stylelint-scss introduces rules specific to SCSS syntax.

What is style Linting?

A mighty, modern linter that helps you avoid errors and enforce conventions in your styles.


1 Answers

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

.stylelintignore

node_modules
bin
obj
*.*
!*.css
!*.scss
like image 138
goofballLogic Avatar answered Oct 06 '22 16:10

goofballLogic