@eslint-community/regexpp 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +177 -0
  3. package/package.json +90 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Toru Nagashima
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,177 @@
1
+ # @eslint-community/regexpp
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@eslint-community/regexpp.svg)](https://www.npmjs.com/package/@eslint-community/regexpp)
4
+ [![Downloads/month](https://img.shields.io/npm/dm/@eslint-community/regexpp.svg)](http://www.npmtrends.com/@eslint-community/regexpp)
5
+ [![Build Status](https://github.com/eslint-community/regexpp/workflows/CI/badge.svg)](https://github.com/eslint-community/regexpp/actions)
6
+ [![codecov](https://codecov.io/gh/eslint-community/regexpp/branch/main/graph/badge.svg)](https://codecov.io/gh/eslint-community/regexpp)
7
+
8
+ A regular expression parser for ECMAScript.
9
+
10
+ ## 💿 Installation
11
+
12
+ ```bash
13
+ $ npm install @eslint-community/regexpp
14
+ ```
15
+
16
+ - require Node.js 8 or newer.
17
+
18
+ ## 📖 Usage
19
+
20
+ ```ts
21
+ import {
22
+ AST,
23
+ RegExpParser,
24
+ RegExpValidator,
25
+ RegExpVisitor,
26
+ parseRegExpLiteral,
27
+ validateRegExpLiteral,
28
+ visitRegExpAST
29
+ } from "@eslint-community/regexpp"
30
+ ```
31
+
32
+ ### parseRegExpLiteral(source, options?)
33
+
34
+ Parse a given regular expression literal then make AST object.
35
+
36
+ This is equivalent to `new RegExpParser(options).parseLiteral(source)`.
37
+
38
+ - **Parameters:**
39
+ - `source` (`string | RegExp`) The source code to parse.
40
+ - `options?` ([`RegExpParser.Options`]) The options to parse.
41
+ - **Return:**
42
+ - The AST of the regular expression.
43
+
44
+ ### validateRegExpLiteral(source, options?)
45
+
46
+ Validate a given regular expression literal.
47
+
48
+ This is equivalent to `new RegExpValidator(options).validateLiteral(source)`.
49
+
50
+ - **Parameters:**
51
+ - `source` (`string`) The source code to validate.
52
+ - `options?` ([`RegExpValidator.Options`]) The options to validate.
53
+
54
+ ### visitRegExpAST(ast, handlers)
55
+
56
+ Visit each node of a given AST.
57
+
58
+ This is equivalent to `new RegExpVisitor(handlers).visit(ast)`.
59
+
60
+ - **Parameters:**
61
+ - `ast` ([`AST.Node`]) The AST to visit.
62
+ - `handlers` ([`RegExpVisitor.Handlers`]) The callbacks.
63
+
64
+ ### RegExpParser
65
+
66
+ #### new RegExpParser(options?)
67
+
68
+ - **Parameters:**
69
+ - `options?` ([`RegExpParser.Options`]) The options to parse.
70
+
71
+ #### parser.parseLiteral(source, start?, end?)
72
+
73
+ Parse a regular expression literal.
74
+
75
+ - **Parameters:**
76
+ - `source` (`string`) The source code to parse. E.g. `"/abc/g"`.
77
+ - `start?` (`number`) The start index in the source code. Default is `0`.
78
+ - `end?` (`number`) The end index in the source code. Default is `source.length`.
79
+ - **Return:**
80
+ - The AST of the regular expression.
81
+
82
+ #### parser.parsePattern(source, start?, end?, uFlag?)
83
+
84
+ Parse a regular expression pattern.
85
+
86
+ - **Parameters:**
87
+ - `source` (`string`) The source code to parse. E.g. `"abc"`.
88
+ - `start?` (`number`) The start index in the source code. Default is `0`.
89
+ - `end?` (`number`) The end index in the source code. Default is `source.length`.
90
+ - `uFlag?` (`boolean`) The flag to enable Unicode mode.
91
+ - **Return:**
92
+ - The AST of the regular expression pattern.
93
+
94
+ #### parser.parseFlags(source, start?, end?)
95
+
96
+ Parse a regular expression flags.
97
+
98
+ - **Parameters:**
99
+ - `source` (`string`) The source code to parse. E.g. `"gim"`.
100
+ - `start?` (`number`) The start index in the source code. Default is `0`.
101
+ - `end?` (`number`) The end index in the source code. Default is `source.length`.
102
+ - **Return:**
103
+ - The AST of the regular expression flags.
104
+
105
+ ### RegExpValidator
106
+
107
+ #### new RegExpValidator(options)
108
+
109
+ - **Parameters:**
110
+ - `options` ([`RegExpValidator.Options`]) The options to validate.
111
+
112
+ #### validator.validateLiteral(source, start, end)
113
+
114
+ Validate a regular expression literal.
115
+
116
+ - **Parameters:**
117
+ - `source` (`string`) The source code to validate.
118
+ - `start?` (`number`) The start index in the source code. Default is `0`.
119
+ - `end?` (`number`) The end index in the source code. Default is `source.length`.
120
+
121
+ #### validator.validatePattern(source, start, end, uFlag)
122
+
123
+ Validate a regular expression pattern.
124
+
125
+ - **Parameters:**
126
+ - `source` (`string`) The source code to validate.
127
+ - `start?` (`number`) The start index in the source code. Default is `0`.
128
+ - `end?` (`number`) The end index in the source code. Default is `source.length`.
129
+ - `uFlag?` (`boolean`) The flag to enable Unicode mode.
130
+
131
+ #### validator.validateFlags(source, start, end)
132
+
133
+ Validate a regular expression flags.
134
+
135
+ - **Parameters:**
136
+ - `source` (`string`) The source code to validate.
137
+ - `start?` (`number`) The start index in the source code. Default is `0`.
138
+ - `end?` (`number`) The end index in the source code. Default is `source.length`.
139
+
140
+ ### RegExpVisitor
141
+
142
+ #### new RegExpVisitor(handlers)
143
+
144
+ - **Parameters:**
145
+ - `handlers` ([`RegExpVisitor.Handlers`]) The callbacks.
146
+
147
+ #### visitor.visit(ast)
148
+
149
+ Validate a regular expression literal.
150
+
151
+ - **Parameters:**
152
+ - `ast` ([`AST.Node`]) The AST to visit.
153
+
154
+ ## 📰 Changelog
155
+
156
+ - [GitHub Releases](https://github.com/eslint-community/regexpp/releases)
157
+
158
+ ## 🍻 Contributing
159
+
160
+ Welcome contributing!
161
+
162
+ Please use GitHub's Issues/PRs.
163
+
164
+ ### Development Tools
165
+
166
+ - `npm test` runs tests and measures coverage.
167
+ - `npm run build` compiles TypeScript source code to `index.js`, `index.js.map`, and `index.d.ts`.
168
+ - `npm run clean` removes the temporary files which are created by `npm test` and `npm run build`.
169
+ - `npm run lint` runs ESLint.
170
+ - `npm run update:test` updates test fixtures.
171
+ - `npm run update:ids` updates `src/unicode/ids.ts`.
172
+ - `npm run watch` runs tests with `--watch` option.
173
+
174
+ [`AST.Node`]: src/ast.ts#L4
175
+ [`RegExpParser.Options`]: src/parser.ts#L539
176
+ [`RegExpValidator.Options`]: src/validator.ts#L127
177
+ [`RegExpVisitor.Handlers`]: src/visitor.ts#L204
package/package.json ADDED
@@ -0,0 +1,90 @@
1
+ {
2
+ "name": "@eslint-community/regexpp",
3
+ "version": "3.2.0",
4
+ "description": "Regular expression parser for ECMAScript.",
5
+ "engines": {
6
+ "node": ">=8"
7
+ },
8
+ "main": "index",
9
+ "files": [
10
+ "index.*"
11
+ ],
12
+ "exports": {
13
+ ".": {
14
+ "import": "./index.mjs",
15
+ "default": "./index.js"
16
+ },
17
+ "./package.json": "./package.json"
18
+ },
19
+ "dependencies": {},
20
+ "devDependencies": {
21
+ "@mysticatea/eslint-plugin": "^11.0.0",
22
+ "@types/eslint": "^4.16.2",
23
+ "@types/jsdom": "^12.2.4",
24
+ "@types/mocha": "^5.2.2",
25
+ "@types/node": "^12.6.8",
26
+ "codecov": "^3.5.0",
27
+ "dts-bundle": "^0.7.3",
28
+ "eslint": "^6.1.0",
29
+ "jsdom": "^15.1.1",
30
+ "mocha": "^6.2.0",
31
+ "npm-run-all": "^4.1.5",
32
+ "nyc": "^14.1.1",
33
+ "rimraf": "^2.6.2",
34
+ "rollup": "^1.17.0",
35
+ "rollup-plugin-node-resolve": "^5.2.0",
36
+ "rollup-plugin-sourcemaps": "^0.4.2",
37
+ "ts-node": "^8.3.0",
38
+ "typescript": "^3.5.3"
39
+ },
40
+ "scripts": {
41
+ "prebuild": "npm run -s clean",
42
+ "build": "run-s build:*",
43
+ "build:tsc": "tsc --module es2015",
44
+ "build:rollup": "rollup -c",
45
+ "build:dts": "dts-bundle --name @eslint-community/regexpp --main .temp/index.d.ts --out ../index.d.ts",
46
+ "clean": "rimraf .temp index.*",
47
+ "codecov": "nyc report -r lcovonly && codecov -t ${CODECOV_TOKEN} --disable=gcov",
48
+ "lint": "eslint scripts src test --ext .ts",
49
+ "pretest": "run-s build lint",
50
+ "test": "nyc _mocha \"test/*.ts\" --reporter dot --timeout 10000",
51
+ "update:test": "ts-node scripts/update-fixtures.ts",
52
+ "update:unicode": "run-s update:unicode:*",
53
+ "update:unicode:ids": "ts-node scripts/update-unicode-ids.ts",
54
+ "update:unicode:props": "ts-node scripts/update-unicode-properties.ts",
55
+ "preversion": "npm test",
56
+ "version": "npm run -s build",
57
+ "postversion": "git push && git push --tags",
58
+ "prewatch": "npm run -s clean",
59
+ "watch": "_mocha \"test/*.ts\" --require ts-node/register --reporter dot --timeout 10000 --watch-extensions ts --watch --growl"
60
+ },
61
+ "repository": {
62
+ "type": "git",
63
+ "url": "https://github.com/eslint-community/regexpp"
64
+ },
65
+ "keywords": [
66
+ "regexp",
67
+ "regular",
68
+ "expression",
69
+ "parser",
70
+ "validator",
71
+ "ast",
72
+ "abstract",
73
+ "syntax",
74
+ "tree",
75
+ "ecmascript",
76
+ "es2015",
77
+ "es2016",
78
+ "es2017",
79
+ "es2018",
80
+ "es2019",
81
+ "es2020",
82
+ "annexB"
83
+ ],
84
+ "author": "Toru Nagashima",
85
+ "license": "MIT",
86
+ "bugs": {
87
+ "url": "https://github.com/eslint-community/regexpp/issues"
88
+ },
89
+ "homepage": "https://github.com/eslint-community/regexpp#readme"
90
+ }