Skip to content

Commit

Permalink
tests: remove check if ESLint version >=v6 (mysticatea#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDeBoey authored Nov 28, 2022
1 parent fa174a8 commit f58fef6
Show file tree
Hide file tree
Showing 3 changed files with 181 additions and 217 deletions.
200 changes: 97 additions & 103 deletions test/get-static-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,106 +145,102 @@ const aMap = Object.freeze({
code: "RegExp.$1",
expected: null,
},
...(semver.gte(eslint.Linter.version, "6.0.0")
? [
{
code: "const a = null, b = 42; a ?? b",
expected: { value: 42 },
},
{
code: "const a = undefined, b = 42; a ?? b",
expected: { value: 42 },
},
{
code: "const a = false, b = 42; a ?? b",
expected: { value: false },
},
{
code: "const a = 42, b = null; a ?? b",
expected: { value: 42 },
},
{
code: "const a = 42, b = undefined; a ?? b",
expected: { value: 42 },
},
{
code: "const a = { b: { c: 42 } }; a?.b?.c",
expected: { value: 42 },
},
{
code: "const a = { b: { c: 42 } }; a?.b?.['c']",
expected: { value: 42 },
},
{
code: "const a = { b: null }; a?.b?.c",
expected: { value: undefined },
},
{
code: "const a = { b: undefined }; a?.b?.c",
expected: { value: undefined },
},
{
code: "const a = { b: null }; a?.b?.['c']",
expected: { value: undefined },
},
{
code: "const a = null; a?.b?.c",
expected: { value: undefined },
},
{
code: "const a = null; a?.b.c",
expected: { value: undefined },
},
{
code: "const a = void 0; a?.b.c",
expected: { value: undefined },
},
{
code: "const a = { b: { c: 42 } }; (a?.b).c",
expected: { value: 42 },
},
{
code: "const a = null; (a?.b).c",
expected: null,
},
{
code: "const a = { b: null }; (a?.b).c",
expected: null,
},
{
code: "const a = { b: { c: String } }; a?.b?.c?.(42)",
expected: { value: "42" },
},
{
code: "const a = null; a?.b?.c?.(42)",
expected: { value: undefined },
},
{
code: "const a = { b: { c: String } }; a?.b.c(42)",
expected: { value: "42" },
},
{
code: "const a = null; a?.b.c(42)",
expected: { value: undefined },
},
{
code: "null?.()",
expected: { value: undefined },
},
{
code: "const a = null; a?.()",
expected: { value: undefined },
},
{
code: "a?.()",
expected: null,
},
{
code: "({'a': 1, 1e+1: 2, 2n: 3})",
expected: { value: { a: 1, 10: 2, 2: 3 } },
},
]
: []),
{
code: "const a = null, b = 42; a ?? b",
expected: { value: 42 },
},
{
code: "const a = undefined, b = 42; a ?? b",
expected: { value: 42 },
},
{
code: "const a = false, b = 42; a ?? b",
expected: { value: false },
},
{
code: "const a = 42, b = null; a ?? b",
expected: { value: 42 },
},
{
code: "const a = 42, b = undefined; a ?? b",
expected: { value: 42 },
},
{
code: "const a = { b: { c: 42 } }; a?.b?.c",
expected: { value: 42 },
},
{
code: "const a = { b: { c: 42 } }; a?.b?.['c']",
expected: { value: 42 },
},
{
code: "const a = { b: null }; a?.b?.c",
expected: { value: undefined },
},
{
code: "const a = { b: undefined }; a?.b?.c",
expected: { value: undefined },
},
{
code: "const a = { b: null }; a?.b?.['c']",
expected: { value: undefined },
},
{
code: "const a = null; a?.b?.c",
expected: { value: undefined },
},
{
code: "const a = null; a?.b.c",
expected: { value: undefined },
},
{
code: "const a = void 0; a?.b.c",
expected: { value: undefined },
},
{
code: "const a = { b: { c: 42 } }; (a?.b).c",
expected: { value: 42 },
},
{
code: "const a = null; (a?.b).c",
expected: null,
},
{
code: "const a = { b: null }; (a?.b).c",
expected: null,
},
{
code: "const a = { b: { c: String } }; a?.b?.c?.(42)",
expected: { value: "42" },
},
{
code: "const a = null; a?.b?.c?.(42)",
expected: { value: undefined },
},
{
code: "const a = { b: { c: String } }; a?.b.c(42)",
expected: { value: "42" },
},
{
code: "const a = null; a?.b.c(42)",
expected: { value: undefined },
},
{
code: "null?.()",
expected: { value: undefined },
},
{
code: "const a = null; a?.()",
expected: { value: undefined },
},
{
code: "a?.()",
expected: null,
},
{
code: "({'a': 1, 1e+1: 2, 2n: 3})",
expected: { value: { a: 1, 10: 2, 2: 3 } },
},
...(semver.gte(eslint.Linter.version, "7.0.0")
? [
{
Expand Down Expand Up @@ -305,9 +301,7 @@ const aMap = Object.freeze({
parserOptions: {
ecmaVersion: semver.gte(eslint.Linter.version, "7.0.0")
? 2022
: semver.gte(eslint.Linter.version, "6.0.0")
? 2020
: 2018,
: 2020,
},
rules: { test: "error" },
})
Expand Down
90 changes: 36 additions & 54 deletions test/has-side-effect.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,29 +47,21 @@ describe("The 'hasSideEffect' function", () => {
options: undefined,
expected: true,
},
...(semver.gte(eslint.Linter.version, "6.0.0")
? [
{
code: "f?.()",
options: undefined,
expected: true,
},
]
: []),
{
code: "f?.()",
options: undefined,
expected: true,
},
{
code: "a + f()",
options: undefined,
expected: true,
},
...(semver.gte(eslint.Linter.version, "6.0.0")
? [
{
code: "a + f?.()",
options: undefined,
expected: true,
},
]
: []),
{
code: "a + f?.()",
options: undefined,
expected: true,
},
{
code: "obj.a",
options: undefined,
Expand All @@ -80,20 +72,16 @@ describe("The 'hasSideEffect' function", () => {
options: { considerGetters: true },
expected: true,
},
...(semver.gte(eslint.Linter.version, "6.0.0")
? [
{
code: "obj?.a",
options: undefined,
expected: false,
},
{
code: "obj?.a",
options: { considerGetters: true },
expected: true,
},
]
: []),
{
code: "obj?.a",
options: undefined,
expected: false,
},
{
code: "obj?.a",
options: { considerGetters: true },
expected: true,
},
{
code: "obj[a]",
options: undefined,
Expand All @@ -109,25 +97,21 @@ describe("The 'hasSideEffect' function", () => {
options: { considerImplicitTypeConversion: true },
expected: true,
},
...(semver.gte(eslint.Linter.version, "6.0.0")
? [
{
code: "obj?.[a]",
options: undefined,
expected: false,
},
{
code: "obj?.[a]",
options: { considerGetters: true },
expected: true,
},
{
code: "obj?.[a]",
options: { considerImplicitTypeConversion: true },
expected: true,
},
]
: []),
{
code: "obj?.[a]",
options: undefined,
expected: false,
},
{
code: "obj?.[a]",
options: { considerGetters: true },
expected: true,
},
{
code: "obj?.[a]",
options: { considerImplicitTypeConversion: true },
expected: true,
},
{
code: "obj[0]",
options: { considerImplicitTypeConversion: true },
Expand Down Expand Up @@ -336,9 +320,7 @@ describe("The 'hasSideEffect' function", () => {
parserOptions: {
ecmaVersion: semver.gte(eslint.Linter.version, "7.0.0")
? 2022
: semver.gte(eslint.Linter.version, "6.0.0")
? 2020
: 2018,
: 2020,
},
rules: { test: "error" },
})
Expand Down
Loading

0 comments on commit f58fef6

Please sign in to comment.