ESLint
ESLint - Pluggable JavaScript linter
JSのLinter
怒られたときはルールを参照できるのが良い
ルールの例
.eslintrcに設定を記述する
設定項目の詳細な説明:Configuring ESLint - ESLint - Pluggable JavaScript linter
env https://eslint.org/docs/user-guide/configuring#specifying-environments
An environment defines global variables that are predefined.
ESLint 最初の一歩 - Qiitaに具体的にどうなるのか説明がある
nodeを設定すると
Node.js 固有の変数や構文 (requireや特殊なトップレベル スコープ等) が定義されます
bowserを設定すると
DOM API (documentやonload等) が定義されます
plugin ESLintのplugin
settings https://eslint.org/docs/user-guide/configuring#adding-shared-settings
You can add settings object to ESLint configuration file and it will be supplied to every rule that will be executed. This may be useful if you are adding custom rules and want them to have access to the same information and be easily configurable.
intelliJ IDEAで有効にする
settings > ESlint > enable
.eslintrcをIntelijに適用してもリフォーマットしたときにスペースの扱いが異なることがあるがoption+enterをするしかない
How to make WebStorm format code according to eslint? - Stack Overflow
https://youtrack.jetbrains.com/oauth?state=%2Fissue%2FWEB-19350
設定例
頑張らないeslint - hokaccha hamalog v3(2018/2/26)
ESLintを活用した漸進的リファクタリングのすすめ - ドワンゴN予備校エンジニアブログ(2019/12/03)
webpackでアラートを出す
pluginがなければ作る
AST explorer
@typescript-eslintによってTypeScriptにも正式対応した
@typescript-eslint ことはじめ - teppeis blog(2019/05/01)
最近の@typescript-eslint/eslint-plugin, Prettierのアップデートによって、正式にTypeScript 3.4対応されました。一通り普通に動いてる感じ。
サポートバージョンは随時上がっている
#静的解析