-
-
Notifications
You must be signed in to change notification settings - Fork 462
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
ts/consistent-type-imports
"You have used a rule which requires parserServices to be generated."
#570
Comments
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:
|
You can do something like this: export default antfu({
typescript: {
overrides: {
'ts/consistent-type-imports': ['error', { fixStyle: 'inline-type-imports' }],
},
}
}) |
I was getting the Edit: I did come across at least one rule that didn't work with this approach, specifically the typescript: {
overrides: {
'ts/consistent-type-definitions': 'off',
'ts/no-misused-promises': [
'error',
{
'checksVoidReturn': false,
},
],
},
}, The above entry still errors with the |
You can try 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. |
It does not works with my config. I set /**
* @typedef {import("@antfu/eslint-config/index.d.ts").} Serverless
*/
import antfu from '@antfu/eslint-config';
import preferArrowFunctions from 'eslint-plugin-prefer-arrow-functions';
export default antfu(
{
formatters: {
css: true,
html: true,
},
ignores: [
'.vscode/**',
'dist/**',
'.dependency-cruiser.js',
],
isInEditor: false,
plugins: {
'prefer-arrow-functions': preferArrowFunctions,
},
stylistic: {
indent: 4,
quotes: 'single',
semi: true,
},
toml: false,
typescript: {
overrides: {
'ts/consistent-type-imports': ['error', {
fixStyle: 'separate-type-imports',
prefer: 'type-imports',
}],
},
},
vue: true,
},
{
// Remember to specify the file glob here, otherwise it might cause the vue plugin to handle non-vue files
files: ['**/*.json'],
rules: {
'jsonc/indent': ['error', 2],
'jsonc/sort-keys': 'off',
},
},
{
// Remember to specify the file glob here, otherwise it might cause the vue plugin to handle non-vue files
files: ['**/*.vue'],
rules: {
'vue/block-order': ['error', { order: ['template', 'script', 'style'] }],
'vue/component-name-in-template-casing': ['warn', 'kebab-case'],
'vue/custom-event-name-casing': 'off',
'vue/html-closing-bracket-newline': ['error', { multiline: 'never' }],
'vue/html-indent': ['error', 4],
'vue/no-v-html': 'off',
'vue/no-v-model-argument': 'off',
'vue/operator-linebreak': ['error', 'before'],
},
},
{
files: ['**/*.yml'],
rules: {
'yaml/indent': ['error', 2],
},
},
{
// Without `files`, they are general rules for all files
rules: {
'antfu/top-level-function': 'off',
'jsdoc/check-param-names': ['warn', {
checkDestructured: false,
disableMissingParamChecks: true,
}],
'no-unused-vars': 'off',
'perfectionist/sort-classes': 'error',
'perfectionist/sort-imports': ['error', {
groups: [
'type',
'internal-type',
['parent-type', 'sibling-type', 'index-type'],
'builtin',
'external',
'internal',
['parent', 'sibling', 'index'],
'object',
'unknown',
],
internalPattern: ['@/**'],
newlinesBetween: 'never',
}],
'perfectionist/sort-named-exports': 'error',
'perfectionist/sort-named-imports': 'error',
'perfectionist/sort-objects': 'error',
'prefer-arrow-functions/prefer-arrow-functions': ['error', {
returnStyle: 'implicit',
}],
'style/brace-style': ['error', '1tbs'],
'style/indent-binary-ops': ['off'],
'style/semi': ['error', 'always'],
'ts/no-empty-function': 'error',
'ts/no-empty-interface': 'error',
'ts/no-explicit-any': ['error'],
'ts/no-non-null-assertion': ['warn'],
'ts/no-unsafe-declaration-merging': 'off',
'ts/no-unused-vars': ['error', {
args: 'after-used',
argsIgnorePattern: '^_',
caughtErrors: 'all',
caughtErrorsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
vars: 'all',
varsIgnorePattern: '^_',
}],
'unused-imports/no-unused-imports': ['off'],
'unused-imports/no-unused-vars': ['off'],
},
},
); And a file with the problem : import type { AxiosRequestConfig } from 'axios';
import type { OrgIdOrCustomerId } from './common.js';
import type { Model, ModelClass, ModelStructure } from './Model.js';
// normally this part must return an error and fix with separate type Ref and ref. but nothing apear
import { ref, type Ref } from 'vue';
import request from '../request.js'; |
Describe the bug
I'm having the same as #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
The text was updated successfully, but these errors were encountered: