-
-
Notifications
You must be signed in to change notification settings - Fork 946
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
Do not try to write back ignored files after --fix. #2652
Conversation
Thank you for a fix! Would you mind adding test for this issue, please? You can add it to |
@hudochenkov Looks like fix.test.js contains tests for lib version of stylelint ( I definitely need help with tests. |
Added a test. Not sure I did it right, but at least linters are okay, and it's green with the proposed fix code and red with the old one |
Thank you for thinking outside the box for test :) I came up with this test: it("doesn't write to ignored file", () => {
return stylelint.lint({
files: [stylesheetPath],
config: {
ignoreFiles: stylesheetPath,
rules: {
"at-rule-name-case": "lower",
"comment-empty-line-before": "always",
"comment-no-empty": true,
},
},
fix: true,
}).then(() => {
return pify(fs.readFile)(stylesheetPath, "utf8").then((newFile) => {
return pify(fs.readFile)(path.join(__dirname, "stylesheet.css"), "utf8").then((oldFile) => {
expect(newFile).toBe(oldFile)
})
})
})
}) I still don't understand promises, so this why it's ugly as hell. If someone could improve code it would be much appreciated :) |
@hudochenkov promises is very ugly if your don't use |
@hudochenkov Actually, I've almost copy-pasted the code chunk from /~https://github.com/stylelint/stylelint/blob/master/system-tests/004/004.test.js#L11-L14 |
@hudochenkov Is this good to go in for |
@jeddy3 it's good to merge, if test looks ok.
Test in this PR looks quite complicated. While my version might be improved. I didn't ask to use my test, because not sure if they are better than @subzey's test. If you accept author's test, then feel free to merge. |
Let's merge and then I'll drop in your test, if only because it's more consistent with the other tests in the file. |
Changelog:
|
Fixes issue #2627
Accessing
opts.syntax
throws if the file is ignored. I wonder why Flow didn't catch that?