in lib/VisualGenerator.js [303:328]
static checkVisualName(name) {
const regexES3ReservedWord = /^(?:do|if|in|for|int|new|try|var|byte|case|char|else|enum|goto|long|null|this|true|void|with|break|catch|class|const|false|final|float|short|super|throw|while|delete|double|export|import|native|public|return|static|switch|throws|typeof|boolean|default|extends|finally|package|private|abstract|continue|debugger|function|volatile|interface|protected|transient|implements|instanceof|synchronized)$/;
const regexNumber = /^(?![+-])([0-9\+\-\.]+)/; // eslint-disable-line no-useless-escape
const regexZeroWidth = /\u200c|\u200d/;
const regexpWrongSymbols = /^[a-zA-Z0-9]+$/;
const valueAsUnescapedString = name.replace(/\\u([a-fA-F0-9]{4})|\\u\{([0-9a-fA-F]{1,})\}/g, ($0, $1, $2) => {
const codePoint = parseInt($2 || $1, 16);
// If it’s a surrogate…
if (codePoint >= 0xD800 && codePoint <= 0xDFFF) {
// Return a character that is never valid in an identifier.
// This prevents the surrogate from pairing with another.
return '\0';
}
return String.fromCodePoint(codePoint);
});
if (regexNumber.test(name)) {
return `The visual name can't begin with a number digit`;
} else if (!regexpWrongSymbols.test(name)) {
return `The visual name can contain only letters and numbers`;
} else if (regexES3ReservedWord.test(valueAsUnescapedString)) {
return `The visual name cannot be equal to a reserved JavaScript keyword.
More information: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Keywords`;
} else if (regexZeroWidth.test(valueAsUnescapedString)) {
return `The visual name can't be empty`;
}
}