Open fregante opened 1 month ago
Moving it to the TypeScript-specific override fixes it:
export default antfu({
rules: {
'ts/consistent-type-definitions': ['error', 'type'],
// Prettier conflicts
'style/jsx-one-expression-per-line': 'off',
},
}, {
files: ['**/*.ts', '**/*.tsx'],
rules: {
'ts/consistent-type-imports': ['error', { fixStyle: 'inline-type-imports' }],
},
});
But this raises a few questions:
ts/consistent-type-definitions
works well in the main rules
object?You can do something like this:
export default antfu({
typescript: {
overrides: {
'ts/consistent-type-imports': ['error', { fixStyle: 'inline-type-imports' }],
},
}
})
You can do something like this:
export default antfu({ typescript: { overrides: { 'ts/consistent-type-imports': ['error', { fixStyle: 'inline-type-imports' }], }, } })
I was getting the You have used a rule which requires parserServices
error as well when attempting to modify ts/
rules in the rules section. Using the typescript
key overrides addressed the issue adequately, though if it's fixable, I did spend a fair amount of time trying to figure out why running pnpm run lint
was suddenly erroring.
Edit:
I did come across at least one rule that didn't work with this approach, specifically the ts/no-misused-promises
rule. I can turn it off completely without issue, but it errors when I customize it as follows:
typescript: {
overrides: {
'ts/consistent-type-definitions': 'off',
'ts/no-misused-promises': [
'error',
{
'checksVoidReturn': false,
},
],
},
},
The above entry still errors with the parserServices
error mentioned previously.
You can do something like this:你可以这样做:
export default antfu({ typescript: { overrides: { 'ts/consistent-type-imports': ['error', { fixStyle: 'inline-type-imports' }], }, } })
I was getting the
You have used a rule which requires parserServices
error as well when attempting to modifyts/
rules in the rules section. Using thetypescript
key overrides addressed the issue adequately, though if it's fixable, I did spend a fair amount of time trying to figure out why runningpnpm run lint
was suddenly erroring.我正在得到You have used a rule which requires parserServices
尝试修改规则部分中的ts/
规则时也会出错。使用typescript
键覆盖充分解决了这个问题,尽管如果可以修复,我确实花了相当多的时间试图找出为什么运行pnpm run lint
突然出错。Edit: 编辑:
I did come across at least one rule that didn't work with this approach, specifically the
ts/no-misused-promises
rule. I can turn it off completely without issue, but it errors when I customize it as follows:我确实遇到了至少一条不适用于这种方法的规则,特别是ts/no-misused-promises
规则。我可以毫无问题地完全关闭它,但是当我按如下方式自定义它时会出错:typescript: { overrides: { 'ts/consistent-type-definitions': 'off', 'ts/no-misused-promises': [ 'error', { 'checksVoidReturn': false, }, ], }, },
The above entry still errors with the
parserServices
error mentioned previously.上面的条目仍然存在前面提到的parserServices
错误。
You can try overridesTypeAware
.
export default antfu({
typescript: {
overridesTypeAware: {
'ts/no-misused-promises': [
'error',
{
checksVoidReturn: false,
},
],
},
},
})
I had a similar problem:
// eslint.config.js
import antfu from '@antfu/eslint-config'
export default antfu({
vue: true,
typescript: {
tsconfigPath: 'tsconfig.json',
overridesTypeAware: {
//This configuration works
'ts/no-unsafe-return': 'warn'
}
},
rules: {
//If the rule is configured here, an error is reported: You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project" property for xxx
//'ts/no-unsafe-return': 'warn'
}
})
It is a great project that configuration rules only take effect at overridesTypeAware. Expect to be able to override or set rules through :
export default antfu({
rules:{}
})
in a future release. Thank you to every open source author.
Describe the bug
I'm having the same as https://github.com/antfu/eslint-config/issues/372 when I try to change this config:
I assume that this is happening because the rule is being configured in the global config instead of in a TS override… but that doesn't explain why the following
ts/consistent-type-definitions
works fine.Reproduction
Config pasted above
System Info
Used Package Manager
npm
Validations
Contributions