-
Notifications
You must be signed in to change notification settings - Fork 320
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
如果我的项目混用 js 和 ts,如何正确设置配置? #67
Comments
eslint 没办法在一个项目中针对不同后缀的文件使用不同的 eslintrc |
你也可以在运行脚本的时候,指定不同的后缀使用不同的 eslintrc |
那好像针对这种情况没有特别完美的方案了,只能同时使用 Eslint 和 TsLint 了,或者项目统一切换至 TypeScript 了。 |
现在应该可以根据不同的后缀使用不同的规则 "overrides": [
{
"files": ['*.js'],
"parser": 'babel-eslint',
},
{
"files": ['*.ts', '*.tsx'],
"extends": ["plugin:@typescript-eslint/recommended"],
"parser": '@typescript-eslint/parser',
"plugins": ['@typescript-eslint/eslint-plugin'],
},
] |
overrides 里面 不允许有extends |
eslint 6.0之后可以有 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
因为当前项目是混用了 javascript 和 typescript 开发,如果同时设置
因为 typescript 使用的 parser 不是 babel-eslint,会出现我在 js 文件中使用新的 babel-plugin-proposal-optional-chaining 等插件提供的语法出现报错的问题。我现在是使用 tslint 来检测 typescript,但是tslint的规则实在是少,想用 eslint 统一做检测,但是又没法区分不同的文件后缀应用不同的配置,请问如何解决这个问题呢?
The text was updated successfully, but these errors were encountered: