@eslinted/core 18.1.1 → 18.1.3
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.
- package/.github/workflows/RELEASE.yml +36 -36
- package/.github/workflows/rc.yml +36 -36
- package/.markdownlint.jsonc +126 -126
- package/LICENSE +21 -21
- package/README.md +4 -4
- package/SECURITY.md +8 -8
- package/eslint.config.js +3 -3
- package/package.json +92 -95
- package/src/factory/index.ts +141 -141
- package/src/factory/manifests.ts +21 -21
- package/src/factory/scopes/css.ts +17 -17
- package/src/factory/scopes/html.ts +14 -14
- package/src/factory/scopes/js.ts +11 -11
- package/src/factory/scopes/json.ts +11 -11
- package/src/factory/scopes/jsonc.ts +11 -11
- package/src/factory/scopes/manifest/index.ts +16 -16
- package/src/factory/scopes/mocha.ts +24 -24
- package/src/factory/scopes/svelte.ts +24 -24
- package/src/factory/scopes/ts.ts +25 -25
- package/src/factory/scopes/yml.ts +15 -15
- package/src/index.input.spec.ts +150 -150
- package/src/index.spec.ts +51 -51
- package/src/index.ts +24 -24
- package/src/interface/index.ts +3 -3
- package/src/interface/input/imports.ts +12 -12
- package/src/interface/input/index.ts +12 -12
- package/src/interface/input/scopes/defaults.ts +8 -8
- package/src/interface/input/scopes/extensions.ts +18 -18
- package/src/interface/input/scopes/index.ts +2 -2
- package/src/interface/output/configs/global/ignores.ts +6 -6
- package/src/interface/output/configs/global/index.ts +3 -3
- package/src/interface/output/configs/global/plugins.ts +7 -7
- package/src/interface/output/configs/global/settings.ts +7 -7
- package/src/interface/output/configs/index.ts +2 -2
- package/src/interface/output/configs/scoped/index.ts +2 -2
- package/src/interface/output/configs/scoped/rules.ts +8 -8
- package/src/interface/output/configs/scoped/settings.ts +12 -12
- package/src/interface/output/index.ts +9 -9
- package/src/interface/proto/config/index.ts +43 -43
- package/src/interface/proto/config/rule/index.ts +14 -14
- package/src/interface/proto/config/utility/index.ts +25 -25
- package/src/interface/proto/index.ts +1 -1
- package/src/scope/index.spec.ts +43 -43
- package/src/scope/index.ts +13 -13
- package/src/scope/tree/index.spec.ts +48 -48
- package/src/scope/tree/index.ts +8 -8
- package/src/scope/types/index.ts +24 -24
- package/tsconfig.json +165 -165
package/src/index.ts
CHANGED
@@ -1,24 +1,24 @@
|
|
1
|
-
import type { Input, Output } from "./interface";
|
2
|
-
import { scopes, tree } from "./scope";
|
3
|
-
import { Factory } from "./factory";
|
4
|
-
|
5
|
-
export type * from "./interface";
|
6
|
-
export type * from "./scope";
|
7
|
-
export default function ({
|
8
|
-
imports: { plugins, parsers },
|
9
|
-
defaults,
|
10
|
-
extensions,
|
11
|
-
}: Input): Output {
|
12
|
-
try {
|
13
|
-
const factory = new Factory(tree, parsers, defaults, extensions);
|
14
|
-
|
15
|
-
return [
|
16
|
-
{ name: "linted/*/plugins/", plugins } as const,
|
17
|
-
...factory.globals,
|
18
|
-
...scopes.flatMap(scope => factory.scope(scope)),
|
19
|
-
] as const;
|
20
|
-
}
|
21
|
-
catch (e) {
|
22
|
-
throw new Error(`Linted Core`, { cause: e });
|
23
|
-
}
|
24
|
-
}
|
1
|
+
import type { Input, Output } from "./interface";
|
2
|
+
import { scopes, tree } from "./scope";
|
3
|
+
import { Factory } from "./factory";
|
4
|
+
|
5
|
+
export type * from "./interface";
|
6
|
+
export type * from "./scope";
|
7
|
+
export default function ({
|
8
|
+
imports: { plugins, parsers },
|
9
|
+
defaults,
|
10
|
+
extensions,
|
11
|
+
}: Input): Output {
|
12
|
+
try {
|
13
|
+
const factory = new Factory(tree, parsers, defaults, extensions);
|
14
|
+
|
15
|
+
return [
|
16
|
+
{ name: "linted/*/plugins/", plugins } as const,
|
17
|
+
...factory.globals,
|
18
|
+
...scopes.flatMap(scope => factory.scope(scope)),
|
19
|
+
] as const;
|
20
|
+
}
|
21
|
+
catch (e) {
|
22
|
+
throw new Error(`Linted Core`, { cause: e });
|
23
|
+
}
|
24
|
+
}
|
package/src/interface/index.ts
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
export type * from "./input";
|
2
|
-
export type * from "./output";
|
3
|
-
export type * as Proto from "./proto";
|
1
|
+
export type * from "./input";
|
2
|
+
export type * from "./output";
|
3
|
+
export type * as Proto from "./proto";
|
@@ -1,12 +1,12 @@
|
|
1
|
-
import type { Config } from "../proto";
|
2
|
-
|
3
|
-
export interface Imports<
|
4
|
-
Plugins extends string,
|
5
|
-
Parsers extends string,
|
6
|
-
> {
|
7
|
-
readonly plugins: Config.Config<Plugins>["plugins"];
|
8
|
-
readonly parsers: Readonly<Record<
|
9
|
-
Parsers,
|
10
|
-
unknown
|
11
|
-
>>;
|
12
|
-
}
|
1
|
+
import type { Config } from "../proto";
|
2
|
+
|
3
|
+
export interface Imports<
|
4
|
+
Plugins extends string,
|
5
|
+
Parsers extends string,
|
6
|
+
> {
|
7
|
+
readonly plugins: Config.Config<Plugins>["plugins"];
|
8
|
+
readonly parsers: Readonly<Record<
|
9
|
+
Parsers,
|
10
|
+
unknown
|
11
|
+
>>;
|
12
|
+
}
|
@@ -1,12 +1,12 @@
|
|
1
|
-
import type { Import, Scope } from "../../scope";
|
2
|
-
import type { Imports } from "./imports";
|
3
|
-
import type { Defaults, Extensions } from "./scopes";
|
4
|
-
|
5
|
-
export interface Input {
|
6
|
-
readonly imports: Imports<
|
7
|
-
Import.Plugin,
|
8
|
-
Import.Parser
|
9
|
-
>;
|
10
|
-
readonly defaults: Defaults<Scope>;
|
11
|
-
readonly extensions: Extensions<Scope>;
|
12
|
-
}
|
1
|
+
import type { Import, Scope } from "../../scope";
|
2
|
+
import type { Imports } from "./imports";
|
3
|
+
import type { Defaults, Extensions } from "./scopes";
|
4
|
+
|
5
|
+
export interface Input {
|
6
|
+
readonly imports: Imports<
|
7
|
+
Import.Plugin,
|
8
|
+
Import.Parser
|
9
|
+
>;
|
10
|
+
readonly defaults: Defaults<Scope>;
|
11
|
+
readonly extensions: Extensions<Scope>;
|
12
|
+
}
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import type { Config } from "../../proto";
|
2
|
-
|
3
|
-
export interface Defaults<Scopes extends string> {
|
4
|
-
readonly settings: Config.Config["linterOptions"] & Config.Config["languageOptions"];
|
5
|
-
readonly files: Readonly<Record<Scopes, string[]>>;
|
6
|
-
readonly ignores: Readonly<Record<"*" | Scopes, string[]>>;
|
7
|
-
readonly rules: Readonly<Record<Scopes, Config.Rule.NamedRuleBag[]>>;
|
8
|
-
}
|
1
|
+
import type { Config } from "../../proto";
|
2
|
+
|
3
|
+
export interface Defaults<Scopes extends string> {
|
4
|
+
readonly settings: Config.Config["linterOptions"] & Config.Config["languageOptions"];
|
5
|
+
readonly files: Readonly<Record<Scopes, string[]>>;
|
6
|
+
readonly ignores: Readonly<Record<"*" | Scopes, string[]>>;
|
7
|
+
readonly rules: Readonly<Record<Scopes, Config.Rule.NamedRuleBag[]>>;
|
8
|
+
}
|
@@ -1,18 +1,18 @@
|
|
1
|
-
import type { Defaults } from "./defaults";
|
2
|
-
|
3
|
-
export type Extensions<Scopes extends string> = (
|
4
|
-
& {
|
5
|
-
readonly "*"?: Partial<Defaults<Scopes>["settings"]> & {
|
6
|
-
readonly override?: boolean;
|
7
|
-
readonly ignores?: Defaults<Scopes>["ignores"]["*"];
|
8
|
-
};
|
9
|
-
}
|
10
|
-
& Partial<Record<
|
11
|
-
Scopes,
|
12
|
-
{
|
13
|
-
readonly files?: Defaults<Scopes>["files"][Scopes];
|
14
|
-
readonly ignores?: Defaults<Scopes>["ignores"][Scopes];
|
15
|
-
readonly rules?: Defaults<Scopes>["rules"][Scopes][number]["rules"];
|
16
|
-
}
|
17
|
-
>>
|
18
|
-
);
|
1
|
+
import type { Defaults } from "./defaults";
|
2
|
+
|
3
|
+
export type Extensions<Scopes extends string> = (
|
4
|
+
& {
|
5
|
+
readonly "*"?: Partial<Defaults<Scopes>["settings"]> & {
|
6
|
+
readonly override?: boolean;
|
7
|
+
readonly ignores?: Defaults<Scopes>["ignores"]["*"];
|
8
|
+
};
|
9
|
+
}
|
10
|
+
& Partial<Record<
|
11
|
+
Scopes,
|
12
|
+
{
|
13
|
+
readonly files?: Defaults<Scopes>["files"][Scopes];
|
14
|
+
readonly ignores?: Defaults<Scopes>["ignores"][Scopes];
|
15
|
+
readonly rules?: Defaults<Scopes>["rules"][Scopes][number]["rules"];
|
16
|
+
}
|
17
|
+
>>
|
18
|
+
);
|
@@ -1,2 +1,2 @@
|
|
1
|
-
export type * from "./defaults";
|
2
|
-
export type * from "./extensions";
|
1
|
+
export type * from "./defaults";
|
2
|
+
export type * from "./extensions";
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import type { Config } from "../../../proto";
|
2
|
-
|
3
|
-
export type Ignores = Config.PickConfig<
|
4
|
-
"linted/*/ignores/",
|
5
|
-
"ignores"
|
6
|
-
>;
|
1
|
+
import type { Config } from "../../../proto";
|
2
|
+
|
3
|
+
export type Ignores = Config.PickConfig<
|
4
|
+
"linted/*/ignores/",
|
5
|
+
"ignores"
|
6
|
+
>;
|
@@ -1,3 +1,3 @@
|
|
1
|
-
export type * from "./plugins";
|
2
|
-
export type * from "./settings";
|
3
|
-
export type * from "./ignores";
|
1
|
+
export type * from "./plugins";
|
2
|
+
export type * from "./settings";
|
3
|
+
export type * from "./ignores";
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import type { Config } from "../../../proto";
|
2
|
-
|
3
|
-
export type Plugins<Plugins extends string> = Config.PickConfig<
|
4
|
-
"linted/*/plugins/",
|
5
|
-
"plugins",
|
6
|
-
Plugins
|
7
|
-
>;
|
1
|
+
import type { Config } from "../../../proto";
|
2
|
+
|
3
|
+
export type Plugins<Plugins extends string> = Config.PickConfig<
|
4
|
+
"linted/*/plugins/",
|
5
|
+
"plugins",
|
6
|
+
Plugins
|
7
|
+
>;
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import type { Config } from "../../../proto";
|
2
|
-
|
3
|
-
export type Settings = Config.PickConfig<
|
4
|
-
"linted/*/settings/",
|
5
|
-
| "linterOptions"
|
6
|
-
| "languageOptions"
|
7
|
-
>;
|
1
|
+
import type { Config } from "../../../proto";
|
2
|
+
|
3
|
+
export type Settings = Config.PickConfig<
|
4
|
+
"linted/*/settings/",
|
5
|
+
| "linterOptions"
|
6
|
+
| "languageOptions"
|
7
|
+
>;
|
@@ -1,2 +1,2 @@
|
|
1
|
-
export type * as Global from "./global";
|
2
|
-
export type * as Scoped from "./scoped";
|
1
|
+
export type * as Global from "./global";
|
2
|
+
export type * as Scoped from "./scoped";
|
@@ -1,2 +1,2 @@
|
|
1
|
-
export type * from "./rules";
|
2
|
-
export type * from "./settings";
|
1
|
+
export type * from "./rules";
|
2
|
+
export type * from "./settings";
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import type { Config } from "../../../proto";
|
2
|
-
|
3
|
-
export type Rules<Scope extends string> = Config.PickConfig<
|
4
|
-
`linted/${Scope}/${string}/`,
|
5
|
-
| "files"
|
6
|
-
| "ignores"
|
7
|
-
| "rules"
|
8
|
-
>;
|
1
|
+
import type { Config } from "../../../proto";
|
2
|
+
|
3
|
+
export type Rules<Scope extends string> = Config.PickConfig<
|
4
|
+
`linted/${Scope}/${string}/`,
|
5
|
+
| "files"
|
6
|
+
| "ignores"
|
7
|
+
| "rules"
|
8
|
+
>;
|
@@ -1,12 +1,12 @@
|
|
1
|
-
import type { Config } from "../../../proto";
|
2
|
-
|
3
|
-
export type Settings<Scope extends string> = Config.PickConfig<
|
4
|
-
`linted/${Scope}/`,
|
5
|
-
| "files"
|
6
|
-
| "ignores"
|
7
|
-
| "processor"
|
8
|
-
| "language"
|
9
|
-
| "settings",
|
10
|
-
string,
|
11
|
-
{ readonly languageOptions: object }
|
12
|
-
>;
|
1
|
+
import type { Config } from "../../../proto";
|
2
|
+
|
3
|
+
export type Settings<Scope extends string> = Config.PickConfig<
|
4
|
+
`linted/${Scope}/`,
|
5
|
+
| "files"
|
6
|
+
| "ignores"
|
7
|
+
| "processor"
|
8
|
+
| "language"
|
9
|
+
| "settings",
|
10
|
+
string,
|
11
|
+
{ readonly languageOptions: object }
|
12
|
+
>;
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import type * as Configs from "./configs";
|
2
|
-
import type { Import, Scope } from "../../scope";
|
3
|
-
|
4
|
-
export type Output = readonly [
|
5
|
-
Configs.Global.Plugins<Import.Plugin>,
|
6
|
-
Configs.Global.Settings,
|
7
|
-
Configs.Global.Ignores,
|
8
|
-
...readonly (Configs.Scoped.Settings<Scope> | Configs.Scoped.Rules<Scope>)[],
|
9
|
-
];
|
1
|
+
import type * as Configs from "./configs";
|
2
|
+
import type { Import, Scope } from "../../scope";
|
3
|
+
|
4
|
+
export type Output = readonly [
|
5
|
+
Configs.Global.Plugins<Import.Plugin>,
|
6
|
+
Configs.Global.Settings,
|
7
|
+
Configs.Global.Ignores,
|
8
|
+
...readonly (Configs.Scoped.Settings<Scope> | Configs.Scoped.Rules<Scope>)[],
|
9
|
+
];
|
@@ -1,43 +1,43 @@
|
|
1
|
-
import type * as Rule from "./rule";
|
2
|
-
|
3
|
-
export type { Rule };
|
4
|
-
export type * from "./utility";
|
5
|
-
export interface Config<Plugins extends string = string> {
|
6
|
-
readonly name: `linted/${string}/`;
|
7
|
-
readonly plugins: Readonly<Record<Plugins, unknown>>;
|
8
|
-
readonly files: readonly string[];
|
9
|
-
readonly ignores: readonly string[];
|
10
|
-
readonly rules: Rule.RuleBag;
|
11
|
-
readonly linterOptions: {
|
12
|
-
readonly noInlineConfig: boolean;
|
13
|
-
readonly reportUnusedDisableDirectives:
|
14
|
-
| "error"
|
15
|
-
| "warn"
|
16
|
-
| "off"
|
17
|
-
;
|
18
|
-
};
|
19
|
-
readonly languageOptions: {
|
20
|
-
readonly sourceType:
|
21
|
-
| "module"
|
22
|
-
| "script"
|
23
|
-
;
|
24
|
-
readonly ecmaVersion:
|
25
|
-
| "latest"
|
26
|
-
| 3
|
27
|
-
| 5
|
28
|
-
| 2015
|
29
|
-
| 2016
|
30
|
-
| 2017
|
31
|
-
| 2018
|
32
|
-
| 2019
|
33
|
-
| 2020
|
34
|
-
| 2021
|
35
|
-
| 2022
|
36
|
-
| 2023
|
37
|
-
| 2024
|
38
|
-
;
|
39
|
-
};
|
40
|
-
readonly processor?: string;
|
41
|
-
readonly language?: string;
|
42
|
-
readonly settings?: Readonly<Record<string, unknown>>;
|
43
|
-
}
|
1
|
+
import type * as Rule from "./rule";
|
2
|
+
|
3
|
+
export type { Rule };
|
4
|
+
export type * from "./utility";
|
5
|
+
export interface Config<Plugins extends string = string> {
|
6
|
+
readonly name: `linted/${string}/`;
|
7
|
+
readonly plugins: Readonly<Record<Plugins, unknown>>;
|
8
|
+
readonly files: readonly string[];
|
9
|
+
readonly ignores: readonly string[];
|
10
|
+
readonly rules: Rule.RuleBag;
|
11
|
+
readonly linterOptions: {
|
12
|
+
readonly noInlineConfig: boolean;
|
13
|
+
readonly reportUnusedDisableDirectives:
|
14
|
+
| "error"
|
15
|
+
| "warn"
|
16
|
+
| "off"
|
17
|
+
;
|
18
|
+
};
|
19
|
+
readonly languageOptions: {
|
20
|
+
readonly sourceType:
|
21
|
+
| "module"
|
22
|
+
| "script"
|
23
|
+
;
|
24
|
+
readonly ecmaVersion:
|
25
|
+
| "latest"
|
26
|
+
| 3
|
27
|
+
| 5
|
28
|
+
| 2015
|
29
|
+
| 2016
|
30
|
+
| 2017
|
31
|
+
| 2018
|
32
|
+
| 2019
|
33
|
+
| 2020
|
34
|
+
| 2021
|
35
|
+
| 2022
|
36
|
+
| 2023
|
37
|
+
| 2024
|
38
|
+
;
|
39
|
+
};
|
40
|
+
readonly processor?: string;
|
41
|
+
readonly language?: string;
|
42
|
+
readonly settings?: Readonly<Record<string, unknown>>;
|
43
|
+
}
|
@@ -1,14 +1,14 @@
|
|
1
|
-
export interface NamedRuleBag {
|
2
|
-
id: string;
|
3
|
-
readonly rules: RuleBag;
|
4
|
-
}
|
5
|
-
export type RuleBag = Readonly<Record<
|
6
|
-
string,
|
7
|
-
| RuleState
|
8
|
-
| readonly [RuleState, ...readonly unknown[]]
|
9
|
-
>>;
|
10
|
-
export type RuleState = (
|
11
|
-
| "error"
|
12
|
-
| "warn"
|
13
|
-
| "off"
|
14
|
-
);
|
1
|
+
export interface NamedRuleBag {
|
2
|
+
id: string;
|
3
|
+
readonly rules: RuleBag;
|
4
|
+
}
|
5
|
+
export type RuleBag = Readonly<Record<
|
6
|
+
string,
|
7
|
+
| RuleState
|
8
|
+
| readonly [RuleState, ...readonly unknown[]]
|
9
|
+
>>;
|
10
|
+
export type RuleState = (
|
11
|
+
| "error"
|
12
|
+
| "warn"
|
13
|
+
| "off"
|
14
|
+
);
|
@@ -1,25 +1,25 @@
|
|
1
|
-
import type { Config } from "..";
|
2
|
-
|
3
|
-
export type PickConfig<
|
4
|
-
Name extends Config["name"],
|
5
|
-
Picks extends Exclude<
|
6
|
-
keyof Config,
|
7
|
-
| "name"
|
8
|
-
| keyof Rest
|
9
|
-
>,
|
10
|
-
Plugins extends string = string,
|
11
|
-
Rest extends object = object,
|
12
|
-
> = (
|
13
|
-
& Rest
|
14
|
-
& Pick<Config<Plugins>, Picks>
|
15
|
-
& { readonly name: Name }
|
16
|
-
& Readonly<Partial<Record<
|
17
|
-
Exclude<
|
18
|
-
keyof Config,
|
19
|
-
| "name"
|
20
|
-
| keyof Rest
|
21
|
-
| Picks
|
22
|
-
>,
|
23
|
-
never
|
24
|
-
>>>
|
25
|
-
);
|
1
|
+
import type { Config } from "..";
|
2
|
+
|
3
|
+
export type PickConfig<
|
4
|
+
Name extends Config["name"],
|
5
|
+
Picks extends Exclude<
|
6
|
+
keyof Config,
|
7
|
+
| "name"
|
8
|
+
| keyof Rest
|
9
|
+
>,
|
10
|
+
Plugins extends string = string,
|
11
|
+
Rest extends object = object,
|
12
|
+
> = (
|
13
|
+
& Rest
|
14
|
+
& Pick<Config<Plugins>, Picks>
|
15
|
+
& { readonly name: Name }
|
16
|
+
& Readonly<Partial<Record<
|
17
|
+
Exclude<
|
18
|
+
keyof Config,
|
19
|
+
| "name"
|
20
|
+
| keyof Rest
|
21
|
+
| Picks
|
22
|
+
>,
|
23
|
+
never
|
24
|
+
>>>
|
25
|
+
);
|
@@ -1 +1 @@
|
|
1
|
-
export type * as Config from "./config";
|
1
|
+
export type * as Config from "./config";
|
package/src/scope/index.spec.ts
CHANGED
@@ -1,43 +1,43 @@
|
|
1
|
-
import { expect } from "chai";
|
2
|
-
import { scopes } from ".";
|
3
|
-
|
4
|
-
describe("Scopes", function () {
|
5
|
-
describe("shape", function () {
|
6
|
-
it("is a non-empty array", function () {
|
7
|
-
expect(scopes)
|
8
|
-
.an("array")
|
9
|
-
.not.empty;
|
10
|
-
});
|
11
|
-
});
|
12
|
-
describe("members", function () {
|
13
|
-
it("are unique", function () {
|
14
|
-
expect(scopes.length)
|
15
|
-
.equals(new Set(scopes).size);
|
16
|
-
});
|
17
|
-
});
|
18
|
-
describe("order", function () {
|
19
|
-
it("`jsonc` > `json`", function () {
|
20
|
-
expect(scopes)
|
21
|
-
.includes.members(["jsonc", "json"]);
|
22
|
-
expect(scopes.indexOf("jsonc"))
|
23
|
-
.greaterThan(scopes.indexOf("json"));
|
24
|
-
});
|
25
|
-
it("`mocha` > `ts`", function () {
|
26
|
-
expect(scopes)
|
27
|
-
.includes.members(["mocha", "ts"]);
|
28
|
-
expect(scopes.indexOf("mocha"))
|
29
|
-
.greaterThan(scopes.indexOf("ts"));
|
30
|
-
});
|
31
|
-
it("`svelte` > `ts`", function () {
|
32
|
-
expect(scopes).includes.members(["svelte", "ts"]);
|
33
|
-
expect(scopes.indexOf("svelte"))
|
34
|
-
.greaterThan(scopes.indexOf("ts"));
|
35
|
-
});
|
36
|
-
it("`ts` > `js`", function () {
|
37
|
-
expect(scopes)
|
38
|
-
.includes.members(["ts", "js"]);
|
39
|
-
expect(scopes.indexOf("ts"))
|
40
|
-
.greaterThan(scopes.indexOf("js"));
|
41
|
-
});
|
42
|
-
});
|
43
|
-
});
|
1
|
+
import { expect } from "chai";
|
2
|
+
import { scopes } from ".";
|
3
|
+
|
4
|
+
describe("Scopes", function () {
|
5
|
+
describe("shape", function () {
|
6
|
+
it("is a non-empty array", function () {
|
7
|
+
expect(scopes)
|
8
|
+
.an("array")
|
9
|
+
.not.empty;
|
10
|
+
});
|
11
|
+
});
|
12
|
+
describe("members", function () {
|
13
|
+
it("are unique", function () {
|
14
|
+
expect(scopes.length)
|
15
|
+
.equals(new Set(scopes).size);
|
16
|
+
});
|
17
|
+
});
|
18
|
+
describe("order", function () {
|
19
|
+
it("`jsonc` > `json`", function () {
|
20
|
+
expect(scopes)
|
21
|
+
.includes.members(["jsonc", "json"]);
|
22
|
+
expect(scopes.indexOf("jsonc"))
|
23
|
+
.greaterThan(scopes.indexOf("json"));
|
24
|
+
});
|
25
|
+
it("`mocha` > `ts`", function () {
|
26
|
+
expect(scopes)
|
27
|
+
.includes.members(["mocha", "ts"]);
|
28
|
+
expect(scopes.indexOf("mocha"))
|
29
|
+
.greaterThan(scopes.indexOf("ts"));
|
30
|
+
});
|
31
|
+
it("`svelte` > `ts`", function () {
|
32
|
+
expect(scopes).includes.members(["svelte", "ts"]);
|
33
|
+
expect(scopes.indexOf("svelte"))
|
34
|
+
.greaterThan(scopes.indexOf("ts"));
|
35
|
+
});
|
36
|
+
it("`ts` > `js`", function () {
|
37
|
+
expect(scopes)
|
38
|
+
.includes.members(["ts", "js"]);
|
39
|
+
expect(scopes.indexOf("ts"))
|
40
|
+
.greaterThan(scopes.indexOf("js"));
|
41
|
+
});
|
42
|
+
});
|
43
|
+
});
|
package/src/scope/index.ts
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
export type * from "./types";
|
2
|
-
export * from "./tree";
|
3
|
-
export const scopes = [
|
4
|
-
"js",
|
5
|
-
"ts",
|
6
|
-
"mocha",
|
7
|
-
"svelte",
|
8
|
-
"html",
|
9
|
-
"css",
|
10
|
-
"json",
|
11
|
-
"jsonc",
|
12
|
-
"yml",
|
13
|
-
] as const;
|
1
|
+
export type * from "./types";
|
2
|
+
export * from "./tree";
|
3
|
+
export const scopes = [
|
4
|
+
"js",
|
5
|
+
"ts",
|
6
|
+
"mocha",
|
7
|
+
"svelte",
|
8
|
+
"html",
|
9
|
+
"css",
|
10
|
+
"json",
|
11
|
+
"jsonc",
|
12
|
+
"yml",
|
13
|
+
] as const;
|