eslintコマンドを実行した際に発生した 「"path" argument must be of type string. Received an instance of Array」エラーの対処

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。
eslintコマンドを実行した際に発生する "path" argument must be of type string.エラーの対処についてメモしました。
経緯
reactとmobx-state-treeを利用しているプロジェクトがあり
そのプロジェクトのパッケージを最新にアップデートしリントチェックしたところ発生しました。
環境
- Yarn 1.22.4
- Node.js 14.15.3
- eslint 7.29
発生したエラー
yarn eslint --fix
コマンドを実行するとエラーになりリントが動かないという状況が発生しました。
zsh$ yarn eslint --fix src/**/*.tsx
yarn run v1.22.10
$ /Users/XXXX/project/node_modules/.bin/eslint --fix src/**/*.tsx
Oops! Something went wrong! :(
ESLint: 7.29.0
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Array
at validateString (internal/validators.js:124:11)
at Object.isAbsolute (path.js:1029:5)
at isFilePath (/Users/XXXX/project/node_modules/@eslint/eslintrc/lib/config-array-factory.js:131:14)
at /Users/XXXX/project/node_modules/@eslint/eslintrc/lib/config-array-factory.js:905:17
at Array.reduce (<anonymous>)
at ConfigArrayFactory._loadPlugins (/Users/XXXX/project/node_modules/@eslint/eslintrc/lib/config-array-factory.js:904:22)
at ConfigArrayFactory._normalizeObjectConfigDataBody (/Users/XXXX/project/node_modules/@eslint/eslintrc/lib/config-array-factory.js:725:44)
at _normalizeObjectConfigDataBody.next (<anonymous>)
at ConfigArrayFactory._normalizeObjectConfigData (/Users/XXXX/project/node_modules/@eslint/eslintrc/lib/config-array-factory.js:665:20)
at _normalizeObjectConfigData.next (<anonymous>)
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
エラーについて
エラーの内容はパスは文字列型を指定する必要があるというエラーです。
zshTypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Array
ファイルなどが明示されている通常のlintのエラーではなかったため悩みました。
原因
mobxのデコレーター(@XXXみたいな書き方)を利用するのに必要な @babel/plugin-proposal-decorators
プラグインの設定が
なぜかeslint設定ファイルのpluginへ記載されていたことが原因でした。
javascript// .eslintrc.js
module.exports = {
plugins: [
["@babel/plugin-proposal-decorators", { legacy: true }],
],
}
プラグインの設定を削除して解決
原因の部分の下記を削除して解決しました。
javascript// .eslintrc.js
module.exports = {
plugins: [
["@babel/plugin-proposal-decorators", { legacy: true }],
],
}
そもそもなぜ@babel/plugin-proposal-decorators
の設定がeslintrcにあったかの確認(.babelrcと設定を間違えた?)が必要だなと思ったのと、オブジェクトが渡っていたことでパスのエラーが出ていたと理解しました。
- review
もう「なんとなく」で決めない!『解像度を上げる』馬田隆明著で身につけた、曖昧思考を一瞬で明晰にする技術
- review
もう疲れ知らず!『最高の体調』鈴木祐著で手に入れた、一生モノの健康習慣術
- review
人生が激変!『苦しかったときの話をしようか』森岡毅著で発見した、本当に幸せなキャリアの築き方
- review
もう「何言ってるの?」とは言わせない!『バナナの魅力を 100 文字で伝えてください』柿内尚文著 で今日からあなたも伝え方の達人!
- review
もう時間に追われない!『エッセンシャル思考』グレッグ・マキューンで本当に重要なことを見抜く!
- review
プロダクト開発の悩みを一刀両断!『プロダクトマネジメントのすべて』及川 卓也, 曽根原 春樹, 小城 久美子