UNPKG

css-module-type-definitions

Version:
62 lines (61 loc) 1.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.validateToken = void 0; var RESERVED_WORDS = new Set([ 'break', 'case', 'catch', 'class', 'const', 'continue', 'debugger', 'default', 'delete', 'do', 'else', 'enum', 'export', 'extends', 'false', 'finally', 'for', 'function', 'if', 'import', 'in', 'instanceof', 'new', 'null', 'return', 'super', 'switch', 'this', 'throw', 'true', 'try', 'typeof', 'var', 'void', 'while', 'with', 'as', 'implements', 'interface', 'type', 'let', 'package', 'private', 'protected', 'public', 'static', 'yield', ]); function validateToken(token) { if (!/^[a-zA-Z$_][0-9a-zA-Z$_]*$/u.test(token)) return { isValid: false, message: token + " is not valid TypeScript variable name." }; if (RESERVED_WORDS.has(token)) return { isValid: false, message: token + " is TypeScript reserved word." }; return { isValid: true }; } exports.validateToken = validateToken; exports.default = validateToken;