mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 10:34:15 +00:00
Make rules more type-safe
This commit is contained in:
@@ -10,53 +10,42 @@ import { RuleTester } from 'eslint';
|
||||
import { EnumType } from 'typescript';
|
||||
|
||||
export type Meta = TSESLint.RuleMetaData<string>;
|
||||
export type Valid = RuleTester.ValidTestCase | TSESLint.ValidTestCase<unknown[]>;
|
||||
export type Invalid = RuleTester.InvalidTestCase | TSESLint.InvalidTestCase<string, unknown[]>;
|
||||
|
||||
export type Valid = TSESLint.ValidTestCase<unknown[]> | RuleTester.ValidTestCase;
|
||||
export type Invalid = TSESLint.InvalidTestCase<string, unknown[]> | RuleTester.InvalidTestCase;
|
||||
|
||||
export interface DSpaceESLintRuleInfo {
|
||||
name: string;
|
||||
meta: Meta,
|
||||
defaultOptions: any[],
|
||||
defaultOptions: unknown[],
|
||||
}
|
||||
|
||||
export interface DSpaceESLintTestInfo {
|
||||
rule: string;
|
||||
export interface NamedTests {
|
||||
plugin: string;
|
||||
valid: Valid[];
|
||||
invalid: Invalid[];
|
||||
}
|
||||
|
||||
export interface DSpaceESLintPluginInfo {
|
||||
name: string;
|
||||
description: string;
|
||||
rules: DSpaceESLintRuleInfo;
|
||||
tests: DSpaceESLintTestInfo;
|
||||
}
|
||||
|
||||
export interface DSpaceESLintInfo {
|
||||
html: DSpaceESLintPluginInfo;
|
||||
ts: DSpaceESLintPluginInfo;
|
||||
}
|
||||
|
||||
export interface RuleExports {
|
||||
Message: EnumType,
|
||||
info: DSpaceESLintRuleInfo,
|
||||
rule: any,
|
||||
tests: any,
|
||||
default: any,
|
||||
rule: TSESLint.RuleModule<string>,
|
||||
tests: NamedTests,
|
||||
default: unknown,
|
||||
}
|
||||
|
||||
export interface PluginExports {
|
||||
name: string,
|
||||
language: string,
|
||||
rules: Record<string, unknown>,
|
||||
index: RuleExports[],
|
||||
}
|
||||
|
||||
export function bundle(
|
||||
name: string,
|
||||
language: string,
|
||||
index: RuleExports[],
|
||||
): {
|
||||
name: string,
|
||||
language: string,
|
||||
rules: Record<string, any>,
|
||||
index: RuleExports[],
|
||||
} {
|
||||
return index.reduce((o: any, i: any) => {
|
||||
): PluginExports {
|
||||
return index.reduce((o: PluginExports, i: RuleExports) => {
|
||||
o.rules[i.info.name] = i.rule;
|
||||
return o;
|
||||
}, {
|
||||
|
Reference in New Issue
Block a user