New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Fix feature does not work #369
Comments
I seem to have a similar issue (I am trying stylelint for the first time with vscode)
|
An additional note:
As described in #25 (comment) |
@AbdealiJK Thanks for the key binding method
It actually try to fix something! But nothing to edit And I didn't know there should be autofix method appeared on editor. It shows lint warning or error, but don't provide autofix method |
@Front-line-dev the keybinding above is for css - I see your file is a .scss file. But either way ... This is just a workaround. A fix for this is really required. Seems like a Major issue |
I hit this problem in my project and narrowed it down to rules with Edit: This was with VSCode extension v1.2.2 and stylelint version 14.5.3 |
I have narrowed it down even further thanks to the hint by @justindm234. It seems to be an issue with the stylelint node api. import * as stylelint from "stylelint";
const cssContent = `.border-top-default{
border: 1px solid red;
margin: 0;
}`
const lintResult = await stylelint.lint({
code: cssContent,
fix: true,
});
console.log(lintResult.output); If my config does not contain any .border-top-default {
margin: 0;
border-top: : 1px solid red;
} But if such a disable exists, the output looks unexpected: [{
"source": "<input css rPadxH>",
"deprecations": [],
"invalidOptionWarnings": [],
"parseErrors": [],
"errored": false,
"warnings": []
}] It then looks pretty similar to the output without the Output without the fix option: [{
"source": "<input css qETqql>",
"deprecations": [],
"invalidOptionWarnings": [],
"parseErrors": [],
"errored": true,
"warnings": [
{
"line": 3,
"column": 5,
"endLine": 3,
"endColumn": 15,
"rule": "order/properties-order",
"severity": "error",
"text": "Expected \"margin\" to come before \"border-top\" (order/properties-order)"
}
]
}] So I think it is a problem of the stylelint itself. Example stylelint config: module.exports = {
customSyntax: "postcss-scss",
plugins: ["stylelint-declaration-strict-value", "stylelint-order"],
rules: {
"order/properties-order": [["margin", "border"], { unspecified: "bottom" }],
"scale-unlimited/declaration-strict-value": [
"/border/",
{ disableFix: true }, // this one breaks the autofix
],
},
}; |
…ue` stylelint#6542 fixes stylelint#6542 and bv that should also fix stylelint/vscode-stylelint#369 Issue: The API did not return the fixed css in `output` if any rule contained `ruleDisableFix`. I have removed the `ruleDisableFix` code, because it did not affect the code fixing itself and was assumingly wrongly used to change the content format of `output`. I have adjusted some tests to adapt to the changed behaviour and extended the test conditions to check that the returned code has the correct fixes applied. Issue was introduced in stylelint#5460
I have found the issue in stylelint itself and opened a pull request. |
How did you encounter this bug?
I try to fix code using vscode stylelint
Fix all auto-fixable problems
command on vscode"source.fixAll.stylelint": true
to settings.json and saveBoth method make no change.
Manually command
stylelint --fix
on terminal worksInstalled vscode-stylelint works fine except fix function. It tells where and what is problem using stylelint config file.
Code Snippet
No response
Stylelint Configuration
Extension Configuration
Actual Behaviour
Fix feature does not work.
It seems running something, but returns no edit (nothing to fix)
Expected Behaviour
The file should be fixed and saved using FormatOnSave or fix-all command
Logs
Stylelint Version
14.2.0
vscode-stylelint Version
1.2.1
Node.js Version
14.18.2
Operating System
macOS 12.1
Windows Subsystem for Linux
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: