vscode-stylelint: [Bug]: Extension starts, but does not show stylelint errors
How did you encounter this bug?
Upgraded to latest versions of stylelint and vscode stylelint and found that the vscode extension no longer shows errors
Code Snippet
code with obvious stylelint issues:
const Button = styled.a`
padding: 3px 25px;
color: ${ ({ theme }) => theme.colors.black };
font-family: ${ ({ theme }) => `${ theme.fonts.InterRegular }` };
font-size: 14px;
display: inline-block;
text-align: center;
text-decoration: none;
background: ${ ({ theme }) => theme.colors.flamingo[2] };
border: 1px solid ${ ({ theme }) => theme.colors.flamingo[2] };
border-radius: 45px;
transition: all 0.25s;
cursor: pointer;
`
Stylelint Configuration
const propertyOrder = require('./property-order')
module.exports = {
customSyntax: '@stylelint/postcss-css-in-js',
plugins: [
'stylelint-order',
],
extends: [
'stylelint-config-recommended',
'stylelint-config-styled-components',
'stylelint-config-standard',
],
rules: {
// Disable these so stylelint autofix doesn't break template literals containing theme breakpoints
'media-feature-range-operator-space-after': null,
'media-feature-range-operator-space-before': null,
// Disable so not to conflict with eslint indentation rules
indentation: null,
'property-no-unknown': [
true,
{
ignoreProperties: [
// CSS Modules composition
// https://github.com/css-modules/css-modules#composition
'composes',
],
},
],
'selector-pseudo-class-no-unknown': [
true,
{
ignorePseudoClasses: [
// CSS Modules :global scope
// https://github.com/css-modules/css-modules#exceptions
'global',
'local',
],
},
],
// Opinionated rule
'string-quotes': 'single',
// https://github.com/hudochenkov/stylelint-order/blob/master/rules/order/README.md
'order/order': [
'custom-properties',
'dollar-variables',
'declarations',
'at-rules',
'rules',
],
// https://github.com/hudochenkov/stylelint-order/blob/master/rules/properties-order/README.md
'order/properties-order': [
propertyOrder,
{ unspecified: 'bottomAlphabetical' }
]
},
}
Extension Configuration
{
"stylelint.validate": [
"postcss",
"javascript",
"javascriptreact",
"js"
],
"editor.codeActionsOnSave": {
"source.fixAll.stylelint": true
},
"css.validate": false,
"less.validate": false,
"scss.validate": false,
}
Actual Behaviour
I can see in the output that the extension is starting:
[Info - 9:20:37 AM] [language-server] Registering module | module: "auto-fix"
[Info - 9:20:37 AM] [language-server] Module registered | module: "auto-fix"
[Info - 9:20:37 AM] [language-server] Registering module | module: "code-action"
[Info - 9:20:37 AM] [language-server] Module registered | module: "code-action"
[Info - 9:20:37 AM] [language-server] Registering module | module: "completion"
[Info - 9:20:37 AM] [language-server] Module registered | module: "completion"
[Info - 9:20:37 AM] [language-server] Registering module | module: "formatter"
[Info - 9:20:37 AM] [language-server] Module registered | module: "formatter"
[Info - 9:20:37 AM] [language-server] Registering module | module: "old-stylelint-warning"
[Info - 9:20:37 AM] [language-server] Module registered | module: "old-stylelint-warning"
[Info - 9:20:37 AM] [language-server] Registering module | module: "validator"
[Info - 9:20:37 AM] [language-server] Module registered | module: "validator"
[Info - 9:20:37 AM] [language-server] Starting language server
[Info - 9:20:37 AM] [language-server] Registering handlers
[Info - 9:20:37 AM] [language-server] Handlers registered
[Info - 9:20:37 AM] [language-server] Language server started
But, when I go to a file and save with known issues, no errors are presented and nothing in the stylelint output is shown.
Expected Behaviour
Within the stylelint output, I should see that styleint is running against the file that was saved
Logs
Logs should be showing that the file that was saved is having stylelint run against it, but it shows no output
Stylelint Version
v14.0.2
vscode-stylelint Version
v1.2.1
Node.js Version
v14.17.0
Operating System
macOS 11.4
Windows Subsystem for Linux
No response
Code of Conduct
- I agree to follow vscode-stylelint’s Code of Conduct
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 8
- Comments: 19 (1 by maintainers)
In my case just add the following to your settings.json of VSCode:
More info (I use the plugin
stylelint-scssinstead ofpostcss-scss). Make sure you use stylelint at version >= 14.Update: Does still not report all problems. But it’s maybe another issue.
The upgrade solution doesn’t work. I’m also seeing errors from stylelint on the command line but not through this extension.
Configuration: stylelint: 14.4.0 vscode-stylelint: 1.2.1 node: 14.17.6 operating system: macOS 12.2 config in package.json:
I want to finalize how to make it works for styled-components with typescript:
stylelint.config.js
VSCode config:
But I’m still getting error:
EDIT: Please disregard; vscode-stylelint was working after all. The issues I was testing it against were formatting ones, which I had not realized were deprecated in v15 in favor of using Prettier or similar.
@jeddy3 Thank you for the reply.
————————
Ditto for vscode-stylelint not highlighting or fixing errors on my Macbook Pro. I see plenty of CSS issues when I run
npx stylelint "**/*.css".All packages are current. I am running VS Code v1.75.1, Stylelint extension v1.2.3.
Here are the relevant sections of my configuration files:
package.json
settings.json
.stylelintrc.json
Per the troubleshooting instructions, I ran
NODE_ENV=development code. When I opened a CSS file with known errors and reloaded VS Code, the Stylelint extension produced this output: stylelint-output.txt. I don’t see any obvious errors.Any help is appreciated. Thank you.
@jeffweim-hm I’m currently using the solution of downgrading
vscode-stylelinttov0.87.6(until I fix some dependencies problems to upgradestylelint)You shouldn’t upgrade stylelint AND downgrade vscode-stylelint. Choose either one of the solutions.
I am also facing this issue in my macbook pro. Following is my settings.
.vscode/settings.json
.stylelintrc
package.json
Stylelint installed in VScode
Same issue with Nuxt,
stylelint 14.1.0andvscode-stylelint v1.2.2Found the workaround :
This problem is due to one of the vscode updates in the last weeks. It upgraded
vscode-stylelintfromv0.xtov1.x, which contains a breaking change if you usestylelint < 14: https://github.com/stylelint/vscode-stylelint#migrating-from-vscode-stylelint-0xstylelint-13xSolutions: You can upgrade
stylelintto the latest version OR downgradevscode-stylelinttov0.87.6(latest compatible version before breaking change).