File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11// @flow
2- import isValidIdentifier from "../validators/isValidIdentifier " ;
2+ import isIdentifierName from "../validators/isIdentifierName " ;
33
44import {
55 BINARY_OPERATORS ,
@@ -406,8 +406,8 @@ defineType("Identifier", {
406406 ...patternLikeCommon ,
407407 name : {
408408 validate : chain ( function ( node , key , val ) {
409- if ( ! isValidIdentifier ( val ) ) {
410- // throw new TypeError(`"${val}" is not a valid identifer name`);
409+ if ( ! isIdentifierName ( val ) ) {
410+ throw new TypeError ( `"${ val } " is not a valid identifer name` ) ;
411411 }
412412 } , assertValueType ( "string" ) ) ,
413413 } ,
Original file line number Diff line number Diff line change @@ -109,6 +109,7 @@ export {
109109 default as isValidES3Identifier ,
110110} from "./validators/isValidES3Identifier" ;
111111export { default as isValidIdentifier } from "./validators/isValidIdentifier" ;
112+ export { default as isIdentifierName } from "./validators/isIdentifierName" ;
112113export { default as isVar } from "./validators/isVar" ;
113114export { default as matchesPattern } from "./validators/matchesPattern" ;
114115export { default as validate } from "./validators/validate" ;
Original file line number Diff line number Diff line change 1+ // @flow
2+ import esutils from "esutils" ;
3+
4+ /**
5+ * Check if the input `name` is a valid identifier name.
6+ */
7+ export default function isIdentifierName ( name : string ) : boolean {
8+ return esutils . keyword . isIdentifierNameES6 ( name ) ;
9+ }
You can’t perform that action at this time.
0 commit comments