Skip to content
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を追加 #43

Merged
merged 7 commits into from
Sep 28, 2024
Merged

ESLintを追加 #43

merged 7 commits into from
Sep 28, 2024

Conversation

Kassy0220
Copy link
Owner

@Kassy0220 Kassy0220 commented Sep 28, 2024

Issue

概要

ESLintとその設定を追加した。
追加で以下のプラグインも追加している。

  • globals
    • READMEには「異なるJavaScript環境からのグローバル識別子」とある。
    • これを追加しないと、window.Stimulusというコードがno-undefルール('window' is not defined)に引っかかってしまう。
  • eslint-plugin-react
  • eslint-plugin-jsx-a11y
    • JSXのアクセシビリティを検査してくれる
  • eslint-plugin-react-hooks

備考

ESLintの設定ファイル

ESLintはバージョン9から新しい設定方法(flat config)を使うようになっている。
新しい設定方法では、設定ファイルとして.eslint.config.jsを利用するようになった(それ以前は.eslintrc.js)。

バージョン8.23.0以降でも.eslint.config.jsが利用できるようになっているため、今回は新しい設定方法を利用することにする。

https://github.com/jsx-eslint/eslint-plugin-react?tab=readme-ov-file#configuration-new-eslintconfigjs

eslint-plugin-react-hooksの設定

どうやら、eslint-plugin-react-hooksはflat configに対応していない模様(2024/09/28時点)。

facebook/react#28313

そこで、以下の記事を参考に設定を行った。

@Kassy0220 Kassy0220 self-assigned this Sep 28, 2024
@Kassy0220 Kassy0220 merged commit 814c080 into main Sep 28, 2024
@Kassy0220 Kassy0220 deleted the chore/add-eslint branch September 28, 2024 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant