Skip to content

Commit

Permalink
Add docs for the new unicode-sets-regex plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Jan 31, 2022
1 parent cfc7b59 commit f5b32dc
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 0 deletions.
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 plugins transform regular expression 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: 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 plugins enabled parsing regular expression 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"],
});
```

0 comments on commit f5b32dc

Please sign in to comment.