-
Notifications
You must be signed in to change notification settings - Fork 15
Conversation
@@ -18,19 +18,19 @@ commands: | |||
# run tests! | |||
- run: yarn test | |||
jobs: | |||
node-v18: | |||
node-v20: |
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.
Node のバージョンをサポート状況にあわせて更新。
これどのリポジトリでも更新漏れますねぇ。
/** | ||
* @type {import('eslint').Linter.Config} | ||
*/ | ||
export default [ |
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.
こちらも Flat Config で書き直し。
原則すべて Flat Config にリライトしただけで内容は一切変わらないよう努めてます。
"import": "./index.js", | ||
"require": "./index.js" | ||
} | ||
}, |
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.
プロダクト側の FlatConfig 上で ESM として扱えるようにするため調整してます。
"test": "jest", | ||
"test:update-snapshot": "jest --updateSnapshot" | ||
"test": "vitest", | ||
"test:update-snapshot": "vitest --updateSnapshot" |
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.
ESM を扱うには Jest は力不足すぎるので、この機会に vitest に差し替えてます。
"jest": "^29.7.0", | ||
"react": "^18.3.1", | ||
"standard-version": "^9.3.2", | ||
"typescript": "^5.7.2" | ||
}, | ||
"peerDependencies": { | ||
"eslint": "^7.0.0 || ^8.0.0", | ||
"eslint": "^9.0.0", |
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.
それなりに頑張らない限りは v8 から利用することは難しいので、もう peer も v9 のみにしちゃいます。
}) | ||
const config = await eslint.calculateConfigForFile('index.js') | ||
expect(config).toMatchSnapshot() | ||
}) |
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.
現行のテストコードでは、設定ファイルを使ってサンプルコードに対して ESLint を実行し、その結果レポートのスナップショットを取るという手法を取られてました。
しかし、ESLint 内部APIに依存しているその仕組みを v9 に移植するのが困難であることと、労力の割に得られるカバレッジがイマイチであることから、設定ファイル全体をスナップショットテストするように変更しました。
"eslint-plugin-react-hooks": "^4.6.2", | ||
"eslint-plugin-smarthr": "^0.5.20" | ||
"eslint-plugin-react-hooks": "^5.0.0", | ||
"eslint-plugin-smarthr": "1.0.0", |
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.
- chore!: ESLint v9 eslint-plugin-smarthr#154
でメジャーバージョンアップしたものを使用する。
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.
ついにv1か〜
@@ -16,12 +16,17 @@ yarn add --dev eslint-config-smarthr | |||
|
|||
## How to use | |||
|
|||
Add a following `.eslintrc.js` in your project. | |||
Add a following `eslint.config.js` in your project. |
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.
申し訳程度に README も更新。
プロダクト固有のカスタムが一切ない場合は、↓のサンプルの設定ファイルで動作します。
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.
👍
WHAT
ESLint v9 へのマイグレーション及び FlatConfig での書き直しをします。
WHY
HOW
確認方法
設定ファイルの差分を確認するのは困難だと思うので、チェックアウトして、
$ npx eslint --inspect-config
を実行するのをオススメします。テストコード基盤自体も刷新してしまったので、テストコードが通ってるからOKとはいかないので目視確認をお願いします。
備考
利用可能な Node/ESLint のバージョン下限が変わるため、メジャーバージョンアップを想定しています。