Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/brainmaestro/eslint-plugin-optimize-regex
Optimize regex literals
https://github.com/brainmaestro/eslint-plugin-optimize-regex
eslint eslint-plugin eslint-rules optimizer regex regexp
Last synced: about 1 month ago
JSON representation
Optimize regex literals
- Host: GitHub
- URL: https://github.com/brainmaestro/eslint-plugin-optimize-regex
- Owner: BrainMaestro
- License: mit
- Created: 2017-04-14T22:31:44.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-06-20T07:38:37.000Z (5 months ago)
- Last Synced: 2024-10-11T17:23:12.715Z (about 1 month ago)
- Topics: eslint, eslint-plugin, eslint-rules, optimizer, regex, regexp
- Language: JavaScript
- Size: 576 KB
- Stars: 75
- Watchers: 4
- Forks: 7
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# eslint-plugin-optimize-regex
[![npm](https://img.shields.io/npm/v/eslint-plugin-optimize-regex.svg)](https://www.npmjs.com/package/eslint-plugin-optimize-regex)
[![npm](https://img.shields.io/npm/dt/eslint-plugin-optimize-regex.svg)](https://www.npmjs.com/package/eslint-plugin-optimize-regex)> Optimize regex literals
## Installation
You'll first need to install [ESLint](http://eslint.org):
```
npm i eslint --save-dev
```Next, install `eslint-plugin-optimize-regex`:
```
npm install eslint-plugin-optimize-regex --save-dev
```**Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `eslint-plugin-optimize-regex` globally.
## Usage
Add `optimize-regex` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix:
```json
{
"plugins": [
"optimize-regex"
]
}
```Then configure the rules you want to use under the rules section.
```json
{
"rules": {
"optimize-regex/optimize-regex": "warn"
}
}
```If you wish to add a `whitelist` or `blacklist` array against `regexp-tree`'s
[transforms](https://github.com/DmitrySoshnikov/regexp-tree/blob/master/src/optimizer/README.md#transforms), you can add them on an objects object:```json
{
"rules": {
"optimize-regex/optimize-regex": ["warn", {
"blacklist": ["charClassClassrangesMerge"]
}]
}
}
```If you want the latter particular settings, you can avoid setting `plugins` and
`rules` and just use:```json
{
"extends": ["optimize-regex/recommended"]
}
```Or without the blacklist:
```json
{
"extends": ["optimize-regex/all"]
}
```## Rules
* [optimize-regex](./docs/rules/optimize-regex.md)
## Inspiration
* [regexp-tree](https://github.com/DmitrySoshnikov/regexp-tree)
## License
MIT © Ezinwa Okpoechi