- install eslint and eslint-config
yarn add -D eslint @kobakazu0429/eslint-config-base
yarn add -D eslint @kobakazu0429/eslint-config-typescript
yarn add -D eslint @kobakazu0429/eslint-config-typescript-react
yarn add -D eslint @kobakazu0429/eslint-config-typescript-svelte
- create and edit
.eslintrc.js
.
$ touch .eslintrc.js
wget https://raw.githubusercontent.com/kobakazu0429/eslint-config/master/template.js -O .eslintrc.js
module.exports = {
extends: "@kobakazu0429/eslint-config-base",
// extends: "@kobakazu0429/eslint-config-typescript",
// extends: "@kobakazu0429/eslint-config-typescript-react",
// extends: "@kobakazu0429/eslint-config-typescript-svelte",
};
- add
lint
command to scripts filed intopackage.json
.
{
"lint": "npm run lint:eslint && npm run lint:prettier",
"lint:eslint": "eslint \"./{src,test}/**/*.{js,ts,tsx,svelte}\" --fix",
"lint:prettier": "prettier \"./{src,test}/**/*.{js,ts,tsx,svelte}\" --write"
}
$ yarn add -D eslint-plugin-import eslint-import-resolver-webpack
module.exports = {
settings: {
"import/resolver": {
webpack: {
config: "config/webpack.config.common.js",
},
},
},
};
FYI: eslint-plugin-import で TypeScript の import 問題を解決する - Qiita
module.exports = {
parserOptions: {
project: "./tsconfig.json",
tsconfigRootDir: __dirname,
},
};