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
新しい自分に会いに行こう!『自分の変え方』村岡大樹の認知科学コーチングで人生リセット
- review
科学革命から AI 時代へ!『サピエンス全史 下巻』ユヴァル・ノア・ハラリが予見する人類の未来
- review
人類はなぜ地球を支配できた?『サピエンス全史 上巻』ユヴァル・ノア・ハラリが解き明かす驚愕の真実