StyleLint - Ignore specific folders and files
Asked Answered
P

2

17

I'm using StyleLint with Webpack.

My current Webpack configuration is:

module.exports.styleLint = (isProd = false) => {
  const options = {
    configFile: './.stylelintrc.json',
    files: '**/*.less',
    format: 'less',
    failOnError: false,
    quiet: false,
    emitErrors: isProd
  };
  return new StyleLintPlugin(options);
};

How can I specify some folders or files to be ignored by StyleLint (I don't want to see any errors in the output)?

Note:

I don't want to add

/* stylelint-disable */

inside these files.

Papoose answered 2/6, 2019 at 11:56 Comment(0)
P
33

I used the following configuration in the stylelint config file:

{
    "extends": "stylelint-config-recommended",
    "ignoreFiles": [
        "app/bootstrap/**/*.less"
    ]
}

And it skipped the files in the specified folder.

Papoose answered 2/6, 2019 at 12:43 Comment(0)
H
14

Another way to exclude something with a stylelint is to use the .stylelintignore file.

As the documentation says:

You can use a .stylelintignore file to ignore specific files. For example:

**/*.js
vendor/**/*.css

The patterns in your .stylelintignore file must match .gitignore syntax. (Behind the scenes, node-ignore parses your patterns.) Your patterns in .stylelintignore are always analyzed relative to process.cwd().

stylelint looks for a .stylelintignore file in process.cwd(). You can also specify a path to your ignore patterns file (absolute or relative to process.cwd()) using the --ignore-path (in the CLI) and ignorePath (in JS) options.

Harmless answered 20/11, 2020 at 11:27 Comment(1)
I had no luck with the ignoreFiles config, but this worked perfectly.Swansea

© 2022 - 2024 — McMap. All rights reserved.