Skip to content

Commit f58fef6

Browse files
tests: remove check if ESLint version >=v6 (mysticatea#22)
1 parent fa174a8 commit f58fef6

File tree

3 files changed

+181
-217
lines changed

3 files changed

+181
-217
lines changed

test/get-static-value.js

Lines changed: 97 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -145,106 +145,102 @@ const aMap = Object.freeze({
145145
code: "RegExp.$1",
146146
expected: null,
147147
},
148-
...(semver.gte(eslint.Linter.version, "6.0.0")
149-
? [
150-
{
151-
code: "const a = null, b = 42; a ?? b",
152-
expected: { value: 42 },
153-
},
154-
{
155-
code: "const a = undefined, b = 42; a ?? b",
156-
expected: { value: 42 },
157-
},
158-
{
159-
code: "const a = false, b = 42; a ?? b",
160-
expected: { value: false },
161-
},
162-
{
163-
code: "const a = 42, b = null; a ?? b",
164-
expected: { value: 42 },
165-
},
166-
{
167-
code: "const a = 42, b = undefined; a ?? b",
168-
expected: { value: 42 },
169-
},
170-
{
171-
code: "const a = { b: { c: 42 } }; a?.b?.c",
172-
expected: { value: 42 },
173-
},
174-
{
175-
code: "const a = { b: { c: 42 } }; a?.b?.['c']",
176-
expected: { value: 42 },
177-
},
178-
{
179-
code: "const a = { b: null }; a?.b?.c",
180-
expected: { value: undefined },
181-
},
182-
{
183-
code: "const a = { b: undefined }; a?.b?.c",
184-
expected: { value: undefined },
185-
},
186-
{
187-
code: "const a = { b: null }; a?.b?.['c']",
188-
expected: { value: undefined },
189-
},
190-
{
191-
code: "const a = null; a?.b?.c",
192-
expected: { value: undefined },
193-
},
194-
{
195-
code: "const a = null; a?.b.c",
196-
expected: { value: undefined },
197-
},
198-
{
199-
code: "const a = void 0; a?.b.c",
200-
expected: { value: undefined },
201-
},
202-
{
203-
code: "const a = { b: { c: 42 } }; (a?.b).c",
204-
expected: { value: 42 },
205-
},
206-
{
207-
code: "const a = null; (a?.b).c",
208-
expected: null,
209-
},
210-
{
211-
code: "const a = { b: null }; (a?.b).c",
212-
expected: null,
213-
},
214-
{
215-
code: "const a = { b: { c: String } }; a?.b?.c?.(42)",
216-
expected: { value: "42" },
217-
},
218-
{
219-
code: "const a = null; a?.b?.c?.(42)",
220-
expected: { value: undefined },
221-
},
222-
{
223-
code: "const a = { b: { c: String } }; a?.b.c(42)",
224-
expected: { value: "42" },
225-
},
226-
{
227-
code: "const a = null; a?.b.c(42)",
228-
expected: { value: undefined },
229-
},
230-
{
231-
code: "null?.()",
232-
expected: { value: undefined },
233-
},
234-
{
235-
code: "const a = null; a?.()",
236-
expected: { value: undefined },
237-
},
238-
{
239-
code: "a?.()",
240-
expected: null,
241-
},
242-
{
243-
code: "({'a': 1, 1e+1: 2, 2n: 3})",
244-
expected: { value: { a: 1, 10: 2, 2: 3 } },
245-
},
246-
]
247-
: []),
148+
{
149+
code: "const a = null, b = 42; a ?? b",
150+
expected: { value: 42 },
151+
},
152+
{
153+
code: "const a = undefined, b = 42; a ?? b",
154+
expected: { value: 42 },
155+
},
156+
{
157+
code: "const a = false, b = 42; a ?? b",
158+
expected: { value: false },
159+
},
160+
{
161+
code: "const a = 42, b = null; a ?? b",
162+
expected: { value: 42 },
163+
},
164+
{
165+
code: "const a = 42, b = undefined; a ?? b",
166+
expected: { value: 42 },
167+
},
168+
{
169+
code: "const a = { b: { c: 42 } }; a?.b?.c",
170+
expected: { value: 42 },
171+
},
172+
{
173+
code: "const a = { b: { c: 42 } }; a?.b?.['c']",
174+
expected: { value: 42 },
175+
},
176+
{
177+
code: "const a = { b: null }; a?.b?.c",
178+
expected: { value: undefined },
179+
},
180+
{
181+
code: "const a = { b: undefined }; a?.b?.c",
182+
expected: { value: undefined },
183+
},
184+
{
185+
code: "const a = { b: null }; a?.b?.['c']",
186+
expected: { value: undefined },
187+
},
188+
{
189+
code: "const a = null; a?.b?.c",
190+
expected: { value: undefined },
191+
},
192+
{
193+
code: "const a = null; a?.b.c",
194+
expected: { value: undefined },
195+
},
196+
{
197+
code: "const a = void 0; a?.b.c",
198+
expected: { value: undefined },
199+
},
200+
{
201+
code: "const a = { b: { c: 42 } }; (a?.b).c",
202+
expected: { value: 42 },
203+
},
204+
{
205+
code: "const a = null; (a?.b).c",
206+
expected: null,
207+
},
208+
{
209+
code: "const a = { b: null }; (a?.b).c",
210+
expected: null,
211+
},
212+
{
213+
code: "const a = { b: { c: String } }; a?.b?.c?.(42)",
214+
expected: { value: "42" },
215+
},
216+
{
217+
code: "const a = null; a?.b?.c?.(42)",
218+
expected: { value: undefined },
219+
},
220+
{
221+
code: "const a = { b: { c: String } }; a?.b.c(42)",
222+
expected: { value: "42" },
223+
},
224+
{
225+
code: "const a = null; a?.b.c(42)",
226+
expected: { value: undefined },
227+
},
228+
{
229+
code: "null?.()",
230+
expected: { value: undefined },
231+
},
232+
{
233+
code: "const a = null; a?.()",
234+
expected: { value: undefined },
235+
},
236+
{
237+
code: "a?.()",
238+
expected: null,
239+
},
240+
{
241+
code: "({'a': 1, 1e+1: 2, 2n: 3})",
242+
expected: { value: { a: 1, 10: 2, 2: 3 } },
243+
},
248244
...(semver.gte(eslint.Linter.version, "7.0.0")
249245
? [
250246
{
@@ -305,9 +301,7 @@ const aMap = Object.freeze({
305301
parserOptions: {
306302
ecmaVersion: semver.gte(eslint.Linter.version, "7.0.0")
307303
? 2022
308-
: semver.gte(eslint.Linter.version, "6.0.0")
309-
? 2020
310-
: 2018,
304+
: 2020,
311305
},
312306
rules: { test: "error" },
313307
})

test/has-side-effect.js

Lines changed: 36 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -47,29 +47,21 @@ describe("The 'hasSideEffect' function", () => {
4747
options: undefined,
4848
expected: true,
4949
},
50-
...(semver.gte(eslint.Linter.version, "6.0.0")
51-
? [
52-
{
53-
code: "f?.()",
54-
options: undefined,
55-
expected: true,
56-
},
57-
]
58-
: []),
50+
{
51+
code: "f?.()",
52+
options: undefined,
53+
expected: true,
54+
},
5955
{
6056
code: "a + f()",
6157
options: undefined,
6258
expected: true,
6359
},
64-
...(semver.gte(eslint.Linter.version, "6.0.0")
65-
? [
66-
{
67-
code: "a + f?.()",
68-
options: undefined,
69-
expected: true,
70-
},
71-
]
72-
: []),
60+
{
61+
code: "a + f?.()",
62+
options: undefined,
63+
expected: true,
64+
},
7365
{
7466
code: "obj.a",
7567
options: undefined,
@@ -80,20 +72,16 @@ describe("The 'hasSideEffect' function", () => {
8072
options: { considerGetters: true },
8173
expected: true,
8274
},
83-
...(semver.gte(eslint.Linter.version, "6.0.0")
84-
? [
85-
{
86-
code: "obj?.a",
87-
options: undefined,
88-
expected: false,
89-
},
90-
{
91-
code: "obj?.a",
92-
options: { considerGetters: true },
93-
expected: true,
94-
},
95-
]
96-
: []),
75+
{
76+
code: "obj?.a",
77+
options: undefined,
78+
expected: false,
79+
},
80+
{
81+
code: "obj?.a",
82+
options: { considerGetters: true },
83+
expected: true,
84+
},
9785
{
9886
code: "obj[a]",
9987
options: undefined,
@@ -109,25 +97,21 @@ describe("The 'hasSideEffect' function", () => {
10997
options: { considerImplicitTypeConversion: true },
11098
expected: true,
11199
},
112-
...(semver.gte(eslint.Linter.version, "6.0.0")
113-
? [
114-
{
115-
code: "obj?.[a]",
116-
options: undefined,
117-
expected: false,
118-
},
119-
{
120-
code: "obj?.[a]",
121-
options: { considerGetters: true },
122-
expected: true,
123-
},
124-
{
125-
code: "obj?.[a]",
126-
options: { considerImplicitTypeConversion: true },
127-
expected: true,
128-
},
129-
]
130-
: []),
100+
{
101+
code: "obj?.[a]",
102+
options: undefined,
103+
expected: false,
104+
},
105+
{
106+
code: "obj?.[a]",
107+
options: { considerGetters: true },
108+
expected: true,
109+
},
110+
{
111+
code: "obj?.[a]",
112+
options: { considerImplicitTypeConversion: true },
113+
expected: true,
114+
},
131115
{
132116
code: "obj[0]",
133117
options: { considerImplicitTypeConversion: true },
@@ -336,9 +320,7 @@ describe("The 'hasSideEffect' function", () => {
336320
parserOptions: {
337321
ecmaVersion: semver.gte(eslint.Linter.version, "7.0.0")
338322
? 2022
339-
: semver.gte(eslint.Linter.version, "6.0.0")
340-
? 2020
341-
: 2018,
323+
: 2020,
342324
},
343325
rules: { test: "error" },
344326
})

0 commit comments

Comments
 (0)