-
-
Notifications
You must be signed in to change notification settings - Fork 942
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 disableFix secondary option #5460
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kuangrs Thanks for the pull request.
Can you add a test or two to standalone-fix.test.js
, e.g. showing:
- one rule being disabled, e.g. indentation
- two rules being disabled
- one rule being disabled and another still autofixing
Co-authored-by: Richard Hallows <jeddy3@users.noreply.github.com>
@jeddy3 it's ok, pls review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding tests.
I've requested we tweak the tests a bit to focus more on the CSS rather than the violations.
fix: true, | ||
}); | ||
|
||
expect(JSON.parse(result.output)[0].errored).toBe(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than check for errors, can we instead check if the output itself has been changed (like the tests at the beginning of the file), e.g.:
const code = " a { color: red; }";
const result = await standalone({
code,
config: {
rules: {
indentation: [
2,
{
disableFix: true,
},
],
},
},
fix: true,
});
expect(result.output).toBe(code);
And:
const code = " a { COLOR: red; }";
const result = await standalone({
code,
config: {
rules: {
indentation: [
2,
{
disableFix: true,
},
],
'property-case': ['lower'],
},
},
fix: true,
});
expect(result.output).toBe(" a { color: red; }");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jeddy3 When we use disableFix
, what we expect is that if there is an error in the check, the output still contains the error message instead of the initial code, so that we can find it easily.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kuangrs Sorry about this slipping off the radar.
LGTM.
@jeddy3 thanks for your approval, Will it have a chance in Release14.0.0? hope my company's project can use this option earlier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[suggestion] How about refactoring to use some()
instead of filter()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems the added logic has no problems. 👍🏼
Thank you!
Yes, it'll make it into |
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
Co-authored-by: Masafumi Koba <473530+ybiquitous@users.noreply.github.com>
@kuangrs Can you run |
done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. LGTM 👍🏼
|
…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
Closes #5431
no