stylelint can't automatically format on save
See original GitHub issueWhat steps are needed to reproduce the bug?
When I was using stylelint 13, it was working fine, but for some reason after I upgraded to version 14, the fix on save function didn’t work, but stylelint has correctly marked the error.
What Stylelint configuration is needed to reproduce the bug?
// stylelint.config.cjs
extends: [
'stylelint-config-standard-scss',
'stylelint-config-recommended-vue',
],
customSyntax: 'postcss-html',
overrides: [
{
files: ['**/*.{scss,css,sass}'],
customSyntax: 'postcss-scss',
},
],
plugins: [
'stylelint-scss',
'stylelint-order',
],
// package.json
"devDependencies": {
"@babel/core": "^7.19.6",
"@babel/eslint-parser": "^7.19.1",
"@types/node": "^18.11.8",
"@vitejs/plugin-vue": "^3.2.0",
"eslint": "^8.26.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-sort": "^2.4.0",
"eslint-plugin-vue": "^9.7.0",
"postcss": "^8.4.18",
"postcss-html": "^1.5.0",
"postcss-scss": "^4.0.5",
"prettier": "^2.6.0",
"prettier-plugin-tailwindcss": "^0.1.11",
"sass": "^1.55.0",
"stylelint": "^14.14.0",
"stylelint-config-recommended-vue": "^1.4.0",
"stylelint-config-standard-scss": "^6.0.0",
"stylelint-order": "^5.0.0",
"stylelint-scss": "^4.3.0",
"typescript": "^4.6.4",
"vite": "^3.2.0",
"vite-plugin-pages": "^0.27.1",
"vue-tsc": "^1.0.9"
}
// setting.json
{
"files.associations": {
"*.vue": "vue"
},
"editor.formatOnSave": false,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.fixAll.tslint": true,
"source.fixAll.stylelint": true,
},
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact"
],
"editor.cursorSmoothCaretAnimation": true,
"files.eol": "\n",
"editor.detectIndentation": false,
"editor.tabSize": 2,
"editor.quickSuggestions": {
"strings": true
},
"css.validate": false,
"less.validate": false,
"scss.validate": false,
"files.autoSaveDelay": 500,
"prettier.singleQuote": true,
"emmet.triggerExpansionOnTab": true,
"editor.snippetSuggestions": "top",
"terminal.integrated.defaultProfile.windows": "Git Bash",
"stylelint.snippet": [
"css",
"less",
"postcss",
"scss"
],
"stylelint.validate": [
"css",
"less",
"postcss",
"scss",
"html",
"javascript",
"vue-html",
"vue-postcss",
"sass",
"markdown",
"vue",
],
"[vue]": {
"editor.defaultFormatter": "octref.vetur"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"bracketPairColorizer.depreciation-notice": false,
"i18n-ally.localesPaths": [
"src/locales/lang",
"lang",
"src/locales",
"src/lang",
],
"i18n-ally.enabledParsers": ["js", "json"],
"i18n-ally.displayLanguage": "zh_cn",
"html.autoClosingTags": false,
}
How did you run Stylelint?
Just save code
Which version of Stylelint are you using?
14.14.0
What did you expect to happen?
I expect it would format the code automatically
What actually happened?
It didn’t format the code automatically
Does the bug relate to non-standard syntax?
No response
Proposal to fix the bug
No response
Issue Analytics
- State:
- Created a year ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Support autofix on autoSave · Issue #35 · stylelint/vscode ...
When creating an error in an scss or css file that can be auto fixed by vscode-stylelint (such as omitting a space in...
Read more >Stylelint VScode doesn't work - Stack Overflow
If you're getting started with stylelint for the first time, there are two key steps to enable it in Visual Studio Code:.
Read more >Options - Stylelint
Automatically fix, where possible, problems reported by rules. For CSS with standard syntax, Stylelint uses postcss-safe-parser to fix syntax errors. When using ...
Read more >How to Fix ESLint & StyleLint Errors Upon Save in VS Code
Complete the following steps to make Visual Studio Code fix any lint errors when a file is saved: Open the following file path:...
Read more >vscode-stylelint - Visual Studio Marketplace
Extension for Visual Studio Code - Official Stylelint extension for Visual ... all auto-fixable Stylelint errors will be fixed on save.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Oh. I made a typo, my setting is the same as yours.
OK, I get it, I’ll find out what the problem is,
Sorry and Thanks for your help.
Masafumi Koba @.***>於 2022年11月2日 週三,13:44寫道:
@ybiquitous Thanks for your help, please refer to the following answers:
Thank you very much.