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
Add stylelint-disable commands support to autofix #2643
Comments
I think it is bug, should be respected by default. |
I think it also ignore |
I know why I have no idea what to do with |
@hudochenkov maybe create util |
I came up to another problem. Disabled ranges assigned before file linted/fixed. For rules which altered lines (change empty lines, add line endings), disabled ranges might be incorrect after few fixes. Even after fixes within one rule. This problem affects every rule. Because if user has rule with fixing which changes lines, then every rule after this rule will have incorrect disabled ranges. |
@hudochenkov Thanks for digging deeper. I suspect there are going to be some significant hurdles to overcome with this issue. As such, I suggest we push on with |
Agree. We should not close this issue, to not forget about this problem.
I think we should add a note somewhere about this caveat. And suggested strategy: if user is using |
@hudochenkov can we learn how it does |
@evilebottnawi of course we can. But I have a feeling that it won't help us, because of differences in architecture and approaches. Also I remember something from discussions, when we were discussing how to do autofixing. ESLint make multiple runs until everything is fixed and violations verified. And it also has some ranges for autofixing or something, that recalculated constantly. I might be mistaken about the last one. |
Any updates on this? Are you still looking for some help here? |
@zkuzmic Yes, definitely. The issue has been labeled as "help wanted" for a while, but I don't think anyone has had time to pick it up as it's quite gnarly. Is it something you can help with? |
I'd be happy to look into it at least! |
Stylelint also fix-breaks calc() functions as it removes units of values that need it (see stylelint/stylelint#3037). It also auto-fixes it (and hence breaks it then): stylelint/stylelint#2643, so we have to disable the whole rule for now. In order to be able to add comments to the stylelint config I moved it to a .js file.
It works but it should also fix styles before |
Respecting these comments is precisely what requires building the new suggested API to provides a fixer callback instead of running the fixing logic directly in the rule, so that the fixing logic could be run only when rules are not ignored. |
This issue is older than one month. Please ask before opening a pull request, as it may no longer be relevant. |
Iv refactored a rule to do just that.
is this issue ready to implement? |
@ybiquitous is this issue ready to be implemented? |
Yes, I think creating a PoC has no problem. We could evaluate this feature by the PoC. |
how to resolve this problem |
Sorry to be insistent, but I won't make the same mistake thrice. |
Yes, this is ready to implement. To clarify this problem, I just created a reproducible demo: a {
/* stylelint-disable */
width: 0px;
/* stylelint-enable */
height: 0px;
/* ^^ this "px" unit should be removed by autofix, but it isn't actually.
*/
} // .stylelintrc.json
{
"rules": {
"length-zero-no-unit": true
}
} |
I have a file that has
/* stylelint-disable */
/* stylelint-enable */
wrapped around it but when using--fix
it tries to format this file and breaks it quite bad.--fix
Before
After
A few of the issues:
;;
onL38
;
onL92
(I imagine this is where the;;
comes fromConfig
The config is pretty huge but i don't think it's the problem here
7.11.0
CLI through
lint-staged
The text was updated successfully, but these errors were encountered: