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
--fix isn't handling "',' should be placed last comma-style" errors #6941
Comments
I don't mind giving this a try if someone is willing to mentor me. |
Let's see what the team thinks. Personally, I'm worried about problems being caused by having to possibly re-align indentation, as well as handling possible conflicts with |
Is it not possible to re-align indentation with respect to config ?
To be honest I'm just looking for some solution that would take arbitrary code and reformat it comply with ESLint config. I was going after esformatter but was pointed out that just providing I don't actually know if that is out of scope for ESLint or not. Also maybe doing it via plugin is more appropriate option ? If possible at all. |
Is this issue asking to make Just to brainstorm a lil bit, what if we during the fix, replace the comma with a space (spot where we are removing the comma) and simply add the comma at the spot its needed. Anything i am missing or could go wrong with this approach? |
Yes |
👍 Such change of comma's position does not change the meaning of code. |
I think i have a PR which works. I will send it out to collect some feedback on it. |
here is something #6957 i had in mind. |
@eslint/eslint-team Needs some eyes/thoughts here.
|
I'm 👍 on accepting this issue. |
👍 on accepting. |
I'll remove my 👎. We just need a champion now (@gyandeeps want to champion?). |
I'm a bit worried about this - trying to autofix across lines can be tricky given the current capabilities. For instance, what would happen here? export var obj =
{ a: 1. // Do somerhing
, b: 2
} I like the idea, I just want to make sure it can be done safely. |
Yeah, this seems like one that just needs really really clear edge case tests. |
@nzakas I was able to cover your specific use case but I dont think we can safely solve all scenarios for comments. |
I dont think we can accept that worst-case scenario, comments are important. If there's a comment in there, and we can't keep it, we just should do the fix. Also, what happens when the property value is a function? Does it still work? Or if there's a concise method? Or shorthand assignment? We really need a lot more tests to consider releasing this into the wild. |
I guess then it will be difficult to get the fix done. Can we just do the fix if their are no comments else dont do fix? guys, feel free to suggest some cases so that i can include them in tests. Because i might miss a lot of them based on the variety. |
Ah, there was the discussion about comments. |
Yeah, our general approach is to do fixes only when it's 100% safe. If there are safe cases that can be fixed, we can definitely do those. |
What version of ESLint are you using? - v3.3.1
What parser (default, Babel-ESLint, etc.) are you using? - babel-eslint
Please show your full configuration:
Standar is defined here https://github.com/feross/eslint-config-standard/blob/master/eslintrc.json
What did you do? Please include the actual source code causing the issue.
What did you expect to happen?
ESLint should fix comma style by placing at the end:
What actually happened? Please include the actual, raw output from ESLint.
eslint --fix ./example.js /Users/gozala/Projects/browser.html/example.js 3:4 error ',' should be placed last comma-style
The text was updated successfully, but these errors were encountered: