eslint
ESLint - Pluggable JavaScript linter
関連
gts
globals
disable-hogehoge は要らなくて列挙すればよい
Configuring ESLint - ESLint - Pluggable JavaScript linter
/* global {...} */ を書く
.eslintrc に "globals": { ... } を書く
一部のファイルだけ特定のルールを無効にしたい
Disabling Rules Only for a Group of Files / Configuring ESLint - ESLint - Pluggable JavaScript linter
code:overrides.json
{
"rules": {...},
"overrides": [
{
"files": "*-test.js","*.spec.js",
"rules": {
"no-unused-expressions": "off"
}
},
{
"files": "webpack.config.js",
"rules": {
"node/no-unpublished-require": "off"
}
}
]
}
eslint-plugin-compat
eslint-plugin-compat - npm
ブラウザ互換性に基づいて使えないメソッドなど出してくれる
しかし Array.prototype.find など通常インスタンスメソッドで呼び出すやつは検知されない(静的解析がむつかしい)
Didn't pick up Array.find incompatibility for IE10 · Issue #93 · amilajack/eslint-plugin-compat
eslint-typescript
no-declare
Declaration Merging · TypeScript を意図していても怒られる、諦めて line や range で disable する
no-redeclare error for declare namespace · Issue #60 · typescript-eslint/typescript-eslint
no-unsed-vars
code:.eslintrc
"@typescript-eslint/no-unused-vars": [
"warn",
{
"vars": "local",
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_"
}
]
0:0 error Parsing error: Cannot read property 'map' of undefined
TypeError: Cannot read property 'map' of undefined · Issue #1653 · typescript-eslint/typescript-eslint
これが出る時はだいたい TypeScript の更新に @typescript-eslint が追いついてない状態
👉 2020/8/25 Parsing error: Cannot read property 'map' of undefined
no-floating-promises
no-floating-promises | TypeScript ESLint
code:rule.json
"@typescript-eslint/no-floating-promises": [
"error",
{
"ignoreIIFE": true
}
]
#npm #TypeScript #JavaScript