Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable regexp unicode sets parsing by default #15638

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 10 additions & 10 deletions packages/babel-core/src/parser/util/missing-plugin-helper.ts
Expand Up @@ -106,16 +106,6 @@ const pluginNameMap: Record<
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-record-and-tuple",
},
},
regexpUnicodeSets: {
syntax: {
name: "@babel/plugin-syntax-unicode-sets-regex",
url: "https://github.com/babel/babel/blob/main/packages/babel-plugin-syntax-unicode-sets-regex/README.md",
},
transform: {
name: "@babel/plugin-proposal-unicode-sets-regex",
url: "https://github.com/babel/babel/blob/main/packages/babel-plugin-proposalunicode-sets-regex/README.md",
},
},
throwExpressions: {
syntax: {
name: "@babel/plugin-syntax-throw-expressions",
Expand Down Expand Up @@ -289,6 +279,16 @@ if (!process.env.BABEL_8_BREAKING) {
url: "https://github.com/babel/babel/tree/main/packages/babel-plugin-proposal-private-property-in-object",
},
},
regexpUnicodeSets: {
syntax: {
name: "@babel/plugin-syntax-unicode-sets-regex",
url: "https://github.com/babel/babel/blob/main/packages/babel-plugin-syntax-unicode-sets-regex/README.md",
},
transform: {
name: "@babel/plugin-proposal-unicode-sets-regex",
url: "https://github.com/babel/babel/blob/main/packages/babel-plugin-proposalunicode-sets-regex/README.md",
},
},
});
}

Expand Down
Expand Up @@ -3,6 +3,7 @@ export const FEATURES = Object.freeze({
dotAllFlag: 1 << 1,
unicodePropertyEscape: 1 << 2,
namedCaptureGroups: 1 << 3,
// Not used, for backward compatibility with syntax-unicode-sets-regex
unicodeSetsFlag_syntax: 1 << 4,
unicodeSetsFlag: 1 << 5,
duplicateNamedCaptureGroups: 1 << 6,
Expand Down
Expand Up @@ -33,9 +33,7 @@ export function generateRegexpuOptions(

return {
unicodeFlag: feat("unicodeFlag"),
unicodeSetsFlag:
feat<Experimental>("unicodeSetsFlag") ||
feat<Experimental>("unicodeSetsFlag_syntax", "parse"),
unicodeSetsFlag: feat<Experimental>("unicodeSetsFlag") || "parse",
dotAllFlag: feat("dotAllFlag"),
unicodePropertyEscapes: feat("unicodePropertyEscape"),
namedGroups: feat("namedCaptureGroups") || featDuplicateNamedGroups(),
Expand Down
3 changes: 0 additions & 3 deletions packages/babel-parser/src/tokenizer/index.ts
Expand Up @@ -57,7 +57,6 @@ const VALID_REGEX_FLAGS = new Set([
charCodes.lowercaseY,
charCodes.lowercaseU,
charCodes.lowercaseD,
// This is only valid when using the regexpUnicodeSets plugin
charCodes.lowercaseV,
]);

Expand Down Expand Up @@ -1100,8 +1099,6 @@ export default abstract class Tokenizer extends CommentsParser {
// @ts-expect-error VALID_REGEX_FLAGS.has should accept expanded type: number
if (VALID_REGEX_FLAGS.has(cp)) {
if (cp === charCodes.lowercaseV) {
this.expectPlugin("regexpUnicodeSets", nextPos());

if (mods.includes("u")) {
this.raise(Errors.IncompatibleRegExpUVFlags, { at: nextPos() });
}
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-parser/src/typings.d.ts
Expand Up @@ -34,7 +34,7 @@ export type Plugin =
| "partialApplication"
| "placeholders"
| "privateIn" // Enabled by default
| "regexpUnicodeSets"
| "regexpUnicodeSets" // Enabled by default
| "throwExpressions"
| "topLevelAwait"
| "v8intrinsic"
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion packages/babel-parser/typings/babel-parser.d.ts
Expand Up @@ -38,7 +38,7 @@ type Plugin =
| "partialApplication"
| "placeholders"
| "privateIn" // Enabled by default
| "regexpUnicodeSets"
| "regexpUnicodeSets" // Enabled by default
| "throwExpressions"
| "topLevelAwait"
| "v8intrinsic"
Expand Down