webpack-autoconf icon indicating copy to clipboard operation
webpack-autoconf copied to clipboard

Add Linters integration options (EsLint, StyleLint, Prettier, Lint-Staged + Husky)

Open JuanmaMenendez opened this issue 5 years ago • 5 comments

Add option to integrate

EsLint StyleLint Prettier Lint-Staged + Husky

Just with some basic standards configurations.

JuanmaMenendez avatar May 22 '19 02:05 JuanmaMenendez

Good idea, I will start working on prettier and eslint first because I think those are most widely used.

jakoblind avatar May 24 '19 06:05 jakoblind

would love some input on what default configs to use

jakoblind avatar Jul 06 '19 06:07 jakoblind

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"]
}

JuanmaMenendez avatar Jul 06 '19 14:07 JuanmaMenendez

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:

  1. npm i -D husky lint-staged

  2. npx mrm lint-staged

JuanmaMenendez avatar Jul 06 '19 14:07 JuanmaMenendez

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 :)

jakoblind avatar Jul 06 '19 17:07 jakoblind