Search code examples
visual-studio-codestylelint

Disable VS Code Stylelint errors in React JavaScript files


enter image description here

[stylelint] Unexpected missing end-of-source newline (no-missing-end-of-source-newline)
[stylelint] Expected "backgroundColor" to be "backgroundcolor" (value-keyword-case)
[stylelint] Expected a trailing semicolon (declaration-block-trailing-semicolon)

How do I stop the VS Code Styleint extension from reporting things like this? It's not particularly useful as you can see :P

UPDATE:

To clarify, I have a .stylelintrc configuration file and my rules are as I want them but I want it to lint my styles and not my JavaScript. The extension description says:

stylelint automatically validates documents with these language identifiers:

...and javascriptreact is one of those language identifiers. I would like to know how to stop the extension from validating javascriptreact documents.


Solution

  • TL;DR

    Here's a working example of .stylelintrc file which makes VS Code ignore JS/JSX files:

    {
      "ignoreFiles": [
        "**/*.js",
        "**/*.jsx"
      ]
    }
    

    Don't forget to restart VS Code after changes!


    Explanation

    Stylelint extension for VS Code reads .stylelintrc, so you can use ignoreFiles key in order to stop VS Code from linting styles on certain file types.

    As documentation stands, you could also use .stylelintignore file, but it's not working for me as VS Code seems to ignore that file.