@eslinted/core 4.0.5-rc.4 → 4.0.5-rc.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. package/package.json +3 -9
  2. package/src/factory/files.ts +20 -9
  3. package/src/factory/index.ts +4 -2
  4. package/src/factory/options/index.ts +2 -0
  5. package/src/factory/options/option/index.ts +25 -33
  6. package/src/factory/options/option/template/globals.ts +5 -0
  7. package/src/factory/options/option/{template.ts → template/index.ts} +6 -4
  8. package/src/factory/options/option/template/language/ecma.ts +3 -0
  9. package/src/factory/options/option/{params/language.ts → template/language/index.ts} +3 -3
  10. package/src/factory/options/option/template/language/source.ts +4 -0
  11. package/src/factory/options/option/template/linter.ts +8 -0
  12. package/src/factory/options/option/template/plugins.ts +1 -0
  13. package/src/factory/rulesets/index.ts +24 -0
  14. package/src/factory/rulesets/ruleset.ts +25 -0
  15. package/src/index.ts +25 -21
  16. package/src/input/files.ts +6 -0
  17. package/src/{inputs → input}/imports/parsers.ts +1 -1
  18. package/src/{inputs → input}/imports/plugins.ts +3 -2
  19. package/src/input/index.ts +23 -0
  20. package/src/input/parsers.ts +3 -0
  21. package/src/input/plugins.ts +3 -0
  22. package/src/input/rules/entry/index.ts +7 -0
  23. package/src/input/rules/entry/record/index.ts +3 -0
  24. package/src/input/rules/entry/record/state.ts +5 -0
  25. package/src/input/rules/index.ts +14 -0
  26. package/src/output.ts +23 -23
  27. package/src/scopes.ts +1 -1
  28. package/tsconfig.json +2 -2
  29. package/src/factory/options/option/params/globals.ts +0 -3
  30. package/src/factory/options/option/params/languageOptions/ecma.ts +0 -1
  31. package/src/factory/options/option/params/languageOptions/source.ts +0 -1
  32. package/src/factory/options/option/params/linter.ts +0 -4
  33. package/src/factory/options/option/params/plugins.ts +0 -1
  34. package/src/factory/ruleset/index.ts +0 -41
  35. package/src/factory/ruleset/rule.ts +0 -8
  36. package/src/factory/rulesets.ts +0 -16
  37. package/src/input.ts +0 -11
  38. package/src/inputs/files/base.ts +0 -3
  39. package/src/inputs/files/includes.ts +0 -3
  40. package/src/inputs/files.ts +0 -7
  41. package/src/inputs/imports.ts +0 -2
  42. package/src/inputs/parsers.ts +0 -3
  43. package/src/inputs/plugins.ts +0 -3
  44. package/src/inputs/rules/entry/index.ts +0 -3
  45. package/src/inputs/rules/entry/object/index.ts +0 -7
  46. package/src/inputs/rules/entry/object/state/index.ts +0 -4
  47. package/src/inputs/rules/overrides.ts +0 -4
  48. package/src/inputs/rules/preset.ts +0 -4
  49. package/src/inputs/rules.ts +0 -7
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "_schemaVersion": "20.18.0-core.0",
3
3
  "name": "@eslinted/core",
4
- "version": "4.0.5-rc.4",
4
+ "version": "4.0.5-rc.6",
5
5
  "description": "Core ESLint flat config factory npm package `linted`.",
6
6
  "keywords": [],
7
7
  "repository": "github:jimmy-zhening-luo/linted-core",
@@ -13,14 +13,8 @@
13
13
  "access": "public"
14
14
  },
15
15
  "type": "module",
16
- "exports": {
17
- ".": {
18
- "import": {
19
- "types": "./dist/index.d.ts",
20
- "default": "./dist/index.js"
21
- }
22
- }
23
- },
16
+ "main": "./dist/index.js",
17
+ "types": "./dist/index.d.ts",
24
18
  "config": {
25
19
  "language": "ts",
26
20
  "fix": "true",
@@ -1,15 +1,26 @@
1
- import type { Scope } from "@eslinted/core";
2
- import type { Input } from "@eslinted/core";
1
+ import type { Input } from ".";
3
2
 
4
3
  export class Files {
5
- constructor(private readonly input: Input["files"]) {}
4
+ private readonly _files = new Map<string, string[]>();
6
5
 
7
- public files(scope: Scope): readonly string[] {
8
- try {
9
- const { files, includes } = this.input;
6
+ constructor(private readonly input: Input["files"]) {
7
+ const { files, includes } = this.input,
8
+ scopes = Object.keys(files) as (keyof typeof files)[];
10
9
 
11
- return [...files[scope], ...includes[scope] ?? []];
12
- }
13
- catch (e) { throw new Error(`linted.factory.Files/scope:${scope}`, { cause: e }); }
10
+ for (const scope of scopes)
11
+ this._files.set(
12
+ scope,
13
+ [
14
+ ...files[scope],
15
+ ...scope in includes ? (includes[scope] as string[]) : [],
16
+ ],
17
+ );
18
+ }
19
+
20
+ public files(scope: string) {
21
+ if (!this._files.has(scope))
22
+ throw new ReferenceError(`Files not found for scope: ${scope}`);
23
+
24
+ return this._files.get(scope) as string[];
14
25
  }
15
26
  }
@@ -1,5 +1,7 @@
1
- import { Rulesets } from "./rulesets";
2
- import { Files } from "./files";
1
+ export type { Scope, Input, Output } from "..";
2
+
3
3
  import Options from "./options";
4
+ import { Files } from "./files";
5
+ import { Rulesets } from "./rulesets";
4
6
 
5
7
  export { Options, Files, Rulesets };
@@ -1,3 +1,5 @@
1
+ export type { Scope, Input, Output } from "..";
2
+
1
3
  import js from "./js";
2
4
  import ts from "./ts";
3
5
  import svelte from "./svelte";
@@ -1,14 +1,14 @@
1
- import type { Input } from "@eslinted/core";
2
- import type { Scope } from "@eslinted/core";
3
- import type { Output } from "@eslinted/core";
4
- import type { Ruleset } from "../../ruleset";
1
+ import globals from "globals";
2
+ import type { Ruleset } from "../../rulesets/ruleset";
5
3
  import type {
4
+ Scope,
5
+ Input,
6
+ Output,
6
7
  OptionTemplate,
7
8
  LanguageOptions,
8
9
  Plugins,
9
10
  Globals,
10
11
  } from "./template";
11
- import globals from "globals";
12
12
 
13
13
  export default abstract class Option<
14
14
  S extends Scope,
@@ -29,41 +29,33 @@ export default abstract class Option<
29
29
  : object;
30
30
 
31
31
  constructor(
32
- public readonly files: readonly string[],
33
- public readonly ruleset: Ruleset<S>,
34
32
  public readonly plugins: Plugins<Plugin>,
35
33
  public readonly parser: Tuple<unknown, ParserCount>,
34
+ public readonly files: string[],
35
+ public readonly ruleset: Ruleset,
36
36
  ) {}
37
37
 
38
38
  public get configs(): Output {
39
- try {
40
- const {
41
- scope,
42
- ruleset,
43
- files,
44
- option,
45
- } = this;
46
-
47
- if (ruleset.id !== scope)
48
- throw new TypeError(`Option and Ruleset scope mismatch`, { cause: { option: scope, ruleset: ruleset.id } });
49
- else if (files.length < 1)
50
- return [];
51
- else {
52
- const baseName = `linted/scope:${scope}/rule:${ruleset.id}` as const;
39
+ const {
40
+ scope,
41
+ ruleset,
42
+ files,
43
+ option,
44
+ } = this;
53
45
 
54
- return ruleset.records.map(([ruleId, rules]) => {
55
- const name = `${baseName}+${ruleId}` as const;
46
+ if (ruleset.scope !== scope)
47
+ throw new TypeError(`Scope mismatch between option and ruleset`, { cause: { option: scope, ruleset: ruleset.scope } });
56
48
 
57
- return {
58
- name,
59
- files,
60
- rules,
61
- ...option,
62
- };
63
- });
64
- }
65
- }
66
- catch (e) { throw new Error(`linted.factory.Option/scope:${this.scope}: configs`, { cause: e }); }
49
+ return files.length < 1
50
+ ? []
51
+ : ruleset.ruleset.map(({ id, rule }) => {
52
+ return {
53
+ name: `linted/${id}`,
54
+ files,
55
+ rules: rule,
56
+ ...option,
57
+ };
58
+ });
67
59
  }
68
60
 
69
61
  private get option() {
@@ -0,0 +1,5 @@
1
+ import type globals from "globals";
2
+
3
+ export type Globals = keyof typeof globals & (
4
+ | "mocha"
5
+ );
@@ -1,7 +1,9 @@
1
- import type { LanguageOptions } from "./params/language";
2
- import type { Linter } from "./params/linter";
3
- import type { Plugins } from "./params/plugins";
4
- import type { Globals } from "./params/globals";
1
+ export type { Scope, Input, Output } from "../..";
2
+
3
+ import type { LanguageOptions } from "./language";
4
+ import type { Linter } from "./linter";
5
+ import type { Plugins } from "./plugins";
6
+ import type { Globals } from "./globals";
5
7
 
6
8
  export type {
7
9
  LanguageOptions,
@@ -0,0 +1,3 @@
1
+ export type EcmaVersion = (
2
+ | "latest"
3
+ );
@@ -1,12 +1,12 @@
1
- import type { Ecma } from "./languageOptions/ecma";
2
- import type { Source } from "./languageOptions/source";
1
+ import type { EcmaVersion } from "./ecma";
2
+ import type { SourceType } from "./source";
3
3
 
4
4
  export type LanguageOptions<
5
5
  IsEcma extends boolean,
6
6
  ParserOptions extends object | boolean,
7
7
  GlobalTypes extends string,
8
8
  > =
9
- & (True<IsEcma> extends never ? object : { ecmaVersion: Ecma; sourceType: Source })
9
+ & (True<IsEcma> extends never ? object : { ecmaVersion: EcmaVersion; sourceType: SourceType })
10
10
  & (literalful<GlobalTypes> extends never ? object : { globals: Record<string, unknown> })
11
11
  & (
12
12
  ParserOptions extends boolean
@@ -0,0 +1,4 @@
1
+ export type SourceType = (
2
+ | "module"
3
+ | "script"
4
+ );
@@ -0,0 +1,8 @@
1
+ export interface Linter {
2
+ noInlineConfig: boolean;
3
+ reportUnusedDisableDirectives:
4
+ | "error"
5
+ | "warn"
6
+ | "off"
7
+ ;
8
+ }
@@ -0,0 +1 @@
1
+ export type Plugins<PluginId extends string> = { [P in literalful<PluginId>]: { configs: unknown } };
@@ -0,0 +1,24 @@
1
+ import type { Input } from "..";
2
+
3
+ export type { Input };
4
+
5
+ import { Ruleset } from "./ruleset";
6
+
7
+ export class Rulesets {
8
+ private readonly rulesets = new Map<string, Ruleset>();
9
+
10
+ constructor(private readonly input: Input["rules"]) {
11
+ const { rules, overrides } = this.input,
12
+ scopes = Object.keys(rules) as (keyof typeof rules)[];
13
+
14
+ for (const scope of scopes)
15
+ this.rulesets.set(scope, new Ruleset(scope, rules[scope], overrides[scope]));
16
+ }
17
+
18
+ public ruleset(scope: string): Ruleset {
19
+ if (!this.rulesets.has(scope))
20
+ throw new ReferenceError(`Ruleset not found for scope: ${scope}`);
21
+
22
+ return this.rulesets.get(scope) as Ruleset;
23
+ }
24
+ }
@@ -0,0 +1,25 @@
1
+ import type { Input } from ".";
2
+
3
+ export class Ruleset {
4
+ public readonly ruleset: { id: string; rule: Input.Rule.Entry.Record }[];
5
+
6
+ constructor(
7
+ public readonly scope: string,
8
+ rules: (readonly [string, Input.Rule.Entry.Record])[],
9
+ override?: Input.Rule.Entry.Record,
10
+ ) {
11
+ const map = ([id, rule]: typeof rules[number]) => {
12
+ return {
13
+ id: `${scope}:${id}`,
14
+ rule,
15
+ };
16
+ };
17
+
18
+ this.ruleset = [
19
+ ...rules.map(rule => map(rule)),
20
+ ...typeof override === "undefined"
21
+ ? []
22
+ : [map([`${scope}:override`, override])],
23
+ ];
24
+ }
25
+ }
package/src/index.ts CHANGED
@@ -1,8 +1,9 @@
1
+ export type { Scope } from "./scopes";
2
+
1
3
  import type { Input } from "./input";
2
- import type { Scope } from "./scopes";
3
4
  import type { Output } from "./output";
4
5
 
5
- export type { Input, Scope, Output };
6
+ export type { Input, Output };
6
7
 
7
8
  import { scopes } from "./scopes";
8
9
  import {
@@ -23,66 +24,66 @@ export default function (
23
24
  options: { [S in typeof scopes[number]]: InstanceType<typeof Options[S]>["configs"] } = {
24
25
  js: new Options
25
26
  .js(
26
- F.files("js"),
27
- R.ruleset("js"),
28
27
  { "@stylistic": plugins["@stylistic"] },
29
28
  [],
29
+ F.files("js"),
30
+ R.ruleset("js"),
30
31
  ).configs,
31
32
  ts: new Options
32
33
  .ts(
33
- F.files("ts"),
34
- R.ruleset("ts"),
35
34
  { "@stylistic": plugins["@stylistic"], "@typescript-eslint": plugins["@typescript-eslint"] },
36
35
  [parsers.ts],
36
+ F.files("ts"),
37
+ R.ruleset("ts"),
37
38
  ).configs,
38
39
  svelte: new Options
39
40
  .svelte(
40
- F.files("svelte"),
41
- R.ruleset("svelte"),
42
41
  { "@stylistic": plugins["@stylistic"], "@typescript-eslint": plugins["@typescript-eslint"], svelte: plugins.svelte },
43
42
  [parsers.svelte, parsers.ts],
43
+ F.files("svelte"),
44
+ R.ruleset("svelte"),
44
45
  ).configs,
45
46
  mocha: new Options
46
47
  .mocha(
47
- F.files("mocha"),
48
- R.ruleset("mocha"),
49
48
  { "@stylistic": plugins["@stylistic"], "@typescript-eslint": plugins["@typescript-eslint"], mocha: plugins.mocha },
50
49
  [parsers.ts],
50
+ F.files("mocha"),
51
+ R.ruleset("mocha"),
51
52
  ).configs,
52
53
  html: new Options
53
54
  .html(
54
- F.files("html"),
55
- R.ruleset("html"),
56
55
  { "@html-eslint": plugins["@html-eslint"] },
57
56
  [parsers.html],
57
+ F.files("html"),
58
+ R.ruleset("html"),
58
59
  ).configs,
59
60
  json: new Options
60
61
  .json(
61
- F.files("json"),
62
- R.ruleset("json"),
63
62
  { jsonc: plugins.jsonc },
64
63
  [parsers.jsonc],
64
+ F.files("json"),
65
+ R.ruleset("json"),
65
66
  ).configs,
66
67
  jsonc: new Options
67
68
  .jsonc(
68
- F.files("jsonc"),
69
- R.ruleset("jsonc"),
70
69
  { jsonc: plugins.jsonc },
71
70
  [parsers.jsonc],
71
+ F.files("jsonc"),
72
+ R.ruleset("jsonc"),
72
73
  ).configs,
73
74
  yml: new Options
74
75
  .yml(
75
- F.files("yml"),
76
- R.ruleset("yml"),
77
76
  { yml: plugins.yml },
78
77
  [parsers.yml],
78
+ F.files("yml"),
79
+ R.ruleset("yml"),
79
80
  ).configs,
80
81
  md: new Options
81
82
  .md(
82
- F.files("md"),
83
- R.ruleset("md"),
84
83
  { markdownlint: plugins.markdownlint },
85
84
  [parsers.md],
85
+ F.files("md"),
86
+ R.ruleset("md"),
86
87
  ).configs,
87
88
  };
88
89
 
@@ -91,8 +92,9 @@ export default function (
91
92
  catch (e) { throw new Error(`linted-core`, { cause: e }); }
92
93
  }
93
94
 
95
+ // #region DEPRECATED
94
96
  namespace Core {
95
- export type Scopes = Scope;
97
+ export type Scopes = typeof scopes[number];
96
98
  export namespace Input {
97
99
  export type Parsers = Input["parsers"];
98
100
  export type Plugins = Input["plugins"];
@@ -111,3 +113,5 @@ namespace Core {
111
113
  }
112
114
 
113
115
  export type { Core };
116
+
117
+ // #endregion
@@ -0,0 +1,6 @@
1
+ import type { Scope } from ".";
2
+
3
+ export interface FilesInput {
4
+ files: Record<Scope, string[]>;
5
+ includes: Partial<FilesInput["files"]>;
6
+ }
@@ -1,4 +1,4 @@
1
- import type { Scope } from "@eslinted/core";
1
+ import type { Scope } from "..";
2
2
 
3
3
  export type Parsers = Scope
4
4
  & (
@@ -1,4 +1,4 @@
1
- export type Plugins =
1
+ export type Plugins = (
2
2
  | "@stylistic"
3
3
  | "@typescript-eslint"
4
4
  | "svelte"
@@ -6,4 +6,5 @@ export type Plugins =
6
6
  | "@html-eslint"
7
7
  | "jsonc"
8
8
  | "yml"
9
- | "markdownlint";
9
+ | "markdownlint"
10
+ );
@@ -0,0 +1,23 @@
1
+ export type { Scope } from "../scopes";
2
+
3
+ import type { PluginsInput } from "./plugins";
4
+ import type { ParsersInput } from "./parsers";
5
+ import type { FilesInput } from "./files";
6
+ import type { RulesInput } from "./rules";
7
+
8
+ export interface Input {
9
+ plugins: PluginsInput;
10
+ parsers: ParsersInput;
11
+ files: FilesInput;
12
+ rules: RulesInput;
13
+ }
14
+ export namespace Input {
15
+ export type Rule = RulesInput;
16
+ export namespace Rule {
17
+ export type Entry = RulesInput.Entry;
18
+ export namespace Entry {
19
+ export type Id = RulesInput.Entry.Id;
20
+ export type Record = RulesInput.Entry.Record;
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,3 @@
1
+ import type { Parsers } from "./imports/parsers";
2
+
3
+ export type ParsersInput = Record<Parsers, unknown>;
@@ -0,0 +1,3 @@
1
+ import type { Plugins } from "./imports/plugins";
2
+
3
+ export type PluginsInput = Record<Plugins, { configs: unknown }>;
@@ -0,0 +1,7 @@
1
+ import type { RuleRecord } from "./record";
2
+
3
+ export type RuleEntry = readonly [string, RuleRecord];
4
+ export namespace RuleEntry {
5
+ export type Id = string;
6
+ export type Record = RuleRecord;
7
+ }
@@ -0,0 +1,3 @@
1
+ import type { RuleState } from "./state";
2
+
3
+ export type RuleRecord = Table<RuleState | readonly [RuleState, ...unknown[]]>;
@@ -0,0 +1,5 @@
1
+ export type RuleState = (
2
+ | "error"
3
+ | "warn"
4
+ | "off"
5
+ );
@@ -0,0 +1,14 @@
1
+ import type { Scope } from "..";
2
+ import type { RuleEntry } from "./entry";
3
+
4
+ export interface RulesInput {
5
+ rules: Record<Scope, RuleEntry[]>;
6
+ overrides: Partial<Record<Scope, RuleEntry.Record>>;
7
+ }
8
+ export namespace RulesInput {
9
+ export type Entry = RuleEntry;
10
+ export namespace Entry {
11
+ export type Id = RuleEntry.Id;
12
+ export type Record = RuleEntry.Record;
13
+ }
14
+ }
package/src/output.ts CHANGED
@@ -1,24 +1,24 @@
1
- import type { Input } from "./input";
1
+ import type { Input } from ".";
2
2
 
3
- interface Config {
4
- name: `linted/scope:${string}/rule:${string}+${string}`;
5
- rules: Input["rules"]["rules"]["html"][number][1];
6
- files: readonly string[];
7
- linterOptions: {
8
- noInlineConfig: true;
9
- reportUnusedDisableDirectives: "error";
10
- };
11
- languageOptions: {
12
- sourceType?:
13
- | "module"
14
- | "script";
15
- ecmaVersion?: "latest";
16
- globals?: Record<string, true>;
17
- parser?: unknown;
18
- parserOptions?: Record<string, unknown>;
19
- };
20
- plugins: Record<string, Record<"configs", unknown>>;
21
- processor?: string;
22
- }
23
-
24
- export type Output = Config[];
3
+ export type Output = (
4
+ {
5
+ name: `linted/${string}`;
6
+ rules: Input["rules"]["rules"]["html"][number][1];
7
+ files: string[];
8
+ linterOptions: {
9
+ noInlineConfig: true;
10
+ reportUnusedDisableDirectives: "error";
11
+ };
12
+ languageOptions: {
13
+ sourceType?:
14
+ | "module"
15
+ | "script";
16
+ ecmaVersion?: "latest";
17
+ globals?: Table<true>;
18
+ parser?: unknown;
19
+ parserOptions?: Record<string, unknown>; // TODO: Change to Table<unknown> after lib update
20
+ };
21
+ plugins: Table<Record<"configs", unknown>>;
22
+ processor?: string;
23
+ }
24
+ )[];
package/src/scopes.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export type Scope = typeof scopes[number];
1
2
  export const scopes = [
2
3
  "js",
3
4
  "ts",
@@ -9,4 +10,3 @@ export const scopes = [
9
10
  "yml",
10
11
  "md",
11
12
  ] as const;
12
- export type Scope = (typeof scopes)[number];
package/tsconfig.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "display": "@jimbojet/tsc",
3
3
  "$schema": "https://json.schemastore.org/tsconfig",
4
- "_version": "5.6.1",
4
+ "_version": "5.6.1-core.1",
5
5
  "include": [
6
6
  "*.config.ts",
7
7
  "src/**/*.ts",
@@ -10,7 +10,7 @@
10
10
  ],
11
11
  "exclude": [],
12
12
  "compilerOptions": {
13
- /* http://aka.ms/tsconfig#quick-nav-Top%20Level */
13
+ /* https://www.typescriptlang.org/tsconfig/#quick-nav-Top%20Level */
14
14
 
15
15
  // #region TYPE CHECKING
16
16
  "allowUnreachableCode": false,
@@ -1,3 +0,0 @@
1
- import type globals from "globals";
2
-
3
- export type Globals = keyof typeof globals & "mocha";
@@ -1 +0,0 @@
1
- export type Ecma = "latest";
@@ -1 +0,0 @@
1
- export type Source = "module" | "script";
@@ -1,4 +0,0 @@
1
- export interface Linter {
2
- noInlineConfig: true;
3
- reportUnusedDisableDirectives: "error";
4
- }
@@ -1 +0,0 @@
1
- export type Plugins<PluginId extends string> = Record<literalful<PluginId>, { configs: unknown }>;
@@ -1,41 +0,0 @@
1
- import type { Input } from "@eslinted/core";
2
- import type { Scope } from "@eslinted/core";
3
- import { Rule } from "./rule";
4
-
5
- export { Rule };
6
- export class Ruleset<S extends Scope> {
7
- public readonly ruleset: readonly Rule[];
8
- public overrides: Null<Rule> = null;
9
-
10
- constructor(private readonly scope: literalful<S>, ...rules: readonly Rule[]) {
11
- try {
12
- this.ruleset = [...rules];
13
- }
14
- catch (e) { throw new Error(`linted.factory.Ruleset`, { cause: e }); }
15
- }
16
-
17
- public get id() {
18
- const { scope } = this;
19
-
20
- return scope;
21
- }
22
-
23
- public get records() {
24
- try {
25
- const { ruleset, overrides } = this;
26
-
27
- return [
28
- ...ruleset.map(rules => [rules.id, rules.rules] as const),
29
- ...overrides === null ? [] : [[overrides.id, overrides.rules] as const] as const,
30
- ];
31
- }
32
- catch (e) { throw new Error(`linted.factory.Ruleset: records`, { cause: e }); }
33
- }
34
-
35
- public override(overrides: undefined | Input["rules"]["rules"][Scope][number][1]) {
36
- if (typeof overrides !== "undefined")
37
- this.overrides = new Rule("override", overrides);
38
-
39
- return this;
40
- }
41
- }
@@ -1,8 +0,0 @@
1
- import type { Input } from "@eslinted/core";
2
-
3
- export class Rule {
4
- constructor(
5
- public readonly id: string,
6
- public readonly rules: Input["rules"]["rules"]["html"][number][1],
7
- ) {}
8
- }
@@ -1,16 +0,0 @@
1
- import type { Input } from "@eslinted/core";
2
- import type { Scope } from "@eslinted/core";
3
- import { Ruleset, Rule } from "./ruleset";
4
-
5
- export class Rulesets {
6
- constructor(private readonly input: Input["rules"]) {}
7
-
8
- public ruleset<S extends Scope>(scope: literalful<S>): Ruleset<S> {
9
- try {
10
- const { rules, overrides } = this.input;
11
-
12
- return new Ruleset<S>(scope, ...rules[scope].map(args => new Rule(...args))).override(overrides[scope]);
13
- }
14
- catch (e) { throw new Error(`linted.factory.Rulesets/ruleset/scope:${scope}`, { cause: e }); }
15
- }
16
- }
package/src/input.ts DELETED
@@ -1,11 +0,0 @@
1
- import type { Plugins } from "./inputs/plugins";
2
- import type { Parsers } from "./inputs/parsers";
3
- import type { Files } from "./inputs/files";
4
- import type { Rules } from "./inputs/rules";
5
-
6
- export interface Input {
7
- files: Files;
8
- rules: Rules;
9
- plugins: Plugins;
10
- parsers: Parsers;
11
- }
@@ -1,3 +0,0 @@
1
- import type { Scope } from "@eslinted/core";
2
-
3
- export type Base = Readonly<Record<Scope, readonly string[]>>;
@@ -1,3 +0,0 @@
1
- import type { Base } from "./base";
2
-
3
- export type Includes = Partial<Base>;
@@ -1,7 +0,0 @@
1
- import type { Base } from "./files/base";
2
- import type { Includes } from "./files/includes";
3
-
4
- export interface Files {
5
- files: Base;
6
- includes: Includes;
7
- }
@@ -1,2 +0,0 @@
1
- export type { Plugins } from "./imports/plugins";
2
- export type { Parsers } from "./imports/parsers";
@@ -1,3 +0,0 @@
1
- import type { Parsers as Imports } from "./imports/parsers";
2
-
3
- export type Parsers = Readonly<Record<Imports, unknown>>;
@@ -1,3 +0,0 @@
1
- import type { Plugins as Imports } from "./imports/plugins";
2
-
3
- export type Plugins = Readonly<Record<Imports, { configs: unknown }>>;
@@ -1,3 +0,0 @@
1
- import type { RuleRecord } from "./object";
2
-
3
- export type RuleEntry = readonly [string, RuleRecord];
@@ -1,7 +0,0 @@
1
- import type { State } from "./state";
2
-
3
- export type RuleRecord = Readonly<Record<
4
- string,
5
- | State
6
- | readonly [State, ...unknown[]]
7
- >>;
@@ -1,4 +0,0 @@
1
- export type State =
2
- | "error"
3
- | "warn"
4
- | "off";
@@ -1,4 +0,0 @@
1
- import type { Scope } from "@eslinted/core";
2
- import type { Preset } from "./preset";
3
-
4
- export type Overrides = Readonly<Partial<Record<Scope, Preset[Scope][number][1]>>>;
@@ -1,4 +0,0 @@
1
- import type { Scope } from "@eslinted/core";
2
- import type { RuleEntry } from "./entry";
3
-
4
- export type Preset = Readonly<Record<Scope, readonly RuleEntry[]>>;
@@ -1,7 +0,0 @@
1
- import type { Preset } from "./rules/preset";
2
- import type { Overrides } from "./rules/overrides";
3
-
4
- export interface Rules {
5
- rules: Preset;
6
- overrides: Overrides;
7
- }