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 a --fix option for dot-notation #7014
Comments
Sounds very good to me. |
Is there a general guideline for what a fixer should do if comments interfere? That seems to be a common problem. My preference would be to not automatically fix code that involves comments. It doesn't hurt anyone to require human intervention in those rare cases. |
@pmcelhaney if i understood your question correctly, this might be related: #5958 (comment) |
Seems reasonable. 👍 To echo what @vitorbal said, if we can't be 100% correct with the fix, we shouldn't attempt it. So in the case of comments, we should just skip that. |
👍 from me, now we just need a champion. |
I'm using Node v6.4.0 and ESLint v3.4.0.
It would be useful to have an autofix option for the
dot-notation
rule. The rule currently reports cases where bracket notation can be safely replaced by dot notation; the fixer would go ahead and make that replacement.The fixer could also replace invalid dot-notations (e.g. keywords when the
{allowKeywords: false}
option is set) with the bracket-notation counterpart.If the brackets contain comments, I'm unsure of what the fixer should do. I suppose one option would be to extract the comment out:
...but that doesn't look very good. I think comments within bracketed properties are fairly rare anyway, so this might be okay. (Alternatively, we could refrain from fixing cases where the brackets contain a comment, but in that case it seems more consistent to not report those cases as errors either.)
I would be willing to add this if the issue is accepted.
edit: Added a section about fixing from dot-notation to bracket-notation with keywords.
edit: Added a section about what to do with comments.
The text was updated successfully, but these errors were encountered: