我已从
[email protected]
在我的项目文件夹中安装了 npm
。运行命令后:
npm init @eslint/config
该包按照我的预期创建了一个
.eslintrc.{js,json,..}
文件,但是,据我了解,它现在只是“有点被弃用”(对吧?)。
当我跑步时
npx eslint .
我收到错误
Oops! Something went wrong! :(
ESLint: 9.1.0
Error: Could not find config file.
如果我跑步
npm init eslint/config
因此,如果没有
@
,npm
连接到 eslint/create-config
存储库,模块不会提示我 Answer questions about my style
,但它确实创建了一个 有效的平面 eslint.config.mjs
文件,并且 linter 再次工作(也在 VSCode 中)。
我觉得这有点不一致,我感觉我错过了一些东西。所以我的问题是:是否有办法继续使用
.eslintrc
文件?如果没有,我如何在本地使用/安装 eslint/config
命令?
我检查了我的全局模块,
eslint
未列出。
我也遇到这个问题了
以前,我会安装 ES Lint,然后分两步创建
eslintrc.json
配置文件:
npm install eslint --save-dev
npm init @eslint/config
但是现在导致了您遇到的错误。
如果我只运行一个命令:
npm init @eslint/config@latest
,它会引导我完成设置步骤并创建我需要的eslint.config.js
文件。