Open
Description
Before You File a Proposal Please Confirm You Have Done The Following...
- I have searched for related issues and found none that match my proposal.
- I have searched the current rule list and found no rules that match my proposal.
- I have read the FAQ and my problem is not listed.
Description
I hope I can define ts lint rules in my flat eslint.config.ts
which will be compared to eslint.config.js
like this:
import type { Linter } from 'eslint';
import type {ruleOptions} from '@typescript-eslint/eslint-plugin';
type TSRules = {
[K in keyof ruleOptions]?: Linter.RuleEntry<ruleOptions[K]>;
};
// Than those rules has hints
const rules: TSRules = {
'accessor-pairs': 'error',
'array-type': ['error', {
readonly: 'array'
}]
};
And It helpful for define rule with prefix:
import type { Linter } from 'eslint';
import type {ruleOptions} from '@typescript-eslint/eslint-plugin';
type TSRules = {
[K in keyof ruleOptions as `ts/${K}`]?: Linter.RuleEntry<ruleOptions[K]>;
};
// Than those rules has hints
const rules: TSRules = {
'ts/accessor-pairs': 'error',
'ts/array-type': ['error', {
readonly: 'array'
}]
};
In use of:
import type { Linter } from 'eslint';
import parseTs from '@typescript-eslint/parser';
import pluginTs from '@typescript-eslint/eslint-plugin';
const flatconfig: Linter.FlatConfig[] = [{
plugins: {
ts: pluginTs as any
},
files: ['**/*.?([cm])ts'],
languageOptions: {
parser: parseTs as any,
parserOptions: {
project: true,
sourceType: 'module',
// extraFileExtensions: ['.vue']
}
},
rules: {
...rules
}
}]