@eslinted/core 18.9.4 → 18.10.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.
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -4
- package/dist/index.js.map +1 -1
- package/dist/index.spec.d.ts +1 -1
- package/dist/index.spec.d.ts.map +1 -1
- package/dist/index.spec.js +34 -19
- package/dist/index.spec.js.map +1 -1
- package/dist/scopes/index.spec.d.ts +1 -1
- package/dist/scopes/index.spec.d.ts.map +1 -1
- package/dist/scopes/index.spec.js +56 -19
- package/dist/scopes/index.spec.js.map +1 -1
- package/dist/scopes/tree/index.spec.d.ts +1 -1
- package/dist/scopes/tree/index.spec.d.ts.map +1 -1
- package/dist/scopes/tree/index.spec.js +51 -20
- package/dist/scopes/tree/index.spec.js.map +1 -1
- package/dist/test/input.d.ts +3 -0
- package/dist/test/input.d.ts.map +1 -0
- package/dist/{index.input.spec.js → test/input.js} +41 -13
- package/dist/test/input.js.map +1 -0
- package/package.json +1 -1
- package/src/index.spec.ts +101 -46
- package/src/index.ts +34 -11
- package/src/scopes/index.spec.ts +126 -41
- package/src/scopes/tree/index.spec.ts +118 -44
- package/src/{index.input.spec.ts → test/input.ts} +63 -35
- package/dist/index.input.spec.d.ts +0 -3
- package/dist/index.input.spec.d.ts.map +0 -1
- package/dist/index.input.spec.js.map +0 -1
package/src/index.spec.ts
CHANGED
@@ -1,51 +1,106 @@
|
|
1
|
-
import
|
1
|
+
import "chai/register-should.js";
|
2
2
|
import core from ".";
|
3
3
|
import { scopes } from "./scopes";
|
4
|
-
import { TestInput } from "./
|
4
|
+
import { TestInput } from "./test/input";
|
5
5
|
|
6
6
|
const configs = core(TestInput);
|
7
7
|
|
8
|
-
describe(
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
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
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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(
|
19
|
+
const factory = new Factory(
|
20
|
+
tree,
|
21
|
+
parsers,
|
22
|
+
defaults,
|
23
|
+
extensions,
|
24
|
+
);
|
14
25
|
|
15
26
|
return [
|
16
|
-
{
|
27
|
+
{
|
28
|
+
name: "linted/*/plugins/",
|
29
|
+
plugins,
|
30
|
+
},
|
17
31
|
...factory.globals,
|
18
|
-
...scopes
|
19
|
-
|
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(
|
42
|
+
throw new Error(
|
43
|
+
"linted-core: ",
|
44
|
+
{ cause: e },
|
45
|
+
);
|
23
46
|
}
|
24
47
|
}
|
package/src/scopes/index.spec.ts
CHANGED
@@ -1,43 +1,128 @@
|
|
1
|
-
import
|
1
|
+
import "chai/register-should.js";
|
2
2
|
import { scopes } from ".";
|
3
3
|
|
4
|
-
describe(
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
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
|
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(
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
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
|
+
);
|