Upgrade to ESLint 9
This commit is contained in:
@ -1,17 +1,40 @@
|
||||
import type { ESLintUtils } from '@typescript-eslint/utils';
|
||||
import type { Rule } from 'eslint';
|
||||
import type { ESLint } from 'eslint';
|
||||
|
||||
import noEmptyObjectLiteral from './no-empty-object-literal';
|
||||
import noImportDot from './no-import-dot';
|
||||
import noUselessImportAlias from './no-useless-import-alias';
|
||||
import restrictTemplateExpressions from './restrict-template-expressions';
|
||||
|
||||
export const rules: Record<
|
||||
string,
|
||||
Rule.RuleModule | ESLintUtils.RuleModule<string, unknown[]>
|
||||
> = {
|
||||
'no-empty-object-literal': noEmptyObjectLiteral,
|
||||
'no-import-dot': noImportDot,
|
||||
'no-useless-import-alias': noUselessImportAlias,
|
||||
'restrict-template-expressions': restrictTemplateExpressions,
|
||||
type RuleLevel = 'error' | 'warn' | 'off' | 0 | 1 | 2;
|
||||
type RuleEntry<Options> = RuleLevel | [RuleLevel, Partial<Options>];
|
||||
|
||||
export interface LocalRuleOptions {
|
||||
/** Bans import from the specifier '.' and '..' and replaces it with '.+/index' */
|
||||
'custom/no-import-dot': RuleEntry<unknown>;
|
||||
/**
|
||||
* Enforce template literal expressions to be of `string` type
|
||||
* @see [restrict-template-expressions](https://typescript-eslint.io/rules/restrict-template-expressions)
|
||||
*/
|
||||
'typed-custom/restrict-template-expressions': RuleEntry<{ allow: string[] }>;
|
||||
/** Ban assignment of empty object literals `{}` and replace them with `Object.create(null)` */
|
||||
'custom/no-empty-object-literal': RuleEntry<unknown>;
|
||||
/** Ban useless import alias */
|
||||
'custom/no-useless-import-alias': RuleEntry<unknown>;
|
||||
}
|
||||
|
||||
export const plugin: ESLint.Plugin = {
|
||||
name: 'custom',
|
||||
rules: {
|
||||
'no-empty-object-literal': noEmptyObjectLiteral,
|
||||
'no-import-dot': noImportDot,
|
||||
'no-useless-import-alias': noUselessImportAlias,
|
||||
},
|
||||
};
|
||||
|
||||
export const typedPlugin: ESLint.Plugin = {
|
||||
name: 'typed-custom',
|
||||
rules: {
|
||||
// @ts-expect-error type mismatch
|
||||
'restrict-template-expressions': restrictTemplateExpressions,
|
||||
},
|
||||
};
|
||||
|
Reference in New Issue
Block a user