atom / language-javascript

JavaScript language package for Atom
Other
194 stars 236 forks source link

Option to add trailing commas (and possibility of tieing behavior in to linters) #674

Closed brettz9 closed 4 years ago

brettz9 commented 4 years ago

Not sure if this belongs here, but offering as it is Atom-related, and somewhat specific to JavaScript...

Summary

Trailing comma usage has become popular, especially as JS has increased its support (e.g., in function parameters).

However, while editing in Atom, there has been no way to configure this (AFAIAA).

Motivation

When working in trailing-comma enforcing projects, it can be troublesome to have to add a comma after each array/object addition and line break. Even if there is a linter fix available, it is nice to have this set beforehand so that Atom's linter doesn't distract in showing errors (and though there are some tools which auto-lint during editing, some of us find it too dangerous to auto-enable when buggy fixers can corrupt the code, potentially going unnoticed if one is not careful reviewing before adding to version control).

Describe alternatives you've considered

language-javascript shows no such options for trailing commas.

I would like it even better for there to be an Atom package which, like .editorconfig auto-edited indents and trailiing commas, but based on one's eslint settings (and potentially aware of nested scopes, e.g., JS within HTML files), but besides this presumably being beyond the project scope of language-javascript, I was hoping that other packages such as this might be more easily added later if they could just auto-toggle language-javascript's settings on the fly.

Thanks!

Alexey-T commented 4 years ago

it must be some "linter" plugin exists for JS, which has the option "do lint on file saving". so it's not work of Atom itself.

brettz9 commented 4 years ago

But my point is that I don't want to do the linting on file saving, but auto-add any (context-aware) trailing comma and indents, as soon as one makes a line break. If not this package, do you know how a package could tweak the core behavior so this would happen?

Alexey-T commented 4 years ago

I don't know, i think it must be a linter anyway, linter with simple settings: add trailing commas, indents

brettz9 commented 4 years ago

Ok, thanks!