-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix #46: Handle most of quoted property name issues
- Loading branch information
1 parent
5202654
commit 30c2efe
Showing
17 changed files
with
198 additions
and
23 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
Binary file added
BIN
+1.2 MB
.yarn/cache/@unicode-unicode-9.0.0-npm-1.5.2-23bcabf22c-2c5e3afdde.zip
Binary file not shown.
Binary file not shown.
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
testPathIgnorePatterns: ['/node_modules/', '/lib/'], | ||
}; |
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
51 changes: 51 additions & 0 deletions
51
packages/typoas-generator/scripts/generate-identifier-regexp.ts
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,51 @@ | ||
/** | ||
* Based on https://gist.github.com/mathiasbynens/6334847 by @mathias | ||
*/ | ||
import { writeFile } from 'node:fs/promises'; | ||
import regenerate from 'regenerate'; | ||
|
||
// Which Unicode version should be used | ||
const version = '9.0.0'; | ||
|
||
// Set up a shorthand function to import Unicode data. | ||
async function get(what: string): Promise<number[]> { | ||
const { default: codePoints } = await import( | ||
`@unicode/unicode-${version}/${what}/code-points.js` | ||
); | ||
return codePoints; | ||
} | ||
|
||
async function main() { | ||
// Get the Unicode properties needed to construct the ES6 regex. | ||
const ID_Start = await get('Binary_Property/ID_Start'); | ||
const ID_Continue = await get('Binary_Property/ID_Continue'); | ||
const Other_ID_Start = await get('Binary_Property/Other_ID_Start'); | ||
|
||
// http://ecma-international.org/ecma-262/6.0/#sec-identifier-names-static-semantics-early-errors | ||
// http://unicode.org/reports/tr31/#Default_Identifier_Syntax | ||
// https://bugs.ecmascript.org/show_bug.cgi?id=2717#c0 | ||
const identifierStart = regenerate(ID_Start) | ||
// Note: this already includes `Other_ID_Start`. http://git.io/wRCAfQ | ||
.add('$', '_'); | ||
const identifierPart = regenerate(ID_Continue) | ||
// Note: `ID_Continue` already includes `Other_ID_Continue`. http://git.io/wRCAfQ | ||
.add(Other_ID_Start) | ||
.add('$', '_', '\u200C', '\u200D'); | ||
|
||
const fileContent = `/* eslint-disable no-misleading-character-class,no-useless-escape */ | ||
// This file is generated by scripts/generate-identifier-regexp.ts | ||
// Do not edit it manually. | ||
export const identifierStartRegexp = | ||
/${identifierStart.toString()}/; | ||
export const identifierPartRegexp = | ||
/${identifierPart.toString()}/; | ||
export const es6IdentifierRegexp = | ||
/^(?:${identifierStart.toString()})(?:${identifierPart.toString()})*$/; | ||
`; | ||
|
||
await writeFile('./src/generator/utils/identifier-regexps.ts', fileContent); | ||
} | ||
|
||
main(); |
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
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
Oops, something went wrong.