-
-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ensure reserved keywords can never be rendered for JS output (#313)
- Loading branch information
1 parent
2795f66
commit 30d18b8
Showing
9 changed files
with
381 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
export const RESERVED_JAVA_KEYWORDS = [ | ||
'abstract', | ||
'continue', | ||
'for', | ||
'new', | ||
'switch assert', | ||
'default', | ||
'goto', | ||
'package', | ||
'synchronized', | ||
'boolean', | ||
'do', | ||
'if', | ||
'private', | ||
'this', | ||
'break', | ||
'double', | ||
'implements', | ||
'protected', | ||
'throw', | ||
'byte', | ||
'else', | ||
'import', | ||
'public', | ||
'throws', | ||
'case', | ||
'enum', | ||
'instanceof', | ||
'return', | ||
'transient', | ||
'catch', | ||
'extends', | ||
'int', | ||
'short', | ||
'try', | ||
'char', | ||
'final', | ||
'interface', | ||
'static', | ||
'void', | ||
'class', | ||
'finally', | ||
'long', | ||
'strictfp', | ||
'volatile', | ||
'const', | ||
'float', | ||
'native', | ||
'super', | ||
'while' | ||
]; | ||
|
||
export function isReservedJavaKeyword(word: string): boolean { | ||
return RESERVED_JAVA_KEYWORDS.includes(word); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
//Based on https://www.w3schools.com/js/js_reserved.asp | ||
export const RESERVED_JAVASCRIPT_KEYWORDS = [ | ||
//Standard reserved keywords | ||
'abstract', | ||
'arguments', | ||
'await', | ||
'boolean', | ||
'break', | ||
'byte', | ||
'case', | ||
'catch', | ||
'char', | ||
'class', | ||
'const', | ||
'continue', | ||
'debugger', | ||
'default', | ||
'delete', | ||
'do', | ||
'double', | ||
'else', | ||
'enum', | ||
'eval', | ||
'export', | ||
'extends', | ||
'false', | ||
'final', | ||
'finally', | ||
'float', | ||
'for', | ||
'function', | ||
'goto', | ||
'if', | ||
'implements', | ||
'import', | ||
'in', | ||
'instanceof', | ||
'int', | ||
'interface', | ||
'let', | ||
'long', | ||
'native', | ||
'new', | ||
'null', | ||
'package', | ||
'private', | ||
'protected', | ||
'public', | ||
'return', | ||
'short', | ||
'static', | ||
'super', | ||
'switch', | ||
'synchronized', | ||
'this', | ||
'throw', | ||
'throws', | ||
'transient', | ||
'true', | ||
'try', | ||
'typeof', | ||
'var', | ||
'void', | ||
'volatile', | ||
'while', | ||
'with', | ||
'yield', | ||
// Reserved for > ECMAScript 5/6 | ||
'abstract', | ||
'boolean', | ||
'byte', | ||
'char', | ||
'double', | ||
'final', | ||
'float', | ||
'goto', | ||
'int', | ||
'long', | ||
'native', | ||
'short', | ||
'synchronized', | ||
'throws', | ||
'transient', | ||
'volatile', | ||
//Reserved built-in objects, properties and methods | ||
'hasOwnProperty', | ||
'Infinity', | ||
'isFinite', | ||
'isNaN', | ||
'isPrototypeOf', | ||
'length', | ||
'Math', | ||
'NaN', | ||
'name', | ||
'Number', | ||
'Object', | ||
'prototype', | ||
'String', | ||
'toString', | ||
'undefined', | ||
'valueOf', | ||
//Java reserved words | ||
'getClass', | ||
'java', | ||
'JavaArray', | ||
'javaClass', | ||
'JavaObject', | ||
'JavaPackage', | ||
//Other reserved words | ||
'alert', | ||
'all', | ||
'anchor', | ||
'anchors', | ||
'area', | ||
'assign', | ||
'blur', | ||
'button', | ||
'checkbox', | ||
'clearInterval', | ||
'clearTimeout', | ||
'clientInformation', | ||
'close', | ||
'closed', | ||
'confirm', | ||
'constructor', | ||
'crypto', | ||
'decodeURI', | ||
'decodeURIComponent', | ||
'defaultStatus', | ||
'document', | ||
'element', | ||
'elements', | ||
'embed', | ||
'embeds', | ||
'encodeURI', | ||
'encodeURIComponent', | ||
'escape', | ||
'event', | ||
'fileUpload', | ||
'focus', | ||
'form', | ||
'forms', | ||
'frame', | ||
'innerHeight', | ||
'innerWidth', | ||
'layer', | ||
'layers', | ||
'link', | ||
'location', | ||
'mimeTypes', | ||
'navigate', | ||
'navigator', | ||
'frames', | ||
'frameRate', | ||
'hidden', | ||
'history', | ||
'image', | ||
'images', | ||
'offscreenBuffering', | ||
'open', | ||
'opener', | ||
'option', | ||
'outerHeight', | ||
'outerWidth', | ||
'packages', | ||
'pageXOffset', | ||
'pageYOffset', | ||
'parent', | ||
'parseFloat', | ||
'parseInt', | ||
'password', | ||
'pkcs11', | ||
'plugin', | ||
'prompt', | ||
'propertyIsEnum', | ||
'radio', | ||
'reset', | ||
'screenX', | ||
'screenY', | ||
'scroll', | ||
'secure', | ||
'select', | ||
'self', | ||
'setInterval', | ||
'setTimeout', | ||
'status', | ||
'submit', | ||
'taint', | ||
'text', | ||
'textarea', | ||
'top', | ||
'unescape', | ||
'untaint', | ||
'window' | ||
]; | ||
|
||
export function isReservedJavaScriptKeyword(word: string): boolean { | ||
return RESERVED_JAVASCRIPT_KEYWORDS.includes(word); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.