stylelint / vscode-stylelint

The official Visual Studio Code extension for Stylelint

Home Page:https://marketplace.visualstudio.com/items?itemName=stylelint.vscode-stylelint

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]:

CGSimplePeople opened this issue · comments

How did you encounter this bug?

When I use the stylelint configuration to format styled-components, every time I write code in the tsx file, there will always be an error message

Link to Minimal Reproducible Example

local project has no address

Code Snippet

{
"extends": ["stylelint-config-rational-order", "stylelint-config-standard"],
"plugins": ["stylelint-order"],
"customSyntax": "postcss-styled-components"
}

Stylelint Configuration

No response

Extension Configuration

"stylelint.validate": ["css", "scss", "less", "javascript ", "typescript", "typescriptreact"],

Actual Behaviour

SyntaxError: Unexpected keyword 'function'. (10:0) at instantiate (E:\GProjects\UI\node_modules.pnpm@babel+parser@7.21.2\node_modules@babel\parser\lib\index.js:64:32) at constructor

Expected Behaviour

I wish I didn't get this type of prompt right away while I was writing the code

Logs

[Error - 13:09:56] [language-server] Error running lint | uri: "file:///e%3A/GProjects/UI/src/App.tsx" error: {"code":"BABEL_PARSER_SYNTAX_ERROR","reasonCode":"UnexpectedKeyword","loc":{"line":10,"column":0,"index":157},"pos":157,"name":"SyntaxError","message":"Unexpected keyword 'function'. (10:0)","stack":"SyntaxError: Unexpected keyword 'function'. (10:0)\n at instantiate (E:\GProjects\UI\node_modules\.pnpm\@babel+parser@7.21.2\node_modules\@babel\parser\lib\index.js:64:32)\n at constructor

Stylelint Version

15.2.0

vscode-stylelint Version

1.2.4

Node.js Version

16.5.1

Operating System

windows11

Windows Subsystem for Linux

No response

Code of Conduct

  • I agree to follow vscode-stylelint's Code of Conduct

@orta Excuse me, what more information do I need?

I have the same problem. Hope I can help clarify: the issue is that it's running the linter and checking for valid syntax on every keystroke.

That means when I'm half way through writing a single line of code, I'm already getting 3 toast prompts about invalid syntax. If it would just wait for me to finish typing, there would be no problem.

Another idea that would help this issue would be the ability to only run the linting on file save, rather than on every keystroke.

// Just typing const it throws an error
const
// Also throwing an error after getting through the variable name
const myVar
// Still throwing errors
const myVar = 
// Finally silent
const myVar = {};

Here's an example of the error toasts showing up for me:

Screen Shot 2023-05-04 at 12 28 38 AM copy