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

Add docs for the new unicode-sets-regex plugin #2615

Merged
merged 2 commits into from Feb 2, 2022
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
49 changes: 49 additions & 0 deletions docs/plugin-proposal-unicode-sets-regex.md
@@ -0,0 +1,49 @@
---
id: babel-plugin-proposal-unicode-sets-regex
title: @babel/plugin-proposal-unicode-sets-regex
sidebar_label: unicode-sets-regex
---

This plugin transforms regular expressions using the `v` flag, introduced by the [RegExp set notation + properties of strings](https://github.com/tc39/proposal-regexp-set-notation) proposal, to regular expressions that use the `u` flag.

## Example

```js
/[\p{ASCII}&&\p{Decimal_Number}]/v
```

will be transformed to

```js
/[0-9]/u
```

## Installation

```sh
npm install --save-dev @babel/plugin-proposal-unicode-sets-regex
```

## Usage

### With a configuration file (Recommended)

```json
{
"plugins": ["@babel/plugin-proposal-unicode-sets-regex"]
}
```

### Via CLI

```sh
babel --plugins @babel/plugin-proposal-unicode-sets-regex script.js
```

### Via Node API

```javascript
require("@babel/core").transformSync("code", {
plugins: ["@babel/plugin-proposal-unicode-sets-regex"],
});
```
47 changes: 47 additions & 0 deletions docs/plugin-syntax-unicode-sets-regex.md
@@ -0,0 +1,47 @@
---
id: babel-plugin-syntax-unicode-sets-regex
title: @babel/plugin-syntax-unicode-sets-regex
sidebar_label: syntax-unicode-sets-regex
---

> #### Syntax only
>
> It's unlikely you want to use this plugin directly as it only enables Babel to parse this syntax. Instead, use [plugin-proposal-unicode-sets-regex](plugin-proposal-unicode-sets-regex.md) to _both_ parse and transform this syntax.

This plugin enables parsing regular expressions using the `v` flag, introduced by the [RegExp set notation + properties of strings](https://github.com/tc39/proposal-regexp-set-notation) proposal, to regular expressions that use the `u` flag.

## Example

```js
/[\p{ASCII}&&\p{Decimal_Number}]/v
```

## Installation

```sh
npm install --save-dev @babel/plugin-syntax-unicode-sets-regex
```

## Usage

### With a configuration file (Recommended)

```json
{
"plugins": ["@babel/plugin-syntax-unicode-sets-regex"]
}
```

### Via CLI

```sh
babel --plugins @babel/plugin-syntax-unicode-sets-regex script.js
```

### Via Node API

```javascript
require("@babel/core").transformSync("code", {
plugins: ["@babel/plugin-syntax-unicode-sets-regex"],
});
```