Revert "throw a TypeError if identifier validation fails (#106… (#10650)

This reverts commit c7d8b8a37752f42163128cf4d5e8b54c2637cec4.
This commit is contained in:
Nicolò Ribaudo 2019-11-05 14:43:23 +01:00 committed by GitHub
parent f8eb290da1
commit bf48fca6a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 13 deletions

View File

@ -1,5 +1,5 @@
// @flow
import isIdentifierName from "../validators/isIdentifierName";
import isValidIdentifier from "../validators/isValidIdentifier";
import {
BINARY_OPERATORS,
@ -406,8 +406,8 @@ defineType("Identifier", {
...patternLikeCommon,
name: {
validate: chain(function(node, key, val) {
if (!isIdentifierName(val)) {
throw new TypeError(`"${val}" is not a valid identifer name`);
if (!isValidIdentifier(val)) {
// throw new TypeError(`"${val}" is not a valid identifer name`);
}
}, assertValueType("string")),
},

View File

@ -109,7 +109,6 @@ export {
default as isValidES3Identifier,
} from "./validators/isValidES3Identifier";
export { default as isValidIdentifier } from "./validators/isValidIdentifier";
export { default as isIdentifierName } from "./validators/isIdentifierName";
export { default as isVar } from "./validators/isVar";
export { default as matchesPattern } from "./validators/matchesPattern";
export { default as validate } from "./validators/validate";

View File

@ -1,9 +0,0 @@
// @flow
import esutils from "esutils";
/**
* Check if the input `name` is a valid identifier name.
*/
export default function isIdentifierName(name: string): boolean {
return esutils.keyword.isIdentifierNameES6(name);
}