Add .eslintrc.json to support use of Prettier code formatter#19296
Add .eslintrc.json to support use of Prettier code formatter#19296nathansobo merged 1 commit intomasterfrom
Conversation
|
I'd recommend adding a compatible version of |
|
@Arcanemagus the plugin I'm using bundles its own version of |
|
That's cool! I'm going to try it! As a followup, it would be cool to add first-class support for prettier (so it can be executed across all codebase by running This way we avoid files going back and forth in codestyle depending on whether the committer is using prettier |
On other projects, I've used the Prettier code formatter via the official Atom package. It saves a lot of time hassling with code formatting, and not having it enabled for Atom is causing me to waste a lot of time fixing linting errors.
On Atom, we're using JS Standard Style, which conflicts with the Prettier's default formatting. This is okay, because the Prettier package can run
eslint --fixautomatically after performing its own formatting, but it requires a bit of configuration. To support it, I've added an.eslintrc.jsonfile to the root of the module. This needs to pull in the shared ES Lint configurations associated with Standard Style, but since we avoid installing dev dependencies in our rootpackage.json, I've added those linting configurations toscript/package.jsonand am including them with an explicit path.With this change, you can now get nice auto-formatting when you install Prettier Atom and enable ES Lint support in the package settings.
We have a lot of files that aren't formatted with prettier, so this might generate a bit of churn initially, but I think the productivity savings will be worth it in the long run.
One particular issue is that Atom's source files don't have a consistent style with respect to spaces inside of curly brackets. Prettier defaults to having spaces (
{ foo: "bar" }, but standard doesn't seem to care, and we have examples of both styles in this repo. It's possible to override the default and remove spaces, but it's more typical style to include these spaces, so I'm going to leave the current default in place.cc @atom/maintainers