But now it’s an archived project:
We are archiving Atom and all projects under the Atom organization for an official sunset on December 15, 2022.
I know that VS Code is the natural editor to migrate to but I wanted to take the opportunity to better learn VI editor and use it as my primary IDE.
Vim has a small footprint, low latency, fast startup, allows for more screen space, customizable and most importantly, once the muscle-memory has been ingrained, it’s nearly impossible to switch to something else.
John Biggs and Ryan Donovan
eslintis pretty great and can auto-format/fix much of your code according to your ESLint config.
prettieris a more powerful automatic formatter. One of the nice things about prettier is how opinionated it is. Unfortunately, it’s not opinionated enough and/or some opinions differ from my own. So after prettier formats the code, I start getting linting errors.
Kent C. Dodds
There are many ways to integrate Prettier and ESLint (see prettier introduction about it), and my preferred way is to format with Prettier and apply ESLint — fix after that for further formatting.
On Atom I have the Prettier Atom plugin with ESlint integration enabled to achieve it. So every time I format the code, Prettier is applied and then “eslint -fix” to further refactor the code to follow my desired rules.
As the first step install prettier-eslint-cli and make sure it’s callable from your path:
This is the executable that Neovim will call to format code (it’s just a CLI that apply prettier-eslint to the input file. The CLI options are compatible with standard prettier CLI).
“Lua” (pronounced LOO-ah) means “Moon” in Portuguese.
Then configure null-ls inside
.config/lvim/config.lua (if you are using vanilla Neovim you can read here on how to use Lua if you are not familiar with it).
The next step (that was necessary for Atom too) is to add some ESLint plugins to your project (adding them globally is not possible):
As the final step don’t forget to add your desired Prettier and ESlint rules to the project (to trigger the auto format and lint phase).
Keep in mind that is bad if Prettier and ESLint rules contradict themself.
You can do this with .eslintrc.json and .prettierrc.json o adding definitions to package.json.
With this configuration, I’m able to automatically format and lint my JS code on Neovim as I was doing on Atom with Prettier plugin with ESLint integration.
The solution is working well but could be much faster if a daemon is implemented instead of running a standalone process for every formatting.
To achieve this, forking and customizing prettied to use
prettier-eslint could be the solution, maybe the next time.