webpack-autoconf
webpack-autoconf copied to clipboard
Add Linters integration options (EsLint, StyleLint, Prettier, Lint-Staged + Husky)
Add option to integrate
EsLint StyleLint Prettier Lint-Staged + Husky
Just with some basic standards configurations.
Good idea, I will start working on prettier and eslint first because I think those are most widely used.
would love some input on what default configs to use
It is a good Idea to use the recommended configurations
To integrate and configure EsLint and Prettier
1- npm install eslint --save-dev
2- npm install prettier --save-dev --save-exact
3- Just follow these two steps https://prettier.io/docs/en/integrating-with-linters.html#recommended-configuration
3.1 npm i eslint-config-prettier eslint-plugin-prettier –save-dev
3.2 In .eslintrc.js
{
"extends": ["plugin:prettier/recommended"]
}
Note: if you want to use as well the ESLint AirBNB configuration just install it and add it to the configuration file like this:
extends: ['airbnb-base', 'plugin:prettier/recommended'],
To integrate and configure StyleLint and Prettier
1- npm install stylelint --save-dev
2- npm install stylelint-config-recommended --save-dev
3- Just follow these two steps https://prettier.io/docs/en/integrating-with-linters.html#recommended-configuration-2
3.1 npm i stylelint-config-prettier stylelint-prettier -–save-dev
3.2 In .stylelintrc
{
"extends": ["stylelint-prettier/recommended"]
}
To integrate and configure Lint-Staged and Husky with ESLint, StyleLint and Prettier
To get the different lint --fix
to be executed automatically in a pre-commit hook you have to configure husky and lint-sataged. And previously configured the package.json the eslint, stylint and prettier (as you can do in my previous comment)
Gladly thanks to https://github.com/sapegin/mrm this is very easy to do, just:
-
npm i -D husky lint-staged
-
npx mrm lint-staged
awesome! thanks a lot @JuanmaMenendez . will add this gradually starting with eslint/prettier. going to need to rethink the UI to be able to squeeze in more options :)