Fix local rules

This commit is contained in:
Alex
2024-08-08 02:59:28 -04:00
parent 25695599aa
commit afb93c4971
9 changed files with 41 additions and 36 deletions

View File

@ -9,7 +9,7 @@ import type { Middleware, MiddlewareConfig, MiddlewareFunctions } from './middle
import { importTypeScript } from './presets/typescript';
import { unicorn } from './presets/unicorn';
import { eslintRules } from './presets/eslint';
import { local } from './presets/local';
import { custom } from './presets/custom';
import { error, warn, off } from './constants';
import { checkEnv } from './env';
@ -41,14 +41,14 @@ type RuleEntry<Options> = RuleLevel | [RuleLevel, Partial<Options>];
export interface LocalRuleOptions {
/** Bans import from the specifier '.' and '..' and replaces it with '.+/index' */
'rules/no-import-dot': RuleEntry<unknown>;
'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)
*/
'rules/restrict-template-expressions': RuleEntry<{ allow: string[] }>;
'custom/restrict-template-expressions': RuleEntry<{ allow: string[] }>;
/** Ban assignment of empty object literals `{}` and replace them with `Object.create(null)` */
'rules/no-empty-object-literal': RuleEntry<unknown>;
'custom/no-empty-object-literal': RuleEntry<unknown>;
}
export type RuleOptions = Rules & Partial<LocalRuleOptions>;
@ -121,25 +121,27 @@ export function extendConfig(
customRuleFiles,
parserOptions,
middlewares: _middlewares = [],
// @ts-expect-error
localRules: _,
...rest
} = of;
let plugins: Plugin[] = [..._plugins];
let extend: Extends[] = ensureArray(_extends);
if (customRuleFiles != null) {
plugins.push('local');
}
const middlewares: Middleware[] = uniq([
importTypeScript,
unicorn,
local,
custom,
...(auto ? checkEnv() : []),
..._middlewares,
]);
const result: MiddlewareConfig = {
root: true,
plugins: unique('rules', plugins),
plugins: unique('custom', plugins),
env: { node: true, browser: true, es2023: true },
reportUnusedDisableDirectives: true,
parserOptions: {