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
object-curly-newline --fix erroneously removes comment #8484
Comments
Thanks for reporting this! We definitely don't want to remove comments via autofix. |
Thanks for triaging quickly. Just adding a few more cases that exhibit the same problem Before let a = {
/* comment */ foo: 'hello'
};
let b = {
foo: 'hello' /* comment */
}; After --fix both comments are removed let a = {foo: 'hello'};
let b = {foo: 'hello'}; |
FYI, I have a condidate fix at https://github.com/freshp86/eslint/commit/496568626008a44652d5e41aebc9295d64f92f97. Tested let a = {
/* comment */ foo: 'hello'
};
let b = {
foo: 'hello' /* comment */
};
let c = { /* comment */
foo: 'hello'
};
let d = {
/* comment */
} and it becomes let a = {/* comment */ foo: 'hello'};
let b = {foo: 'hello' /* comment */};
let c = { /* comment */
foo: 'hello'
};
let d = {/*comment*/}; which seems correct. If that seems promising I can look on how to add proper tests and send a PR (have not contributed to ESLint before). Having said that, when I use my complete config object (not posted in this bug), I end up with the comments removed again. I'll keep investigating that separately, since that seems to be caused by some other rule. |
References rule object-curly-newline. Avoid fixing line breaks when the token after opening brace is a comment or token before closing brace is a comment.
ESLint Version: v3.19.0
Node Version: v7.9.0
Before
After invoking ESLint with the --fix flag the file is modified as follows
What did you expect to happen?
The comment should have been preserved.
What actually happened?
The comment was removed.
The text was updated successfully, but these errors were encountered: