Skip to content

Commit 68e1fb4

Browse files
committed
Add documentation
1 parent 851a060 commit 68e1fb4

File tree

3 files changed

+80
-1
lines changed

3 files changed

+80
-1
lines changed

Diff for: README.md

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# eslint-plugin-optimize-regex
2+
3+
Optimize regex literals
4+
5+
## Installation
6+
7+
You'll first need to install [ESLint](http://eslint.org):
8+
9+
```
10+
$ npm i eslint --save-dev
11+
```
12+
13+
Next, install `eslint-plugin-optimize-regex`:
14+
15+
```
16+
$ npm install eslint-plugin-eslint-optimize-regex --save-dev
17+
```
18+
19+
**Note:** If you installed ESLint globally (using the `-g` flag) then you must also install `eslint-plugin--optimize-regex` globally.
20+
21+
## Usage
22+
23+
Add `optimize-regex` to the plugins section of your `.eslintrc` configuration file. You can omit the `eslint-plugin-` prefix:
24+
25+
```json
26+
{
27+
"plugins": [
28+
"optimize-regex"
29+
]
30+
}
31+
```
32+
33+
34+
Then configure the rules you want to use under the rules section.
35+
36+
```json
37+
{
38+
"rules": {
39+
"optimize-regex/optimize-regex": "error"
40+
}
41+
}
42+
```
43+
44+
## Rules
45+
46+
* [optimize-regex](./docs/rules/optimize-regex.md)
47+
48+
## Inspiration
49+
50+
* [regexp-tree](https://github.com/DmitrySoshnikov/regexp-tree)
51+
52+
## License
53+
54+
MIT © Ezinwa Okpoechi

Diff for: docs/rules/optimize-regex.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Optimize regex literals (optimize-regex)
2+
3+
This rule enforces an idiomatic and sometimes clearer usage of regexes.
4+
5+
6+
## Rule Details
7+
8+
Examples of **incorrect** code for this rule:
9+
10+
```js
11+
12+
const re = /[a-zA-Z_0-9][A-Z_\da-z]*\e{1,}/
13+
14+
```
15+
16+
Examples of **correct** code for this rule:
17+
18+
```js
19+
20+
const re = /\w+e+/
21+
22+
```
23+
24+
The two regexes have the exact same functionality.

Diff for: package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"name": "eslint-plugin-optimize-regex",
3-
"version": "0.0.0",
3+
"version": "0.1.0",
44
"description": "Optimize regex literals",
5+
"repository": "BrainMaestro/eslint-plugin-optimize-regex",
56
"keywords": [
67
"eslint",
78
"eslintplugin",

0 commit comments

Comments
 (0)