@simplysm/lint 13.0.69 → 13.0.71
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/README.md +12 -490
- package/dist/eslint-recommended.js +41 -41
- package/dist/rules/no-hard-private.d.ts +6 -6
- package/dist/rules/no-hard-private.js +6 -6
- package/dist/rules/no-subpath-imports-from-simplysm.d.ts +5 -5
- package/dist/rules/no-subpath-imports-from-simplysm.js +6 -6
- package/dist/rules/ts-no-throw-not-implemented-error.d.ts +5 -5
- package/dist/rules/ts-no-throw-not-implemented-error.js +2 -2
- package/dist/stylelint-recommended.js +3 -3
- package/dist/utils/create-rule.d.ts +3 -3
- package/package.json +5 -4
- package/src/eslint-recommended.ts +54 -54
- package/src/rules/no-hard-private.ts +23 -23
- package/src/rules/no-subpath-imports-from-simplysm.ts +13 -13
- package/src/rules/ts-no-throw-not-implemented-error.ts +13 -13
- package/src/stylelint-recommended.ts +3 -3
- package/src/utils/create-rule.ts +3 -3
- package/tests/no-hard-private.spec.ts +961 -0
- package/tests/no-subpath-imports-from-simplysm.spec.ts +352 -0
- package/tests/recommended.spec.ts +155 -0
- package/tests/ts-no-throw-not-implemented-error.spec.ts +386 -0
- package/tests/vitest.setup.ts +10 -0
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import "./vitest.setup";
|
|
2
|
+
import { describe } from "vitest";
|
|
3
|
+
import { RuleTester } from "@typescript-eslint/rule-tester";
|
|
4
|
+
import rule from "../src/rules/no-subpath-imports-from-simplysm";
|
|
5
|
+
|
|
6
|
+
const ruleTester = new RuleTester();
|
|
7
|
+
|
|
8
|
+
describe("no-subpath-imports-from-simplysm rule", () => {
|
|
9
|
+
describe("allowed code (valid)", () => {
|
|
10
|
+
describe("package root import is allowed", () => {
|
|
11
|
+
ruleTester.run("no-subpath-imports-from-simplysm", rule, {
|
|
12
|
+
valid: [
|
|
13
|
+
{
|
|
14
|
+
code: `import { Something } from "@simplysm/sd-core-common";`,
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
invalid: [],
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
describe("subpath import other than src is allowed", () => {
|
|
22
|
+
ruleTester.run("no-subpath-imports-from-simplysm", rule, {
|
|
23
|
+
valid: [
|
|
24
|
+
{
|
|
25
|
+
code: `import { Something } from "@simplysm/sd-core-common/utils";`,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
code: `import { Something } from "@simplysm/sd-core-common/types/DateOnly";`,
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
invalid: [],
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
describe("packages other than @simplysm are allowed", () => {
|
|
36
|
+
ruleTester.run("no-subpath-imports-from-simplysm", rule, {
|
|
37
|
+
valid: [
|
|
38
|
+
{
|
|
39
|
+
code: `import { Something } from "@angular/core";`,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
code: `import { Something } from "lodash/src/utils";`,
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
invalid: [],
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
describe("dynamic import - path other than src is allowed", () => {
|
|
50
|
+
ruleTester.run("no-subpath-imports-from-simplysm", rule, {
|
|
51
|
+
valid: [
|
|
52
|
+
{
|
|
53
|
+
code: `const mod = await import("@simplysm/sd-core-common");`,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
code: `const mod = await import("@simplysm/sd-core-common/utils");`,
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
invalid: [],
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
describe("re-export - path other than src is allowed", () => {
|
|
64
|
+
ruleTester.run("no-subpath-imports-from-simplysm", rule, {
|
|
65
|
+
valid: [
|
|
66
|
+
{
|
|
67
|
+
code: `export { Something } from "@simplysm/sd-core-common";`,
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
code: `export * from "@simplysm/sd-core-common/utils";`,
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
invalid: [],
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
describe("code that should cause errors (invalid)", () => {
|
|
79
|
+
describe("@simplysm/*/src import is prohibited", () => {
|
|
80
|
+
ruleTester.run("no-subpath-imports-from-simplysm", rule, {
|
|
81
|
+
valid: [],
|
|
82
|
+
invalid: [
|
|
83
|
+
{
|
|
84
|
+
code: `import { Something } from "@simplysm/sd-core-common/src";`,
|
|
85
|
+
output: `import { Something } from "@simplysm/sd-core-common";`,
|
|
86
|
+
errors: [
|
|
87
|
+
{
|
|
88
|
+
messageId: "noSubpathImport",
|
|
89
|
+
data: {
|
|
90
|
+
pkg: "sd-core-common",
|
|
91
|
+
importPath: "@simplysm/sd-core-common/src",
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
describe("@simplysm/*/src/xxx import is prohibited", () => {
|
|
101
|
+
ruleTester.run("no-subpath-imports-from-simplysm", rule, {
|
|
102
|
+
valid: [],
|
|
103
|
+
invalid: [
|
|
104
|
+
{
|
|
105
|
+
code: `import { DateOnly } from "@simplysm/sd-core-common/src/types/DateOnly";`,
|
|
106
|
+
output: `import { DateOnly } from "@simplysm/sd-core-common";`,
|
|
107
|
+
errors: [
|
|
108
|
+
{
|
|
109
|
+
messageId: "noSubpathImport",
|
|
110
|
+
data: {
|
|
111
|
+
pkg: "sd-core-common",
|
|
112
|
+
importPath: "@simplysm/sd-core-common/src/types/DateOnly",
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
],
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
describe("src import prohibited from multiple packages", () => {
|
|
122
|
+
ruleTester.run("no-subpath-imports-from-simplysm", rule, {
|
|
123
|
+
valid: [],
|
|
124
|
+
invalid: [
|
|
125
|
+
{
|
|
126
|
+
code: `import { SdServiceClient } from "@simplysm/sd-service-client/src/SdServiceClient";`,
|
|
127
|
+
output: `import { SdServiceClient } from "@simplysm/sd-service-client";`,
|
|
128
|
+
errors: [
|
|
129
|
+
{
|
|
130
|
+
messageId: "noSubpathImport",
|
|
131
|
+
data: {
|
|
132
|
+
pkg: "sd-service-client",
|
|
133
|
+
importPath: "@simplysm/sd-service-client/src/SdServiceClient",
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
],
|
|
137
|
+
},
|
|
138
|
+
],
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
describe("src path prohibited in dynamic import", () => {
|
|
143
|
+
ruleTester.run("no-subpath-imports-from-simplysm", rule, {
|
|
144
|
+
valid: [],
|
|
145
|
+
invalid: [
|
|
146
|
+
{
|
|
147
|
+
code: `const mod = await import("@simplysm/sd-core-common/src/utils");`,
|
|
148
|
+
output: `const mod = await import("@simplysm/sd-core-common");`,
|
|
149
|
+
errors: [
|
|
150
|
+
{
|
|
151
|
+
messageId: "noSubpathImport",
|
|
152
|
+
data: {
|
|
153
|
+
pkg: "sd-core-common",
|
|
154
|
+
importPath: "@simplysm/sd-core-common/src/utils",
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
describe("src path prohibited in re-export", () => {
|
|
164
|
+
ruleTester.run("no-subpath-imports-from-simplysm", rule, {
|
|
165
|
+
valid: [],
|
|
166
|
+
invalid: [
|
|
167
|
+
{
|
|
168
|
+
code: `export { Something } from "@simplysm/sd-core-common/src/types";`,
|
|
169
|
+
output: `export { Something } from "@simplysm/sd-core-common";`,
|
|
170
|
+
errors: [
|
|
171
|
+
{
|
|
172
|
+
messageId: "noSubpathImport",
|
|
173
|
+
data: {
|
|
174
|
+
pkg: "sd-core-common",
|
|
175
|
+
importPath: "@simplysm/sd-core-common/src/types",
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
],
|
|
179
|
+
},
|
|
180
|
+
],
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
describe("src path prohibited in export * from", () => {
|
|
185
|
+
ruleTester.run("no-subpath-imports-from-simplysm", rule, {
|
|
186
|
+
valid: [],
|
|
187
|
+
invalid: [
|
|
188
|
+
{
|
|
189
|
+
code: `export * from "@simplysm/sd-core-common/src/types";`,
|
|
190
|
+
output: `export * from "@simplysm/sd-core-common";`,
|
|
191
|
+
errors: [
|
|
192
|
+
{
|
|
193
|
+
messageId: "noSubpathImport",
|
|
194
|
+
data: {
|
|
195
|
+
pkg: "sd-core-common",
|
|
196
|
+
importPath: "@simplysm/sd-core-common/src/types",
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
],
|
|
200
|
+
},
|
|
201
|
+
],
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
describe("preserve quote style when using single quotes", () => {
|
|
206
|
+
ruleTester.run("no-subpath-imports-from-simplysm", rule, {
|
|
207
|
+
valid: [],
|
|
208
|
+
invalid: [
|
|
209
|
+
{
|
|
210
|
+
code: `import { Something } from '@simplysm/sd-core-common/src';`,
|
|
211
|
+
output: `import { Something } from '@simplysm/sd-core-common';`,
|
|
212
|
+
errors: [
|
|
213
|
+
{
|
|
214
|
+
messageId: "noSubpathImport",
|
|
215
|
+
data: {
|
|
216
|
+
pkg: "sd-core-common",
|
|
217
|
+
importPath: "@simplysm/sd-core-common/src",
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
],
|
|
221
|
+
},
|
|
222
|
+
],
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
describe("src path prohibited in type-only import", () => {
|
|
227
|
+
ruleTester.run("no-subpath-imports-from-simplysm", rule, {
|
|
228
|
+
valid: [],
|
|
229
|
+
invalid: [
|
|
230
|
+
{
|
|
231
|
+
code: `import type { DateOnly } from "@simplysm/sd-core-common/src/types";`,
|
|
232
|
+
output: `import type { DateOnly } from "@simplysm/sd-core-common";`,
|
|
233
|
+
errors: [
|
|
234
|
+
{
|
|
235
|
+
messageId: "noSubpathImport",
|
|
236
|
+
data: {
|
|
237
|
+
pkg: "sd-core-common",
|
|
238
|
+
importPath: "@simplysm/sd-core-common/src/types",
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
],
|
|
242
|
+
},
|
|
243
|
+
],
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
describe("src path prohibited in export type", () => {
|
|
248
|
+
ruleTester.run("no-subpath-imports-from-simplysm", rule, {
|
|
249
|
+
valid: [],
|
|
250
|
+
invalid: [
|
|
251
|
+
{
|
|
252
|
+
code: `export type { DateOnly } from "@simplysm/sd-core-common/src/types";`,
|
|
253
|
+
output: `export type { DateOnly } from "@simplysm/sd-core-common";`,
|
|
254
|
+
errors: [
|
|
255
|
+
{
|
|
256
|
+
messageId: "noSubpathImport",
|
|
257
|
+
data: {
|
|
258
|
+
pkg: "sd-core-common",
|
|
259
|
+
importPath: "@simplysm/sd-core-common/src/types",
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
],
|
|
263
|
+
},
|
|
264
|
+
],
|
|
265
|
+
});
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
describe("src path prohibited in namespace import", () => {
|
|
269
|
+
ruleTester.run("no-subpath-imports-from-simplysm", rule, {
|
|
270
|
+
valid: [],
|
|
271
|
+
invalid: [
|
|
272
|
+
{
|
|
273
|
+
code: `import * as CoreCommon from "@simplysm/sd-core-common/src";`,
|
|
274
|
+
output: `import * as CoreCommon from "@simplysm/sd-core-common";`,
|
|
275
|
+
errors: [
|
|
276
|
+
{
|
|
277
|
+
messageId: "noSubpathImport",
|
|
278
|
+
data: {
|
|
279
|
+
pkg: "sd-core-common",
|
|
280
|
+
importPath: "@simplysm/sd-core-common/src",
|
|
281
|
+
},
|
|
282
|
+
},
|
|
283
|
+
],
|
|
284
|
+
},
|
|
285
|
+
],
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
describe("src path prohibited in side-effect import", () => {
|
|
290
|
+
ruleTester.run("no-subpath-imports-from-simplysm", rule, {
|
|
291
|
+
valid: [],
|
|
292
|
+
invalid: [
|
|
293
|
+
{
|
|
294
|
+
code: `import "@simplysm/sd-core-common/src/polyfills";`,
|
|
295
|
+
output: `import "@simplysm/sd-core-common";`,
|
|
296
|
+
errors: [
|
|
297
|
+
{
|
|
298
|
+
messageId: "noSubpathImport",
|
|
299
|
+
data: {
|
|
300
|
+
pkg: "sd-core-common",
|
|
301
|
+
importPath: "@simplysm/sd-core-common/src/polyfills",
|
|
302
|
+
},
|
|
303
|
+
},
|
|
304
|
+
],
|
|
305
|
+
},
|
|
306
|
+
],
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
describe("src path prohibited in default import", () => {
|
|
311
|
+
ruleTester.run("no-subpath-imports-from-simplysm", rule, {
|
|
312
|
+
valid: [],
|
|
313
|
+
invalid: [
|
|
314
|
+
{
|
|
315
|
+
code: `import SomeDefault from "@simplysm/sd-core-common/src/default";`,
|
|
316
|
+
output: `import SomeDefault from "@simplysm/sd-core-common";`,
|
|
317
|
+
errors: [
|
|
318
|
+
{
|
|
319
|
+
messageId: "noSubpathImport",
|
|
320
|
+
data: {
|
|
321
|
+
pkg: "sd-core-common",
|
|
322
|
+
importPath: "@simplysm/sd-core-common/src/default",
|
|
323
|
+
},
|
|
324
|
+
},
|
|
325
|
+
],
|
|
326
|
+
},
|
|
327
|
+
],
|
|
328
|
+
});
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
describe("src path prohibited in mixed import (default + named)", () => {
|
|
332
|
+
ruleTester.run("no-subpath-imports-from-simplysm", rule, {
|
|
333
|
+
valid: [],
|
|
334
|
+
invalid: [
|
|
335
|
+
{
|
|
336
|
+
code: `import SomeDefault, { Something } from "@simplysm/sd-core-common/src";`,
|
|
337
|
+
output: `import SomeDefault, { Something } from "@simplysm/sd-core-common";`,
|
|
338
|
+
errors: [
|
|
339
|
+
{
|
|
340
|
+
messageId: "noSubpathImport",
|
|
341
|
+
data: {
|
|
342
|
+
pkg: "sd-core-common",
|
|
343
|
+
importPath: "@simplysm/sd-core-common/src",
|
|
344
|
+
},
|
|
345
|
+
},
|
|
346
|
+
],
|
|
347
|
+
},
|
|
348
|
+
],
|
|
349
|
+
});
|
|
350
|
+
});
|
|
351
|
+
});
|
|
352
|
+
});
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import recommended from "../src/eslint-recommended";
|
|
3
|
+
import plugin from "../src/eslint-plugin";
|
|
4
|
+
|
|
5
|
+
// ESLint config type helper
|
|
6
|
+
type ConfigItem = (typeof recommended)[number];
|
|
7
|
+
|
|
8
|
+
const hasIgnores = (config: ConfigItem): config is ConfigItem & { ignores: string[] } => {
|
|
9
|
+
return "ignores" in config && Array.isArray(config.ignores);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const hasFiles = (config: ConfigItem): config is ConfigItem & { files: (string | string[])[] } => {
|
|
13
|
+
return "files" in config && Array.isArray(config.files);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const hasRules = (
|
|
17
|
+
config: ConfigItem,
|
|
18
|
+
): config is ConfigItem & { rules: Record<string, unknown> } => {
|
|
19
|
+
return "rules" in config && config.rules != null;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const hasPlugins = (
|
|
23
|
+
config: ConfigItem,
|
|
24
|
+
): config is ConfigItem & { plugins: Record<string, unknown> } => {
|
|
25
|
+
return "plugins" in config && config.plugins != null;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const flattenFiles = (files: (string | string[])[]): string[] => {
|
|
29
|
+
return files.flat();
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
describe("recommended config", () => {
|
|
33
|
+
it("should export as array", () => {
|
|
34
|
+
expect(Array.isArray(recommended)).toBe(true);
|
|
35
|
+
expect(recommended.length).toBeGreaterThan(0);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("should include globalIgnores config", () => {
|
|
39
|
+
const ignoresConfig = recommended.find(hasIgnores);
|
|
40
|
+
expect(ignoresConfig).toBeDefined();
|
|
41
|
+
if (ignoresConfig == null) return;
|
|
42
|
+
|
|
43
|
+
const expectedPatterns = ["**/node_modules/**", "**/dist/**", "**/.*/**", "**/_*/**"];
|
|
44
|
+
expect(ignoresConfig.ignores).toEqual(expect.arrayContaining(expectedPatterns));
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("should include JS file config", () => {
|
|
48
|
+
const jsConfig = recommended.find(
|
|
49
|
+
(config) => hasFiles(config) && flattenFiles(config.files).some((f) => f.includes("*.js")),
|
|
50
|
+
);
|
|
51
|
+
expect(jsConfig).toBeDefined();
|
|
52
|
+
if (jsConfig == null) return;
|
|
53
|
+
if (hasPlugins(jsConfig)) {
|
|
54
|
+
expect(jsConfig.plugins).toHaveProperty("@simplysm");
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("should include TS file config", () => {
|
|
59
|
+
const tsConfig = recommended.find(
|
|
60
|
+
(config) => hasFiles(config) && flattenFiles(config.files).some((f) => f.includes("*.ts")),
|
|
61
|
+
);
|
|
62
|
+
expect(tsConfig).toBeDefined();
|
|
63
|
+
if (tsConfig == null) return;
|
|
64
|
+
if (hasPlugins(tsConfig)) {
|
|
65
|
+
expect(tsConfig.plugins).toHaveProperty("@typescript-eslint");
|
|
66
|
+
expect(tsConfig.plugins).toHaveProperty("@simplysm");
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("should enable @simplysm custom rules with correct severity in TS config", () => {
|
|
71
|
+
const tsConfig = recommended.find(
|
|
72
|
+
(config) => hasFiles(config) && flattenFiles(config.files).some((f) => f.includes("*.ts")),
|
|
73
|
+
);
|
|
74
|
+
expect(tsConfig).toBeDefined();
|
|
75
|
+
if (tsConfig == null) return;
|
|
76
|
+
if (hasRules(tsConfig)) {
|
|
77
|
+
expect(tsConfig.rules).toHaveProperty("@simplysm/no-hard-private", "error");
|
|
78
|
+
expect(tsConfig.rules).toHaveProperty("@simplysm/no-subpath-imports-from-simplysm", "error");
|
|
79
|
+
expect(tsConfig.rules).toHaveProperty("@simplysm/ts-no-throw-not-implemented-error", "warn");
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("should enable @simplysm custom rules in JS config", () => {
|
|
84
|
+
const jsConfig = recommended.find(
|
|
85
|
+
(config) => hasFiles(config) && flattenFiles(config.files).some((f) => f.includes("*.js")),
|
|
86
|
+
);
|
|
87
|
+
expect(jsConfig).toBeDefined();
|
|
88
|
+
if (jsConfig == null) return;
|
|
89
|
+
if (hasRules(jsConfig)) {
|
|
90
|
+
expect(jsConfig.rules).toHaveProperty("@simplysm/no-hard-private", "error");
|
|
91
|
+
expect(jsConfig.rules).toHaveProperty("@simplysm/no-subpath-imports-from-simplysm", "error");
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("should disable import/no-extraneous-dependencies in test folder", () => {
|
|
96
|
+
const testConfig = recommended.find(
|
|
97
|
+
(config) =>
|
|
98
|
+
hasFiles(config) && flattenFiles(config.files).some((f) => f.includes("**/tests/**")),
|
|
99
|
+
);
|
|
100
|
+
expect(testConfig).toBeDefined();
|
|
101
|
+
if (testConfig == null) return;
|
|
102
|
+
if (hasRules(testConfig)) {
|
|
103
|
+
expect(testConfig.rules).toHaveProperty("import/no-extraneous-dependencies", "off");
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it("should include all plugin.rules in recommended config", () => {
|
|
108
|
+
const tsConfig = recommended.find(
|
|
109
|
+
(config) => hasFiles(config) && flattenFiles(config.files).some((f) => f.includes("*.ts")),
|
|
110
|
+
);
|
|
111
|
+
expect(tsConfig).toBeDefined();
|
|
112
|
+
if (tsConfig == null) return;
|
|
113
|
+
|
|
114
|
+
if (hasRules(tsConfig)) {
|
|
115
|
+
const ruleNames = Object.keys(plugin.rules);
|
|
116
|
+
for (const ruleName of ruleNames) {
|
|
117
|
+
const fullRuleName = `@simplysm/${ruleName}`;
|
|
118
|
+
expect(tsConfig.rules, `rule '${fullRuleName}' should be included in TS config`).toHaveProperty(
|
|
119
|
+
fullRuleName,
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it("should set parserOptions.project to true in TS config", () => {
|
|
126
|
+
const tsConfig = recommended.find(
|
|
127
|
+
(config) => hasFiles(config) && flattenFiles(config.files).some((f) => f.includes("*.ts")),
|
|
128
|
+
) as ConfigItem & {
|
|
129
|
+
languageOptions?: { parserOptions?: { project?: unknown } };
|
|
130
|
+
};
|
|
131
|
+
expect(tsConfig).toBeDefined();
|
|
132
|
+
expect(tsConfig.languageOptions?.parserOptions?.project).toBe(true);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it("should apply solid plugin to TSX files", () => {
|
|
136
|
+
// Find config that includes solid plugin and handles .tsx files
|
|
137
|
+
// (in current implementation, **/*.ts and **/*.tsx are handled together)
|
|
138
|
+
const tsxSolidConfig = recommended.find(
|
|
139
|
+
(config) =>
|
|
140
|
+
hasFiles(config) &&
|
|
141
|
+
flattenFiles(config.files).some((f) => f.includes(".tsx")) &&
|
|
142
|
+
hasPlugins(config) &&
|
|
143
|
+
"solid" in config.plugins,
|
|
144
|
+
);
|
|
145
|
+
expect(tsxSolidConfig).toBeDefined();
|
|
146
|
+
if (tsxSolidConfig == null) return;
|
|
147
|
+
if (hasPlugins(tsxSolidConfig)) {
|
|
148
|
+
expect(tsxSolidConfig.plugins).toHaveProperty("solid");
|
|
149
|
+
}
|
|
150
|
+
if (hasRules(tsxSolidConfig)) {
|
|
151
|
+
// eslint-plugin-solid flat/typescript rules should be applied
|
|
152
|
+
expect(tsxSolidConfig.rules).toHaveProperty("solid/jsx-no-undef");
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
});
|