rkralston
rkralston

Reputation: 386

How to prevent stylelint from generating error on first word of JS file?

I just switched to stylelint. When I open a JS file, it registers an error on the first word in code:

import React from 'react';

It highlights "import" and flags it with Unknown word (CssSyntaxError)

OTW, it's great for my CSS.

Upvotes: 1

Views: 3529

Answers (1)

rkralston
rkralston

Reputation: 386

Similar question here: Can I stop stylelint extension from validating JavaScript file?

However, the selected answer is in the stylelint documents as a non-preferred method for skipping JS files: https://github.com/stylelint/stylelint/blob/master/docs/user-guide/configuration.md#ignorefiles

The preferred answer is found in the docs here: https://github.com/stylelint/stylelint/blob/master/docs/user-guide/configuration.md#ignorefiles

Create .stylelintignore file and set it up like .gitignore. I added **/*.js and stylelint ignores my JS files.

I am using React and I am not sure if stylint should look at JS files. However, this has fixed my problem for now. If stylelint is supposed to look at JS files, I'd be interested in how I should configure it to work correctly.

Upvotes: 1

Related Questions