@eslinted/core 18.9.4 → 18.10.1

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/src/index.spec.ts CHANGED
@@ -1,51 +1,106 @@
1
- import { expect } from "chai";
1
+ import "chai/register-should.js";
2
2
  import core from ".";
3
3
  import { scopes } from "./scopes";
4
- import { TestInput } from "./index.input.spec";
4
+ import { TestInput } from "./test/input";
5
5
 
6
6
  const configs = core(TestInput);
7
7
 
8
- describe("Core", function () {
9
- describe("shape", function () {
10
- it("is a function", function () {
11
- expect(core)
12
- .a("function");
13
- });
14
- });
15
- describe("output", function () {
16
- it("is a non-empty array", function () {
17
- expect(configs)
18
- .an("array")
19
- .not.empty;
20
- });
21
- it(`with length >= plugins + */ignores + */settings + ${scopes.length} scopes = ${scopes.length + 3} [Actual: ${configs.length}`, function () {
22
- expect(configs)
23
- .lengthOf.above(scopes.length + 2);
24
- });
25
- it("containing only config-like members", function () {
26
- expect(configs)
27
- .satisfies((configs: unknown[]) => configs.every(config => typeof config === "object" && config !== null && "name" in config && typeof config.name === "string"));
28
- });
29
- });
30
- describe("configs", function () {
31
- it("begin with plugins", function () {
32
- expect(configs[0])
33
- .has.property("name", "linted/*/plugins/");
34
- expect(configs[0])
35
- .has.property("plugins")
36
- .an("object");
37
- });
38
- it("followed by global settings", function () {
39
- expect(configs[1])
40
- .has.property("name", "linted/*/settings/");
41
- expect(configs[1])
42
- .has.property("linterOptions")
43
- .an("object");
44
- expect(configs[1])
45
- .has.nested.property("languageOptions.sourceType")
46
- .a("string");
47
- expect(configs[1])
48
- .has.nested.property("languageOptions.ecmaVersion");
49
- });
50
- });
51
- });
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
@@ -2,23 +2,46 @@ import type { Input, Output } from "./interface";
2
2
  import { scopes, tree } from "./scopes";
3
3
  import { Factory } from "./factory";
4
4
 
5
- export type * from "./interface";
5
+ export type * from "./interface/input";
6
+ export type * from "./interface/proto";
6
7
  export type * from "./scopes";
7
- export default function ({
8
- imports: { plugins, parsers },
9
- defaults,
10
- extensions,
11
- }: Input): Output {
8
+ export default function (
9
+ {
10
+ imports: {
11
+ plugins,
12
+ parsers,
13
+ },
14
+ defaults,
15
+ extensions,
16
+ }: Input,
17
+ ) {
12
18
  try {
13
- const factory = new Factory(tree, parsers, defaults, extensions);
19
+ const factory = new Factory(
20
+ tree,
21
+ parsers,
22
+ defaults,
23
+ extensions,
24
+ );
14
25
 
15
26
  return [
16
- { name: "linted/*/plugins/", plugins } as const,
27
+ {
28
+ name: "linted/*/plugins/",
29
+ plugins,
30
+ },
17
31
  ...factory.globals,
18
- ...scopes.flatMap(scope => factory.scope(scope)),
19
- ] as const;
32
+ ...scopes
33
+ .flatMap(
34
+ scope => factory
35
+ .scope(
36
+ scope,
37
+ ),
38
+ ),
39
+ ] satisfies Output satisfies unknown[] as unknown[];
20
40
  }
21
41
  catch (e) {
22
- throw new Error(`Linted Core`, { cause: e });
42
+ throw new Error(
43
+ "linted-core: ",
44
+ { cause: e },
45
+ );
23
46
  }
24
47
  }
@@ -1,43 +1,128 @@
1
- import { expect } from "chai";
1
+ import "chai/register-should.js";
2
2
  import { scopes } from ".";
3
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
- });
4
+ describe(
5
+ "Scopes",
6
+ function () {
7
+ describe(
8
+ "shape",
9
+ function () {
10
+ it(
11
+ "is a non-empty array",
12
+ function () {
13
+ scopes
14
+ .should.be
15
+ .an("array")
16
+ .not.empty;
17
+ },
18
+ );
19
+ },
20
+ );
21
+ describe(
22
+ "members",
23
+ function () {
24
+ it(
25
+ "are unique",
26
+ function () {
27
+ scopes
28
+ .length
29
+ .should
30
+ .equal(
31
+ new Set(scopes)
32
+ .size,
33
+ );
34
+ },
35
+ );
36
+ },
37
+ );
38
+ describe(
39
+ "order",
40
+ function () {
41
+ it(
42
+ "`jsonc` > `json`",
43
+ function () {
44
+ scopes
45
+ .should
46
+ .include
47
+ .members(
48
+ [
49
+ "jsonc",
50
+ "json",
51
+ ],
52
+ );
53
+ scopes
54
+ .indexOf("jsonc")
55
+ .should.be
56
+ .greaterThan(
57
+ scopes
58
+ .indexOf("json"),
59
+ );
60
+ },
61
+ );
62
+ it(
63
+ "`mocha` > `ts`",
64
+ function () {
65
+ scopes
66
+ .should
67
+ .include
68
+ .members(
69
+ [
70
+ "mocha",
71
+ "ts",
72
+ ],
73
+ );
74
+ scopes
75
+ .indexOf("mocha")
76
+ .should.be
77
+ .greaterThan(
78
+ scopes
79
+ .indexOf("ts"),
80
+ );
81
+ },
82
+ );
83
+ it(
84
+ "`svelte` > `ts`",
85
+ function () {
86
+ scopes
87
+ .should
88
+ .include
89
+ .members(
90
+ [
91
+ "svelte",
92
+ "ts",
93
+ ],
94
+ );
95
+ scopes
96
+ .indexOf("svelte")
97
+ .should.be
98
+ .greaterThan(
99
+ scopes
100
+ .indexOf("ts"),
101
+ );
102
+ },
103
+ );
104
+ it(
105
+ "`ts` > `js`",
106
+ function () {
107
+ scopes
108
+ .should
109
+ .include
110
+ .members(
111
+ [
112
+ "ts",
113
+ "js",
114
+ ],
115
+ );
116
+ scopes
117
+ .indexOf("ts")
118
+ .should.be
119
+ .greaterThan(
120
+ scopes
121
+ .indexOf("js"),
122
+ );
123
+ },
124
+ );
125
+ },
126
+ );
127
+ },
128
+ );
@@ -1,48 +1,122 @@
1
- import { expect } from "chai";
1
+ import "chai/register-should.js";
2
2
  import { tree } from ".";
3
3
 
4
4
  const nodes = tree.map(([scope]) => scope);
5
5
 
6
- describe("Scope Tree", function () {
7
- describe("shape", function () {
8
- it("is an array", function () {
9
- expect(tree)
10
- .an("array");
11
- });
12
- });
13
- describe("members", function () {
14
- it("are unique", function () {
15
- expect(tree.length)
16
- .equals(new Set(nodes).size);
17
- });
18
- it("omit `js`", function () {
19
- expect(nodes)
20
- .to.not.include.members(["js"]);
21
- });
22
- });
23
- describe("order", function () {
24
- it("`jsonc` < [`json`]?", function () {
25
- expect(nodes)
26
- .includes.members(["jsonc"]);
27
- expect(nodes.indexOf("jsonc"))
28
- .lessThan(-nodes.indexOf("json") * tree.length);
29
- });
30
- it("`mocha` < `ts`", function () {
31
- expect(nodes)
32
- .includes.members(["mocha", "ts"]);
33
- expect(nodes.indexOf("mocha"))
34
- .lessThan(nodes.indexOf("ts"));
35
- });
36
- it("`svelte` < `ts`", function () {
37
- expect(nodes).includes.members(["svelte", "ts"]);
38
- expect(nodes.indexOf("svelte"))
39
- .lessThan(nodes.indexOf("ts"));
40
- });
41
- it("`ts` is last", function () {
42
- expect(nodes)
43
- .includes.members(["ts"]);
44
- expect(nodes.indexOf("ts"))
45
- .equals(tree.length - 1);
46
- });
47
- });
48
- });
6
+ describe(
7
+ "Scope Tree",
8
+ function () {
9
+ describe(
10
+ "shape",
11
+ function () {
12
+ it(
13
+ "is an array",
14
+ function () {
15
+ tree
16
+ .should.be
17
+ .an("array");
18
+ },
19
+ );
20
+ },
21
+ );
22
+ describe(
23
+ "members",
24
+ function () {
25
+ it(
26
+ "are unique",
27
+ function () {
28
+ tree
29
+ .length
30
+ .should
31
+ .equal(
32
+ new Set(nodes)
33
+ .size,
34
+ );
35
+ },
36
+ );
37
+ it(
38
+ "omit `js`",
39
+ function () {
40
+ nodes
41
+ .should
42
+ .not.include
43
+ .members(["js"]);
44
+ },
45
+ );
46
+ },
47
+ );
48
+ describe(
49
+ "order",
50
+ function () {
51
+ it(
52
+ "`jsonc` < [`json`]?",
53
+ function () {
54
+ nodes
55
+ .should
56
+ .include
57
+ .members(["jsonc"]);
58
+ nodes
59
+ .indexOf("jsonc")
60
+ .should.be
61
+ .lessThan(-nodes.indexOf("json") * tree.length);
62
+ },
63
+ );
64
+ it(
65
+ "`mocha` < `ts`",
66
+ function () {
67
+ nodes
68
+ .should
69
+ .include
70
+ .members(
71
+ [
72
+ "mocha",
73
+ "ts",
74
+ ],
75
+ );
76
+ nodes
77
+ .indexOf("mocha")
78
+ .should.be
79
+ .lessThan(
80
+ nodes
81
+ .indexOf("ts"),
82
+ );
83
+ },
84
+ );
85
+ it(
86
+ "`svelte` < `ts`",
87
+ function () {
88
+ nodes
89
+ .should
90
+ .include
91
+ .members(
92
+ [
93
+ "svelte",
94
+ "ts",
95
+ ],
96
+ );
97
+ nodes
98
+ .indexOf("svelte")
99
+ .should.be
100
+ .lessThan(
101
+ nodes
102
+ .indexOf("ts"),
103
+ );
104
+ },
105
+ );
106
+ it(
107
+ "`ts` is last",
108
+ function () {
109
+ nodes
110
+ .should
111
+ .include
112
+ .members(["ts"]);
113
+ nodes
114
+ .indexOf("ts")
115
+ .should
116
+ .equal(tree.length - 1);
117
+ },
118
+ );
119
+ },
120
+ );
121
+ },
122
+ );