Skip to content

Commit 86f17d2

Browse files
committed
[Tests] fix ecmaVersion logic
1 parent 4d19cd6 commit 86f17d2

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

tests/helpers/parsers.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ const parsers = {
5757
}
5858
const features = new Set([].concat(test.features || []));
5959
delete test.features;
60-
const es = test.parserOptions && test.parserOptions.ecmaVersion;
60+
61+
const es = features.has('class fields') ? 2022 : (features.has('optional chaining') ? 2020 : (test.parserOptions && test.parserOptions.ecmaVersion) || undefined); // eslint-disable-line no-nested-ternary
6162

6263
function addComment(testObject, parser) {
6364
const extras = [].concat(
@@ -130,13 +131,11 @@ const parsers = {
130131
const tsOld = !skipTS && !features.has('no-ts-old');
131132
const tsNew = !skipTS && !features.has('no-ts-new');
132133

133-
const minES = features.has('class fields') ? 2022 : (features.has('optional chaining') ? 2020 : 5); // eslint-disable-line no-nested-ternary
134-
135134
return [].concat(
136135
skipBase ? [] : addComment(
137-
Object.assign({}, test, minES > 5 && {
136+
Object.assign({}, test, typeof es !== 'undefined' && {
138137
parserOptions: Object.assign({}, test.parserOptions, {
139-
ecmaVersion: Math.max((test.parserOptions && test.parserOptions.ecmaVersion) || 0, minES),
138+
ecmaVersion: Math.max((test.parserOptions && test.parserOptions.ecmaVersion) || 0, es),
140139
}),
141140
}),
142141
'default'

0 commit comments

Comments
 (0)