File tree 3 files changed +80
-1
lines changed
3 files changed +80
-1
lines changed Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 _\d a-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.
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " eslint-plugin-optimize-regex" ,
3
- "version" : " 0.0 .0" ,
3
+ "version" : " 0.1 .0" ,
4
4
"description" : " Optimize regex literals" ,
5
+ "repository" : " BrainMaestro/eslint-plugin-optimize-regex" ,
5
6
"keywords" : [
6
7
" eslint" ,
7
8
" eslintplugin" ,
You can’t perform that action at this time.
0 commit comments