Skip to content

Commit

Permalink
Fix:generic error for invalid ecmaVersion(fixes eslint#7405) (#303)
Browse files Browse the repository at this point in the history
  • Loading branch information
sstern6 authored and nzakas committed Nov 4, 2016
1 parent d6b383d commit 58f75be
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
6 changes: 1 addition & 5 deletions espree.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,7 @@ function normalizeEcmaVersion(ecmaVersion) {
return version;

default:
if (ecmaVersion > 1000) { // assuming user wanted to set year
throw new Error("ecmaVersion must be 2015, 2016, or 2017.");
} else {
throw new Error("ecmaVersion must be 3, 5, 6, 7, or 8.");
}
throw new Error("Invalid ecmaVersion.");
}
} else {
return DEFAULT_ECMA_VERSION;
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/ecma-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ describe("ecmaVersion", function() {
range: true,
loc: true
});
}, "ecmaVersion must be 3, 5, 6, 7, or 8.");
}, "Invalid ecmaVersion.");
});

it("Should throw error using invalid year", function() {
Expand All @@ -135,7 +135,7 @@ describe("ecmaVersion", function() {
range: true,
loc: true
});
}, "ecmaVersion must be 2015, 2016, or 2017.");
}, "Invalid ecmaVersion.");
});

});
Expand Down

0 comments on commit 58f75be

Please sign in to comment.