ESLint
https://gyazo.com/f57fbb44b9395e3ee1e4bf4547958ae1
JavaScript のための静的検証ツール
コードを実行する前に明らかなバグを見つける
括弧やスペースの使い方などのスタイルを統一したりする
JavaScriptのLinters
導入
ESLint追加
code:add.sh
yarn add -D eslint
// TypeScript
yarn add -D @typescript-eslint/parser @typescript-eslint/eslint-plugin
Prettierも一緒に
code:add.sh
yarn add -D prettier eslint-config-prettier eslint-plugin-prettier
.eslintrc.jsonの設定
package.jsonにも書ける
code:package.json
"scripts":{
"lint": "eslint . --ext .js,.jsx,.ts,.tsx", // たまに忘れて勘違いするので注意
"lint:fix": "yarn lint --fix"
}
parser
ES2015 ES6とか使う際に必要
parser: babel-eslint
参考記事
💯ESLint 最初の一歩
Quramy/eslint-plugin-tutorial: A tutorial/template repository to explain how to create your eslint plugins
https://blog.ojisan.io/eslint-prettier