Closed clyfish closed 4 years ago
Hey @clyfish, I think we jumped the gun. Did you test your change? As I went to write tests for it, I realized your change isn't correct. I'm going to revert it for now.
Do you have an example of a file that gets emptied when you run autoFix?
I found the file gets emptied when it's a less or scss file. It's ok with css files.
a.less
a
b.scss
a {
}
b
https://github.com/stylelint/stylelint/issues/4452 I've created an issue for stylelint.
Before they fix the bug, we can have a workaround.
output
to empty stringoutput
is updated to the fixed code, it can rarely be an empty string.So, when output
is empty string, stylelint doesn't done its job.
What a pity that stylelint
use output
for error message and fixed code.
Hey @clyfish, I had a chance to try out a couple of your examples and I think I see the right way to fix this, or, at least, prevent it from clearing the file. I'll have a fix in the next day or so... have family things what with Thanksgiving.
I just cut a new version, v1.0.3, that I think will avoid clearing the file if there's a syntax error. Let me know if you have any trouble with it.
Plan A: if (result.ignored || output === "") {
Plan B: if (errored || result.ignored || output === "") {
I think plan A is better than plan B.
When there's a syntax error in a css
file, it gets fixed with plan A, but not with plan B. (errored === true
, output !== ""
)
When there's a syntax error in a less
file, output
is always empty, so it doesn't get fixed with plan A and plan B. (errored = true
, output === ""
)
https://github.com/stylelint/stylelint/issues/4452#issuecomment-559436082
For CSS we use postcss-safe-parser, which could tolerate syntax errors. There is no such syntax for Less.
Ah, you're right. I've updated the code and cut a new version.
Thank you for the coc-stylelintplus
tool.
Please update package.json
and yarn.lock
in coc-stylelintplus
.
coc.nvim
version in package.json
should set to 0.0.74
or neoclide/coc.nvim#9edc0ed
(release branch)coc.nvim
and stylelint-lsp
version in yarn.lock
should be updated.I use vim-plug
to install coc-stylelintplus
, my nvim config:
Plug 'bmatcuk/coc-stylelintplus', {'do': 'yarn install --frozen-lockfile'}
I've updated coc-stylelintplus. You could remove the --frozen-lockfile
part to accomplish the same thing in the future.
I've created a PR. #3