-
Notifications
You must be signed in to change notification settings - Fork 5
/
experimental.test.js
165 lines (123 loc) · 5.2 KB
/
experimental.test.js
1
2
3
4
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
const { ESLint } = require("eslint");
const assert = require("assert");
const { configLib } = require("../../utils");
const cfg = require("./experimental");
const eslint = new ESLint({
useEslintrc: false,
baseConfig: configLib.setParser(cfg),
});
describe("Import order experimental:", () => {
it("should lint with errors.", async () => {
const report = await eslint.lintText(`
import { Cart } from "@/entities/cart";
import { Input } from "~/shared/ui";
import { getSmth } from "./lib";
import axios from "axios";
import { data } from "../fixtures";
import { authModel } from "entities/auth";
import { Button } from "shared/ui";
import { LoginForm } from "features/login-form";
import { Header } from "widgets/header";
import { debounce } from "shared/lib/fp";
import { One } from "@entities/one";
import { Two } from "~entities/two";
`);
assert.strictEqual(report[0].errorCount, 18);
});
it("should lint without errors.", async () => {
const report = await eslint.lintText(`
import axios from "axios";
import { Shared } from "shared";
import { debounce } from "shared/lib/fp";
import { model } from "shared/model";
import { Button } from "shared/ui";
import { globalEntities } from "entities";
import { authModel } from "entities/auth";
import { Cart } from "entities/cart";
import { One } from "entities/one";
import { Two } from "entities/two";
import { LoginForm } from "features/login-form";
import { Widgets } from "widgets";
import { Header } from "widgets/header";
import { Zero } from "widgets/zero";
import { data } from "../fixtures";
import { getSmth } from "./lib";
`);
assert.strictEqual(report[0].errorCount, 0);
});
it("~aliased should lint without errors.", async () => {
const report = await eslint.lintText(`
import axios from "axios";
import { debounce } from "~shared/lib/fp";
import { model } from "~shared/model";
import { Button } from "~shared/ui";
import { authModel } from "~entities/auth";
import { Cart } from "~entities/cart";
import { One } from "~entities/one";
import { Two } from "~entities/two";
import { LoginForm } from "~features/login-form";
import { Widgets } from "~widgets";
import { Header } from "~widgets/header";
import { Zero } from "~widgets/zero";
import { data } from "../fixtures";
import { getSmth } from "./lib";
`);
assert.strictEqual(report[0].errorCount, 0);
});
it("~/aliased should lint without errors.", async () => {
const report = await eslint.lintText(`
import axios from "axios";
import { debounce } from "~/shared/lib/fp";
import { model } from "~/shared/model";
import { Button } from "~/shared/ui";
import { authModel } from "~/entities/auth";
import { Cart } from "~/entities/cart";
import { One } from "~/entities/one";
import { Two } from "~/entities/two";
import { LoginForm } from "~/features/login-form";
import { Widgets } from "~/widgets";
import { Header } from "~/widgets/header";
import { Zero } from "~/widgets/zero";
import { data } from "../fixtures";
import { getSmth } from "./lib";
`);
assert.strictEqual(report[0].errorCount, 0);
});
it("should be alphabetic", async () => {
const report = await eslint.lintText(`
import { Apple } from 'features/apple';
import { Bee } from 'features/bee';
import { Cord } from 'features/cord';
import { Dream } from 'features/dream';
`);
assert.strictEqual(report[0].errorCount, 0);
});
it("should be alphabetic error", async () => {
const report = await eslint.lintText(`
import { Dream } from 'features/dream';
import { Cord } from 'features/cord';
import { Bee } from 'features/bee';
import { Apple } from 'features/apple';
`);
assert.strictEqual(report[0].errorCount, 3);
});
it("should be with spaces between layers", async () => {
const report = await eslint.lintText(`
import { Dream } from 'shared/dream';
import { Cord } from 'entities/cord';
import { Bee } from 'features/bee';
import { Apple } from 'app/apple';
`);
assert.strictEqual(report[0].errorCount, 0);
});
it("should be with spaces between layers errors", async () => {
const report = await eslint.lintText(`
import React from 'react';
import { Dream } from 'shared/dream';
import { Cord } from 'entities/cord';
import { Bee } from 'features/bee';
import { Apple } from 'app/apple';
`);
assert.strictEqual(report[0].errorCount, 4);
});
});