@eslinted/core 22.1.4 → 22.1.5-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/.github/workflows/RELEASE.yml +36 -36
  2. package/.github/workflows/rc.yml +36 -36
  3. package/.markdownlint.jsonc +128 -128
  4. package/.mocharc.yml +15 -15
  5. package/LICENSE +20 -20
  6. package/README.md +4 -4
  7. package/eslint.config.js +3 -3
  8. package/package.json +55 -55
  9. package/src/_test/index.ts +266 -266
  10. package/src/factory.ts +306 -306
  11. package/src/index.spec.ts +106 -106
  12. package/src/index.ts +87 -87
  13. package/src/interface/config/index.ts +42 -42
  14. package/src/interface/config/rule.ts +12 -12
  15. package/src/interface/index.ts +3 -3
  16. package/src/interface/input/configuration/attachment.ts +13 -13
  17. package/src/interface/input/configuration/defaults.ts +24 -24
  18. package/src/interface/input/configuration/extensions.ts +25 -25
  19. package/src/interface/input/configuration/index.ts +17 -17
  20. package/src/interface/input/configuration/manifest/index.ts +15 -15
  21. package/src/interface/input/configuration/settings.ts +18 -18
  22. package/src/interface/input/imports/index.ts +16 -16
  23. package/src/interface/input/imports/optional.ts +11 -11
  24. package/src/interface/input/imports/required.ts +13 -13
  25. package/src/interface/input/index.ts +22 -22
  26. package/src/interface/output/configs/attachment.ts +13 -13
  27. package/src/interface/output/configs/global/ignores.d.ts +6 -6
  28. package/src/interface/output/configs/global/index.d.ts +3 -3
  29. package/src/interface/output/configs/global/plugins.d.ts +6 -6
  30. package/src/interface/output/configs/global/settings.d.ts +11 -11
  31. package/src/interface/output/configs/index.d.ts +3 -3
  32. package/src/interface/output/configs/scoped/index.d.ts +2 -2
  33. package/src/interface/output/configs/scoped/rules.d.ts +12 -12
  34. package/src/interface/output/configs/scoped/settings.d.ts +15 -15
  35. package/src/interface/output/index.d.ts +12 -12
  36. package/src/scope/dependencies/index.ts +2 -2
  37. package/src/scope/dependencies/parsers.ts +5 -5
  38. package/src/scope/dependencies/plugins.ts +12 -12
  39. package/src/scope/index.spec.ts +136 -136
  40. package/src/scope/index.ts +18 -18
  41. package/src/scope/tree/index.spec.ts +124 -124
  42. package/src/scope/tree/index.ts +22 -22
  43. package/tsconfig.json +156 -156
package/src/index.spec.ts CHANGED
@@ -1,106 +1,106 @@
1
- import "chai/register-should.js";
2
- import Core from ".";
3
- import { scopes } from "./scope";
4
- import { TEST_INPUT } from "./_test";
5
-
6
- const configs = Core(TEST_INPUT);
7
-
8
- describe(
9
- "Core",
10
- function () {
11
- describe(
12
- "shape",
13
- function () {
14
- it(
15
- "is a function",
16
- function () {
17
- Core
18
- .should.be
19
- .a("function");
20
- },
21
- );
22
- },
23
- );
24
- describe(
25
- "output",
26
- function () {
27
- it(
28
- "is a non-empty array",
29
- function () {
30
- configs
31
- .should.be
32
- .an("array")
33
- .not.empty;
34
- },
35
- );
36
- it(
37
- `with length >= plugins + */ignores + */settings + ${scopes.length} scopes = ${scopes.length + 3} [Actual: ${configs.length}`,
38
- function () {
39
- configs
40
- .should.have
41
- .lengthOf.above(scopes.length + 2);
42
- },
43
- );
44
- it(
45
- "containing only config-like members",
46
- function () {
47
- configs
48
- .should
49
- .satisfy((configs: unknown[]) => configs
50
- .every(config => typeof config === "object"
51
- && config !== null
52
- && "name" in config
53
- && typeof config.name === "string"));
54
- },
55
- );
56
- },
57
- );
58
- describe(
59
- "configs",
60
- function () {
61
- const [
62
- first,
63
- second,
64
- ] = configs as [object, object];
65
-
66
- it(
67
- "begin with plugins",
68
- function () {
69
- first
70
- .should.have
71
- .property(
72
- "name",
73
- "linted/*/plugins/",
74
- );
75
- first
76
- .should.have
77
- .property("plugins")
78
- .an("object");
79
- },
80
- );
81
- it(
82
- "followed by global settings",
83
- function () {
84
- second
85
- .should.have
86
- .property(
87
- "name",
88
- "linted/*/settings/",
89
- );
90
- second
91
- .should.have
92
- .property("linterOptions")
93
- .an("object");
94
- second
95
- .should.have
96
- .nested.property("languageOptions.sourceType")
97
- .a("string");
98
- second
99
- .should.have
100
- .nested.property("languageOptions.ecmaVersion");
101
- },
102
- );
103
- },
104
- );
105
- },
106
- );
1
+ import "chai/register-should.js";
2
+ import Core from ".";
3
+ import { scopes } from "./scope";
4
+ import { TEST_INPUT } from "./_test";
5
+
6
+ const configs = Core(TEST_INPUT);
7
+
8
+ describe(
9
+ "Core",
10
+ function () {
11
+ describe(
12
+ "shape",
13
+ function () {
14
+ it(
15
+ "is a function",
16
+ function () {
17
+ Core
18
+ .should.be
19
+ .a("function");
20
+ },
21
+ );
22
+ },
23
+ );
24
+ describe(
25
+ "output",
26
+ function () {
27
+ it(
28
+ "is a non-empty array",
29
+ function () {
30
+ configs
31
+ .should.be
32
+ .an("array")
33
+ .not.empty;
34
+ },
35
+ );
36
+ it(
37
+ `with length >= plugins + */ignores + */settings + ${scopes.length} scopes = ${scopes.length + 3} [Actual: ${configs.length}`,
38
+ function () {
39
+ configs
40
+ .should.have
41
+ .lengthOf.above(scopes.length + 2);
42
+ },
43
+ );
44
+ it(
45
+ "containing only config-like members",
46
+ function () {
47
+ configs
48
+ .should
49
+ .satisfy((configs: unknown[]) => configs
50
+ .every(config => typeof config === "object"
51
+ && config !== null
52
+ && "name" in config
53
+ && typeof config.name === "string"));
54
+ },
55
+ );
56
+ },
57
+ );
58
+ describe(
59
+ "configs",
60
+ function () {
61
+ const [
62
+ first,
63
+ second,
64
+ ] = configs as [object, object];
65
+
66
+ it(
67
+ "begin with plugins",
68
+ function () {
69
+ first
70
+ .should.have
71
+ .property(
72
+ "name",
73
+ "linted/*/plugins/",
74
+ );
75
+ first
76
+ .should.have
77
+ .property("plugins")
78
+ .an("object");
79
+ },
80
+ );
81
+ it(
82
+ "followed by global settings",
83
+ function () {
84
+ second
85
+ .should.have
86
+ .property(
87
+ "name",
88
+ "linted/*/settings/",
89
+ );
90
+ second
91
+ .should.have
92
+ .property("linterOptions")
93
+ .an("object");
94
+ second
95
+ .should.have
96
+ .nested.property("languageOptions.sourceType")
97
+ .a("string");
98
+ second
99
+ .should.have
100
+ .nested.property("languageOptions.ecmaVersion");
101
+ },
102
+ );
103
+ },
104
+ );
105
+ },
106
+ );
package/src/index.ts CHANGED
@@ -1,87 +1,87 @@
1
- import type {
2
- Input,
3
- Output,
4
- } from "./interface";
5
- import type {
6
- RequiredPlugin,
7
- RequiredParser,
8
- } from "./scope";
9
- import {
10
- scopes,
11
- optionalScopes,
12
- tree,
13
- } from "./scope";
14
- import { Factory } from "./factory";
15
-
16
- export default function (
17
- {
18
- imports: {
19
- required: {
20
- plugins,
21
- parsers,
22
- },
23
- optional = {},
24
- },
25
- configuration: {
26
- settings,
27
- defaults,
28
- extensions,
29
- attachments,
30
- },
31
- }: Input<
32
- RequiredPlugin,
33
- RequiredParser,
34
- (typeof optionalScopes[number]),
35
- (typeof scopes[number])
36
- >,
37
- ) {
38
- try {
39
- const factory = new Factory<
40
- RequiredPlugin,
41
- RequiredParser,
42
- (typeof optionalScopes[number]),
43
- (typeof scopes[number])
44
- >(
45
- optionalScopes,
46
- tree,
47
- settings,
48
- {
49
- ...parsers,
50
- ..."svelte" in optional
51
- ? {
52
- svelte: optional.svelte.parser,
53
- }
54
- : {},
55
- },
56
- defaults,
57
- extensions,
58
- attachments,
59
- );
60
-
61
- return [
62
- {
63
- name: "linted/*/plugins/",
64
- plugins: {
65
- ...plugins,
66
- ..."svelte" in optional
67
- ? {
68
- svelte: optional.svelte.plugin,
69
- }
70
- : {},
71
- },
72
- },
73
- ...factory.globals,
74
- ...scopes
75
- .flatMap(
76
- scope => factory.scope(scope),
77
- ),
78
- ...factory.attachments,
79
- ] satisfies Output as unknown[];
80
- }
81
- catch (e) {
82
- throw new Error(
83
- "linted-core: ",
84
- { cause: e },
85
- );
86
- }
87
- }
1
+ import type {
2
+ Input,
3
+ Output,
4
+ } from "./interface";
5
+ import type {
6
+ RequiredPlugin,
7
+ RequiredParser,
8
+ } from "./scope";
9
+ import {
10
+ scopes,
11
+ optionalScopes,
12
+ tree,
13
+ } from "./scope";
14
+ import { Factory } from "./factory";
15
+
16
+ export default function (
17
+ {
18
+ imports: {
19
+ required: {
20
+ plugins,
21
+ parsers,
22
+ },
23
+ optional = {},
24
+ },
25
+ configuration: {
26
+ settings,
27
+ defaults,
28
+ extensions,
29
+ attachments,
30
+ },
31
+ }: Input<
32
+ RequiredPlugin,
33
+ RequiredParser,
34
+ (typeof optionalScopes[number]),
35
+ (typeof scopes[number])
36
+ >,
37
+ ) {
38
+ try {
39
+ const factory = new Factory<
40
+ RequiredPlugin,
41
+ RequiredParser,
42
+ (typeof optionalScopes[number]),
43
+ (typeof scopes[number])
44
+ >(
45
+ optionalScopes,
46
+ tree,
47
+ settings,
48
+ {
49
+ ...parsers,
50
+ ..."svelte" in optional
51
+ ? {
52
+ svelte: optional.svelte.parser,
53
+ }
54
+ : {},
55
+ },
56
+ defaults,
57
+ extensions,
58
+ attachments,
59
+ );
60
+
61
+ return [
62
+ {
63
+ name: "linted/*/plugins/",
64
+ plugins: {
65
+ ...plugins,
66
+ ..."svelte" in optional
67
+ ? {
68
+ svelte: optional.svelte.plugin,
69
+ }
70
+ : {},
71
+ },
72
+ },
73
+ ...factory.globals,
74
+ ...scopes
75
+ .flatMap(
76
+ scope => factory.scope(scope),
77
+ ),
78
+ ...factory.attachments,
79
+ ] satisfies Output as unknown[];
80
+ }
81
+ catch (e) {
82
+ throw new Error(
83
+ "linted-core: ",
84
+ { cause: e },
85
+ );
86
+ }
87
+ }
@@ -1,42 +1,42 @@
1
- import type * as Rule from "./rule";
2
-
3
- export interface IConfig {
4
- name: `linted/${string}`;
5
- plugins: Record<string, unknown>;
6
- files: string[];
7
- ignores: string[];
8
- rules: Rule.Rules;
9
- linterOptions: {
10
- noInlineConfig: boolean;
11
- reportUnusedDisableDirectives:
12
- | "error"
13
- | "warn"
14
- | "off"
15
- ;
16
- };
17
- languageOptions: {
18
- sourceType:
19
- | "module"
20
- | "script"
21
- ;
22
- ecmaVersion:
23
- | "latest"
24
- | 3
25
- | 5
26
- | 2015
27
- | 2016
28
- | 2017
29
- | 2018
30
- | 2019
31
- | 2020
32
- | 2021
33
- | 2022
34
- | 2023
35
- | 2024
36
- ;
37
- };
38
- basePath?: string;
39
- processor?: string;
40
- language?: string;
41
- settings?: Record<string, unknown>;
42
- }
1
+ import type * as Rule from "./rule";
2
+
3
+ export interface IConfig {
4
+ name: `linted/${string}`;
5
+ plugins: Record<string, unknown>;
6
+ files: string[];
7
+ ignores: string[];
8
+ rules: Rule.Rules;
9
+ linterOptions: {
10
+ noInlineConfig: boolean;
11
+ reportUnusedDisableDirectives:
12
+ | "error"
13
+ | "warn"
14
+ | "off"
15
+ ;
16
+ };
17
+ languageOptions: {
18
+ sourceType:
19
+ | "module"
20
+ | "script"
21
+ ;
22
+ ecmaVersion:
23
+ | "latest"
24
+ | 3
25
+ | 5
26
+ | 2015
27
+ | 2016
28
+ | 2017
29
+ | 2018
30
+ | 2019
31
+ | 2020
32
+ | 2021
33
+ | 2022
34
+ | 2023
35
+ | 2024
36
+ ;
37
+ };
38
+ basePath?: string;
39
+ processor?: string;
40
+ language?: string;
41
+ settings?: Record<string, unknown>;
42
+ }
@@ -1,12 +1,12 @@
1
- export type State
2
- = | "error"
3
- | "warn"
4
- | "off";
5
- export type Rules = Record<
6
- string,
7
- | State
8
- | readonly [
9
- State,
10
- ...unknown[],
11
- ]
12
- >;
1
+ export type State
2
+ = | "error"
3
+ | "warn"
4
+ | "off";
5
+ export type Rules = Record<
6
+ string,
7
+ | State
8
+ | readonly [
9
+ State,
10
+ ...unknown[],
11
+ ]
12
+ >;
@@ -1,3 +1,3 @@
1
- export type * from "./input";
2
- export type * from "./output";
3
- export type * from "./config";
1
+ export type * from "./input";
2
+ export type * from "./output";
3
+ export type * from "./config";
@@ -1,13 +1,13 @@
1
- import type { IConfig } from "../../config";
2
-
3
- export type IAttachment
4
- = & {
5
- files: string[];
6
- }
7
- & Partial<
8
- Omit<
9
- IConfig,
10
- "files"
11
- >
12
- >;
13
-
1
+ import type { IConfig } from "../../config";
2
+
3
+ export type IAttachment
4
+ = & {
5
+ files: string[];
6
+ }
7
+ & Partial<
8
+ Omit<
9
+ IConfig,
10
+ "files"
11
+ >
12
+ >;
13
+
@@ -1,24 +1,24 @@
1
- import type { IConfig } from "../../config";
2
-
3
- export interface Defaults<
4
- Scope extends string,
5
- > {
6
- files: Record<
7
- Scope,
8
- string[]
9
- >;
10
- ignores: Record<
11
- (
12
- | "*"
13
- | Scope
14
- ),
15
- string[]
16
- >;
17
- rules: Record<
18
- Scope,
19
- {
20
- id: string;
21
- rules: IConfig["rules"];
22
- }[]
23
- >;
24
- }
1
+ import type { IConfig } from "../../config";
2
+
3
+ export interface Defaults<
4
+ Scope extends string,
5
+ > {
6
+ files: Record<
7
+ Scope,
8
+ string[]
9
+ >;
10
+ ignores: Record<
11
+ (
12
+ | "*"
13
+ | Scope
14
+ ),
15
+ string[]
16
+ >;
17
+ rules: Record<
18
+ Scope,
19
+ {
20
+ id: string;
21
+ rules: IConfig["rules"];
22
+ }[]
23
+ >;
24
+ }
@@ -1,25 +1,25 @@
1
- import type { IConfig } from "../../config";
2
-
3
- export type Extensions<
4
- Scope extends string,
5
- >
6
- = & {
7
- "*"?: Partial<
8
- & IConfig["linterOptions"]
9
- & IConfig["languageOptions"]
10
- > & {
11
- ignores?: string[];
12
- override?: boolean;
13
- };
14
- }
15
- & Partial<
16
- Record<
17
- Scope,
18
- {
19
- files?: string[];
20
- ignores?: string[];
21
- rules?: IConfig["rules"];
22
- }
23
- >
24
- >;
25
-
1
+ import type { IConfig } from "../../config";
2
+
3
+ export type Extensions<
4
+ Scope extends string,
5
+ >
6
+ = & {
7
+ "*"?: Partial<
8
+ & IConfig["linterOptions"]
9
+ & IConfig["languageOptions"]
10
+ > & {
11
+ ignores?: string[];
12
+ override?: boolean;
13
+ };
14
+ }
15
+ & Partial<
16
+ Record<
17
+ Scope,
18
+ {
19
+ files?: string[];
20
+ ignores?: string[];
21
+ rules?: IConfig["rules"];
22
+ }
23
+ >
24
+ >;
25
+
@@ -1,17 +1,17 @@
1
- import type { Settings } from "./settings";
2
- import type { Defaults } from "./defaults";
3
- import type { Extensions } from "./extensions";
4
- import type { IAttachment } from "./attachment";
5
-
6
- export interface Configuration<
7
- Scope extends string,
8
- Parser extends string,
9
- > {
10
- settings: Settings<
11
- Scope,
12
- Parser
13
- >;
14
- defaults: Defaults<Scope>;
15
- extensions: Extensions<Scope>;
16
- attachments: readonly IAttachment[];
17
- }
1
+ import type { Settings } from "./settings";
2
+ import type { Defaults } from "./defaults";
3
+ import type { Extensions } from "./extensions";
4
+ import type { IAttachment } from "./attachment";
5
+
6
+ export interface Configuration<
7
+ Scope extends string,
8
+ Parser extends string,
9
+ > {
10
+ settings: Settings<
11
+ Scope,
12
+ Parser
13
+ >;
14
+ defaults: Defaults<Scope>;
15
+ extensions: Extensions<Scope>;
16
+ attachments: readonly IAttachment[];
17
+ }