Use isIdentifierChar instead of regex for toIdentifier (#12575)
* Use isIdentifierChar instead of regex for toIdentifier * Apply suggestions from code review Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com> * Undo dep * Update packages/babel-types/test/converters.js * Add testcase starting with a number * Add test for non-ascii starting character Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
This commit is contained in:
committed by
GitHub
parent
2d35f5a8f7
commit
fdb5829a60
@@ -14,6 +14,10 @@ function generateCode(node) {
|
||||
describe("converters", function () {
|
||||
it("toIdentifier", function () {
|
||||
expect(t.toIdentifier("swag-lord")).toBe("swagLord");
|
||||
expect(t.toIdentifier("ɵ2")).toBe("ɵ2");
|
||||
expect(t.toIdentifier("ℬ1")).toBe("ℬ1");
|
||||
expect(t.toIdentifier("1bc")).toBe("bc");
|
||||
expect(t.toIdentifier("\u0487a")).toBe("_\u0487a");
|
||||
});
|
||||
|
||||
describe("valueToNode", function () {
|
||||
|
||||
Reference in New Issue
Block a user