-
Notifications
You must be signed in to change notification settings - Fork 312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ESLintを最新にしてFlat Configにする #2560
base: main
Are you sure you want to change the base?
Conversation
🚀 プレビュー用ページを作成しました 🚀 更新時点でのコミットハッシュ: |
おーーーーー!!!!!! お待ちしていました!!! @sevenc-nanashi さんもアサインさせていただきました!
これって変更しなくてもCIはエラーを出さない感じでしょうか? 👀 でもちょっと修正は厄介なやつもある気がするので、僕とか @sevenc-nanashi さんとかが直すのが良いかも?(もちろん @MT224244 さんでも!!) |
全lintエラーを解決するPRを作ってmainブランチに向けて投げました!! マージされたあとにmainブランチマージすればlintエラーは消えるはず・・・!! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no-empty-object-type
オフにした時のメリット(vuex.tsのコメントがなくなる程度)が小さすぎるのでオンにした方がいいと思います。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここまで来るとjiti入れた方が良さそう(どういう事情で入れられてないのかな)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jitiはDiscordで話題に出たことあって、依存増やすほどなんだろうかみたいなコメントをしたことがあります!
https://discord.com/channels/879570910208733277/893889888208977960/1328201417760182383
でも今回のPRを見て、たしかに恩恵ありそうに感じたのでjitiに依存しても良いかもと感じました!
ただまあ恩恵あるのがeslintくらいな気がして若干迷いどころなので、このままでもOKだとも感じます。
よく考えてみると、確かにオフにする意味があまりない気がしてきました…。 |
これ、productionでだけ条件が変わる系のは全部排除して条件揃えてしまっても良い気がしますね!! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ほぼLGTMです!!
ありがとうございます!!!
{ | ||
name: "voicevox/defaults/linterOptions", | ||
linterOptions: { | ||
reportUnusedDisableDirectives: false, | ||
}, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
野望としてTODOを書いても良いかも
{ | |
name: "voicevox/defaults/linterOptions", | |
linterOptions: { | |
reportUnusedDisableDirectives: false, | |
}, | |
}, | |
// TODO: いずれは有効化する | |
{ | |
name: "voicevox/defaults/linterOptions", | |
linterOptions: { | |
reportUnusedDisableDirectives: false, | |
}, | |
}, |
import vueParser from "vue-eslint-parser"; | ||
import vuePlugin from "eslint-plugin-vue"; | ||
import vuePrettierConfig from "@vue/eslint-config-prettier"; | ||
import { | ||
defineConfigWithVueTs, | ||
vueTsConfigs, | ||
} from "@vue/eslint-config-typescript"; | ||
import { | ||
configs as tseslintConfigs, | ||
parser as typescriptParser, | ||
} from "typescript-eslint"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
整理されて消えたのかもなのですが、一応確認まで・・・!
以前あった
- "@vue/typescript/recommended"
- "@vue/prettier"
がなくなってそうですが、これは別のに含まれている感じでしょうか? 👀
"*.config.*", | ||
"src/**/*.{js,ts,vue}", | ||
"tests/**/*.{js,ts,mts,vue}", | ||
"build/**/*.{js,ts,vue}", | ||
"tools/**/*.{js,ts,mts}", | ||
".storybook/**/*.{js,ts,vue}", | ||
"eslint-plugin/**/*.{js,mjs,ts,mts}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ちなみにこれって
"*.config.*", | |
"src/**/*.{js,ts,vue}", | |
"tests/**/*.{js,ts,mts,vue}", | |
"build/**/*.{js,ts,vue}", | |
"tools/**/*.{js,ts,mts}", | |
".storybook/**/*.{js,ts,vue}", | |
"eslint-plugin/**/*.{js,mjs,ts,mts}", | |
"**/*.{js,mjs,ts,mts,vue}", |
でも行けたりしませんかね・・・?
追加絶対忘れるので、サボれるならこっちのが嬉しいな~~みたいな。
まああるいはtargetExtentions = "{js,mjs,ts,mts,vue}"
みたいなconst定義して、全部に付けちゃうとか!!
configs as tseslintConfigs, | ||
parser as typescriptParser, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここ表記ゆれしてるかも?
個人的にはtypescript
だとわかりやすい気がするのと、このファイル内は全部eslint
なので省けるはずというのと、まあこれくらいなら略さなくてもという気がするので、typescriptConfigs
・typescriptParser
が好みです!
const typeCheckedParserOptions = { | ||
project: ["./tsconfig.json"], | ||
tsconfigRootDir: __dirname, | ||
}; | ||
|
||
/** @type {Rules} */ | ||
const typeCheckedRules = { | ||
// Storeでよくasyncなしの関数を定義するので無効化 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
こちらもtypescript
ではなくtypeChecked
となってて表記揺れを感じるかもです!
vueParser
→vueParserOptions
なのでこちらもtypescriptParserOptions
・typescriptRules
とかが良いかも!
内容
ESLintに関連した依存関係を最新にし、FlatConfigにします。
fmtの実行と簡単に修正できそうな点は直しましたが、まだ以下の8件のエラーが残っています。
これらの修正はこのPRの範囲外だと思うので、そのままにしています。
pnpm lint
FlatConfig化以外の主な変更点
@typescript-eslint/no-var-requires
ルールの名前が変更されました。(->
@typescript-eslint/no-require-imports
)https://typescript-eslint.io/rules/no-var-requires/
@typescript-eslint/ban-types
このルールは廃止され、4つのルールに分割されました。
https://typescript-eslint.io/rules/ban-types/
no-restricted-types
no-empty-object-type
no-unsafe-function-type
no-wrapper-object-types
このPRでは
no-empty-object-type
のみoffにしてありますが、議論の余地はあるかと思います。Unused eslint-disable directive警告
v9から、 eslint-disable 系のルール無効化コメントが不要な場合にデフォルトで警告が出るようになったようです。
本来なら警告を出す方が良いと思います。
しかし、このプロジェクトには開発時はoffでproductionビルド時に警告を出すルールがあり、それを無効化するコメントが入っています。(no-console等)
このルールが開発時に不要だとして警告を出し続けてしまうため、無効にしています。
eslint-plugin/
ディレクトリの中身FlatConfig用に書き換えています。
また、このディレクトリもESLintの観測対象になっています。
ESLint Config Inspector
FlatConfigにしたことによって、こちらのツールが使用可能になりました。
どのルールがどのファイルに適用されているのか等の確認がしやすくなります。
https://eslint.org/docs/latest/use/configure/debug#use-the-config-inspector
npm scriptsに
lint:inspector
を追加しています。関連 Issue
close #2216
close #2250
スクリーンショット・動画など
その他
eslint.config.mjs
を.mts
化しようと思いましたが、jiti
の導入に関して何やらこのプロジェクトなりの事情がありそうだったので.mjs
のままにしています。