Leon4gr45 commited on
Commit
e0ac63d
·
verified ·
1 Parent(s): b0fd1a0

Include updated package-lock.json (part 7)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. node_modules/@csstools/css-syntax-patches-for-csstree/README.md +43 -0
  2. node_modules/@csstools/css-syntax-patches-for-csstree/package.json +56 -0
  3. node_modules/@csstools/css-tokenizer/CHANGELOG.md +10 -0
  4. node_modules/@csstools/css-tokenizer/LICENSE.md +20 -0
  5. node_modules/@csstools/css-tokenizer/README.md +111 -0
  6. node_modules/@csstools/css-tokenizer/package.json +55 -0
  7. node_modules/@emnapi/core/LICENSE +21 -0
  8. node_modules/@emnapi/core/README.md +1 -0
  9. node_modules/@emnapi/core/index.js +5 -0
  10. node_modules/@emnapi/core/package.json +49 -0
  11. node_modules/@emnapi/runtime/LICENSE +21 -0
  12. node_modules/@emnapi/runtime/README.md +1 -0
  13. node_modules/@emnapi/runtime/index.js +5 -0
  14. node_modules/@emnapi/runtime/package.json +48 -0
  15. node_modules/@emnapi/wasi-threads/LICENSE +21 -0
  16. node_modules/@emnapi/wasi-threads/README.md +203 -0
  17. node_modules/@emnapi/wasi-threads/index.js +5 -0
  18. node_modules/@emnapi/wasi-threads/package.json +50 -0
  19. node_modules/@eslint-community/eslint-utils/LICENSE +21 -0
  20. node_modules/@eslint-community/eslint-utils/README.md +37 -0
  21. node_modules/@eslint-community/eslint-utils/index.d.mts +217 -0
  22. node_modules/@eslint-community/eslint-utils/index.d.ts +217 -0
  23. node_modules/@eslint-community/eslint-utils/index.js +2620 -0
  24. node_modules/@eslint-community/eslint-utils/index.js.map +0 -0
  25. node_modules/@eslint-community/eslint-utils/index.mjs +2579 -0
  26. node_modules/@eslint-community/eslint-utils/index.mjs.map +0 -0
  27. node_modules/@eslint-community/eslint-utils/package.json +89 -0
  28. node_modules/@eslint-community/regexpp/LICENSE +21 -0
  29. node_modules/@eslint-community/regexpp/README.md +177 -0
  30. node_modules/@eslint-community/regexpp/index.d.ts +1163 -0
  31. node_modules/@eslint-community/regexpp/index.js +0 -0
  32. node_modules/@eslint-community/regexpp/index.js.map +0 -0
  33. node_modules/@eslint-community/regexpp/index.mjs +0 -0
  34. node_modules/@eslint-community/regexpp/index.mjs.map +0 -0
  35. node_modules/@eslint-community/regexpp/package.json +91 -0
  36. node_modules/@eslint/compat/LICENSE +201 -0
  37. node_modules/@eslint/compat/README.md +213 -0
  38. node_modules/@eslint/compat/package.json +72 -0
  39. node_modules/@eslint/config-array/LICENSE +201 -0
  40. node_modules/@eslint/config-array/README.md +369 -0
  41. node_modules/@eslint/config-array/package.json +65 -0
  42. node_modules/@eslint/config-helpers/LICENSE +201 -0
  43. node_modules/@eslint/config-helpers/README.md +150 -0
  44. node_modules/@eslint/config-helpers/package.json +62 -0
  45. node_modules/@eslint/core/LICENSE +201 -0
  46. node_modules/@eslint/core/README.md +29 -0
  47. node_modules/@eslint/core/package.json +52 -0
  48. node_modules/@eslint/eslintrc/LICENSE +19 -0
  49. node_modules/@eslint/eslintrc/README.md +145 -0
  50. node_modules/@eslint/eslintrc/conf/config-schema.js +79 -0
node_modules/@csstools/css-syntax-patches-for-csstree/README.md ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CSS Syntax Patches For CSSTree <img src="https://cssdb.org/images/css.svg" alt="for CSS" width="90" height="90" align="right">
2
+
3
+ [<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/css-syntax-patches-for-csstree.svg" height="20">][npm-url]
4
+ [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/actions/workflows/test.yml/badge.svg?branch=main" height="20">][cli-url]
5
+
6
+ Patch [csstree](https://github.com/csstree/csstree) syntax definitions with the latest data from CSS specifications.
7
+
8
+ ## Usage
9
+
10
+ ```bash
11
+ npm install @csstools/css-syntax-patches-for-csstree
12
+ ```
13
+
14
+ ```js
15
+ import { fork } from 'css-tree';
16
+ import syntax_patches from '@csstools/css-syntax-patches-for-csstree' with { type: 'json' };
17
+
18
+ const forkedLexer = fork({
19
+ atrules: syntax_patches.next.atrules,
20
+ properties: syntax_patches.next.properties,
21
+ types: syntax_patches.next.types,
22
+ }).lexer;
23
+ ```
24
+
25
+ ## `next`
26
+
27
+ ```js
28
+ import syntax_patches from '@csstools/css-syntax-patches-for-csstree' with { type: 'json' };
29
+
30
+ console.log(syntax_patches.next);
31
+ // ^^^^
32
+ ```
33
+
34
+ CSS specifications are often still in flux and various parts might change or disappear altogether.
35
+ Specifications also contains parts that haven't been implemented yet in a browser.
36
+ Only CSS that is widely adopted can be expected to be stable.
37
+
38
+ The `next` grouping contains a combination of what is currently valid in browsers and the progress in various specifications.
39
+
40
+ _In the future more groupings might be added._
41
+
42
+ [cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test
43
+ [npm-url]: https://www.npmjs.com/package/@csstools/css-syntax-patches-for-csstree
node_modules/@csstools/css-syntax-patches-for-csstree/package.json ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@csstools/css-syntax-patches-for-csstree",
3
+ "description": "CSS syntax patches for CSS tree",
4
+ "version": "1.1.5",
5
+ "contributors": [
6
+ {
7
+ "name": "Antonio Laguna",
8
+ "email": "antonio@laguna.es",
9
+ "url": "https://antonio.laguna.es"
10
+ },
11
+ {
12
+ "name": "Romain Menke",
13
+ "email": "romainmenke@gmail.com"
14
+ }
15
+ ],
16
+ "license": "MIT-0",
17
+ "funding": [
18
+ {
19
+ "type": "github",
20
+ "url": "https://github.com/sponsors/csstools"
21
+ },
22
+ {
23
+ "type": "opencollective",
24
+ "url": "https://opencollective.com/csstools"
25
+ }
26
+ ],
27
+ "main": "dist/index.json",
28
+ "types": "dist/index.d.ts",
29
+ "files": [
30
+ "CHANGELOG.md",
31
+ "LICENSE.md",
32
+ "README.md",
33
+ "dist"
34
+ ],
35
+ "peerDependencies": {
36
+ "css-tree": "^3.2.1"
37
+ },
38
+ "peerDependenciesMeta": {
39
+ "css-tree": {
40
+ "optional": true
41
+ }
42
+ },
43
+ "scripts": {},
44
+ "homepage": "https://github.com/csstools/postcss-plugins/tree/main/packages/css-syntax-patches-for-csstree#readme",
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "git+https://github.com/csstools/postcss-plugins.git",
48
+ "directory": "packages/css-syntax-patches-for-csstree"
49
+ },
50
+ "bugs": "https://github.com/csstools/postcss-plugins/issues",
51
+ "keywords": [
52
+ "css",
53
+ "csstree",
54
+ "syntax"
55
+ ]
56
+ }
node_modules/@csstools/css-tokenizer/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ # Changes to CSS Tokenizer
2
+
3
+ ### 4.0.0
4
+
5
+ _January 14, 2026_
6
+
7
+ - Updated: Support for Node `20.19.0` or later (major).
8
+ - Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes.
9
+
10
+ [Full CHANGELOG](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer/CHANGELOG.md)
node_modules/@csstools/css-tokenizer/LICENSE.md ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ The MIT License (MIT)
2
+
3
+ Copyright 2022 Romain Menke, Antonio Laguna <antonio@laguna.es>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ 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, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
node_modules/@csstools/css-tokenizer/README.md ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CSS Tokenizer <img src="https://cssdb.org/images/css.svg" alt="for CSS" width="90" height="90" align="right">
2
+
3
+ [<img alt="npm version" src="https://img.shields.io/npm/v/@csstools/css-tokenizer.svg" height="20">][npm-url]
4
+ [<img alt="Build Status" src="https://github.com/csstools/postcss-plugins/actions/workflows/test.yml/badge.svg?branch=main" height="20">][cli-url]
5
+ [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord]
6
+
7
+ Implemented from : https://drafts.csswg.org/css-syntax/
8
+
9
+ ## API
10
+
11
+ [Read the API docs](./docs/css-tokenizer.md)
12
+
13
+ ## Usage
14
+
15
+ Add [CSS Tokenizer] to your project:
16
+
17
+ ```bash
18
+ npm install @csstools/css-tokenizer --save-dev
19
+ ```
20
+
21
+ ```js
22
+ import { tokenize } from '@csstools/css-tokenizer';
23
+
24
+ const myCSS = `@media only screen and (min-width: 768rem) {
25
+ .foo {
26
+ content: 'Some content!' !important;
27
+ }
28
+ }
29
+ `;
30
+
31
+ const tokens = tokenize({
32
+ css: myCSS,
33
+ });
34
+
35
+ console.log(tokens);
36
+ ```
37
+
38
+ Or use the streaming interface:
39
+
40
+ ```js
41
+ import { tokenizer, TokenType } from '@csstools/css-tokenizer';
42
+
43
+ const myCSS = `@media only screen and (min-width: 768rem) {
44
+ .foo {
45
+ content: 'Some content!' !important;
46
+ }
47
+ }
48
+ `;
49
+
50
+ const t = tokenizer({
51
+ css: myCSS,
52
+ });
53
+
54
+ while (true) {
55
+ const token = t.nextToken();
56
+ if (token[0] === TokenType.EOF) {
57
+ break;
58
+ }
59
+
60
+ console.log(token);
61
+ }
62
+ ```
63
+
64
+ ### Options
65
+
66
+ ```ts
67
+ {
68
+ onParseError?: (error: ParseError) => void
69
+ }
70
+ ```
71
+
72
+ #### `onParseError`
73
+
74
+ The tokenizer is forgiving and won't stop when a parse error is encountered.
75
+
76
+ To receive parsing error information you can set a callback.
77
+
78
+ ```js
79
+ import { tokenizer, TokenType } from '@csstools/css-tokenizer';
80
+
81
+ const t = tokenizer({
82
+ css: '\\',
83
+ }, { onParseError: (err) => console.warn(err) });
84
+
85
+ while (true) {
86
+ const token = t.nextToken();
87
+ if (token[0] === TokenType.EOF) {
88
+ break;
89
+ }
90
+ }
91
+ ```
92
+
93
+ Parser errors will try to inform you where in the tokenizer logic the error happened.
94
+ This tells you what kind of error occurred.
95
+
96
+ ## Order of priorities
97
+
98
+ 1. specification compliance
99
+ 2. correctness
100
+ 3. reliability
101
+ 4. tokenizing and serializing must round trip losslessly
102
+ 5. exposing useful aspects about the source code
103
+ 6. runtime performance
104
+ 7. package size
105
+
106
+
107
+ [cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test
108
+ [discord]: https://discord.gg/bUadyRwkJS
109
+ [npm-url]: https://www.npmjs.com/package/@csstools/css-tokenizer
110
+
111
+ [CSS Tokenizer]: https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer
node_modules/@csstools/css-tokenizer/package.json ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@csstools/css-tokenizer",
3
+ "description": "Tokenize CSS",
4
+ "version": "4.0.0",
5
+ "contributors": [
6
+ {
7
+ "name": "Antonio Laguna",
8
+ "email": "antonio@laguna.es",
9
+ "url": "https://antonio.laguna.es"
10
+ },
11
+ {
12
+ "name": "Romain Menke",
13
+ "email": "romainmenke@gmail.com"
14
+ }
15
+ ],
16
+ "license": "MIT",
17
+ "funding": [
18
+ {
19
+ "type": "github",
20
+ "url": "https://github.com/sponsors/csstools"
21
+ },
22
+ {
23
+ "type": "opencollective",
24
+ "url": "https://opencollective.com/csstools"
25
+ }
26
+ ],
27
+ "engines": {
28
+ "node": ">=20.19.0"
29
+ },
30
+ "type": "module",
31
+ "exports": {
32
+ ".": {
33
+ "types": "./dist/index.d.ts",
34
+ "default": "./dist/index.mjs"
35
+ }
36
+ },
37
+ "files": [
38
+ "CHANGELOG.md",
39
+ "LICENSE.md",
40
+ "README.md",
41
+ "dist"
42
+ ],
43
+ "scripts": {},
44
+ "homepage": "https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer#readme",
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "git+https://github.com/csstools/postcss-plugins.git",
48
+ "directory": "packages/css-tokenizer"
49
+ },
50
+ "bugs": "https://github.com/csstools/postcss-plugins/issues",
51
+ "keywords": [
52
+ "css",
53
+ "tokenizer"
54
+ ]
55
+ }
node_modules/@emnapi/core/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2021-present Toyobayashi
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.
node_modules/@emnapi/core/README.md ADDED
@@ -0,0 +1 @@
 
 
1
+ See [https://github.com/toyobayashi/emnapi](https://github.com/toyobayashi/emnapi)
node_modules/@emnapi/core/index.js ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ if (typeof process !== 'undefined' && process.env.NODE_ENV === 'production') {
2
+ module.exports = require('./dist/emnapi-core.cjs.min.js')
3
+ } else {
4
+ module.exports = require('./dist/emnapi-core.cjs.js')
5
+ }
node_modules/@emnapi/core/package.json ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@emnapi/core",
3
+ "version": "1.10.0",
4
+ "description": "emnapi core",
5
+ "main": "index.js",
6
+ "module": "./dist/emnapi-core.esm-bundler.js",
7
+ "types": "./dist/emnapi-core.d.ts",
8
+ "sideEffects": false,
9
+ "exports": {
10
+ ".": {
11
+ "types": {
12
+ "module": "./dist/emnapi-core.d.ts",
13
+ "import": "./dist/emnapi-core.d.mts",
14
+ "default": "./dist/emnapi-core.d.ts"
15
+ },
16
+ "module": "./dist/emnapi-core.esm-bundler.js",
17
+ "import": "./dist/emnapi-core.mjs",
18
+ "default": "./index.js"
19
+ },
20
+ "./dist/emnapi-core.cjs.min": {
21
+ "types": "./dist/emnapi-core.d.ts",
22
+ "default": "./dist/emnapi-core.cjs.min.js"
23
+ },
24
+ "./dist/emnapi-core.min.mjs": {
25
+ "types": "./dist/emnapi-core.d.mts",
26
+ "default": "./dist/emnapi-core.min.mjs"
27
+ }
28
+ },
29
+ "dependencies": {
30
+ "@emnapi/wasi-threads": "1.2.1",
31
+ "tslib": "^2.4.0"
32
+ },
33
+ "scripts": {
34
+ "build": "node ./script/build.js"
35
+ },
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "git+https://github.com/toyobayashi/emnapi.git"
39
+ },
40
+ "author": "toyobayashi",
41
+ "license": "MIT",
42
+ "bugs": {
43
+ "url": "https://github.com/toyobayashi/emnapi/issues"
44
+ },
45
+ "homepage": "https://github.com/toyobayashi/emnapi#readme",
46
+ "publishConfig": {
47
+ "access": "public"
48
+ }
49
+ }
node_modules/@emnapi/runtime/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2021-present Toyobayashi
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.
node_modules/@emnapi/runtime/README.md ADDED
@@ -0,0 +1 @@
 
 
1
+ See [https://github.com/toyobayashi/emnapi](https://github.com/toyobayashi/emnapi)
node_modules/@emnapi/runtime/index.js ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ if (typeof process !== 'undefined' && process.env.NODE_ENV === 'production') {
2
+ module.exports = require('./dist/emnapi.cjs.min.js')
3
+ } else {
4
+ module.exports = require('./dist/emnapi.cjs.js')
5
+ }
node_modules/@emnapi/runtime/package.json ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@emnapi/runtime",
3
+ "version": "1.11.1",
4
+ "description": "emnapi runtime",
5
+ "main": "index.js",
6
+ "module": "./dist/emnapi.esm-bundler.js",
7
+ "types": "./dist/emnapi.d.ts",
8
+ "sideEffects": false,
9
+ "exports": {
10
+ ".": {
11
+ "types": {
12
+ "module": "./dist/emnapi.d.ts",
13
+ "import": "./dist/emnapi.d.mts",
14
+ "default": "./dist/emnapi.d.ts"
15
+ },
16
+ "module": "./dist/emnapi.esm-bundler.js",
17
+ "import": "./dist/emnapi.mjs",
18
+ "default": "./index.js"
19
+ },
20
+ "./dist/emnapi.cjs.min": {
21
+ "types": "./dist/emnapi.d.ts",
22
+ "default": "./dist/emnapi.cjs.min.js"
23
+ },
24
+ "./dist/emnapi.min.mjs": {
25
+ "types": "./dist/emnapi.d.mts",
26
+ "default": "./dist/emnapi.min.mjs"
27
+ }
28
+ },
29
+ "dependencies": {
30
+ "tslib": "^2.4.0"
31
+ },
32
+ "scripts": {
33
+ "build": "node ./script/build.js"
34
+ },
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "git+https://github.com/toyobayashi/emnapi.git"
38
+ },
39
+ "author": "toyobayashi",
40
+ "license": "MIT",
41
+ "bugs": {
42
+ "url": "https://github.com/toyobayashi/emnapi/issues"
43
+ },
44
+ "homepage": "https://github.com/toyobayashi/emnapi#readme",
45
+ "publishConfig": {
46
+ "access": "public"
47
+ }
48
+ }
node_modules/@emnapi/wasi-threads/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2021-present Toyobayashi
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.
node_modules/@emnapi/wasi-threads/README.md ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # @emnapi/wasi-threads
2
+
3
+ This package makes [wasi-threads proposal](https://github.com/WebAssembly/wasi-threads) based WASI modules work in Node.js and browser.
4
+
5
+ ## Quick Start
6
+
7
+ `index.html`
8
+
9
+ ```html
10
+ <script src="./node_modules/@tybys/wasm-util/dist/wasm-util.js"></script>
11
+ <script src="./node_modules/@emnapi/wasi-threads/dist/wasi-threads.js"></script>
12
+ <script src="./index.js"></script>
13
+ ```
14
+
15
+ If your application will block browser main thread (for example `pthread_join`), please run it in worker instead.
16
+
17
+ ```html
18
+ <script>
19
+ // pthread_join (Atomics.wait) cannot be called in browser main thread
20
+ new Worker('./index.js')
21
+ </script>
22
+ ```
23
+
24
+ `index.js`
25
+
26
+ ```js
27
+ const ENVIRONMENT_IS_NODE =
28
+ typeof process === 'object' && process !== null &&
29
+ typeof process.versions === 'object' && process.versions !== null &&
30
+ typeof process.versions.node === 'string';
31
+
32
+ (function (main) {
33
+ if (ENVIRONMENT_IS_NODE) {
34
+ main(require)
35
+ } else {
36
+ if (typeof importScripts === 'function') {
37
+ importScripts('./node_modules/@tybys/wasm-util/dist/wasm-util.js')
38
+ importScripts('./node_modules/@emnapi/wasi-threads/dist/wasi-threads.js')
39
+ }
40
+ const nodeWasi = { WASI: globalThis.wasmUtil.WASI }
41
+ const nodeWorkerThreads = {
42
+ Worker: globalThis.Worker
43
+ }
44
+ const _require = function (request) {
45
+ if (request === 'node:wasi' || request === 'wasi') return nodeWasi
46
+ if (request === 'node:worker_threads' || request === 'worker_threads') return nodeWorkerThreads
47
+ if (request === '@emnapi/wasi-threads') return globalThis.wasiThreads
48
+ throw new Error('Can not find module: ' + request)
49
+ }
50
+ main(_require)
51
+ }
52
+ })(async function (require) {
53
+ const { WASI } = require('wasi')
54
+ const { Worker } = require('worker_threads')
55
+ const { WASIThreads } = require('@emnapi/wasi-threads')
56
+
57
+ const wasi = new WASI({
58
+ version: 'preview1'
59
+ })
60
+ const wasiThreads = new WASIThreads({
61
+ wasi,
62
+
63
+ /**
64
+ * avoid Atomics.wait() deadlock during thread creation in browser
65
+ * see https://emscripten.org/docs/tools_reference/settings_reference.html#pthread-pool-size
66
+ */
67
+ reuseWorker: ENVIRONMENT_IS_NODE
68
+ ? false
69
+ : {
70
+ size: 4 /** greater than actual needs (2) */,
71
+ strict: true
72
+ },
73
+
74
+ /**
75
+ * Synchronous thread creation
76
+ * pthread_create will not return until thread worker actually starts
77
+ */
78
+ waitThreadStart: typeof window === 'undefined' ? 1000 : false,
79
+
80
+ onCreateWorker: () => {
81
+ return new Worker('./worker.js', {
82
+ execArgv: ['--experimental-wasi-unstable-preview1']
83
+ })
84
+ }
85
+ })
86
+ const memory = new WebAssembly.Memory({
87
+ initial: 16777216 / 65536,
88
+ maximum: 2147483648 / 65536,
89
+ shared: true
90
+ })
91
+ let input
92
+ const file = 'path/to/your/wasi-module.wasm'
93
+ try {
94
+ input = require('fs').readFileSync(require('path').join(__dirname, file))
95
+ } catch (err) {
96
+ const response = await fetch(file)
97
+ input = await response.arrayBuffer()
98
+ }
99
+ let { module, instance } = await WebAssembly.instantiate(input, {
100
+ env: { memory },
101
+ wasi_snapshot_preview1: wasi.wasiImport,
102
+ ...wasiThreads.getImportObject()
103
+ })
104
+
105
+ wasiThreads.setup(instance, module, memory)
106
+ await wasiThreads.preloadWorkers()
107
+
108
+ if (typeof instance.exports._start === 'function') {
109
+ return wasi.start(instance)
110
+ } else {
111
+ wasi.initialize(instance)
112
+ // instance.exports.exported_wasm_function()
113
+ }
114
+ })
115
+ ```
116
+
117
+ `worker.js`
118
+
119
+ ```js
120
+ (function (main) {
121
+ const ENVIRONMENT_IS_NODE =
122
+ typeof process === 'object' && process !== null &&
123
+ typeof process.versions === 'object' && process.versions !== null &&
124
+ typeof process.versions.node === 'string'
125
+
126
+ if (ENVIRONMENT_IS_NODE) {
127
+ const _require = function (request) {
128
+ return require(request)
129
+ }
130
+
131
+ const _init = function () {
132
+ const nodeWorkerThreads = require('worker_threads')
133
+ const parentPort = nodeWorkerThreads.parentPort
134
+
135
+ parentPort.on('message', (data) => {
136
+ globalThis.onmessage({ data })
137
+ })
138
+
139
+ Object.assign(globalThis, {
140
+ self: globalThis,
141
+ require,
142
+ Worker: nodeWorkerThreads.Worker,
143
+ importScripts: function (f) {
144
+ (0, eval)(require('fs').readFileSync(f, 'utf8') + '//# sourceURL=' + f)
145
+ },
146
+ postMessage: function (msg) {
147
+ parentPort.postMessage(msg)
148
+ }
149
+ })
150
+ }
151
+
152
+ main(_require, _init)
153
+ } else {
154
+ importScripts('./node_modules/@tybys/wasm-util/dist/wasm-util.js')
155
+ importScripts('./node_modules/@emnapi/wasi-threads/dist/wasi-threads.js')
156
+
157
+ const nodeWasi = { WASI: globalThis.wasmUtil.WASI }
158
+ const _require = function (request) {
159
+ if (request === '@emnapi/wasi-threads') return globalThis.wasiThreads
160
+ if (request === 'node:wasi' || request === 'wasi') return nodeWasi
161
+ throw new Error('Can not find module: ' + request)
162
+ }
163
+ const _init = function () {}
164
+ main(_require, _init)
165
+ }
166
+ })(function main (require, init) {
167
+ init()
168
+
169
+ const { WASI } = require('wasi')
170
+ const { ThreadMessageHandler, WASIThreads } = require('@emnapi/wasi-threads')
171
+
172
+ const handler = new ThreadMessageHandler({
173
+ async onLoad ({ wasmModule, wasmMemory }) {
174
+ const wasi = new WASI({
175
+ version: 'preview1'
176
+ })
177
+
178
+ const wasiThreads = new WASIThreads({
179
+ wasi,
180
+ childThread: true
181
+ })
182
+
183
+ const originalInstance = await WebAssembly.instantiate(wasmModule, {
184
+ env: {
185
+ memory: wasmMemory,
186
+ },
187
+ wasi_snapshot_preview1: wasi.wasiImport,
188
+ ...wasiThreads.getImportObject()
189
+ })
190
+
191
+ // must call `initialize` instead of `start` in child thread
192
+ const instance = wasiThreads.initialize(originalInstance, wasmModule, wasmMemory)
193
+
194
+ return { module: wasmModule, instance }
195
+ }
196
+ })
197
+
198
+ globalThis.onmessage = function (e) {
199
+ handler.handle(e)
200
+ // handle other messages
201
+ }
202
+ })
203
+ ```
node_modules/@emnapi/wasi-threads/index.js ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ if (typeof process !== 'undefined' && process.env.NODE_ENV === 'production') {
2
+ module.exports = require('./dist/wasi-threads.cjs.min.js')
3
+ } else {
4
+ module.exports = require('./dist/wasi-threads.cjs.js')
5
+ }
node_modules/@emnapi/wasi-threads/package.json ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@emnapi/wasi-threads",
3
+ "version": "1.2.1",
4
+ "description": "WASI threads proposal implementation in JavaScript",
5
+ "main": "index.js",
6
+ "module": "./dist/wasi-threads.esm-bundler.js",
7
+ "types": "./dist/wasi-threads.d.ts",
8
+ "sideEffects": false,
9
+ "exports": {
10
+ ".": {
11
+ "types": {
12
+ "module": "./dist/wasi-threads.d.ts",
13
+ "import": "./dist/wasi-threads.d.mts",
14
+ "default": "./dist/wasi-threads.d.ts"
15
+ },
16
+ "module": "./dist/wasi-threads.esm-bundler.js",
17
+ "import": "./dist/wasi-threads.mjs",
18
+ "default": "./index.js"
19
+ },
20
+ "./dist/wasi-threads.cjs.min": {
21
+ "types": "./dist/wasi-threads.d.ts",
22
+ "default": "./dist/wasi-threads.cjs.min.js"
23
+ },
24
+ "./dist/wasi-threads.min.mjs": {
25
+ "types": "./dist/wasi-threads.d.mts",
26
+ "default": "./dist/wasi-threads.min.mjs"
27
+ }
28
+ },
29
+ "dependencies": {
30
+ "tslib": "^2.4.0"
31
+ },
32
+ "scripts": {
33
+ "build": "node ./script/build.js",
34
+ "build:test": "node ./test/build.js",
35
+ "test": "node ./test/index.js"
36
+ },
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "git+https://github.com/toyobayashi/emnapi.git"
40
+ },
41
+ "author": "toyobayashi",
42
+ "license": "MIT",
43
+ "bugs": {
44
+ "url": "https://github.com/toyobayashi/emnapi/issues"
45
+ },
46
+ "homepage": "https://github.com/toyobayashi/emnapi#readme",
47
+ "publishConfig": {
48
+ "access": "public"
49
+ }
50
+ }
node_modules/@eslint-community/eslint-utils/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.
node_modules/@eslint-community/eslint-utils/README.md ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # @eslint-community/eslint-utils
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@eslint-community/eslint-utils.svg)](https://www.npmjs.com/package/@eslint-community/eslint-utils)
4
+ [![Downloads/month](https://img.shields.io/npm/dm/@eslint-community/eslint-utils.svg)](http://www.npmtrends.com/@eslint-community/eslint-utils)
5
+ [![Build Status](https://github.com/eslint-community/eslint-utils/workflows/CI/badge.svg)](https://github.com/eslint-community/eslint-utils/actions)
6
+ [![Coverage Status](https://codecov.io/gh/eslint-community/eslint-utils/branch/main/graph/badge.svg)](https://codecov.io/gh/eslint-community/eslint-utils)
7
+
8
+ ## 🏁 Goal
9
+
10
+ This package provides utility functions and classes for make ESLint custom rules.
11
+
12
+ For examples:
13
+
14
+ - [`getStaticValue`](https://eslint-community.github.io/eslint-utils/api/ast-utils.html#getstaticvalue) evaluates static value on AST.
15
+ - [`ReferenceTracker`](https://eslint-community.github.io/eslint-utils/api/scope-utils.html#referencetracker-class) checks the members of modules/globals as handling assignments and destructuring.
16
+
17
+ ## 📖 Usage
18
+
19
+ See [documentation](https://eslint-community.github.io/eslint-utils).
20
+
21
+ ## 📰 Changelog
22
+
23
+ See [releases](https://github.com/eslint-community/eslint-utils/releases).
24
+
25
+ ## ❤️ Contributing
26
+
27
+ Welcome contributing!
28
+
29
+ Please use GitHub's Issues/PRs.
30
+
31
+ ### Development Tools
32
+
33
+ - `npm run test-coverage` runs tests and measures coverage.
34
+ - `npm run clean` removes the coverage result of `npm run test-coverage` command.
35
+ - `npm run coverage` shows the coverage result of the last `npm run test-coverage` command.
36
+ - `npm run lint` runs ESLint.
37
+ - `npm run watch` runs tests on each file change.
node_modules/@eslint-community/eslint-utils/index.d.mts ADDED
@@ -0,0 +1,217 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as eslint from 'eslint';
2
+ import { Rule, AST } from 'eslint';
3
+ import * as estree from 'estree';
4
+
5
+ declare const READ: unique symbol;
6
+ declare const CALL: unique symbol;
7
+ declare const CONSTRUCT: unique symbol;
8
+ declare const ESM: unique symbol;
9
+ declare class ReferenceTracker {
10
+ constructor(globalScope: Scope$2, options?: {
11
+ mode?: "legacy" | "strict" | undefined;
12
+ globalObjectNames?: string[] | undefined;
13
+ } | undefined);
14
+ private variableStack;
15
+ private globalScope;
16
+ private mode;
17
+ private globalObjectNames;
18
+ iterateGlobalReferences<T>(traceMap: TraceMap$2<T>): IterableIterator<TrackedReferences$2<T>>;
19
+ iterateCjsReferences<T_1>(traceMap: TraceMap$2<T_1>): IterableIterator<TrackedReferences$2<T_1>>;
20
+ iterateEsmReferences<T_2>(traceMap: TraceMap$2<T_2>): IterableIterator<TrackedReferences$2<T_2>>;
21
+ iteratePropertyReferences<T_3>(node: Expression, traceMap: TraceMap$2<T_3>): IterableIterator<TrackedReferences$2<T_3>>;
22
+ private _iterateVariableReferences;
23
+ private _iteratePropertyReferences;
24
+ private _iterateLhsReferences;
25
+ private _iterateImportReferences;
26
+ }
27
+ declare namespace ReferenceTracker {
28
+ export { READ };
29
+ export { CALL };
30
+ export { CONSTRUCT };
31
+ export { ESM };
32
+ }
33
+ type Scope$2 = eslint.Scope.Scope;
34
+ type Expression = estree.Expression;
35
+ type TraceMap$2<T> = TraceMap$1<T>;
36
+ type TrackedReferences$2<T> = TrackedReferences$1<T>;
37
+
38
+ type StaticValue$2 = StaticValueProvided$1 | StaticValueOptional$1;
39
+ type StaticValueProvided$1 = {
40
+ optional?: undefined;
41
+ value: unknown;
42
+ };
43
+ type StaticValueOptional$1 = {
44
+ optional?: true;
45
+ value: undefined;
46
+ };
47
+ type ReferenceTrackerOptions$1 = {
48
+ globalObjectNames?: string[];
49
+ mode?: "legacy" | "strict";
50
+ };
51
+ type TraceMap$1<T = unknown> = {
52
+ [i: string]: TraceMapObject<T>;
53
+ };
54
+ type TraceMapObject<T> = {
55
+ [i: string]: TraceMapObject<T>;
56
+ [CALL]?: T;
57
+ [CONSTRUCT]?: T;
58
+ [READ]?: T;
59
+ [ESM]?: boolean;
60
+ };
61
+ type TrackedReferences$1<T> = {
62
+ info: T;
63
+ node: Rule.Node;
64
+ path: string[];
65
+ type: typeof CALL | typeof CONSTRUCT | typeof READ;
66
+ };
67
+ type HasSideEffectOptions$1 = {
68
+ considerGetters?: boolean;
69
+ considerImplicitTypeConversion?: boolean;
70
+ };
71
+ type PunctuatorToken<Value extends string> = AST.Token & {
72
+ type: "Punctuator";
73
+ value: Value;
74
+ };
75
+ type ArrowToken$1 = PunctuatorToken<"=>">;
76
+ type CommaToken$1 = PunctuatorToken<",">;
77
+ type SemicolonToken$1 = PunctuatorToken<";">;
78
+ type ColonToken$1 = PunctuatorToken<":">;
79
+ type OpeningParenToken$1 = PunctuatorToken<"(">;
80
+ type ClosingParenToken$1 = PunctuatorToken<")">;
81
+ type OpeningBracketToken$1 = PunctuatorToken<"[">;
82
+ type ClosingBracketToken$1 = PunctuatorToken<"]">;
83
+ type OpeningBraceToken$1 = PunctuatorToken<"{">;
84
+ type ClosingBraceToken$1 = PunctuatorToken<"}">;
85
+
86
+ declare function findVariable(initialScope: Scope$1, nameOrNode: string | Identifier): Variable | null;
87
+ type Scope$1 = eslint.Scope.Scope;
88
+ type Variable = eslint.Scope.Variable;
89
+ type Identifier = estree.Identifier;
90
+
91
+ declare function getFunctionHeadLocation(node: FunctionNode$1, sourceCode: SourceCode$2): SourceLocation | null;
92
+ type SourceCode$2 = eslint.SourceCode;
93
+ type FunctionNode$1 = estree.Function;
94
+ type SourceLocation = estree.SourceLocation;
95
+
96
+ declare function getFunctionNameWithKind(node: FunctionNode, sourceCode?: eslint.SourceCode | undefined): string;
97
+ type FunctionNode = estree.Function;
98
+
99
+ declare function getInnermostScope(initialScope: Scope, node: Node$4): Scope;
100
+ type Scope = eslint.Scope.Scope;
101
+ type Node$4 = estree.Node;
102
+
103
+ declare function getPropertyName(node: MemberExpression | MethodDefinition | Property | PropertyDefinition, initialScope?: eslint.Scope.Scope | undefined): string | null | undefined;
104
+ type MemberExpression = estree.MemberExpression;
105
+ type MethodDefinition = estree.MethodDefinition;
106
+ type Property = estree.Property;
107
+ type PropertyDefinition = estree.PropertyDefinition;
108
+
109
+ declare function getStaticValue(node: Node$3, initialScope?: eslint.Scope.Scope | null | undefined): StaticValue$1 | null;
110
+ type StaticValue$1 = StaticValue$2;
111
+ type Node$3 = estree.Node;
112
+
113
+ declare function getStringIfConstant(node: Node$2, initialScope?: eslint.Scope.Scope | null | undefined): string | null;
114
+ type Node$2 = estree.Node;
115
+
116
+ declare function hasSideEffect(node: Node$1, sourceCode: SourceCode$1, options?: HasSideEffectOptions$1 | undefined): boolean;
117
+ type Node$1 = estree.Node;
118
+ type SourceCode$1 = eslint.SourceCode;
119
+
120
+ declare function isArrowToken(token: CommentOrToken): token is ArrowToken$1;
121
+ declare function isCommaToken(token: CommentOrToken): token is CommaToken$1;
122
+ declare function isSemicolonToken(token: CommentOrToken): token is SemicolonToken$1;
123
+ declare function isColonToken(token: CommentOrToken): token is ColonToken$1;
124
+ declare function isOpeningParenToken(token: CommentOrToken): token is OpeningParenToken$1;
125
+ declare function isClosingParenToken(token: CommentOrToken): token is ClosingParenToken$1;
126
+ declare function isOpeningBracketToken(token: CommentOrToken): token is OpeningBracketToken$1;
127
+ declare function isClosingBracketToken(token: CommentOrToken): token is ClosingBracketToken$1;
128
+ declare function isOpeningBraceToken(token: CommentOrToken): token is OpeningBraceToken$1;
129
+ declare function isClosingBraceToken(token: CommentOrToken): token is ClosingBraceToken$1;
130
+ declare function isCommentToken(token: CommentOrToken): token is estree.Comment;
131
+ declare function isNotArrowToken(arg0: CommentOrToken): boolean;
132
+ declare function isNotCommaToken(arg0: CommentOrToken): boolean;
133
+ declare function isNotSemicolonToken(arg0: CommentOrToken): boolean;
134
+ declare function isNotColonToken(arg0: CommentOrToken): boolean;
135
+ declare function isNotOpeningParenToken(arg0: CommentOrToken): boolean;
136
+ declare function isNotClosingParenToken(arg0: CommentOrToken): boolean;
137
+ declare function isNotOpeningBracketToken(arg0: CommentOrToken): boolean;
138
+ declare function isNotClosingBracketToken(arg0: CommentOrToken): boolean;
139
+ declare function isNotOpeningBraceToken(arg0: CommentOrToken): boolean;
140
+ declare function isNotClosingBraceToken(arg0: CommentOrToken): boolean;
141
+ declare function isNotCommentToken(arg0: CommentOrToken): boolean;
142
+ type Token = eslint.AST.Token;
143
+ type Comment = estree.Comment;
144
+ type CommentOrToken = Comment | Token;
145
+
146
+ declare function isParenthesized(timesOrNode: Node | number, nodeOrSourceCode: Node | SourceCode, optionalSourceCode?: eslint.SourceCode | undefined): boolean;
147
+ type Node = estree.Node;
148
+ type SourceCode = eslint.SourceCode;
149
+
150
+ declare class PatternMatcher {
151
+ constructor(pattern: RegExp, options?: {
152
+ escaped?: boolean | undefined;
153
+ } | undefined);
154
+ execAll(str: string): IterableIterator<RegExpExecArray>;
155
+ test(str: string): boolean;
156
+ [Symbol.replace](str: string, replacer: string | ((...strs: string[]) => string)): string;
157
+ }
158
+
159
+ declare namespace _default {
160
+ export { CALL };
161
+ export { CONSTRUCT };
162
+ export { ESM };
163
+ export { findVariable };
164
+ export { getFunctionHeadLocation };
165
+ export { getFunctionNameWithKind };
166
+ export { getInnermostScope };
167
+ export { getPropertyName };
168
+ export { getStaticValue };
169
+ export { getStringIfConstant };
170
+ export { hasSideEffect };
171
+ export { isArrowToken };
172
+ export { isClosingBraceToken };
173
+ export { isClosingBracketToken };
174
+ export { isClosingParenToken };
175
+ export { isColonToken };
176
+ export { isCommaToken };
177
+ export { isCommentToken };
178
+ export { isNotArrowToken };
179
+ export { isNotClosingBraceToken };
180
+ export { isNotClosingBracketToken };
181
+ export { isNotClosingParenToken };
182
+ export { isNotColonToken };
183
+ export { isNotCommaToken };
184
+ export { isNotCommentToken };
185
+ export { isNotOpeningBraceToken };
186
+ export { isNotOpeningBracketToken };
187
+ export { isNotOpeningParenToken };
188
+ export { isNotSemicolonToken };
189
+ export { isOpeningBraceToken };
190
+ export { isOpeningBracketToken };
191
+ export { isOpeningParenToken };
192
+ export { isParenthesized };
193
+ export { isSemicolonToken };
194
+ export { PatternMatcher };
195
+ export { READ };
196
+ export { ReferenceTracker };
197
+ }
198
+
199
+ type StaticValue = StaticValue$2;
200
+ type StaticValueOptional = StaticValueOptional$1;
201
+ type StaticValueProvided = StaticValueProvided$1;
202
+ type ReferenceTrackerOptions = ReferenceTrackerOptions$1;
203
+ type TraceMap<T> = TraceMap$1<T>;
204
+ type TrackedReferences<T> = TrackedReferences$1<T>;
205
+ type HasSideEffectOptions = HasSideEffectOptions$1;
206
+ type ArrowToken = ArrowToken$1;
207
+ type CommaToken = CommaToken$1;
208
+ type SemicolonToken = SemicolonToken$1;
209
+ type ColonToken = ColonToken$1;
210
+ type OpeningParenToken = OpeningParenToken$1;
211
+ type ClosingParenToken = ClosingParenToken$1;
212
+ type OpeningBracketToken = OpeningBracketToken$1;
213
+ type ClosingBracketToken = ClosingBracketToken$1;
214
+ type OpeningBraceToken = OpeningBraceToken$1;
215
+ type ClosingBraceToken = ClosingBraceToken$1;
216
+
217
+ export { ArrowToken, CALL, CONSTRUCT, ClosingBraceToken, ClosingBracketToken, ClosingParenToken, ColonToken, CommaToken, ESM, HasSideEffectOptions, OpeningBraceToken, OpeningBracketToken, OpeningParenToken, PatternMatcher, READ, ReferenceTracker, ReferenceTrackerOptions, SemicolonToken, StaticValue, StaticValueOptional, StaticValueProvided, TraceMap, TrackedReferences, _default as default, findVariable, getFunctionHeadLocation, getFunctionNameWithKind, getInnermostScope, getPropertyName, getStaticValue, getStringIfConstant, hasSideEffect, isArrowToken, isClosingBraceToken, isClosingBracketToken, isClosingParenToken, isColonToken, isCommaToken, isCommentToken, isNotArrowToken, isNotClosingBraceToken, isNotClosingBracketToken, isNotClosingParenToken, isNotColonToken, isNotCommaToken, isNotCommentToken, isNotOpeningBraceToken, isNotOpeningBracketToken, isNotOpeningParenToken, isNotSemicolonToken, isOpeningBraceToken, isOpeningBracketToken, isOpeningParenToken, isParenthesized, isSemicolonToken };
node_modules/@eslint-community/eslint-utils/index.d.ts ADDED
@@ -0,0 +1,217 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as eslint from 'eslint';
2
+ import { Rule, AST } from 'eslint';
3
+ import * as estree from 'estree';
4
+
5
+ declare const READ: unique symbol;
6
+ declare const CALL: unique symbol;
7
+ declare const CONSTRUCT: unique symbol;
8
+ declare const ESM: unique symbol;
9
+ declare class ReferenceTracker {
10
+ constructor(globalScope: Scope$2, options?: {
11
+ mode?: "legacy" | "strict" | undefined;
12
+ globalObjectNames?: string[] | undefined;
13
+ } | undefined);
14
+ private variableStack;
15
+ private globalScope;
16
+ private mode;
17
+ private globalObjectNames;
18
+ iterateGlobalReferences<T>(traceMap: TraceMap$2<T>): IterableIterator<TrackedReferences$2<T>>;
19
+ iterateCjsReferences<T_1>(traceMap: TraceMap$2<T_1>): IterableIterator<TrackedReferences$2<T_1>>;
20
+ iterateEsmReferences<T_2>(traceMap: TraceMap$2<T_2>): IterableIterator<TrackedReferences$2<T_2>>;
21
+ iteratePropertyReferences<T_3>(node: Expression, traceMap: TraceMap$2<T_3>): IterableIterator<TrackedReferences$2<T_3>>;
22
+ private _iterateVariableReferences;
23
+ private _iteratePropertyReferences;
24
+ private _iterateLhsReferences;
25
+ private _iterateImportReferences;
26
+ }
27
+ declare namespace ReferenceTracker {
28
+ export { READ };
29
+ export { CALL };
30
+ export { CONSTRUCT };
31
+ export { ESM };
32
+ }
33
+ type Scope$2 = eslint.Scope.Scope;
34
+ type Expression = estree.Expression;
35
+ type TraceMap$2<T> = TraceMap$1<T>;
36
+ type TrackedReferences$2<T> = TrackedReferences$1<T>;
37
+
38
+ type StaticValue$2 = StaticValueProvided$1 | StaticValueOptional$1;
39
+ type StaticValueProvided$1 = {
40
+ optional?: undefined;
41
+ value: unknown;
42
+ };
43
+ type StaticValueOptional$1 = {
44
+ optional?: true;
45
+ value: undefined;
46
+ };
47
+ type ReferenceTrackerOptions$1 = {
48
+ globalObjectNames?: string[];
49
+ mode?: "legacy" | "strict";
50
+ };
51
+ type TraceMap$1<T = unknown> = {
52
+ [i: string]: TraceMapObject<T>;
53
+ };
54
+ type TraceMapObject<T> = {
55
+ [i: string]: TraceMapObject<T>;
56
+ [CALL]?: T;
57
+ [CONSTRUCT]?: T;
58
+ [READ]?: T;
59
+ [ESM]?: boolean;
60
+ };
61
+ type TrackedReferences$1<T> = {
62
+ info: T;
63
+ node: Rule.Node;
64
+ path: string[];
65
+ type: typeof CALL | typeof CONSTRUCT | typeof READ;
66
+ };
67
+ type HasSideEffectOptions$1 = {
68
+ considerGetters?: boolean;
69
+ considerImplicitTypeConversion?: boolean;
70
+ };
71
+ type PunctuatorToken<Value extends string> = AST.Token & {
72
+ type: "Punctuator";
73
+ value: Value;
74
+ };
75
+ type ArrowToken$1 = PunctuatorToken<"=>">;
76
+ type CommaToken$1 = PunctuatorToken<",">;
77
+ type SemicolonToken$1 = PunctuatorToken<";">;
78
+ type ColonToken$1 = PunctuatorToken<":">;
79
+ type OpeningParenToken$1 = PunctuatorToken<"(">;
80
+ type ClosingParenToken$1 = PunctuatorToken<")">;
81
+ type OpeningBracketToken$1 = PunctuatorToken<"[">;
82
+ type ClosingBracketToken$1 = PunctuatorToken<"]">;
83
+ type OpeningBraceToken$1 = PunctuatorToken<"{">;
84
+ type ClosingBraceToken$1 = PunctuatorToken<"}">;
85
+
86
+ declare function findVariable(initialScope: Scope$1, nameOrNode: string | Identifier): Variable | null;
87
+ type Scope$1 = eslint.Scope.Scope;
88
+ type Variable = eslint.Scope.Variable;
89
+ type Identifier = estree.Identifier;
90
+
91
+ declare function getFunctionHeadLocation(node: FunctionNode$1, sourceCode: SourceCode$2): SourceLocation | null;
92
+ type SourceCode$2 = eslint.SourceCode;
93
+ type FunctionNode$1 = estree.Function;
94
+ type SourceLocation = estree.SourceLocation;
95
+
96
+ declare function getFunctionNameWithKind(node: FunctionNode, sourceCode?: eslint.SourceCode | undefined): string;
97
+ type FunctionNode = estree.Function;
98
+
99
+ declare function getInnermostScope(initialScope: Scope, node: Node$4): Scope;
100
+ type Scope = eslint.Scope.Scope;
101
+ type Node$4 = estree.Node;
102
+
103
+ declare function getPropertyName(node: MemberExpression | MethodDefinition | Property | PropertyDefinition, initialScope?: eslint.Scope.Scope | undefined): string | null | undefined;
104
+ type MemberExpression = estree.MemberExpression;
105
+ type MethodDefinition = estree.MethodDefinition;
106
+ type Property = estree.Property;
107
+ type PropertyDefinition = estree.PropertyDefinition;
108
+
109
+ declare function getStaticValue(node: Node$3, initialScope?: eslint.Scope.Scope | null | undefined): StaticValue$1 | null;
110
+ type StaticValue$1 = StaticValue$2;
111
+ type Node$3 = estree.Node;
112
+
113
+ declare function getStringIfConstant(node: Node$2, initialScope?: eslint.Scope.Scope | null | undefined): string | null;
114
+ type Node$2 = estree.Node;
115
+
116
+ declare function hasSideEffect(node: Node$1, sourceCode: SourceCode$1, options?: HasSideEffectOptions$1 | undefined): boolean;
117
+ type Node$1 = estree.Node;
118
+ type SourceCode$1 = eslint.SourceCode;
119
+
120
+ declare function isArrowToken(token: CommentOrToken): token is ArrowToken$1;
121
+ declare function isCommaToken(token: CommentOrToken): token is CommaToken$1;
122
+ declare function isSemicolonToken(token: CommentOrToken): token is SemicolonToken$1;
123
+ declare function isColonToken(token: CommentOrToken): token is ColonToken$1;
124
+ declare function isOpeningParenToken(token: CommentOrToken): token is OpeningParenToken$1;
125
+ declare function isClosingParenToken(token: CommentOrToken): token is ClosingParenToken$1;
126
+ declare function isOpeningBracketToken(token: CommentOrToken): token is OpeningBracketToken$1;
127
+ declare function isClosingBracketToken(token: CommentOrToken): token is ClosingBracketToken$1;
128
+ declare function isOpeningBraceToken(token: CommentOrToken): token is OpeningBraceToken$1;
129
+ declare function isClosingBraceToken(token: CommentOrToken): token is ClosingBraceToken$1;
130
+ declare function isCommentToken(token: CommentOrToken): token is estree.Comment;
131
+ declare function isNotArrowToken(arg0: CommentOrToken): boolean;
132
+ declare function isNotCommaToken(arg0: CommentOrToken): boolean;
133
+ declare function isNotSemicolonToken(arg0: CommentOrToken): boolean;
134
+ declare function isNotColonToken(arg0: CommentOrToken): boolean;
135
+ declare function isNotOpeningParenToken(arg0: CommentOrToken): boolean;
136
+ declare function isNotClosingParenToken(arg0: CommentOrToken): boolean;
137
+ declare function isNotOpeningBracketToken(arg0: CommentOrToken): boolean;
138
+ declare function isNotClosingBracketToken(arg0: CommentOrToken): boolean;
139
+ declare function isNotOpeningBraceToken(arg0: CommentOrToken): boolean;
140
+ declare function isNotClosingBraceToken(arg0: CommentOrToken): boolean;
141
+ declare function isNotCommentToken(arg0: CommentOrToken): boolean;
142
+ type Token = eslint.AST.Token;
143
+ type Comment = estree.Comment;
144
+ type CommentOrToken = Comment | Token;
145
+
146
+ declare function isParenthesized(timesOrNode: Node | number, nodeOrSourceCode: Node | SourceCode, optionalSourceCode?: eslint.SourceCode | undefined): boolean;
147
+ type Node = estree.Node;
148
+ type SourceCode = eslint.SourceCode;
149
+
150
+ declare class PatternMatcher {
151
+ constructor(pattern: RegExp, options?: {
152
+ escaped?: boolean | undefined;
153
+ } | undefined);
154
+ execAll(str: string): IterableIterator<RegExpExecArray>;
155
+ test(str: string): boolean;
156
+ [Symbol.replace](str: string, replacer: string | ((...strs: string[]) => string)): string;
157
+ }
158
+
159
+ declare namespace _default {
160
+ export { CALL };
161
+ export { CONSTRUCT };
162
+ export { ESM };
163
+ export { findVariable };
164
+ export { getFunctionHeadLocation };
165
+ export { getFunctionNameWithKind };
166
+ export { getInnermostScope };
167
+ export { getPropertyName };
168
+ export { getStaticValue };
169
+ export { getStringIfConstant };
170
+ export { hasSideEffect };
171
+ export { isArrowToken };
172
+ export { isClosingBraceToken };
173
+ export { isClosingBracketToken };
174
+ export { isClosingParenToken };
175
+ export { isColonToken };
176
+ export { isCommaToken };
177
+ export { isCommentToken };
178
+ export { isNotArrowToken };
179
+ export { isNotClosingBraceToken };
180
+ export { isNotClosingBracketToken };
181
+ export { isNotClosingParenToken };
182
+ export { isNotColonToken };
183
+ export { isNotCommaToken };
184
+ export { isNotCommentToken };
185
+ export { isNotOpeningBraceToken };
186
+ export { isNotOpeningBracketToken };
187
+ export { isNotOpeningParenToken };
188
+ export { isNotSemicolonToken };
189
+ export { isOpeningBraceToken };
190
+ export { isOpeningBracketToken };
191
+ export { isOpeningParenToken };
192
+ export { isParenthesized };
193
+ export { isSemicolonToken };
194
+ export { PatternMatcher };
195
+ export { READ };
196
+ export { ReferenceTracker };
197
+ }
198
+
199
+ type StaticValue = StaticValue$2;
200
+ type StaticValueOptional = StaticValueOptional$1;
201
+ type StaticValueProvided = StaticValueProvided$1;
202
+ type ReferenceTrackerOptions = ReferenceTrackerOptions$1;
203
+ type TraceMap<T> = TraceMap$1<T>;
204
+ type TrackedReferences<T> = TrackedReferences$1<T>;
205
+ type HasSideEffectOptions = HasSideEffectOptions$1;
206
+ type ArrowToken = ArrowToken$1;
207
+ type CommaToken = CommaToken$1;
208
+ type SemicolonToken = SemicolonToken$1;
209
+ type ColonToken = ColonToken$1;
210
+ type OpeningParenToken = OpeningParenToken$1;
211
+ type ClosingParenToken = ClosingParenToken$1;
212
+ type OpeningBracketToken = OpeningBracketToken$1;
213
+ type ClosingBracketToken = ClosingBracketToken$1;
214
+ type OpeningBraceToken = OpeningBraceToken$1;
215
+ type ClosingBraceToken = ClosingBraceToken$1;
216
+
217
+ export { ArrowToken, CALL, CONSTRUCT, ClosingBraceToken, ClosingBracketToken, ClosingParenToken, ColonToken, CommaToken, ESM, HasSideEffectOptions, OpeningBraceToken, OpeningBracketToken, OpeningParenToken, PatternMatcher, READ, ReferenceTracker, ReferenceTrackerOptions, SemicolonToken, StaticValue, StaticValueOptional, StaticValueProvided, TraceMap, TrackedReferences, _default as default, findVariable, getFunctionHeadLocation, getFunctionNameWithKind, getInnermostScope, getPropertyName, getStaticValue, getStringIfConstant, hasSideEffect, isArrowToken, isClosingBraceToken, isClosingBracketToken, isClosingParenToken, isColonToken, isCommaToken, isCommentToken, isNotArrowToken, isNotClosingBraceToken, isNotClosingBracketToken, isNotClosingParenToken, isNotColonToken, isNotCommaToken, isNotCommentToken, isNotOpeningBraceToken, isNotOpeningBracketToken, isNotOpeningParenToken, isNotSemicolonToken, isOpeningBraceToken, isOpeningBracketToken, isOpeningParenToken, isParenthesized, isSemicolonToken };
node_modules/@eslint-community/eslint-utils/index.js ADDED
@@ -0,0 +1,2620 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var eslintVisitorKeys = require('eslint-visitor-keys');
6
+
7
+ /** @typedef {import("eslint").Scope.Scope} Scope */
8
+ /** @typedef {import("estree").Node} Node */
9
+
10
+ /**
11
+ * Get the innermost scope which contains a given location.
12
+ * @param {Scope} initialScope The initial scope to search.
13
+ * @param {Node} node The location to search.
14
+ * @returns {Scope} The innermost scope.
15
+ */
16
+ function getInnermostScope(initialScope, node) {
17
+ const location = /** @type {[number, number]} */ (node.range)[0];
18
+
19
+ let scope = initialScope;
20
+ let found = false;
21
+ do {
22
+ found = false;
23
+ for (const childScope of scope.childScopes) {
24
+ const range = /** @type {[number, number]} */ (
25
+ childScope.block.range
26
+ );
27
+
28
+ if (range[0] <= location && location < range[1]) {
29
+ scope = childScope;
30
+ found = true;
31
+ break
32
+ }
33
+ }
34
+ } while (found)
35
+
36
+ return scope
37
+ }
38
+
39
+ /** @typedef {import("eslint").Scope.Scope} Scope */
40
+ /** @typedef {import("eslint").Scope.Variable} Variable */
41
+ /** @typedef {import("estree").Identifier} Identifier */
42
+
43
+ /**
44
+ * Find the variable of a given name.
45
+ * @param {Scope} initialScope The scope to start finding.
46
+ * @param {string|Identifier} nameOrNode The variable name to find. If this is a Node object then it should be an Identifier node.
47
+ * @returns {Variable|null} The found variable or null.
48
+ */
49
+ function findVariable(initialScope, nameOrNode) {
50
+ let name = "";
51
+ /** @type {Scope|null} */
52
+ let scope = initialScope;
53
+
54
+ if (typeof nameOrNode === "string") {
55
+ name = nameOrNode;
56
+ } else {
57
+ name = nameOrNode.name;
58
+ scope = getInnermostScope(scope, nameOrNode);
59
+ }
60
+
61
+ while (scope != null) {
62
+ const variable = scope.set.get(name);
63
+ if (variable != null) {
64
+ return variable
65
+ }
66
+ scope = scope.upper;
67
+ }
68
+
69
+ return null
70
+ }
71
+
72
+ /** @typedef {import("eslint").AST.Token} Token */
73
+ /** @typedef {import("estree").Comment} Comment */
74
+ /** @typedef {import("./types.mjs").ArrowToken} ArrowToken */
75
+ /** @typedef {import("./types.mjs").CommaToken} CommaToken */
76
+ /** @typedef {import("./types.mjs").SemicolonToken} SemicolonToken */
77
+ /** @typedef {import("./types.mjs").ColonToken} ColonToken */
78
+ /** @typedef {import("./types.mjs").OpeningParenToken} OpeningParenToken */
79
+ /** @typedef {import("./types.mjs").ClosingParenToken} ClosingParenToken */
80
+ /** @typedef {import("./types.mjs").OpeningBracketToken} OpeningBracketToken */
81
+ /** @typedef {import("./types.mjs").ClosingBracketToken} ClosingBracketToken */
82
+ /** @typedef {import("./types.mjs").OpeningBraceToken} OpeningBraceToken */
83
+ /** @typedef {import("./types.mjs").ClosingBraceToken} ClosingBraceToken */
84
+ /**
85
+ * @template {string} Value
86
+ * @typedef {import("./types.mjs").PunctuatorToken<Value>} PunctuatorToken
87
+ */
88
+
89
+ /** @typedef {Comment | Token} CommentOrToken */
90
+
91
+ /**
92
+ * Creates the negate function of the given function.
93
+ * @param {function(CommentOrToken):boolean} f - The function to negate.
94
+ * @returns {function(CommentOrToken):boolean} Negated function.
95
+ */
96
+ function negate(f) {
97
+ return (token) => !f(token)
98
+ }
99
+
100
+ /**
101
+ * Checks if the given token is a PunctuatorToken with the given value
102
+ * @template {string} Value
103
+ * @param {CommentOrToken} token - The token to check.
104
+ * @param {Value} value - The value to check.
105
+ * @returns {token is PunctuatorToken<Value>} `true` if the token is a PunctuatorToken with the given value.
106
+ */
107
+ function isPunctuatorTokenWithValue(token, value) {
108
+ return token.type === "Punctuator" && token.value === value
109
+ }
110
+
111
+ /**
112
+ * Checks if the given token is an arrow token or not.
113
+ * @param {CommentOrToken} token - The token to check.
114
+ * @returns {token is ArrowToken} `true` if the token is an arrow token.
115
+ */
116
+ function isArrowToken(token) {
117
+ return isPunctuatorTokenWithValue(token, "=>")
118
+ }
119
+
120
+ /**
121
+ * Checks if the given token is a comma token or not.
122
+ * @param {CommentOrToken} token - The token to check.
123
+ * @returns {token is CommaToken} `true` if the token is a comma token.
124
+ */
125
+ function isCommaToken(token) {
126
+ return isPunctuatorTokenWithValue(token, ",")
127
+ }
128
+
129
+ /**
130
+ * Checks if the given token is a semicolon token or not.
131
+ * @param {CommentOrToken} token - The token to check.
132
+ * @returns {token is SemicolonToken} `true` if the token is a semicolon token.
133
+ */
134
+ function isSemicolonToken(token) {
135
+ return isPunctuatorTokenWithValue(token, ";")
136
+ }
137
+
138
+ /**
139
+ * Checks if the given token is a colon token or not.
140
+ * @param {CommentOrToken} token - The token to check.
141
+ * @returns {token is ColonToken} `true` if the token is a colon token.
142
+ */
143
+ function isColonToken(token) {
144
+ return isPunctuatorTokenWithValue(token, ":")
145
+ }
146
+
147
+ /**
148
+ * Checks if the given token is an opening parenthesis token or not.
149
+ * @param {CommentOrToken} token - The token to check.
150
+ * @returns {token is OpeningParenToken} `true` if the token is an opening parenthesis token.
151
+ */
152
+ function isOpeningParenToken(token) {
153
+ return isPunctuatorTokenWithValue(token, "(")
154
+ }
155
+
156
+ /**
157
+ * Checks if the given token is a closing parenthesis token or not.
158
+ * @param {CommentOrToken} token - The token to check.
159
+ * @returns {token is ClosingParenToken} `true` if the token is a closing parenthesis token.
160
+ */
161
+ function isClosingParenToken(token) {
162
+ return isPunctuatorTokenWithValue(token, ")")
163
+ }
164
+
165
+ /**
166
+ * Checks if the given token is an opening square bracket token or not.
167
+ * @param {CommentOrToken} token - The token to check.
168
+ * @returns {token is OpeningBracketToken} `true` if the token is an opening square bracket token.
169
+ */
170
+ function isOpeningBracketToken(token) {
171
+ return isPunctuatorTokenWithValue(token, "[")
172
+ }
173
+
174
+ /**
175
+ * Checks if the given token is a closing square bracket token or not.
176
+ * @param {CommentOrToken} token - The token to check.
177
+ * @returns {token is ClosingBracketToken} `true` if the token is a closing square bracket token.
178
+ */
179
+ function isClosingBracketToken(token) {
180
+ return isPunctuatorTokenWithValue(token, "]")
181
+ }
182
+
183
+ /**
184
+ * Checks if the given token is an opening brace token or not.
185
+ * @param {CommentOrToken} token - The token to check.
186
+ * @returns {token is OpeningBraceToken} `true` if the token is an opening brace token.
187
+ */
188
+ function isOpeningBraceToken(token) {
189
+ return isPunctuatorTokenWithValue(token, "{")
190
+ }
191
+
192
+ /**
193
+ * Checks if the given token is a closing brace token or not.
194
+ * @param {CommentOrToken} token - The token to check.
195
+ * @returns {token is ClosingBraceToken} `true` if the token is a closing brace token.
196
+ */
197
+ function isClosingBraceToken(token) {
198
+ return isPunctuatorTokenWithValue(token, "}")
199
+ }
200
+
201
+ /**
202
+ * Checks if the given token is a comment token or not.
203
+ * @param {CommentOrToken} token - The token to check.
204
+ * @returns {token is Comment} `true` if the token is a comment token.
205
+ */
206
+ function isCommentToken(token) {
207
+ return ["Block", "Line", "Shebang"].includes(token.type)
208
+ }
209
+
210
+ const isNotArrowToken = negate(isArrowToken);
211
+ const isNotCommaToken = negate(isCommaToken);
212
+ const isNotSemicolonToken = negate(isSemicolonToken);
213
+ const isNotColonToken = negate(isColonToken);
214
+ const isNotOpeningParenToken = negate(isOpeningParenToken);
215
+ const isNotClosingParenToken = negate(isClosingParenToken);
216
+ const isNotOpeningBracketToken = negate(isOpeningBracketToken);
217
+ const isNotClosingBracketToken = negate(isClosingBracketToken);
218
+ const isNotOpeningBraceToken = negate(isOpeningBraceToken);
219
+ const isNotClosingBraceToken = negate(isClosingBraceToken);
220
+ const isNotCommentToken = negate(isCommentToken);
221
+
222
+ /** @typedef {import("eslint").Rule.Node} RuleNode */
223
+ /** @typedef {import("eslint").SourceCode} SourceCode */
224
+ /** @typedef {import("eslint").AST.Token} Token */
225
+ /** @typedef {import("estree").Function} FunctionNode */
226
+ /** @typedef {import("estree").FunctionDeclaration} FunctionDeclaration */
227
+ /** @typedef {import("estree").FunctionExpression} FunctionExpression */
228
+ /** @typedef {import("estree").SourceLocation} SourceLocation */
229
+ /** @typedef {import("estree").Position} Position */
230
+
231
+ /**
232
+ * Get the `(` token of the given function node.
233
+ * @param {FunctionExpression | FunctionDeclaration} node - The function node to get.
234
+ * @param {SourceCode} sourceCode - The source code object to get tokens.
235
+ * @returns {Token} `(` token.
236
+ */
237
+ function getOpeningParenOfParams(node, sourceCode) {
238
+ return node.id
239
+ ? /** @type {Token} */ (
240
+ sourceCode.getTokenAfter(node.id, isOpeningParenToken)
241
+ )
242
+ : /** @type {Token} */ (
243
+ sourceCode.getFirstToken(node, isOpeningParenToken)
244
+ )
245
+ }
246
+
247
+ /**
248
+ * Get the location of the given function node for reporting.
249
+ * @param {FunctionNode} node - The function node to get.
250
+ * @param {SourceCode} sourceCode - The source code object to get tokens.
251
+ * @returns {SourceLocation|null} The location of the function node for reporting.
252
+ */
253
+ function getFunctionHeadLocation(node, sourceCode) {
254
+ const parent = /** @type {RuleNode} */ (node).parent;
255
+
256
+ /** @type {Position|null} */
257
+ let start = null;
258
+ /** @type {Position|null} */
259
+ let end = null;
260
+
261
+ if (node.type === "ArrowFunctionExpression") {
262
+ const arrowToken = /** @type {Token} */ (
263
+ sourceCode.getTokenBefore(node.body, isArrowToken)
264
+ );
265
+
266
+ start = arrowToken.loc.start;
267
+ end = arrowToken.loc.end;
268
+ } else if (
269
+ parent &&
270
+ (parent.type === "Property" ||
271
+ parent.type === "MethodDefinition" ||
272
+ parent.type === "PropertyDefinition")
273
+ ) {
274
+ start = /** @type {SourceLocation} */ (parent.loc).start;
275
+ end = getOpeningParenOfParams(node, sourceCode).loc.start;
276
+ } else {
277
+ start = /** @type {SourceLocation} */ (node.loc).start;
278
+ end = getOpeningParenOfParams(node, sourceCode).loc.start;
279
+ }
280
+
281
+ return {
282
+ start: { ...start },
283
+ end: { ...end },
284
+ }
285
+ }
286
+
287
+ /* globals globalThis, global, self, window */
288
+ /** @typedef {import("./types.mjs").StaticValue} StaticValue */
289
+ /** @typedef {import("eslint").Scope.Scope} Scope */
290
+ /** @typedef {import("eslint").Scope.Variable} Variable */
291
+ /** @typedef {import("estree").Node} Node */
292
+ /** @typedef {import("@typescript-eslint/types").TSESTree.Node} TSESTreeNode */
293
+ /** @typedef {import("@typescript-eslint/types").TSESTree.AST_NODE_TYPES} TSESTreeNodeTypes */
294
+ /** @typedef {import("@typescript-eslint/types").TSESTree.MemberExpression} MemberExpression */
295
+ /** @typedef {import("@typescript-eslint/types").TSESTree.Property} Property */
296
+ /** @typedef {import("@typescript-eslint/types").TSESTree.RegExpLiteral} RegExpLiteral */
297
+ /** @typedef {import("@typescript-eslint/types").TSESTree.BigIntLiteral} BigIntLiteral */
298
+ /** @typedef {import("@typescript-eslint/types").TSESTree.Literal} Literal */
299
+
300
+ const globalObject =
301
+ typeof globalThis !== "undefined"
302
+ ? globalThis
303
+ : // @ts-ignore
304
+ typeof self !== "undefined"
305
+ ? // @ts-ignore
306
+ self
307
+ : // @ts-ignore
308
+ typeof window !== "undefined"
309
+ ? // @ts-ignore
310
+ window
311
+ : typeof global !== "undefined"
312
+ ? global
313
+ : {};
314
+
315
+ const builtinNames = Object.freeze(
316
+ new Set([
317
+ "Array",
318
+ "ArrayBuffer",
319
+ "BigInt",
320
+ "BigInt64Array",
321
+ "BigUint64Array",
322
+ "Boolean",
323
+ "DataView",
324
+ "Date",
325
+ "decodeURI",
326
+ "decodeURIComponent",
327
+ "encodeURI",
328
+ "encodeURIComponent",
329
+ "escape",
330
+ "Float32Array",
331
+ "Float64Array",
332
+ "Function",
333
+ "Infinity",
334
+ "Int16Array",
335
+ "Int32Array",
336
+ "Int8Array",
337
+ "isFinite",
338
+ "isNaN",
339
+ "isPrototypeOf",
340
+ "JSON",
341
+ "Map",
342
+ "Math",
343
+ "NaN",
344
+ "Number",
345
+ "Object",
346
+ "parseFloat",
347
+ "parseInt",
348
+ "Promise",
349
+ "Proxy",
350
+ "Reflect",
351
+ "RegExp",
352
+ "Set",
353
+ "String",
354
+ "Symbol",
355
+ "Uint16Array",
356
+ "Uint32Array",
357
+ "Uint8Array",
358
+ "Uint8ClampedArray",
359
+ "undefined",
360
+ "unescape",
361
+ "WeakMap",
362
+ "WeakSet",
363
+ ]),
364
+ );
365
+ const callAllowed = new Set(
366
+ [
367
+ Array.isArray,
368
+ Array.of,
369
+ Array.prototype.at,
370
+ Array.prototype.concat,
371
+ Array.prototype.entries,
372
+ Array.prototype.every,
373
+ Array.prototype.filter,
374
+ Array.prototype.find,
375
+ Array.prototype.findIndex,
376
+ Array.prototype.flat,
377
+ Array.prototype.includes,
378
+ Array.prototype.indexOf,
379
+ Array.prototype.join,
380
+ Array.prototype.keys,
381
+ Array.prototype.lastIndexOf,
382
+ Array.prototype.slice,
383
+ Array.prototype.some,
384
+ Array.prototype.toString,
385
+ Array.prototype.values,
386
+ typeof BigInt === "function" ? BigInt : undefined,
387
+ Boolean,
388
+ Date,
389
+ Date.parse,
390
+ decodeURI,
391
+ decodeURIComponent,
392
+ encodeURI,
393
+ encodeURIComponent,
394
+ escape,
395
+ isFinite,
396
+ isNaN,
397
+ // @ts-ignore
398
+ isPrototypeOf,
399
+ Map,
400
+ Map.prototype.entries,
401
+ Map.prototype.get,
402
+ Map.prototype.has,
403
+ Map.prototype.keys,
404
+ Map.prototype.values,
405
+ .../** @type {(keyof typeof Math)[]} */ (
406
+ Object.getOwnPropertyNames(Math)
407
+ )
408
+ .filter((k) => k !== "random")
409
+ .map((k) => Math[k])
410
+ .filter((f) => typeof f === "function"),
411
+ Number,
412
+ Number.isFinite,
413
+ Number.isNaN,
414
+ Number.parseFloat,
415
+ Number.parseInt,
416
+ Number.prototype.toExponential,
417
+ Number.prototype.toFixed,
418
+ Number.prototype.toPrecision,
419
+ Number.prototype.toString,
420
+ Object,
421
+ Object.entries,
422
+ Object.is,
423
+ Object.isExtensible,
424
+ Object.isFrozen,
425
+ Object.isSealed,
426
+ Object.keys,
427
+ Object.values,
428
+ parseFloat,
429
+ parseInt,
430
+ RegExp,
431
+ Set,
432
+ Set.prototype.entries,
433
+ Set.prototype.has,
434
+ Set.prototype.keys,
435
+ Set.prototype.values,
436
+ String,
437
+ String.fromCharCode,
438
+ String.fromCodePoint,
439
+ String.raw,
440
+ String.prototype.at,
441
+ String.prototype.charAt,
442
+ String.prototype.charCodeAt,
443
+ String.prototype.codePointAt,
444
+ String.prototype.concat,
445
+ String.prototype.endsWith,
446
+ String.prototype.includes,
447
+ String.prototype.indexOf,
448
+ String.prototype.lastIndexOf,
449
+ String.prototype.normalize,
450
+ String.prototype.padEnd,
451
+ String.prototype.padStart,
452
+ String.prototype.slice,
453
+ String.prototype.startsWith,
454
+ String.prototype.substr,
455
+ String.prototype.substring,
456
+ String.prototype.toLowerCase,
457
+ String.prototype.toString,
458
+ String.prototype.toUpperCase,
459
+ String.prototype.trim,
460
+ String.prototype.trimEnd,
461
+ String.prototype.trimLeft,
462
+ String.prototype.trimRight,
463
+ String.prototype.trimStart,
464
+ Symbol.for,
465
+ Symbol.keyFor,
466
+ unescape,
467
+ ].filter((f) => typeof f === "function"),
468
+ );
469
+ const callPassThrough = new Set([
470
+ Object.freeze,
471
+ Object.preventExtensions,
472
+ Object.seal,
473
+ ]);
474
+
475
+ /** @type {ReadonlyArray<readonly [Function, ReadonlySet<string>]>} */
476
+ const getterAllowed = [
477
+ [Map, new Set(["size"])],
478
+ [
479
+ RegExp,
480
+ new Set([
481
+ "dotAll",
482
+ "flags",
483
+ "global",
484
+ "hasIndices",
485
+ "ignoreCase",
486
+ "multiline",
487
+ "source",
488
+ "sticky",
489
+ "unicode",
490
+ ]),
491
+ ],
492
+ [Set, new Set(["size"])],
493
+ ];
494
+
495
+ /**
496
+ * Get the property descriptor.
497
+ * @param {object} object The object to get.
498
+ * @param {string|number|symbol} name The property name to get.
499
+ */
500
+ function getPropertyDescriptor(object, name) {
501
+ let x = object;
502
+ while ((typeof x === "object" || typeof x === "function") && x !== null) {
503
+ const d = Object.getOwnPropertyDescriptor(x, name);
504
+ if (d) {
505
+ return d
506
+ }
507
+ x = Object.getPrototypeOf(x);
508
+ }
509
+ return null
510
+ }
511
+
512
+ /**
513
+ * Check if a property is getter or not.
514
+ * @param {object} object The object to check.
515
+ * @param {string|number|symbol} name The property name to check.
516
+ */
517
+ function isGetter(object, name) {
518
+ const d = getPropertyDescriptor(object, name);
519
+ return d != null && d.get != null
520
+ }
521
+
522
+ /**
523
+ * Get the element values of a given node list.
524
+ * @param {(Node|TSESTreeNode|null)[]} nodeList The node list to get values.
525
+ * @param {Scope|undefined|null} initialScope The initial scope to find variables.
526
+ * @returns {any[]|null} The value list if all nodes are constant. Otherwise, null.
527
+ */
528
+ function getElementValues(nodeList, initialScope) {
529
+ const valueList = [];
530
+
531
+ for (let i = 0; i < nodeList.length; ++i) {
532
+ const elementNode = nodeList[i];
533
+
534
+ if (elementNode == null) {
535
+ valueList.length = i + 1;
536
+ } else if (elementNode.type === "SpreadElement") {
537
+ const argument = getStaticValueR(elementNode.argument, initialScope);
538
+ if (argument == null) {
539
+ return null
540
+ }
541
+ valueList.push(.../** @type {Iterable<any>} */ (argument.value));
542
+ } else {
543
+ const element = getStaticValueR(elementNode, initialScope);
544
+ if (element == null) {
545
+ return null
546
+ }
547
+ valueList.push(element.value);
548
+ }
549
+ }
550
+
551
+ return valueList
552
+ }
553
+
554
+ /**
555
+ * Checks if a variable is a built-in global.
556
+ * @param {Variable|null} variable The variable to check.
557
+ * @returns {variable is Variable & {defs:[]}}
558
+ */
559
+ function isBuiltinGlobal(variable) {
560
+ return (
561
+ variable != null &&
562
+ variable.defs.length === 0 &&
563
+ builtinNames.has(variable.name) &&
564
+ variable.name in globalObject
565
+ )
566
+ }
567
+
568
+ /**
569
+ * Checks if a variable can be considered as a constant.
570
+ * @param {Variable} variable
571
+ * @returns {variable is Variable & {defs: [import("eslint").Scope.Definition & { type: "Variable" }]}} True if the variable can be considered as a constant.
572
+ */
573
+ function canBeConsideredConst(variable) {
574
+ if (variable.defs.length !== 1) {
575
+ return false
576
+ }
577
+ const def = variable.defs[0];
578
+ return Boolean(
579
+ def.parent &&
580
+ def.type === "Variable" &&
581
+ (def.parent.kind === "const" || isEffectivelyConst(variable)),
582
+ )
583
+ }
584
+
585
+ /**
586
+ * Returns whether the given variable is never written to after initialization.
587
+ * @param {Variable} variable
588
+ * @returns {boolean}
589
+ */
590
+ function isEffectivelyConst(variable) {
591
+ const refs = variable.references;
592
+
593
+ const inits = refs.filter((r) => r.init).length;
594
+ const reads = refs.filter((r) => r.isReadOnly()).length;
595
+ if (inits === 1 && reads + inits === refs.length) {
596
+ // there is only one init and all other references only read
597
+ return true
598
+ }
599
+ return false
600
+ }
601
+
602
+ /**
603
+ * Checks if a variable has mutation in its property.
604
+ * @param {Variable} variable The variable to check.
605
+ * @param {Scope|null} initialScope The scope to start finding variable. Optional. If the node is a computed property node and this scope was given, this checks the computed property name by the `getStringIfConstant` function with the scope, and returns the value of it.
606
+ * @returns {boolean} True if the variable has mutation in its property.
607
+ */
608
+ function hasMutationInProperty(variable, initialScope) {
609
+ for (const ref of variable.references) {
610
+ let node = /** @type {TSESTreeNode} */ (ref.identifier);
611
+ while (node && node.parent && node.parent.type === "MemberExpression") {
612
+ node = node.parent;
613
+ }
614
+ if (!node || !node.parent) {
615
+ continue
616
+ }
617
+ if (
618
+ (node.parent.type === "AssignmentExpression" &&
619
+ node.parent.left === node) ||
620
+ (node.parent.type === "UpdateExpression" &&
621
+ node.parent.argument === node)
622
+ ) {
623
+ // This is a mutation.
624
+ return true
625
+ }
626
+ if (
627
+ node.parent.type === "CallExpression" &&
628
+ node.parent.callee === node &&
629
+ node.type === "MemberExpression"
630
+ ) {
631
+ const methodName = getStaticPropertyNameValue(node, initialScope);
632
+ if (isNameOfMutationArrayMethod(methodName)) {
633
+ // This is a mutation.
634
+ return true
635
+ }
636
+ }
637
+ }
638
+ return false
639
+
640
+ /**
641
+ * Checks if a method name is one of the mutation array methods.
642
+ * @param {StaticValue|null} methodName The method name to check.
643
+ * @returns {boolean} True if the method name is a mutation array method.
644
+ */
645
+ function isNameOfMutationArrayMethod(methodName) {
646
+ if (methodName == null || methodName.value == null) {
647
+ return false
648
+ }
649
+ const name = methodName.value;
650
+ return (
651
+ name === "copyWithin" ||
652
+ name === "fill" ||
653
+ name === "pop" ||
654
+ name === "push" ||
655
+ name === "reverse" ||
656
+ name === "shift" ||
657
+ name === "sort" ||
658
+ name === "splice" ||
659
+ name === "unshift"
660
+ )
661
+ }
662
+ }
663
+
664
+ /**
665
+ * @template {TSESTreeNodeTypes} T
666
+ * @callback VisitorCallback
667
+ * @param {TSESTreeNode & { type: T }} node
668
+ * @param {Scope|undefined|null} initialScope
669
+ * @returns {StaticValue | null}
670
+ */
671
+ /**
672
+ * @typedef { { [K in TSESTreeNodeTypes]?: VisitorCallback<K> } } Operations
673
+ */
674
+ /**
675
+ * @type {Operations}
676
+ */
677
+ const operations = Object.freeze({
678
+ ArrayExpression(node, initialScope) {
679
+ const elements = getElementValues(node.elements, initialScope);
680
+ return elements != null ? { value: elements } : null
681
+ },
682
+
683
+ AssignmentExpression(node, initialScope) {
684
+ if (node.operator === "=") {
685
+ return getStaticValueR(node.right, initialScope)
686
+ }
687
+ return null
688
+ },
689
+
690
+ //eslint-disable-next-line complexity
691
+ BinaryExpression(node, initialScope) {
692
+ if (node.operator === "in" || node.operator === "instanceof") {
693
+ // Not supported.
694
+ return null
695
+ }
696
+
697
+ const left = getStaticValueR(node.left, initialScope);
698
+ const right = getStaticValueR(node.right, initialScope);
699
+ if (left != null && right != null) {
700
+ switch (node.operator) {
701
+ case "==":
702
+ return { value: left.value == right.value } //eslint-disable-line eqeqeq
703
+ case "!=":
704
+ return { value: left.value != right.value } //eslint-disable-line eqeqeq
705
+ case "===":
706
+ return { value: left.value === right.value }
707
+ case "!==":
708
+ return { value: left.value !== right.value }
709
+ case "<":
710
+ return {
711
+ value:
712
+ /** @type {any} */ (left.value) <
713
+ /** @type {any} */ (right.value),
714
+ }
715
+ case "<=":
716
+ return {
717
+ value:
718
+ /** @type {any} */ (left.value) <=
719
+ /** @type {any} */ (right.value),
720
+ }
721
+ case ">":
722
+ return {
723
+ value:
724
+ /** @type {any} */ (left.value) >
725
+ /** @type {any} */ (right.value),
726
+ }
727
+ case ">=":
728
+ return {
729
+ value:
730
+ /** @type {any} */ (left.value) >=
731
+ /** @type {any} */ (right.value),
732
+ }
733
+ case "<<":
734
+ return {
735
+ value:
736
+ /** @type {any} */ (left.value) <<
737
+ /** @type {any} */ (right.value),
738
+ }
739
+ case ">>":
740
+ return {
741
+ value:
742
+ /** @type {any} */ (left.value) >>
743
+ /** @type {any} */ (right.value),
744
+ }
745
+ case ">>>":
746
+ return {
747
+ value:
748
+ /** @type {any} */ (left.value) >>>
749
+ /** @type {any} */ (right.value),
750
+ }
751
+ case "+":
752
+ return {
753
+ value:
754
+ /** @type {any} */ (left.value) +
755
+ /** @type {any} */ (right.value),
756
+ }
757
+ case "-":
758
+ return {
759
+ value:
760
+ /** @type {any} */ (left.value) -
761
+ /** @type {any} */ (right.value),
762
+ }
763
+ case "*":
764
+ return {
765
+ value:
766
+ /** @type {any} */ (left.value) *
767
+ /** @type {any} */ (right.value),
768
+ }
769
+ case "/":
770
+ return {
771
+ value:
772
+ /** @type {any} */ (left.value) /
773
+ /** @type {any} */ (right.value),
774
+ }
775
+ case "%":
776
+ return {
777
+ value:
778
+ /** @type {any} */ (left.value) %
779
+ /** @type {any} */ (right.value),
780
+ }
781
+ case "**":
782
+ return {
783
+ value:
784
+ /** @type {any} */ (left.value) **
785
+ /** @type {any} */ (right.value),
786
+ }
787
+ case "|":
788
+ return {
789
+ value:
790
+ /** @type {any} */ (left.value) |
791
+ /** @type {any} */ (right.value),
792
+ }
793
+ case "^":
794
+ return {
795
+ value:
796
+ /** @type {any} */ (left.value) ^
797
+ /** @type {any} */ (right.value),
798
+ }
799
+ case "&":
800
+ return {
801
+ value:
802
+ /** @type {any} */ (left.value) &
803
+ /** @type {any} */ (right.value),
804
+ }
805
+
806
+ // no default
807
+ }
808
+ }
809
+
810
+ return null
811
+ },
812
+
813
+ CallExpression(node, initialScope) {
814
+ const calleeNode = node.callee;
815
+ const args = getElementValues(node.arguments, initialScope);
816
+
817
+ if (args != null) {
818
+ if (calleeNode.type === "MemberExpression") {
819
+ if (calleeNode.property.type === "PrivateIdentifier") {
820
+ return null
821
+ }
822
+ const object = getStaticValueR(calleeNode.object, initialScope);
823
+ if (object != null) {
824
+ if (
825
+ object.value == null &&
826
+ (object.optional || node.optional)
827
+ ) {
828
+ return { value: undefined, optional: true }
829
+ }
830
+ const property = getStaticPropertyNameValue(
831
+ calleeNode,
832
+ initialScope,
833
+ );
834
+
835
+ if (property != null) {
836
+ const receiver =
837
+ /** @type {Record<PropertyKey, (...args: any[]) => any>} */ (
838
+ object.value
839
+ );
840
+ const methodName = /** @type {PropertyKey} */ (
841
+ property.value
842
+ );
843
+ if (callAllowed.has(receiver[methodName])) {
844
+ return {
845
+ value: receiver[methodName](...args),
846
+ }
847
+ }
848
+ if (callPassThrough.has(receiver[methodName])) {
849
+ return { value: args[0] }
850
+ }
851
+ }
852
+ }
853
+ } else {
854
+ const callee = getStaticValueR(calleeNode, initialScope);
855
+ if (callee != null) {
856
+ if (callee.value == null && node.optional) {
857
+ return { value: undefined, optional: true }
858
+ }
859
+ const func = /** @type {(...args: any[]) => any} */ (
860
+ callee.value
861
+ );
862
+ if (callAllowed.has(func)) {
863
+ return { value: func(...args) }
864
+ }
865
+ if (callPassThrough.has(func)) {
866
+ return { value: args[0] }
867
+ }
868
+ }
869
+ }
870
+ }
871
+
872
+ return null
873
+ },
874
+
875
+ ConditionalExpression(node, initialScope) {
876
+ const test = getStaticValueR(node.test, initialScope);
877
+ if (test != null) {
878
+ return test.value
879
+ ? getStaticValueR(node.consequent, initialScope)
880
+ : getStaticValueR(node.alternate, initialScope)
881
+ }
882
+ return null
883
+ },
884
+
885
+ ExpressionStatement(node, initialScope) {
886
+ return getStaticValueR(node.expression, initialScope)
887
+ },
888
+
889
+ Identifier(node, initialScope) {
890
+ if (initialScope != null) {
891
+ const variable = findVariable(initialScope, node);
892
+
893
+ if (variable != null) {
894
+ // Built-in globals.
895
+ if (isBuiltinGlobal(variable)) {
896
+ return { value: globalObject[variable.name] }
897
+ }
898
+
899
+ // Constants.
900
+ if (canBeConsideredConst(variable)) {
901
+ const def = variable.defs[0];
902
+ if (
903
+ // TODO(mysticatea): don't support destructuring here.
904
+ def.node.id.type === "Identifier"
905
+ ) {
906
+ const init = getStaticValueR(
907
+ def.node.init,
908
+ initialScope,
909
+ );
910
+ if (
911
+ init &&
912
+ typeof init.value === "object" &&
913
+ init.value !== null
914
+ ) {
915
+ if (hasMutationInProperty(variable, initialScope)) {
916
+ // This variable has mutation in its property.
917
+ return null
918
+ }
919
+ }
920
+ return init
921
+ }
922
+ }
923
+ }
924
+ }
925
+ return null
926
+ },
927
+
928
+ Literal(node) {
929
+ const literal =
930
+ /** @type {Partial<Literal> & Partial<RegExpLiteral> & Partial<BigIntLiteral>} */ (
931
+ node
932
+ );
933
+ //istanbul ignore if : this is implementation-specific behavior.
934
+ if (
935
+ (literal.regex != null || literal.bigint != null) &&
936
+ literal.value == null
937
+ ) {
938
+ // It was a RegExp/BigInt literal, but Node.js didn't support it.
939
+ return null
940
+ }
941
+ return { value: literal.value }
942
+ },
943
+
944
+ LogicalExpression(node, initialScope) {
945
+ const left = getStaticValueR(node.left, initialScope);
946
+ if (left != null) {
947
+ if (
948
+ (node.operator === "||" && Boolean(left.value) === true) ||
949
+ (node.operator === "&&" && Boolean(left.value) === false) ||
950
+ (node.operator === "??" && left.value != null)
951
+ ) {
952
+ return left
953
+ }
954
+
955
+ const right = getStaticValueR(node.right, initialScope);
956
+ if (right != null) {
957
+ return right
958
+ }
959
+ }
960
+
961
+ return null
962
+ },
963
+
964
+ MemberExpression(node, initialScope) {
965
+ if (node.property.type === "PrivateIdentifier") {
966
+ return null
967
+ }
968
+ const object = getStaticValueR(node.object, initialScope);
969
+ if (object != null) {
970
+ if (object.value == null && (object.optional || node.optional)) {
971
+ return { value: undefined, optional: true }
972
+ }
973
+ const property = getStaticPropertyNameValue(node, initialScope);
974
+
975
+ if (property != null) {
976
+ if (
977
+ !isGetter(
978
+ /** @type {object} */ (object.value),
979
+ /** @type {PropertyKey} */ (property.value),
980
+ )
981
+ ) {
982
+ return {
983
+ value: /** @type {Record<PropertyKey, unknown>} */ (
984
+ object.value
985
+ )[/** @type {PropertyKey} */ (property.value)],
986
+ }
987
+ }
988
+
989
+ for (const [classFn, allowed] of getterAllowed) {
990
+ if (
991
+ object.value instanceof classFn &&
992
+ allowed.has(/** @type {string} */ (property.value))
993
+ ) {
994
+ return {
995
+ value: /** @type {Record<PropertyKey, unknown>} */ (
996
+ object.value
997
+ )[/** @type {PropertyKey} */ (property.value)],
998
+ }
999
+ }
1000
+ }
1001
+ }
1002
+ }
1003
+ return null
1004
+ },
1005
+
1006
+ ChainExpression(node, initialScope) {
1007
+ const expression = getStaticValueR(node.expression, initialScope);
1008
+ if (expression != null) {
1009
+ return { value: expression.value }
1010
+ }
1011
+ return null
1012
+ },
1013
+
1014
+ NewExpression(node, initialScope) {
1015
+ const callee = getStaticValueR(node.callee, initialScope);
1016
+ const args = getElementValues(node.arguments, initialScope);
1017
+
1018
+ if (callee != null && args != null) {
1019
+ const Func = /** @type {new (...args: any[]) => any} */ (
1020
+ callee.value
1021
+ );
1022
+ if (callAllowed.has(Func)) {
1023
+ return { value: new Func(...args) }
1024
+ }
1025
+ }
1026
+
1027
+ return null
1028
+ },
1029
+
1030
+ ObjectExpression(node, initialScope) {
1031
+ /** @type {Record<PropertyKey, unknown>} */
1032
+ const object = {};
1033
+
1034
+ for (const propertyNode of node.properties) {
1035
+ if (propertyNode.type === "Property") {
1036
+ if (propertyNode.kind !== "init") {
1037
+ return null
1038
+ }
1039
+ const key = getStaticPropertyNameValue(
1040
+ propertyNode,
1041
+ initialScope,
1042
+ );
1043
+ const value = getStaticValueR(propertyNode.value, initialScope);
1044
+ if (key == null || value == null) {
1045
+ return null
1046
+ }
1047
+ object[/** @type {PropertyKey} */ (key.value)] = value.value;
1048
+ } else if (
1049
+ propertyNode.type === "SpreadElement" ||
1050
+ // @ts-expect-error -- Backward compatibility
1051
+ propertyNode.type === "ExperimentalSpreadProperty"
1052
+ ) {
1053
+ const argument = getStaticValueR(
1054
+ propertyNode.argument,
1055
+ initialScope,
1056
+ );
1057
+ if (argument == null) {
1058
+ return null
1059
+ }
1060
+ Object.assign(object, argument.value);
1061
+ } else {
1062
+ return null
1063
+ }
1064
+ }
1065
+
1066
+ return { value: object }
1067
+ },
1068
+
1069
+ SequenceExpression(node, initialScope) {
1070
+ const last = node.expressions[node.expressions.length - 1];
1071
+ return getStaticValueR(last, initialScope)
1072
+ },
1073
+
1074
+ TaggedTemplateExpression(node, initialScope) {
1075
+ const tag = getStaticValueR(node.tag, initialScope);
1076
+ const expressions = getElementValues(
1077
+ node.quasi.expressions,
1078
+ initialScope,
1079
+ );
1080
+
1081
+ if (tag != null && expressions != null) {
1082
+ const func = /** @type {(...args: any[]) => any} */ (tag.value);
1083
+ /** @type {any[] & { raw?: string[] }} */
1084
+ const strings = node.quasi.quasis.map((q) => q.value.cooked);
1085
+ strings.raw = node.quasi.quasis.map((q) => q.value.raw);
1086
+
1087
+ if (func === String.raw) {
1088
+ return { value: func(strings, ...expressions) }
1089
+ }
1090
+ }
1091
+
1092
+ return null
1093
+ },
1094
+
1095
+ TemplateLiteral(node, initialScope) {
1096
+ const expressions = getElementValues(node.expressions, initialScope);
1097
+ if (expressions != null) {
1098
+ let value = node.quasis[0].value.cooked;
1099
+ for (let i = 0; i < expressions.length; ++i) {
1100
+ value += expressions[i];
1101
+ value += /** @type {string} */ (node.quasis[i + 1].value.cooked);
1102
+ }
1103
+ return { value }
1104
+ }
1105
+ return null
1106
+ },
1107
+
1108
+ UnaryExpression(node, initialScope) {
1109
+ if (node.operator === "delete") {
1110
+ // Not supported.
1111
+ return null
1112
+ }
1113
+ if (node.operator === "void") {
1114
+ return { value: undefined }
1115
+ }
1116
+
1117
+ const arg = getStaticValueR(node.argument, initialScope);
1118
+ if (arg != null) {
1119
+ switch (node.operator) {
1120
+ case "-":
1121
+ return { value: -(/** @type {any} */ (arg.value)) }
1122
+ case "+":
1123
+ return { value: +(/** @type {any} */ (arg.value)) } //eslint-disable-line no-implicit-coercion
1124
+ case "!":
1125
+ return { value: !arg.value }
1126
+ case "~":
1127
+ return { value: ~(/** @type {any} */ (arg.value)) }
1128
+ case "typeof":
1129
+ return { value: typeof arg.value }
1130
+
1131
+ // no default
1132
+ }
1133
+ }
1134
+
1135
+ return null
1136
+ },
1137
+ TSAsExpression(node, initialScope) {
1138
+ return getStaticValueR(node.expression, initialScope)
1139
+ },
1140
+ TSSatisfiesExpression(node, initialScope) {
1141
+ return getStaticValueR(node.expression, initialScope)
1142
+ },
1143
+ TSTypeAssertion(node, initialScope) {
1144
+ return getStaticValueR(node.expression, initialScope)
1145
+ },
1146
+ TSNonNullExpression(node, initialScope) {
1147
+ return getStaticValueR(node.expression, initialScope)
1148
+ },
1149
+ TSInstantiationExpression(node, initialScope) {
1150
+ return getStaticValueR(node.expression, initialScope)
1151
+ },
1152
+ });
1153
+
1154
+ /**
1155
+ * Get the value of a given node if it's a static value.
1156
+ * @param {Node|TSESTreeNode|null|undefined} node The node to get.
1157
+ * @param {Scope|undefined|null} initialScope The scope to start finding variable.
1158
+ * @returns {StaticValue|null} The static value of the node, or `null`.
1159
+ */
1160
+ function getStaticValueR(node, initialScope) {
1161
+ if (node != null && Object.hasOwnProperty.call(operations, node.type)) {
1162
+ return /** @type {VisitorCallback<any>} */ (operations[node.type])(
1163
+ /** @type {TSESTreeNode} */ (node),
1164
+ initialScope,
1165
+ )
1166
+ }
1167
+ return null
1168
+ }
1169
+
1170
+ /**
1171
+ * Get the static value of property name from a MemberExpression node or a Property node.
1172
+ * @param {MemberExpression|Property} node The node to get.
1173
+ * @param {Scope|null} [initialScope] The scope to start finding variable. Optional. If the node is a computed property node and this scope was given, this checks the computed property name by the `getStringIfConstant` function with the scope, and returns the value of it.
1174
+ * @returns {StaticValue|null} The static value of the property name of the node, or `null`.
1175
+ */
1176
+ function getStaticPropertyNameValue(node, initialScope) {
1177
+ const nameNode = node.type === "Property" ? node.key : node.property;
1178
+
1179
+ if (node.computed) {
1180
+ return getStaticValueR(nameNode, initialScope)
1181
+ }
1182
+
1183
+ if (nameNode.type === "Identifier") {
1184
+ return { value: nameNode.name }
1185
+ }
1186
+
1187
+ if (nameNode.type === "Literal") {
1188
+ if (/** @type {Partial<BigIntLiteral>} */ (nameNode).bigint) {
1189
+ return { value: /** @type {BigIntLiteral} */ (nameNode).bigint }
1190
+ }
1191
+ return { value: String(nameNode.value) }
1192
+ }
1193
+
1194
+ return null
1195
+ }
1196
+
1197
+ /**
1198
+ * Get the value of a given node if it's a static value.
1199
+ * @param {Node} node The node to get.
1200
+ * @param {Scope|null} [initialScope] The scope to start finding variable. Optional. If this scope was given, this tries to resolve identifier references which are in the given node as much as possible.
1201
+ * @returns {StaticValue | null} The static value of the node, or `null`.
1202
+ */
1203
+ function getStaticValue(node, initialScope = null) {
1204
+ try {
1205
+ return getStaticValueR(node, initialScope)
1206
+ } catch (_error) {
1207
+ return null
1208
+ }
1209
+ }
1210
+
1211
+ /** @typedef {import("eslint").Scope.Scope} Scope */
1212
+ /** @typedef {import("estree").Node} Node */
1213
+ /** @typedef {import("estree").RegExpLiteral} RegExpLiteral */
1214
+ /** @typedef {import("estree").BigIntLiteral} BigIntLiteral */
1215
+ /** @typedef {import("estree").SimpleLiteral} SimpleLiteral */
1216
+
1217
+ /**
1218
+ * Get the value of a given node if it's a literal or a template literal.
1219
+ * @param {Node} node The node to get.
1220
+ * @param {Scope|null} [initialScope] The scope to start finding variable. Optional. If the node is an Identifier node and this scope was given, this checks the variable of the identifier, and returns the value of it if the variable is a constant.
1221
+ * @returns {string|null} The value of the node, or `null`.
1222
+ */
1223
+ function getStringIfConstant(node, initialScope = null) {
1224
+ // Handle the literals that the platform doesn't support natively.
1225
+ if (node && node.type === "Literal" && node.value === null) {
1226
+ const literal =
1227
+ /** @type {Partial<SimpleLiteral> & Partial<RegExpLiteral> & Partial<BigIntLiteral>} */ (
1228
+ node
1229
+ );
1230
+ if (literal.regex) {
1231
+ return `/${literal.regex.pattern}/${literal.regex.flags}`
1232
+ }
1233
+ if (literal.bigint) {
1234
+ return literal.bigint
1235
+ }
1236
+ }
1237
+
1238
+ const evaluated = getStaticValue(node, initialScope);
1239
+
1240
+ if (evaluated) {
1241
+ // `String(Symbol.prototype)` throws error
1242
+ try {
1243
+ return String(evaluated.value)
1244
+ } catch {
1245
+ // No op
1246
+ }
1247
+ }
1248
+
1249
+ return null
1250
+ }
1251
+
1252
+ /** @typedef {import("eslint").Scope.Scope} Scope */
1253
+ /** @typedef {import("estree").MemberExpression} MemberExpression */
1254
+ /** @typedef {import("estree").MethodDefinition} MethodDefinition */
1255
+ /** @typedef {import("estree").Property} Property */
1256
+ /** @typedef {import("estree").PropertyDefinition} PropertyDefinition */
1257
+ /** @typedef {import("estree").Identifier} Identifier */
1258
+
1259
+ /**
1260
+ * Get the property name from a MemberExpression node or a Property node.
1261
+ * @param {MemberExpression | MethodDefinition | Property | PropertyDefinition} node The node to get.
1262
+ * @param {Scope} [initialScope] The scope to start finding variable. Optional. If the node is a computed property node and this scope was given, this checks the computed property name by the `getStringIfConstant` function with the scope, and returns the value of it.
1263
+ * @returns {string|null|undefined} The property name of the node.
1264
+ */
1265
+ function getPropertyName(node, initialScope) {
1266
+ switch (node.type) {
1267
+ case "MemberExpression":
1268
+ if (node.computed) {
1269
+ return getStringIfConstant(node.property, initialScope)
1270
+ }
1271
+ if (node.property.type === "PrivateIdentifier") {
1272
+ return null
1273
+ }
1274
+ return /** @type {Partial<Identifier>} */ (node.property).name
1275
+
1276
+ case "Property":
1277
+ case "MethodDefinition":
1278
+ case "PropertyDefinition":
1279
+ if (node.computed) {
1280
+ return getStringIfConstant(node.key, initialScope)
1281
+ }
1282
+ if (node.key.type === "Literal") {
1283
+ return String(node.key.value)
1284
+ }
1285
+ if (node.key.type === "PrivateIdentifier") {
1286
+ return null
1287
+ }
1288
+ return /** @type {Partial<Identifier>} */ (node.key).name
1289
+ }
1290
+
1291
+ return null
1292
+ }
1293
+
1294
+ /** @typedef {import("eslint").Rule.Node} RuleNode */
1295
+ /** @typedef {import("eslint").SourceCode} SourceCode */
1296
+ /** @typedef {import("estree").Function} FunctionNode */
1297
+ /** @typedef {import("estree").FunctionDeclaration} FunctionDeclaration */
1298
+ /** @typedef {import("estree").FunctionExpression} FunctionExpression */
1299
+ /** @typedef {import("estree").Identifier} Identifier */
1300
+
1301
+ /**
1302
+ * Get the name and kind of the given function node.
1303
+ * @param {FunctionNode} node - The function node to get.
1304
+ * @param {SourceCode} [sourceCode] The source code object to get the code of computed property keys.
1305
+ * @returns {string} The name and kind of the function node.
1306
+ */
1307
+ // eslint-disable-next-line complexity
1308
+ function getFunctionNameWithKind(node, sourceCode) {
1309
+ const parent = /** @type {RuleNode} */ (node).parent;
1310
+
1311
+ if (!parent) {
1312
+ return ""
1313
+ }
1314
+
1315
+ const tokens = [];
1316
+ const isObjectMethod = parent.type === "Property" && parent.value === node;
1317
+ const isClassMethod =
1318
+ parent.type === "MethodDefinition" && parent.value === node;
1319
+ const isClassFieldMethod =
1320
+ parent.type === "PropertyDefinition" && parent.value === node;
1321
+
1322
+ // Modifiers.
1323
+ if (isClassMethod || isClassFieldMethod) {
1324
+ if (parent.static) {
1325
+ tokens.push("static");
1326
+ }
1327
+ if (parent.key.type === "PrivateIdentifier") {
1328
+ tokens.push("private");
1329
+ }
1330
+ }
1331
+ if (node.async) {
1332
+ tokens.push("async");
1333
+ }
1334
+ if (node.generator) {
1335
+ tokens.push("generator");
1336
+ }
1337
+
1338
+ // Kinds.
1339
+ if (isObjectMethod || isClassMethod) {
1340
+ if (parent.kind === "constructor") {
1341
+ return "constructor"
1342
+ }
1343
+ if (parent.kind === "get") {
1344
+ tokens.push("getter");
1345
+ } else if (parent.kind === "set") {
1346
+ tokens.push("setter");
1347
+ } else {
1348
+ tokens.push("method");
1349
+ }
1350
+ } else if (isClassFieldMethod) {
1351
+ tokens.push("method");
1352
+ } else {
1353
+ if (node.type === "ArrowFunctionExpression") {
1354
+ tokens.push("arrow");
1355
+ }
1356
+ tokens.push("function");
1357
+ }
1358
+
1359
+ // Names.
1360
+ if (isObjectMethod || isClassMethod || isClassFieldMethod) {
1361
+ if (parent.key.type === "PrivateIdentifier") {
1362
+ tokens.push(`#${parent.key.name}`);
1363
+ } else {
1364
+ const name = getPropertyName(parent);
1365
+ if (name) {
1366
+ tokens.push(`'${name}'`);
1367
+ } else if (sourceCode) {
1368
+ const keyText = sourceCode.getText(parent.key);
1369
+ if (!keyText.includes("\n")) {
1370
+ tokens.push(`[${keyText}]`);
1371
+ }
1372
+ }
1373
+ }
1374
+ } else if (hasId(node)) {
1375
+ tokens.push(`'${node.id.name}'`);
1376
+ } else if (
1377
+ parent.type === "VariableDeclarator" &&
1378
+ parent.id &&
1379
+ parent.id.type === "Identifier"
1380
+ ) {
1381
+ tokens.push(`'${parent.id.name}'`);
1382
+ } else if (
1383
+ (parent.type === "AssignmentExpression" ||
1384
+ parent.type === "AssignmentPattern") &&
1385
+ parent.left &&
1386
+ parent.left.type === "Identifier"
1387
+ ) {
1388
+ tokens.push(`'${parent.left.name}'`);
1389
+ } else if (
1390
+ parent.type === "ExportDefaultDeclaration" &&
1391
+ parent.declaration === node
1392
+ ) {
1393
+ tokens.push("'default'");
1394
+ }
1395
+
1396
+ return tokens.join(" ")
1397
+ }
1398
+
1399
+ /**
1400
+ * @param {FunctionNode} node
1401
+ * @returns {node is FunctionDeclaration | FunctionExpression & { id: Identifier }}
1402
+ */
1403
+ function hasId(node) {
1404
+ return Boolean(
1405
+ /** @type {Partial<FunctionDeclaration | FunctionExpression>} */ (node)
1406
+ .id,
1407
+ )
1408
+ }
1409
+
1410
+ /** @typedef {import("estree").Node} Node */
1411
+ /** @typedef {import("eslint").SourceCode} SourceCode */
1412
+ /** @typedef {import("./types.mjs").HasSideEffectOptions} HasSideEffectOptions */
1413
+ /** @typedef {import("estree").BinaryExpression} BinaryExpression */
1414
+ /** @typedef {import("estree").MemberExpression} MemberExpression */
1415
+ /** @typedef {import("estree").MethodDefinition} MethodDefinition */
1416
+ /** @typedef {import("estree").Property} Property */
1417
+ /** @typedef {import("estree").PropertyDefinition} PropertyDefinition */
1418
+ /** @typedef {import("estree").UnaryExpression} UnaryExpression */
1419
+
1420
+ const typeConversionBinaryOps = Object.freeze(
1421
+ new Set([
1422
+ "==",
1423
+ "!=",
1424
+ "<",
1425
+ "<=",
1426
+ ">",
1427
+ ">=",
1428
+ "<<",
1429
+ ">>",
1430
+ ">>>",
1431
+ "+",
1432
+ "-",
1433
+ "*",
1434
+ "/",
1435
+ "%",
1436
+ "|",
1437
+ "^",
1438
+ "&",
1439
+ "in",
1440
+ ]),
1441
+ );
1442
+ const typeConversionUnaryOps = Object.freeze(new Set(["-", "+", "!", "~"]));
1443
+
1444
+ /**
1445
+ * Check whether the given value is an ASTNode or not.
1446
+ * @param {any} x The value to check.
1447
+ * @returns {x is Node} `true` if the value is an ASTNode.
1448
+ */
1449
+ function isNode(x) {
1450
+ return x !== null && typeof x === "object" && typeof x.type === "string"
1451
+ }
1452
+
1453
+ const visitor = Object.freeze(
1454
+ Object.assign(Object.create(null), {
1455
+ /**
1456
+ * @param {Node} node
1457
+ * @param {HasSideEffectOptions} options
1458
+ * @param {Record<string, string[]>} visitorKeys
1459
+ */
1460
+ $visit(node, options, visitorKeys) {
1461
+ const { type } = node;
1462
+
1463
+ if (typeof (/** @type {any} */ (this)[type]) === "function") {
1464
+ return /** @type {any} */ (this)[type](
1465
+ node,
1466
+ options,
1467
+ visitorKeys,
1468
+ )
1469
+ }
1470
+
1471
+ return this.$visitChildren(node, options, visitorKeys)
1472
+ },
1473
+
1474
+ /**
1475
+ * @param {Node} node
1476
+ * @param {HasSideEffectOptions} options
1477
+ * @param {Record<string, string[]>} visitorKeys
1478
+ */
1479
+ $visitChildren(node, options, visitorKeys) {
1480
+ const { type } = node;
1481
+
1482
+ for (const key of /** @type {(keyof Node)[]} */ (
1483
+ visitorKeys[type] || eslintVisitorKeys.getKeys(node)
1484
+ )) {
1485
+ const value = node[key];
1486
+
1487
+ if (Array.isArray(value)) {
1488
+ for (const element of value) {
1489
+ if (
1490
+ isNode(element) &&
1491
+ this.$visit(element, options, visitorKeys)
1492
+ ) {
1493
+ return true
1494
+ }
1495
+ }
1496
+ } else if (
1497
+ isNode(value) &&
1498
+ this.$visit(value, options, visitorKeys)
1499
+ ) {
1500
+ return true
1501
+ }
1502
+ }
1503
+
1504
+ return false
1505
+ },
1506
+
1507
+ ArrowFunctionExpression() {
1508
+ return false
1509
+ },
1510
+ AssignmentExpression() {
1511
+ return true
1512
+ },
1513
+ AwaitExpression() {
1514
+ return true
1515
+ },
1516
+ /**
1517
+ * @param {BinaryExpression} node
1518
+ * @param {HasSideEffectOptions} options
1519
+ * @param {Record<string, string[]>} visitorKeys
1520
+ */
1521
+ BinaryExpression(node, options, visitorKeys) {
1522
+ if (
1523
+ options.considerImplicitTypeConversion &&
1524
+ typeConversionBinaryOps.has(node.operator) &&
1525
+ (node.left.type !== "Literal" || node.right.type !== "Literal")
1526
+ ) {
1527
+ return true
1528
+ }
1529
+ return this.$visitChildren(node, options, visitorKeys)
1530
+ },
1531
+ CallExpression() {
1532
+ return true
1533
+ },
1534
+ FunctionExpression() {
1535
+ return false
1536
+ },
1537
+ ImportExpression() {
1538
+ return true
1539
+ },
1540
+ /**
1541
+ * @param {MemberExpression} node
1542
+ * @param {HasSideEffectOptions} options
1543
+ * @param {Record<string, string[]>} visitorKeys
1544
+ */
1545
+ MemberExpression(node, options, visitorKeys) {
1546
+ if (options.considerGetters) {
1547
+ return true
1548
+ }
1549
+ if (
1550
+ options.considerImplicitTypeConversion &&
1551
+ node.computed &&
1552
+ node.property.type !== "Literal"
1553
+ ) {
1554
+ return true
1555
+ }
1556
+ return this.$visitChildren(node, options, visitorKeys)
1557
+ },
1558
+ /**
1559
+ * @param {MethodDefinition} node
1560
+ * @param {HasSideEffectOptions} options
1561
+ * @param {Record<string, string[]>} visitorKeys
1562
+ */
1563
+ MethodDefinition(node, options, visitorKeys) {
1564
+ if (
1565
+ options.considerImplicitTypeConversion &&
1566
+ node.computed &&
1567
+ node.key.type !== "Literal"
1568
+ ) {
1569
+ return true
1570
+ }
1571
+ return this.$visitChildren(node, options, visitorKeys)
1572
+ },
1573
+ NewExpression() {
1574
+ return true
1575
+ },
1576
+ /**
1577
+ * @param {Property} node
1578
+ * @param {HasSideEffectOptions} options
1579
+ * @param {Record<string, string[]>} visitorKeys
1580
+ */
1581
+ Property(node, options, visitorKeys) {
1582
+ if (
1583
+ options.considerImplicitTypeConversion &&
1584
+ node.computed &&
1585
+ node.key.type !== "Literal"
1586
+ ) {
1587
+ return true
1588
+ }
1589
+ return this.$visitChildren(node, options, visitorKeys)
1590
+ },
1591
+ /**
1592
+ * @param {PropertyDefinition} node
1593
+ * @param {HasSideEffectOptions} options
1594
+ * @param {Record<string, string[]>} visitorKeys
1595
+ */
1596
+ PropertyDefinition(node, options, visitorKeys) {
1597
+ if (
1598
+ options.considerImplicitTypeConversion &&
1599
+ node.computed &&
1600
+ node.key.type !== "Literal"
1601
+ ) {
1602
+ return true
1603
+ }
1604
+ return this.$visitChildren(node, options, visitorKeys)
1605
+ },
1606
+ /**
1607
+ * @param {UnaryExpression} node
1608
+ * @param {HasSideEffectOptions} options
1609
+ * @param {Record<string, string[]>} visitorKeys
1610
+ */
1611
+ UnaryExpression(node, options, visitorKeys) {
1612
+ if (node.operator === "delete") {
1613
+ return true
1614
+ }
1615
+ if (
1616
+ options.considerImplicitTypeConversion &&
1617
+ typeConversionUnaryOps.has(node.operator) &&
1618
+ node.argument.type !== "Literal"
1619
+ ) {
1620
+ return true
1621
+ }
1622
+ return this.$visitChildren(node, options, visitorKeys)
1623
+ },
1624
+ UpdateExpression() {
1625
+ return true
1626
+ },
1627
+ YieldExpression() {
1628
+ return true
1629
+ },
1630
+ }),
1631
+ );
1632
+
1633
+ /**
1634
+ * Check whether a given node has any side effect or not.
1635
+ * @param {Node} node The node to get.
1636
+ * @param {SourceCode} sourceCode The source code object.
1637
+ * @param {HasSideEffectOptions} [options] The option object.
1638
+ * @returns {boolean} `true` if the node has a certain side effect.
1639
+ */
1640
+ function hasSideEffect(node, sourceCode, options = {}) {
1641
+ const { considerGetters = false, considerImplicitTypeConversion = false } =
1642
+ options;
1643
+ return visitor.$visit(
1644
+ node,
1645
+ { considerGetters, considerImplicitTypeConversion },
1646
+ sourceCode.visitorKeys || eslintVisitorKeys.KEYS,
1647
+ )
1648
+ }
1649
+
1650
+ /** @typedef {import("estree").Node} Node */
1651
+ /** @typedef {import("@typescript-eslint/types").TSESTree.NewExpression} TSNewExpression */
1652
+ /** @typedef {import("@typescript-eslint/types").TSESTree.CallExpression} TSCallExpression */
1653
+ /** @typedef {import("eslint").SourceCode} SourceCode */
1654
+ /** @typedef {import("eslint").AST.Token} Token */
1655
+ /** @typedef {import("eslint").Rule.Node} RuleNode */
1656
+
1657
+ /**
1658
+ * Get the left parenthesis of the parent node syntax if it exists.
1659
+ * E.g., `if (a) {}` then the `(`.
1660
+ * @param {Node} node The AST node to check.
1661
+ * @param {SourceCode} sourceCode The source code object to get tokens.
1662
+ * @returns {Token|null} The left parenthesis of the parent node syntax
1663
+ */
1664
+ // eslint-disable-next-line complexity
1665
+ function getParentSyntaxParen(node, sourceCode) {
1666
+ const parent = /** @type {RuleNode} */ (node).parent;
1667
+
1668
+ if (!parent) {
1669
+ return null
1670
+ }
1671
+
1672
+ switch (parent.type) {
1673
+ case "CallExpression":
1674
+ case "NewExpression":
1675
+ if (parent.arguments.length === 1 && parent.arguments[0] === node) {
1676
+ return sourceCode.getTokenAfter(
1677
+ // @ts-expect-error https://github.com/typescript-eslint/typescript-eslint/pull/5384
1678
+ parent.typeArguments ||
1679
+ /** @type {RuleNode} */ (
1680
+ /** @type {unknown} */ (
1681
+ /** @type {TSNewExpression | TSCallExpression} */ (
1682
+ parent
1683
+ ).typeParameters
1684
+ )
1685
+ ) ||
1686
+ parent.callee,
1687
+ isOpeningParenToken,
1688
+ )
1689
+ }
1690
+ return null
1691
+
1692
+ case "DoWhileStatement":
1693
+ if (parent.test === node) {
1694
+ return sourceCode.getTokenAfter(
1695
+ parent.body,
1696
+ isOpeningParenToken,
1697
+ )
1698
+ }
1699
+ return null
1700
+
1701
+ case "IfStatement":
1702
+ case "WhileStatement":
1703
+ if (parent.test === node) {
1704
+ return sourceCode.getFirstToken(parent, 1)
1705
+ }
1706
+ return null
1707
+
1708
+ case "ImportExpression":
1709
+ if (parent.source === node) {
1710
+ return sourceCode.getFirstToken(parent, 1)
1711
+ }
1712
+ return null
1713
+
1714
+ case "SwitchStatement":
1715
+ if (parent.discriminant === node) {
1716
+ return sourceCode.getFirstToken(parent, 1)
1717
+ }
1718
+ return null
1719
+
1720
+ case "WithStatement":
1721
+ if (parent.object === node) {
1722
+ return sourceCode.getFirstToken(parent, 1)
1723
+ }
1724
+ return null
1725
+
1726
+ default:
1727
+ return null
1728
+ }
1729
+ }
1730
+
1731
+ /**
1732
+ * Check whether a given node is parenthesized or not.
1733
+ * @param {number} times The number of parantheses.
1734
+ * @param {Node} node The AST node to check.
1735
+ * @param {SourceCode} sourceCode The source code object to get tokens.
1736
+ * @returns {boolean} `true` if the node is parenthesized the given times.
1737
+ */
1738
+ /**
1739
+ * Check whether a given node is parenthesized or not.
1740
+ * @param {Node} node The AST node to check.
1741
+ * @param {SourceCode} sourceCode The source code object to get tokens.
1742
+ * @returns {boolean} `true` if the node is parenthesized.
1743
+ */
1744
+ /**
1745
+ * Check whether a given node is parenthesized or not.
1746
+ * @param {Node|number} timesOrNode The first parameter.
1747
+ * @param {Node|SourceCode} nodeOrSourceCode The second parameter.
1748
+ * @param {SourceCode} [optionalSourceCode] The third parameter.
1749
+ * @returns {boolean} `true` if the node is parenthesized.
1750
+ */
1751
+ function isParenthesized(
1752
+ timesOrNode,
1753
+ nodeOrSourceCode,
1754
+ optionalSourceCode,
1755
+ ) {
1756
+ /** @type {number} */
1757
+ let times,
1758
+ /** @type {RuleNode} */
1759
+ node,
1760
+ /** @type {SourceCode} */
1761
+ sourceCode,
1762
+ maybeLeftParen,
1763
+ maybeRightParen;
1764
+ if (typeof timesOrNode === "number") {
1765
+ times = timesOrNode | 0;
1766
+ node = /** @type {RuleNode} */ (nodeOrSourceCode);
1767
+ sourceCode = /** @type {SourceCode} */ (optionalSourceCode);
1768
+ if (!(times >= 1)) {
1769
+ throw new TypeError("'times' should be a positive integer.")
1770
+ }
1771
+ } else {
1772
+ times = 1;
1773
+ node = /** @type {RuleNode} */ (timesOrNode);
1774
+ sourceCode = /** @type {SourceCode} */ (nodeOrSourceCode);
1775
+ }
1776
+
1777
+ if (
1778
+ node == null ||
1779
+ // `Program` can't be parenthesized
1780
+ node.parent == null ||
1781
+ // `CatchClause.param` can't be parenthesized, example `try {} catch (error) {}`
1782
+ (node.parent.type === "CatchClause" && node.parent.param === node)
1783
+ ) {
1784
+ return false
1785
+ }
1786
+
1787
+ maybeLeftParen = maybeRightParen = node;
1788
+ do {
1789
+ maybeLeftParen = sourceCode.getTokenBefore(maybeLeftParen);
1790
+ maybeRightParen = sourceCode.getTokenAfter(maybeRightParen);
1791
+ } while (
1792
+ maybeLeftParen != null &&
1793
+ maybeRightParen != null &&
1794
+ isOpeningParenToken(maybeLeftParen) &&
1795
+ isClosingParenToken(maybeRightParen) &&
1796
+ // Avoid false positive such as `if (a) {}`
1797
+ maybeLeftParen !== getParentSyntaxParen(node, sourceCode) &&
1798
+ --times > 0
1799
+ )
1800
+
1801
+ return times === 0
1802
+ }
1803
+
1804
+ /**
1805
+ * @author Toru Nagashima <https://github.com/mysticatea>
1806
+ * See LICENSE file in root directory for full license.
1807
+ */
1808
+
1809
+ const placeholder = /\$(?:[$&`']|[1-9][0-9]?)/gu;
1810
+
1811
+ /** @type {WeakMap<PatternMatcher, {pattern:RegExp,escaped:boolean}>} */
1812
+ const internal = new WeakMap();
1813
+
1814
+ /**
1815
+ * Check whether a given character is escaped or not.
1816
+ * @param {string} str The string to check.
1817
+ * @param {number} index The location of the character to check.
1818
+ * @returns {boolean} `true` if the character is escaped.
1819
+ */
1820
+ function isEscaped(str, index) {
1821
+ let escaped = false;
1822
+ for (let i = index - 1; i >= 0 && str.charCodeAt(i) === 0x5c; --i) {
1823
+ escaped = !escaped;
1824
+ }
1825
+ return escaped
1826
+ }
1827
+
1828
+ /**
1829
+ * Replace a given string by a given matcher.
1830
+ * @param {PatternMatcher} matcher The pattern matcher.
1831
+ * @param {string} str The string to be replaced.
1832
+ * @param {string} replacement The new substring to replace each matched part.
1833
+ * @returns {string} The replaced string.
1834
+ */
1835
+ function replaceS(matcher, str, replacement) {
1836
+ const chunks = [];
1837
+ let index = 0;
1838
+
1839
+ /**
1840
+ * @param {string} key The placeholder.
1841
+ * @param {RegExpExecArray} match The matched information.
1842
+ * @returns {string} The replaced string.
1843
+ */
1844
+ function replacer(key, match) {
1845
+ switch (key) {
1846
+ case "$$":
1847
+ return "$"
1848
+ case "$&":
1849
+ return match[0]
1850
+ case "$`":
1851
+ return str.slice(0, match.index)
1852
+ case "$'":
1853
+ return str.slice(match.index + match[0].length)
1854
+ default: {
1855
+ const i = key.slice(1);
1856
+ if (i in match) {
1857
+ return match[/** @type {any} */ (i)]
1858
+ }
1859
+ return key
1860
+ }
1861
+ }
1862
+ }
1863
+
1864
+ for (const match of matcher.execAll(str)) {
1865
+ chunks.push(str.slice(index, match.index));
1866
+ chunks.push(
1867
+ replacement.replace(placeholder, (key) => replacer(key, match)),
1868
+ );
1869
+ index = match.index + match[0].length;
1870
+ }
1871
+ chunks.push(str.slice(index));
1872
+
1873
+ return chunks.join("")
1874
+ }
1875
+
1876
+ /**
1877
+ * Replace a given string by a given matcher.
1878
+ * @param {PatternMatcher} matcher The pattern matcher.
1879
+ * @param {string} str The string to be replaced.
1880
+ * @param {(substring: string, ...args: any[]) => string} replace The function to replace each matched part.
1881
+ * @returns {string} The replaced string.
1882
+ */
1883
+ function replaceF(matcher, str, replace) {
1884
+ const chunks = [];
1885
+ let index = 0;
1886
+
1887
+ for (const match of matcher.execAll(str)) {
1888
+ chunks.push(str.slice(index, match.index));
1889
+ chunks.push(
1890
+ String(
1891
+ replace(
1892
+ .../** @type {[string, ...string[]]} */ (
1893
+ /** @type {string[]} */ (match)
1894
+ ),
1895
+ match.index,
1896
+ match.input,
1897
+ ),
1898
+ ),
1899
+ );
1900
+ index = match.index + match[0].length;
1901
+ }
1902
+ chunks.push(str.slice(index));
1903
+
1904
+ return chunks.join("")
1905
+ }
1906
+
1907
+ /**
1908
+ * The class to find patterns as considering escape sequences.
1909
+ */
1910
+ class PatternMatcher {
1911
+ /**
1912
+ * Initialize this matcher.
1913
+ * @param {RegExp} pattern The pattern to match.
1914
+ * @param {{escaped?:boolean}} [options] The options.
1915
+ */
1916
+ constructor(pattern, options = {}) {
1917
+ const { escaped = false } = options;
1918
+ if (!(pattern instanceof RegExp)) {
1919
+ throw new TypeError("'pattern' should be a RegExp instance.")
1920
+ }
1921
+ if (!pattern.flags.includes("g")) {
1922
+ throw new Error("'pattern' should contains 'g' flag.")
1923
+ }
1924
+
1925
+ internal.set(this, {
1926
+ pattern: new RegExp(pattern.source, pattern.flags),
1927
+ escaped: Boolean(escaped),
1928
+ });
1929
+ }
1930
+
1931
+ /**
1932
+ * Find the pattern in a given string.
1933
+ * @param {string} str The string to find.
1934
+ * @returns {IterableIterator<RegExpExecArray>} The iterator which iterate the matched information.
1935
+ */
1936
+ *execAll(str) {
1937
+ const { pattern, escaped } =
1938
+ /** @type {{pattern:RegExp,escaped:boolean}} */ (internal.get(this));
1939
+ let match = null;
1940
+ let lastIndex = 0;
1941
+
1942
+ pattern.lastIndex = 0;
1943
+ while ((match = pattern.exec(str)) != null) {
1944
+ if (escaped || !isEscaped(str, match.index)) {
1945
+ lastIndex = pattern.lastIndex;
1946
+ yield match;
1947
+ pattern.lastIndex = lastIndex;
1948
+ }
1949
+ }
1950
+ }
1951
+
1952
+ /**
1953
+ * Check whether the pattern is found in a given string.
1954
+ * @param {string} str The string to check.
1955
+ * @returns {boolean} `true` if the pattern was found in the string.
1956
+ */
1957
+ test(str) {
1958
+ const it = this.execAll(str);
1959
+ const ret = it.next();
1960
+ return !ret.done
1961
+ }
1962
+
1963
+ /**
1964
+ * Replace a given string.
1965
+ * @param {string} str The string to be replaced.
1966
+ * @param {(string|((...strs:string[])=>string))} replacer The string or function to replace. This is the same as the 2nd argument of `String.prototype.replace`.
1967
+ * @returns {string} The replaced string.
1968
+ */
1969
+ [Symbol.replace](str, replacer) {
1970
+ return typeof replacer === "function"
1971
+ ? replaceF(this, String(str), replacer)
1972
+ : replaceS(this, String(str), String(replacer))
1973
+ }
1974
+ }
1975
+
1976
+ /** @typedef {import("eslint").Scope.Scope} Scope */
1977
+ /** @typedef {import("eslint").Scope.Variable} Variable */
1978
+ /** @typedef {import("eslint").Rule.Node} RuleNode */
1979
+ /** @typedef {import("estree").Node} Node */
1980
+ /** @typedef {import("estree").Expression} Expression */
1981
+ /** @typedef {import("estree").Pattern} Pattern */
1982
+ /** @typedef {import("estree").Identifier} Identifier */
1983
+ /** @typedef {import("estree").SimpleCallExpression} CallExpression */
1984
+ /** @typedef {import("estree").Program} Program */
1985
+ /** @typedef {import("estree").ImportDeclaration} ImportDeclaration */
1986
+ /** @typedef {import("estree").ExportAllDeclaration} ExportAllDeclaration */
1987
+ /** @typedef {import("estree").ExportDefaultDeclaration} ExportDefaultDeclaration */
1988
+ /** @typedef {import("estree").ExportNamedDeclaration} ExportNamedDeclaration */
1989
+ /** @typedef {import("estree").ImportSpecifier} ImportSpecifier */
1990
+ /** @typedef {import("estree").ImportDefaultSpecifier} ImportDefaultSpecifier */
1991
+ /** @typedef {import("estree").ImportNamespaceSpecifier} ImportNamespaceSpecifier */
1992
+ /** @typedef {import("estree").ExportSpecifier} ExportSpecifier */
1993
+ /** @typedef {import("estree").Property} Property */
1994
+ /** @typedef {import("estree").AssignmentProperty} AssignmentProperty */
1995
+ /** @typedef {import("estree").Literal} Literal */
1996
+ /** @typedef {import("@typescript-eslint/types").TSESTree.Node} TSESTreeNode */
1997
+ /** @typedef {import("./types.mjs").ReferenceTrackerOptions} ReferenceTrackerOptions */
1998
+ /**
1999
+ * @template T
2000
+ * @typedef {import("./types.mjs").TraceMap<T>} TraceMap
2001
+ */
2002
+ /**
2003
+ * @template T
2004
+ * @typedef {import("./types.mjs").TraceMapObject<T>} TraceMapObject
2005
+ */
2006
+ /**
2007
+ * @template T
2008
+ * @typedef {import("./types.mjs").TrackedReferences<T>} TrackedReferences
2009
+ */
2010
+
2011
+ const IMPORT_TYPE = /^(?:Import|Export(?:All|Default|Named))Declaration$/u;
2012
+
2013
+ /**
2014
+ * Check whether a given node is an import node or not.
2015
+ * @param {Node} node
2016
+ * @returns {node is ImportDeclaration|ExportAllDeclaration|ExportNamedDeclaration&{source: Literal}} `true` if the node is an import node.
2017
+ */
2018
+ function isHasSource(node) {
2019
+ return (
2020
+ IMPORT_TYPE.test(node.type) &&
2021
+ /** @type {ImportDeclaration|ExportAllDeclaration|ExportNamedDeclaration} */ (
2022
+ node
2023
+ ).source != null
2024
+ )
2025
+ }
2026
+ const has =
2027
+ /** @type {<T>(traceMap: TraceMap<unknown>, v: T) => v is (string extends T ? string : T)} */ (
2028
+ Function.call.bind(Object.hasOwnProperty)
2029
+ );
2030
+
2031
+ const READ = Symbol("read");
2032
+ const CALL = Symbol("call");
2033
+ const CONSTRUCT = Symbol("construct");
2034
+ const ESM = Symbol("esm");
2035
+
2036
+ const requireCall = { require: { [CALL]: true } };
2037
+
2038
+ /**
2039
+ * Check whether a given variable is modified or not.
2040
+ * @param {Variable|undefined} variable The variable to check.
2041
+ * @returns {boolean} `true` if the variable is modified.
2042
+ */
2043
+ function isModifiedGlobal(variable) {
2044
+ return (
2045
+ variable == null ||
2046
+ variable.defs.length !== 0 ||
2047
+ variable.references.some((r) => r.isWrite())
2048
+ )
2049
+ }
2050
+
2051
+ /**
2052
+ * Check if the value of a given node is passed through to the parent syntax as-is.
2053
+ * For example, `a` and `b` in (`a || b` and `c ? a : b`) are passed through.
2054
+ * @param {Node} node A node to check.
2055
+ * @returns {node is RuleNode & {parent: Expression}} `true` if the node is passed through.
2056
+ */
2057
+ function isPassThrough(node) {
2058
+ const parent = /** @type {TSESTreeNode} */ (node).parent;
2059
+
2060
+ if (parent) {
2061
+ switch (parent.type) {
2062
+ case "ConditionalExpression":
2063
+ return parent.consequent === node || parent.alternate === node
2064
+ case "LogicalExpression":
2065
+ return true
2066
+ case "SequenceExpression":
2067
+ return (
2068
+ parent.expressions[parent.expressions.length - 1] === node
2069
+ )
2070
+ case "ChainExpression":
2071
+ return true
2072
+ case "TSAsExpression":
2073
+ case "TSSatisfiesExpression":
2074
+ case "TSTypeAssertion":
2075
+ case "TSNonNullExpression":
2076
+ case "TSInstantiationExpression":
2077
+ return true
2078
+
2079
+ default:
2080
+ return false
2081
+ }
2082
+ }
2083
+ return false
2084
+ }
2085
+
2086
+ /**
2087
+ * The reference tracker.
2088
+ */
2089
+ class ReferenceTracker {
2090
+ /**
2091
+ * Initialize this tracker.
2092
+ * @param {Scope} globalScope The global scope.
2093
+ * @param {object} [options] The options.
2094
+ * @param {"legacy"|"strict"} [options.mode="strict"] The mode to determine the ImportDeclaration's behavior for CJS modules.
2095
+ * @param {string[]} [options.globalObjectNames=["global","globalThis","self","window"]] The variable names for Global Object.
2096
+ */
2097
+ constructor(globalScope, options = {}) {
2098
+ const {
2099
+ mode = "strict",
2100
+ globalObjectNames = ["global", "globalThis", "self", "window"],
2101
+ } = options;
2102
+ /** @private @type {Variable[]} */
2103
+ this.variableStack = [];
2104
+ /** @private */
2105
+ this.globalScope = globalScope;
2106
+ /** @private */
2107
+ this.mode = mode;
2108
+ /** @private */
2109
+ this.globalObjectNames = globalObjectNames.slice(0);
2110
+ }
2111
+
2112
+ /**
2113
+ * Iterate the references of global variables.
2114
+ * @template T
2115
+ * @param {TraceMap<T>} traceMap The trace map.
2116
+ * @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate references.
2117
+ */
2118
+ *iterateGlobalReferences(traceMap) {
2119
+ for (const key of Object.keys(traceMap)) {
2120
+ const nextTraceMap = traceMap[key];
2121
+ const path = [key];
2122
+ const variable = this.globalScope.set.get(key);
2123
+
2124
+ if (isModifiedGlobal(variable)) {
2125
+ continue
2126
+ }
2127
+
2128
+ yield* this._iterateVariableReferences(
2129
+ /** @type {Variable} */ (variable),
2130
+ path,
2131
+ nextTraceMap,
2132
+ true,
2133
+ );
2134
+ }
2135
+
2136
+ for (const key of this.globalObjectNames) {
2137
+ /** @type {string[]} */
2138
+ const path = [];
2139
+ const variable = this.globalScope.set.get(key);
2140
+
2141
+ if (isModifiedGlobal(variable)) {
2142
+ continue
2143
+ }
2144
+
2145
+ yield* this._iterateVariableReferences(
2146
+ /** @type {Variable} */ (variable),
2147
+ path,
2148
+ traceMap,
2149
+ false,
2150
+ );
2151
+ }
2152
+ }
2153
+
2154
+ /**
2155
+ * Iterate the references of CommonJS modules.
2156
+ * @template T
2157
+ * @param {TraceMap<T>} traceMap The trace map.
2158
+ * @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate references.
2159
+ */
2160
+ *iterateCjsReferences(traceMap) {
2161
+ for (const { node } of this.iterateGlobalReferences(requireCall)) {
2162
+ const key = getStringIfConstant(
2163
+ /** @type {CallExpression} */ (node).arguments[0],
2164
+ );
2165
+ if (key == null || !has(traceMap, key)) {
2166
+ continue
2167
+ }
2168
+
2169
+ const nextTraceMap = traceMap[key];
2170
+ const path = [key];
2171
+
2172
+ if (nextTraceMap[READ]) {
2173
+ yield {
2174
+ node,
2175
+ path,
2176
+ type: READ,
2177
+ info: nextTraceMap[READ],
2178
+ };
2179
+ }
2180
+ yield* this._iteratePropertyReferences(
2181
+ /** @type {CallExpression} */ (node),
2182
+ path,
2183
+ nextTraceMap,
2184
+ );
2185
+ }
2186
+ }
2187
+
2188
+ /**
2189
+ * Iterate the references of ES modules.
2190
+ * @template T
2191
+ * @param {TraceMap<T>} traceMap The trace map.
2192
+ * @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate references.
2193
+ */
2194
+ *iterateEsmReferences(traceMap) {
2195
+ const programNode = /** @type {Program} */ (this.globalScope.block);
2196
+
2197
+ for (const node of programNode.body) {
2198
+ if (!isHasSource(node)) {
2199
+ continue
2200
+ }
2201
+ const moduleId = /** @type {string} */ (node.source.value);
2202
+
2203
+ if (!has(traceMap, moduleId)) {
2204
+ continue
2205
+ }
2206
+ const nextTraceMap = traceMap[moduleId];
2207
+ const path = [moduleId];
2208
+
2209
+ if (nextTraceMap[READ]) {
2210
+ yield {
2211
+ // eslint-disable-next-line object-shorthand -- apply type
2212
+ node: /** @type {RuleNode} */ (node),
2213
+ path,
2214
+ type: READ,
2215
+ info: nextTraceMap[READ],
2216
+ };
2217
+ }
2218
+
2219
+ if (node.type === "ExportAllDeclaration") {
2220
+ for (const key of Object.keys(nextTraceMap)) {
2221
+ const exportTraceMap = nextTraceMap[key];
2222
+ if (exportTraceMap[READ]) {
2223
+ yield {
2224
+ // eslint-disable-next-line object-shorthand -- apply type
2225
+ node: /** @type {RuleNode} */ (node),
2226
+ path: path.concat(key),
2227
+ type: READ,
2228
+ info: exportTraceMap[READ],
2229
+ };
2230
+ }
2231
+ }
2232
+ } else {
2233
+ for (const specifier of node.specifiers) {
2234
+ const esm = has(nextTraceMap, ESM);
2235
+ const it = this._iterateImportReferences(
2236
+ specifier,
2237
+ path,
2238
+ esm
2239
+ ? nextTraceMap
2240
+ : this.mode === "legacy"
2241
+ ? { default: nextTraceMap, ...nextTraceMap }
2242
+ : { default: nextTraceMap },
2243
+ );
2244
+
2245
+ if (esm) {
2246
+ yield* it;
2247
+ } else {
2248
+ for (const report of it) {
2249
+ report.path = report.path.filter(exceptDefault);
2250
+ if (
2251
+ report.path.length >= 2 ||
2252
+ report.type !== READ
2253
+ ) {
2254
+ yield report;
2255
+ }
2256
+ }
2257
+ }
2258
+ }
2259
+ }
2260
+ }
2261
+ }
2262
+
2263
+ /**
2264
+ * Iterate the property references for a given expression AST node.
2265
+ * @template T
2266
+ * @param {Expression} node The expression AST node to iterate property references.
2267
+ * @param {TraceMap<T>} traceMap The trace map.
2268
+ * @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate property references.
2269
+ */
2270
+ *iteratePropertyReferences(node, traceMap) {
2271
+ yield* this._iteratePropertyReferences(node, [], traceMap);
2272
+ }
2273
+
2274
+ /**
2275
+ * Iterate the references for a given variable.
2276
+ * @private
2277
+ * @template T
2278
+ * @param {Variable} variable The variable to iterate that references.
2279
+ * @param {string[]} path The current path.
2280
+ * @param {TraceMapObject<T>} traceMap The trace map.
2281
+ * @param {boolean} shouldReport = The flag to report those references.
2282
+ * @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate references.
2283
+ */
2284
+ *_iterateVariableReferences(variable, path, traceMap, shouldReport) {
2285
+ if (this.variableStack.includes(variable)) {
2286
+ return
2287
+ }
2288
+ this.variableStack.push(variable);
2289
+ try {
2290
+ for (const reference of variable.references) {
2291
+ if (!reference.isRead()) {
2292
+ continue
2293
+ }
2294
+ const node = /** @type {RuleNode & Identifier} */ (
2295
+ reference.identifier
2296
+ );
2297
+
2298
+ if (shouldReport && traceMap[READ]) {
2299
+ yield { node, path, type: READ, info: traceMap[READ] };
2300
+ }
2301
+ yield* this._iteratePropertyReferences(node, path, traceMap);
2302
+ }
2303
+ } finally {
2304
+ this.variableStack.pop();
2305
+ }
2306
+ }
2307
+
2308
+ /**
2309
+ * Iterate the references for a given AST node.
2310
+ * @private
2311
+ * @template T
2312
+ * @param {Expression} rootNode The AST node to iterate references.
2313
+ * @param {string[]} path The current path.
2314
+ * @param {TraceMapObject<T>} traceMap The trace map.
2315
+ * @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate references.
2316
+ */
2317
+ //eslint-disable-next-line complexity
2318
+ *_iteratePropertyReferences(rootNode, path, traceMap) {
2319
+ let node = rootNode;
2320
+ while (isPassThrough(node)) {
2321
+ node = node.parent;
2322
+ }
2323
+
2324
+ const parent = /** @type {RuleNode} */ (node).parent;
2325
+ if (!parent) {
2326
+ return
2327
+ }
2328
+ if (parent.type === "MemberExpression") {
2329
+ if (parent.object === node) {
2330
+ const key = getPropertyName(parent);
2331
+ if (key == null || !has(traceMap, key)) {
2332
+ return
2333
+ }
2334
+
2335
+ path = path.concat(key); //eslint-disable-line no-param-reassign
2336
+ const nextTraceMap = traceMap[key];
2337
+ if (nextTraceMap[READ]) {
2338
+ yield {
2339
+ node: parent,
2340
+ path,
2341
+ type: READ,
2342
+ info: nextTraceMap[READ],
2343
+ };
2344
+ }
2345
+ yield* this._iteratePropertyReferences(
2346
+ parent,
2347
+ path,
2348
+ nextTraceMap,
2349
+ );
2350
+ }
2351
+ return
2352
+ }
2353
+ if (parent.type === "CallExpression") {
2354
+ if (parent.callee === node && traceMap[CALL]) {
2355
+ yield { node: parent, path, type: CALL, info: traceMap[CALL] };
2356
+ }
2357
+ return
2358
+ }
2359
+ if (parent.type === "NewExpression") {
2360
+ if (parent.callee === node && traceMap[CONSTRUCT]) {
2361
+ yield {
2362
+ node: parent,
2363
+ path,
2364
+ type: CONSTRUCT,
2365
+ info: traceMap[CONSTRUCT],
2366
+ };
2367
+ }
2368
+ return
2369
+ }
2370
+ if (parent.type === "AssignmentExpression") {
2371
+ if (parent.right === node) {
2372
+ yield* this._iterateLhsReferences(parent.left, path, traceMap);
2373
+ yield* this._iteratePropertyReferences(parent, path, traceMap);
2374
+ }
2375
+ return
2376
+ }
2377
+ if (parent.type === "AssignmentPattern") {
2378
+ if (parent.right === node) {
2379
+ yield* this._iterateLhsReferences(parent.left, path, traceMap);
2380
+ }
2381
+ return
2382
+ }
2383
+ if (parent.type === "VariableDeclarator") {
2384
+ if (parent.init === node) {
2385
+ yield* this._iterateLhsReferences(parent.id, path, traceMap);
2386
+ }
2387
+ }
2388
+ }
2389
+
2390
+ /**
2391
+ * Iterate the references for a given Pattern node.
2392
+ * @private
2393
+ * @template T
2394
+ * @param {Pattern} patternNode The Pattern node to iterate references.
2395
+ * @param {string[]} path The current path.
2396
+ * @param {TraceMapObject<T>} traceMap The trace map.
2397
+ * @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate references.
2398
+ */
2399
+ *_iterateLhsReferences(patternNode, path, traceMap) {
2400
+ if (patternNode.type === "Identifier") {
2401
+ const variable = findVariable(this.globalScope, patternNode);
2402
+ if (variable != null) {
2403
+ yield* this._iterateVariableReferences(
2404
+ variable,
2405
+ path,
2406
+ traceMap,
2407
+ false,
2408
+ );
2409
+ }
2410
+ return
2411
+ }
2412
+ if (patternNode.type === "ObjectPattern") {
2413
+ for (const property of patternNode.properties) {
2414
+ const key = getPropertyName(
2415
+ /** @type {AssignmentProperty} */ (property),
2416
+ );
2417
+
2418
+ if (key == null || !has(traceMap, key)) {
2419
+ continue
2420
+ }
2421
+
2422
+ const nextPath = path.concat(key);
2423
+ const nextTraceMap = traceMap[key];
2424
+ if (nextTraceMap[READ]) {
2425
+ yield {
2426
+ node: /** @type {RuleNode} */ (property),
2427
+ path: nextPath,
2428
+ type: READ,
2429
+ info: nextTraceMap[READ],
2430
+ };
2431
+ }
2432
+ yield* this._iterateLhsReferences(
2433
+ /** @type {AssignmentProperty} */ (property).value,
2434
+ nextPath,
2435
+ nextTraceMap,
2436
+ );
2437
+ }
2438
+ return
2439
+ }
2440
+ if (patternNode.type === "AssignmentPattern") {
2441
+ yield* this._iterateLhsReferences(patternNode.left, path, traceMap);
2442
+ }
2443
+ }
2444
+
2445
+ /**
2446
+ * Iterate the references for a given ModuleSpecifier node.
2447
+ * @private
2448
+ * @template T
2449
+ * @param {ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier} specifierNode The ModuleSpecifier node to iterate references.
2450
+ * @param {string[]} path The current path.
2451
+ * @param {TraceMapObject<T>} traceMap The trace map.
2452
+ * @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate references.
2453
+ */
2454
+ *_iterateImportReferences(specifierNode, path, traceMap) {
2455
+ const type = specifierNode.type;
2456
+
2457
+ if (type === "ImportSpecifier" || type === "ImportDefaultSpecifier") {
2458
+ const key =
2459
+ type === "ImportDefaultSpecifier"
2460
+ ? "default"
2461
+ : specifierNode.imported.type === "Identifier"
2462
+ ? specifierNode.imported.name
2463
+ : specifierNode.imported.value;
2464
+ if (!has(traceMap, key)) {
2465
+ return
2466
+ }
2467
+
2468
+ path = path.concat(key); //eslint-disable-line no-param-reassign
2469
+ const nextTraceMap = traceMap[key];
2470
+ if (nextTraceMap[READ]) {
2471
+ yield {
2472
+ node: /** @type {RuleNode} */ (specifierNode),
2473
+ path,
2474
+ type: READ,
2475
+ info: nextTraceMap[READ],
2476
+ };
2477
+ }
2478
+ yield* this._iterateVariableReferences(
2479
+ /** @type {Variable} */ (
2480
+ findVariable(this.globalScope, specifierNode.local)
2481
+ ),
2482
+ path,
2483
+ nextTraceMap,
2484
+ false,
2485
+ );
2486
+
2487
+ return
2488
+ }
2489
+
2490
+ if (type === "ImportNamespaceSpecifier") {
2491
+ yield* this._iterateVariableReferences(
2492
+ /** @type {Variable} */ (
2493
+ findVariable(this.globalScope, specifierNode.local)
2494
+ ),
2495
+ path,
2496
+ traceMap,
2497
+ false,
2498
+ );
2499
+ return
2500
+ }
2501
+
2502
+ if (type === "ExportSpecifier") {
2503
+ const key =
2504
+ specifierNode.local.type === "Identifier"
2505
+ ? specifierNode.local.name
2506
+ : specifierNode.local.value;
2507
+ if (!has(traceMap, key)) {
2508
+ return
2509
+ }
2510
+
2511
+ path = path.concat(key); //eslint-disable-line no-param-reassign
2512
+ const nextTraceMap = traceMap[key];
2513
+ if (nextTraceMap[READ]) {
2514
+ yield {
2515
+ node: /** @type {RuleNode} */ (specifierNode),
2516
+ path,
2517
+ type: READ,
2518
+ info: nextTraceMap[READ],
2519
+ };
2520
+ }
2521
+ }
2522
+ }
2523
+ }
2524
+
2525
+ ReferenceTracker.READ = READ;
2526
+ ReferenceTracker.CALL = CALL;
2527
+ ReferenceTracker.CONSTRUCT = CONSTRUCT;
2528
+ ReferenceTracker.ESM = ESM;
2529
+
2530
+ /**
2531
+ * This is a predicate function for Array#filter.
2532
+ * @param {string} name A name part.
2533
+ * @param {number} index The index of the name.
2534
+ * @returns {boolean} `false` if it's default.
2535
+ */
2536
+ function exceptDefault(name, index) {
2537
+ return !(index === 1 && name === "default")
2538
+ }
2539
+
2540
+ /** @typedef {import("./types.mjs").StaticValue} StaticValue */
2541
+
2542
+ var index = {
2543
+ CALL,
2544
+ CONSTRUCT,
2545
+ ESM,
2546
+ findVariable,
2547
+ getFunctionHeadLocation,
2548
+ getFunctionNameWithKind,
2549
+ getInnermostScope,
2550
+ getPropertyName,
2551
+ getStaticValue,
2552
+ getStringIfConstant,
2553
+ hasSideEffect,
2554
+ isArrowToken,
2555
+ isClosingBraceToken,
2556
+ isClosingBracketToken,
2557
+ isClosingParenToken,
2558
+ isColonToken,
2559
+ isCommaToken,
2560
+ isCommentToken,
2561
+ isNotArrowToken,
2562
+ isNotClosingBraceToken,
2563
+ isNotClosingBracketToken,
2564
+ isNotClosingParenToken,
2565
+ isNotColonToken,
2566
+ isNotCommaToken,
2567
+ isNotCommentToken,
2568
+ isNotOpeningBraceToken,
2569
+ isNotOpeningBracketToken,
2570
+ isNotOpeningParenToken,
2571
+ isNotSemicolonToken,
2572
+ isOpeningBraceToken,
2573
+ isOpeningBracketToken,
2574
+ isOpeningParenToken,
2575
+ isParenthesized,
2576
+ isSemicolonToken,
2577
+ PatternMatcher,
2578
+ READ,
2579
+ ReferenceTracker,
2580
+ };
2581
+
2582
+ exports.CALL = CALL;
2583
+ exports.CONSTRUCT = CONSTRUCT;
2584
+ exports.ESM = ESM;
2585
+ exports.PatternMatcher = PatternMatcher;
2586
+ exports.READ = READ;
2587
+ exports.ReferenceTracker = ReferenceTracker;
2588
+ exports["default"] = index;
2589
+ exports.findVariable = findVariable;
2590
+ exports.getFunctionHeadLocation = getFunctionHeadLocation;
2591
+ exports.getFunctionNameWithKind = getFunctionNameWithKind;
2592
+ exports.getInnermostScope = getInnermostScope;
2593
+ exports.getPropertyName = getPropertyName;
2594
+ exports.getStaticValue = getStaticValue;
2595
+ exports.getStringIfConstant = getStringIfConstant;
2596
+ exports.hasSideEffect = hasSideEffect;
2597
+ exports.isArrowToken = isArrowToken;
2598
+ exports.isClosingBraceToken = isClosingBraceToken;
2599
+ exports.isClosingBracketToken = isClosingBracketToken;
2600
+ exports.isClosingParenToken = isClosingParenToken;
2601
+ exports.isColonToken = isColonToken;
2602
+ exports.isCommaToken = isCommaToken;
2603
+ exports.isCommentToken = isCommentToken;
2604
+ exports.isNotArrowToken = isNotArrowToken;
2605
+ exports.isNotClosingBraceToken = isNotClosingBraceToken;
2606
+ exports.isNotClosingBracketToken = isNotClosingBracketToken;
2607
+ exports.isNotClosingParenToken = isNotClosingParenToken;
2608
+ exports.isNotColonToken = isNotColonToken;
2609
+ exports.isNotCommaToken = isNotCommaToken;
2610
+ exports.isNotCommentToken = isNotCommentToken;
2611
+ exports.isNotOpeningBraceToken = isNotOpeningBraceToken;
2612
+ exports.isNotOpeningBracketToken = isNotOpeningBracketToken;
2613
+ exports.isNotOpeningParenToken = isNotOpeningParenToken;
2614
+ exports.isNotSemicolonToken = isNotSemicolonToken;
2615
+ exports.isOpeningBraceToken = isOpeningBraceToken;
2616
+ exports.isOpeningBracketToken = isOpeningBracketToken;
2617
+ exports.isOpeningParenToken = isOpeningParenToken;
2618
+ exports.isParenthesized = isParenthesized;
2619
+ exports.isSemicolonToken = isSemicolonToken;
2620
+ //# sourceMappingURL=index.js.map
node_modules/@eslint-community/eslint-utils/index.js.map ADDED
The diff for this file is too large to render. See raw diff
 
node_modules/@eslint-community/eslint-utils/index.mjs ADDED
@@ -0,0 +1,2579 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { getKeys, KEYS } from 'eslint-visitor-keys';
2
+
3
+ /** @typedef {import("eslint").Scope.Scope} Scope */
4
+ /** @typedef {import("estree").Node} Node */
5
+
6
+ /**
7
+ * Get the innermost scope which contains a given location.
8
+ * @param {Scope} initialScope The initial scope to search.
9
+ * @param {Node} node The location to search.
10
+ * @returns {Scope} The innermost scope.
11
+ */
12
+ function getInnermostScope(initialScope, node) {
13
+ const location = /** @type {[number, number]} */ (node.range)[0];
14
+
15
+ let scope = initialScope;
16
+ let found = false;
17
+ do {
18
+ found = false;
19
+ for (const childScope of scope.childScopes) {
20
+ const range = /** @type {[number, number]} */ (
21
+ childScope.block.range
22
+ );
23
+
24
+ if (range[0] <= location && location < range[1]) {
25
+ scope = childScope;
26
+ found = true;
27
+ break
28
+ }
29
+ }
30
+ } while (found)
31
+
32
+ return scope
33
+ }
34
+
35
+ /** @typedef {import("eslint").Scope.Scope} Scope */
36
+ /** @typedef {import("eslint").Scope.Variable} Variable */
37
+ /** @typedef {import("estree").Identifier} Identifier */
38
+
39
+ /**
40
+ * Find the variable of a given name.
41
+ * @param {Scope} initialScope The scope to start finding.
42
+ * @param {string|Identifier} nameOrNode The variable name to find. If this is a Node object then it should be an Identifier node.
43
+ * @returns {Variable|null} The found variable or null.
44
+ */
45
+ function findVariable(initialScope, nameOrNode) {
46
+ let name = "";
47
+ /** @type {Scope|null} */
48
+ let scope = initialScope;
49
+
50
+ if (typeof nameOrNode === "string") {
51
+ name = nameOrNode;
52
+ } else {
53
+ name = nameOrNode.name;
54
+ scope = getInnermostScope(scope, nameOrNode);
55
+ }
56
+
57
+ while (scope != null) {
58
+ const variable = scope.set.get(name);
59
+ if (variable != null) {
60
+ return variable
61
+ }
62
+ scope = scope.upper;
63
+ }
64
+
65
+ return null
66
+ }
67
+
68
+ /** @typedef {import("eslint").AST.Token} Token */
69
+ /** @typedef {import("estree").Comment} Comment */
70
+ /** @typedef {import("./types.mjs").ArrowToken} ArrowToken */
71
+ /** @typedef {import("./types.mjs").CommaToken} CommaToken */
72
+ /** @typedef {import("./types.mjs").SemicolonToken} SemicolonToken */
73
+ /** @typedef {import("./types.mjs").ColonToken} ColonToken */
74
+ /** @typedef {import("./types.mjs").OpeningParenToken} OpeningParenToken */
75
+ /** @typedef {import("./types.mjs").ClosingParenToken} ClosingParenToken */
76
+ /** @typedef {import("./types.mjs").OpeningBracketToken} OpeningBracketToken */
77
+ /** @typedef {import("./types.mjs").ClosingBracketToken} ClosingBracketToken */
78
+ /** @typedef {import("./types.mjs").OpeningBraceToken} OpeningBraceToken */
79
+ /** @typedef {import("./types.mjs").ClosingBraceToken} ClosingBraceToken */
80
+ /**
81
+ * @template {string} Value
82
+ * @typedef {import("./types.mjs").PunctuatorToken<Value>} PunctuatorToken
83
+ */
84
+
85
+ /** @typedef {Comment | Token} CommentOrToken */
86
+
87
+ /**
88
+ * Creates the negate function of the given function.
89
+ * @param {function(CommentOrToken):boolean} f - The function to negate.
90
+ * @returns {function(CommentOrToken):boolean} Negated function.
91
+ */
92
+ function negate(f) {
93
+ return (token) => !f(token)
94
+ }
95
+
96
+ /**
97
+ * Checks if the given token is a PunctuatorToken with the given value
98
+ * @template {string} Value
99
+ * @param {CommentOrToken} token - The token to check.
100
+ * @param {Value} value - The value to check.
101
+ * @returns {token is PunctuatorToken<Value>} `true` if the token is a PunctuatorToken with the given value.
102
+ */
103
+ function isPunctuatorTokenWithValue(token, value) {
104
+ return token.type === "Punctuator" && token.value === value
105
+ }
106
+
107
+ /**
108
+ * Checks if the given token is an arrow token or not.
109
+ * @param {CommentOrToken} token - The token to check.
110
+ * @returns {token is ArrowToken} `true` if the token is an arrow token.
111
+ */
112
+ function isArrowToken(token) {
113
+ return isPunctuatorTokenWithValue(token, "=>")
114
+ }
115
+
116
+ /**
117
+ * Checks if the given token is a comma token or not.
118
+ * @param {CommentOrToken} token - The token to check.
119
+ * @returns {token is CommaToken} `true` if the token is a comma token.
120
+ */
121
+ function isCommaToken(token) {
122
+ return isPunctuatorTokenWithValue(token, ",")
123
+ }
124
+
125
+ /**
126
+ * Checks if the given token is a semicolon token or not.
127
+ * @param {CommentOrToken} token - The token to check.
128
+ * @returns {token is SemicolonToken} `true` if the token is a semicolon token.
129
+ */
130
+ function isSemicolonToken(token) {
131
+ return isPunctuatorTokenWithValue(token, ";")
132
+ }
133
+
134
+ /**
135
+ * Checks if the given token is a colon token or not.
136
+ * @param {CommentOrToken} token - The token to check.
137
+ * @returns {token is ColonToken} `true` if the token is a colon token.
138
+ */
139
+ function isColonToken(token) {
140
+ return isPunctuatorTokenWithValue(token, ":")
141
+ }
142
+
143
+ /**
144
+ * Checks if the given token is an opening parenthesis token or not.
145
+ * @param {CommentOrToken} token - The token to check.
146
+ * @returns {token is OpeningParenToken} `true` if the token is an opening parenthesis token.
147
+ */
148
+ function isOpeningParenToken(token) {
149
+ return isPunctuatorTokenWithValue(token, "(")
150
+ }
151
+
152
+ /**
153
+ * Checks if the given token is a closing parenthesis token or not.
154
+ * @param {CommentOrToken} token - The token to check.
155
+ * @returns {token is ClosingParenToken} `true` if the token is a closing parenthesis token.
156
+ */
157
+ function isClosingParenToken(token) {
158
+ return isPunctuatorTokenWithValue(token, ")")
159
+ }
160
+
161
+ /**
162
+ * Checks if the given token is an opening square bracket token or not.
163
+ * @param {CommentOrToken} token - The token to check.
164
+ * @returns {token is OpeningBracketToken} `true` if the token is an opening square bracket token.
165
+ */
166
+ function isOpeningBracketToken(token) {
167
+ return isPunctuatorTokenWithValue(token, "[")
168
+ }
169
+
170
+ /**
171
+ * Checks if the given token is a closing square bracket token or not.
172
+ * @param {CommentOrToken} token - The token to check.
173
+ * @returns {token is ClosingBracketToken} `true` if the token is a closing square bracket token.
174
+ */
175
+ function isClosingBracketToken(token) {
176
+ return isPunctuatorTokenWithValue(token, "]")
177
+ }
178
+
179
+ /**
180
+ * Checks if the given token is an opening brace token or not.
181
+ * @param {CommentOrToken} token - The token to check.
182
+ * @returns {token is OpeningBraceToken} `true` if the token is an opening brace token.
183
+ */
184
+ function isOpeningBraceToken(token) {
185
+ return isPunctuatorTokenWithValue(token, "{")
186
+ }
187
+
188
+ /**
189
+ * Checks if the given token is a closing brace token or not.
190
+ * @param {CommentOrToken} token - The token to check.
191
+ * @returns {token is ClosingBraceToken} `true` if the token is a closing brace token.
192
+ */
193
+ function isClosingBraceToken(token) {
194
+ return isPunctuatorTokenWithValue(token, "}")
195
+ }
196
+
197
+ /**
198
+ * Checks if the given token is a comment token or not.
199
+ * @param {CommentOrToken} token - The token to check.
200
+ * @returns {token is Comment} `true` if the token is a comment token.
201
+ */
202
+ function isCommentToken(token) {
203
+ return ["Block", "Line", "Shebang"].includes(token.type)
204
+ }
205
+
206
+ const isNotArrowToken = negate(isArrowToken);
207
+ const isNotCommaToken = negate(isCommaToken);
208
+ const isNotSemicolonToken = negate(isSemicolonToken);
209
+ const isNotColonToken = negate(isColonToken);
210
+ const isNotOpeningParenToken = negate(isOpeningParenToken);
211
+ const isNotClosingParenToken = negate(isClosingParenToken);
212
+ const isNotOpeningBracketToken = negate(isOpeningBracketToken);
213
+ const isNotClosingBracketToken = negate(isClosingBracketToken);
214
+ const isNotOpeningBraceToken = negate(isOpeningBraceToken);
215
+ const isNotClosingBraceToken = negate(isClosingBraceToken);
216
+ const isNotCommentToken = negate(isCommentToken);
217
+
218
+ /** @typedef {import("eslint").Rule.Node} RuleNode */
219
+ /** @typedef {import("eslint").SourceCode} SourceCode */
220
+ /** @typedef {import("eslint").AST.Token} Token */
221
+ /** @typedef {import("estree").Function} FunctionNode */
222
+ /** @typedef {import("estree").FunctionDeclaration} FunctionDeclaration */
223
+ /** @typedef {import("estree").FunctionExpression} FunctionExpression */
224
+ /** @typedef {import("estree").SourceLocation} SourceLocation */
225
+ /** @typedef {import("estree").Position} Position */
226
+
227
+ /**
228
+ * Get the `(` token of the given function node.
229
+ * @param {FunctionExpression | FunctionDeclaration} node - The function node to get.
230
+ * @param {SourceCode} sourceCode - The source code object to get tokens.
231
+ * @returns {Token} `(` token.
232
+ */
233
+ function getOpeningParenOfParams(node, sourceCode) {
234
+ return node.id
235
+ ? /** @type {Token} */ (
236
+ sourceCode.getTokenAfter(node.id, isOpeningParenToken)
237
+ )
238
+ : /** @type {Token} */ (
239
+ sourceCode.getFirstToken(node, isOpeningParenToken)
240
+ )
241
+ }
242
+
243
+ /**
244
+ * Get the location of the given function node for reporting.
245
+ * @param {FunctionNode} node - The function node to get.
246
+ * @param {SourceCode} sourceCode - The source code object to get tokens.
247
+ * @returns {SourceLocation|null} The location of the function node for reporting.
248
+ */
249
+ function getFunctionHeadLocation(node, sourceCode) {
250
+ const parent = /** @type {RuleNode} */ (node).parent;
251
+
252
+ /** @type {Position|null} */
253
+ let start = null;
254
+ /** @type {Position|null} */
255
+ let end = null;
256
+
257
+ if (node.type === "ArrowFunctionExpression") {
258
+ const arrowToken = /** @type {Token} */ (
259
+ sourceCode.getTokenBefore(node.body, isArrowToken)
260
+ );
261
+
262
+ start = arrowToken.loc.start;
263
+ end = arrowToken.loc.end;
264
+ } else if (
265
+ parent &&
266
+ (parent.type === "Property" ||
267
+ parent.type === "MethodDefinition" ||
268
+ parent.type === "PropertyDefinition")
269
+ ) {
270
+ start = /** @type {SourceLocation} */ (parent.loc).start;
271
+ end = getOpeningParenOfParams(node, sourceCode).loc.start;
272
+ } else {
273
+ start = /** @type {SourceLocation} */ (node.loc).start;
274
+ end = getOpeningParenOfParams(node, sourceCode).loc.start;
275
+ }
276
+
277
+ return {
278
+ start: { ...start },
279
+ end: { ...end },
280
+ }
281
+ }
282
+
283
+ /* globals globalThis, global, self, window */
284
+ /** @typedef {import("./types.mjs").StaticValue} StaticValue */
285
+ /** @typedef {import("eslint").Scope.Scope} Scope */
286
+ /** @typedef {import("eslint").Scope.Variable} Variable */
287
+ /** @typedef {import("estree").Node} Node */
288
+ /** @typedef {import("@typescript-eslint/types").TSESTree.Node} TSESTreeNode */
289
+ /** @typedef {import("@typescript-eslint/types").TSESTree.AST_NODE_TYPES} TSESTreeNodeTypes */
290
+ /** @typedef {import("@typescript-eslint/types").TSESTree.MemberExpression} MemberExpression */
291
+ /** @typedef {import("@typescript-eslint/types").TSESTree.Property} Property */
292
+ /** @typedef {import("@typescript-eslint/types").TSESTree.RegExpLiteral} RegExpLiteral */
293
+ /** @typedef {import("@typescript-eslint/types").TSESTree.BigIntLiteral} BigIntLiteral */
294
+ /** @typedef {import("@typescript-eslint/types").TSESTree.Literal} Literal */
295
+
296
+ const globalObject =
297
+ typeof globalThis !== "undefined"
298
+ ? globalThis
299
+ : // @ts-ignore
300
+ typeof self !== "undefined"
301
+ ? // @ts-ignore
302
+ self
303
+ : // @ts-ignore
304
+ typeof window !== "undefined"
305
+ ? // @ts-ignore
306
+ window
307
+ : typeof global !== "undefined"
308
+ ? global
309
+ : {};
310
+
311
+ const builtinNames = Object.freeze(
312
+ new Set([
313
+ "Array",
314
+ "ArrayBuffer",
315
+ "BigInt",
316
+ "BigInt64Array",
317
+ "BigUint64Array",
318
+ "Boolean",
319
+ "DataView",
320
+ "Date",
321
+ "decodeURI",
322
+ "decodeURIComponent",
323
+ "encodeURI",
324
+ "encodeURIComponent",
325
+ "escape",
326
+ "Float32Array",
327
+ "Float64Array",
328
+ "Function",
329
+ "Infinity",
330
+ "Int16Array",
331
+ "Int32Array",
332
+ "Int8Array",
333
+ "isFinite",
334
+ "isNaN",
335
+ "isPrototypeOf",
336
+ "JSON",
337
+ "Map",
338
+ "Math",
339
+ "NaN",
340
+ "Number",
341
+ "Object",
342
+ "parseFloat",
343
+ "parseInt",
344
+ "Promise",
345
+ "Proxy",
346
+ "Reflect",
347
+ "RegExp",
348
+ "Set",
349
+ "String",
350
+ "Symbol",
351
+ "Uint16Array",
352
+ "Uint32Array",
353
+ "Uint8Array",
354
+ "Uint8ClampedArray",
355
+ "undefined",
356
+ "unescape",
357
+ "WeakMap",
358
+ "WeakSet",
359
+ ]),
360
+ );
361
+ const callAllowed = new Set(
362
+ [
363
+ Array.isArray,
364
+ Array.of,
365
+ Array.prototype.at,
366
+ Array.prototype.concat,
367
+ Array.prototype.entries,
368
+ Array.prototype.every,
369
+ Array.prototype.filter,
370
+ Array.prototype.find,
371
+ Array.prototype.findIndex,
372
+ Array.prototype.flat,
373
+ Array.prototype.includes,
374
+ Array.prototype.indexOf,
375
+ Array.prototype.join,
376
+ Array.prototype.keys,
377
+ Array.prototype.lastIndexOf,
378
+ Array.prototype.slice,
379
+ Array.prototype.some,
380
+ Array.prototype.toString,
381
+ Array.prototype.values,
382
+ typeof BigInt === "function" ? BigInt : undefined,
383
+ Boolean,
384
+ Date,
385
+ Date.parse,
386
+ decodeURI,
387
+ decodeURIComponent,
388
+ encodeURI,
389
+ encodeURIComponent,
390
+ escape,
391
+ isFinite,
392
+ isNaN,
393
+ // @ts-ignore
394
+ isPrototypeOf,
395
+ Map,
396
+ Map.prototype.entries,
397
+ Map.prototype.get,
398
+ Map.prototype.has,
399
+ Map.prototype.keys,
400
+ Map.prototype.values,
401
+ .../** @type {(keyof typeof Math)[]} */ (
402
+ Object.getOwnPropertyNames(Math)
403
+ )
404
+ .filter((k) => k !== "random")
405
+ .map((k) => Math[k])
406
+ .filter((f) => typeof f === "function"),
407
+ Number,
408
+ Number.isFinite,
409
+ Number.isNaN,
410
+ Number.parseFloat,
411
+ Number.parseInt,
412
+ Number.prototype.toExponential,
413
+ Number.prototype.toFixed,
414
+ Number.prototype.toPrecision,
415
+ Number.prototype.toString,
416
+ Object,
417
+ Object.entries,
418
+ Object.is,
419
+ Object.isExtensible,
420
+ Object.isFrozen,
421
+ Object.isSealed,
422
+ Object.keys,
423
+ Object.values,
424
+ parseFloat,
425
+ parseInt,
426
+ RegExp,
427
+ Set,
428
+ Set.prototype.entries,
429
+ Set.prototype.has,
430
+ Set.prototype.keys,
431
+ Set.prototype.values,
432
+ String,
433
+ String.fromCharCode,
434
+ String.fromCodePoint,
435
+ String.raw,
436
+ String.prototype.at,
437
+ String.prototype.charAt,
438
+ String.prototype.charCodeAt,
439
+ String.prototype.codePointAt,
440
+ String.prototype.concat,
441
+ String.prototype.endsWith,
442
+ String.prototype.includes,
443
+ String.prototype.indexOf,
444
+ String.prototype.lastIndexOf,
445
+ String.prototype.normalize,
446
+ String.prototype.padEnd,
447
+ String.prototype.padStart,
448
+ String.prototype.slice,
449
+ String.prototype.startsWith,
450
+ String.prototype.substr,
451
+ String.prototype.substring,
452
+ String.prototype.toLowerCase,
453
+ String.prototype.toString,
454
+ String.prototype.toUpperCase,
455
+ String.prototype.trim,
456
+ String.prototype.trimEnd,
457
+ String.prototype.trimLeft,
458
+ String.prototype.trimRight,
459
+ String.prototype.trimStart,
460
+ Symbol.for,
461
+ Symbol.keyFor,
462
+ unescape,
463
+ ].filter((f) => typeof f === "function"),
464
+ );
465
+ const callPassThrough = new Set([
466
+ Object.freeze,
467
+ Object.preventExtensions,
468
+ Object.seal,
469
+ ]);
470
+
471
+ /** @type {ReadonlyArray<readonly [Function, ReadonlySet<string>]>} */
472
+ const getterAllowed = [
473
+ [Map, new Set(["size"])],
474
+ [
475
+ RegExp,
476
+ new Set([
477
+ "dotAll",
478
+ "flags",
479
+ "global",
480
+ "hasIndices",
481
+ "ignoreCase",
482
+ "multiline",
483
+ "source",
484
+ "sticky",
485
+ "unicode",
486
+ ]),
487
+ ],
488
+ [Set, new Set(["size"])],
489
+ ];
490
+
491
+ /**
492
+ * Get the property descriptor.
493
+ * @param {object} object The object to get.
494
+ * @param {string|number|symbol} name The property name to get.
495
+ */
496
+ function getPropertyDescriptor(object, name) {
497
+ let x = object;
498
+ while ((typeof x === "object" || typeof x === "function") && x !== null) {
499
+ const d = Object.getOwnPropertyDescriptor(x, name);
500
+ if (d) {
501
+ return d
502
+ }
503
+ x = Object.getPrototypeOf(x);
504
+ }
505
+ return null
506
+ }
507
+
508
+ /**
509
+ * Check if a property is getter or not.
510
+ * @param {object} object The object to check.
511
+ * @param {string|number|symbol} name The property name to check.
512
+ */
513
+ function isGetter(object, name) {
514
+ const d = getPropertyDescriptor(object, name);
515
+ return d != null && d.get != null
516
+ }
517
+
518
+ /**
519
+ * Get the element values of a given node list.
520
+ * @param {(Node|TSESTreeNode|null)[]} nodeList The node list to get values.
521
+ * @param {Scope|undefined|null} initialScope The initial scope to find variables.
522
+ * @returns {any[]|null} The value list if all nodes are constant. Otherwise, null.
523
+ */
524
+ function getElementValues(nodeList, initialScope) {
525
+ const valueList = [];
526
+
527
+ for (let i = 0; i < nodeList.length; ++i) {
528
+ const elementNode = nodeList[i];
529
+
530
+ if (elementNode == null) {
531
+ valueList.length = i + 1;
532
+ } else if (elementNode.type === "SpreadElement") {
533
+ const argument = getStaticValueR(elementNode.argument, initialScope);
534
+ if (argument == null) {
535
+ return null
536
+ }
537
+ valueList.push(.../** @type {Iterable<any>} */ (argument.value));
538
+ } else {
539
+ const element = getStaticValueR(elementNode, initialScope);
540
+ if (element == null) {
541
+ return null
542
+ }
543
+ valueList.push(element.value);
544
+ }
545
+ }
546
+
547
+ return valueList
548
+ }
549
+
550
+ /**
551
+ * Checks if a variable is a built-in global.
552
+ * @param {Variable|null} variable The variable to check.
553
+ * @returns {variable is Variable & {defs:[]}}
554
+ */
555
+ function isBuiltinGlobal(variable) {
556
+ return (
557
+ variable != null &&
558
+ variable.defs.length === 0 &&
559
+ builtinNames.has(variable.name) &&
560
+ variable.name in globalObject
561
+ )
562
+ }
563
+
564
+ /**
565
+ * Checks if a variable can be considered as a constant.
566
+ * @param {Variable} variable
567
+ * @returns {variable is Variable & {defs: [import("eslint").Scope.Definition & { type: "Variable" }]}} True if the variable can be considered as a constant.
568
+ */
569
+ function canBeConsideredConst(variable) {
570
+ if (variable.defs.length !== 1) {
571
+ return false
572
+ }
573
+ const def = variable.defs[0];
574
+ return Boolean(
575
+ def.parent &&
576
+ def.type === "Variable" &&
577
+ (def.parent.kind === "const" || isEffectivelyConst(variable)),
578
+ )
579
+ }
580
+
581
+ /**
582
+ * Returns whether the given variable is never written to after initialization.
583
+ * @param {Variable} variable
584
+ * @returns {boolean}
585
+ */
586
+ function isEffectivelyConst(variable) {
587
+ const refs = variable.references;
588
+
589
+ const inits = refs.filter((r) => r.init).length;
590
+ const reads = refs.filter((r) => r.isReadOnly()).length;
591
+ if (inits === 1 && reads + inits === refs.length) {
592
+ // there is only one init and all other references only read
593
+ return true
594
+ }
595
+ return false
596
+ }
597
+
598
+ /**
599
+ * Checks if a variable has mutation in its property.
600
+ * @param {Variable} variable The variable to check.
601
+ * @param {Scope|null} initialScope The scope to start finding variable. Optional. If the node is a computed property node and this scope was given, this checks the computed property name by the `getStringIfConstant` function with the scope, and returns the value of it.
602
+ * @returns {boolean} True if the variable has mutation in its property.
603
+ */
604
+ function hasMutationInProperty(variable, initialScope) {
605
+ for (const ref of variable.references) {
606
+ let node = /** @type {TSESTreeNode} */ (ref.identifier);
607
+ while (node && node.parent && node.parent.type === "MemberExpression") {
608
+ node = node.parent;
609
+ }
610
+ if (!node || !node.parent) {
611
+ continue
612
+ }
613
+ if (
614
+ (node.parent.type === "AssignmentExpression" &&
615
+ node.parent.left === node) ||
616
+ (node.parent.type === "UpdateExpression" &&
617
+ node.parent.argument === node)
618
+ ) {
619
+ // This is a mutation.
620
+ return true
621
+ }
622
+ if (
623
+ node.parent.type === "CallExpression" &&
624
+ node.parent.callee === node &&
625
+ node.type === "MemberExpression"
626
+ ) {
627
+ const methodName = getStaticPropertyNameValue(node, initialScope);
628
+ if (isNameOfMutationArrayMethod(methodName)) {
629
+ // This is a mutation.
630
+ return true
631
+ }
632
+ }
633
+ }
634
+ return false
635
+
636
+ /**
637
+ * Checks if a method name is one of the mutation array methods.
638
+ * @param {StaticValue|null} methodName The method name to check.
639
+ * @returns {boolean} True if the method name is a mutation array method.
640
+ */
641
+ function isNameOfMutationArrayMethod(methodName) {
642
+ if (methodName == null || methodName.value == null) {
643
+ return false
644
+ }
645
+ const name = methodName.value;
646
+ return (
647
+ name === "copyWithin" ||
648
+ name === "fill" ||
649
+ name === "pop" ||
650
+ name === "push" ||
651
+ name === "reverse" ||
652
+ name === "shift" ||
653
+ name === "sort" ||
654
+ name === "splice" ||
655
+ name === "unshift"
656
+ )
657
+ }
658
+ }
659
+
660
+ /**
661
+ * @template {TSESTreeNodeTypes} T
662
+ * @callback VisitorCallback
663
+ * @param {TSESTreeNode & { type: T }} node
664
+ * @param {Scope|undefined|null} initialScope
665
+ * @returns {StaticValue | null}
666
+ */
667
+ /**
668
+ * @typedef { { [K in TSESTreeNodeTypes]?: VisitorCallback<K> } } Operations
669
+ */
670
+ /**
671
+ * @type {Operations}
672
+ */
673
+ const operations = Object.freeze({
674
+ ArrayExpression(node, initialScope) {
675
+ const elements = getElementValues(node.elements, initialScope);
676
+ return elements != null ? { value: elements } : null
677
+ },
678
+
679
+ AssignmentExpression(node, initialScope) {
680
+ if (node.operator === "=") {
681
+ return getStaticValueR(node.right, initialScope)
682
+ }
683
+ return null
684
+ },
685
+
686
+ //eslint-disable-next-line complexity
687
+ BinaryExpression(node, initialScope) {
688
+ if (node.operator === "in" || node.operator === "instanceof") {
689
+ // Not supported.
690
+ return null
691
+ }
692
+
693
+ const left = getStaticValueR(node.left, initialScope);
694
+ const right = getStaticValueR(node.right, initialScope);
695
+ if (left != null && right != null) {
696
+ switch (node.operator) {
697
+ case "==":
698
+ return { value: left.value == right.value } //eslint-disable-line eqeqeq
699
+ case "!=":
700
+ return { value: left.value != right.value } //eslint-disable-line eqeqeq
701
+ case "===":
702
+ return { value: left.value === right.value }
703
+ case "!==":
704
+ return { value: left.value !== right.value }
705
+ case "<":
706
+ return {
707
+ value:
708
+ /** @type {any} */ (left.value) <
709
+ /** @type {any} */ (right.value),
710
+ }
711
+ case "<=":
712
+ return {
713
+ value:
714
+ /** @type {any} */ (left.value) <=
715
+ /** @type {any} */ (right.value),
716
+ }
717
+ case ">":
718
+ return {
719
+ value:
720
+ /** @type {any} */ (left.value) >
721
+ /** @type {any} */ (right.value),
722
+ }
723
+ case ">=":
724
+ return {
725
+ value:
726
+ /** @type {any} */ (left.value) >=
727
+ /** @type {any} */ (right.value),
728
+ }
729
+ case "<<":
730
+ return {
731
+ value:
732
+ /** @type {any} */ (left.value) <<
733
+ /** @type {any} */ (right.value),
734
+ }
735
+ case ">>":
736
+ return {
737
+ value:
738
+ /** @type {any} */ (left.value) >>
739
+ /** @type {any} */ (right.value),
740
+ }
741
+ case ">>>":
742
+ return {
743
+ value:
744
+ /** @type {any} */ (left.value) >>>
745
+ /** @type {any} */ (right.value),
746
+ }
747
+ case "+":
748
+ return {
749
+ value:
750
+ /** @type {any} */ (left.value) +
751
+ /** @type {any} */ (right.value),
752
+ }
753
+ case "-":
754
+ return {
755
+ value:
756
+ /** @type {any} */ (left.value) -
757
+ /** @type {any} */ (right.value),
758
+ }
759
+ case "*":
760
+ return {
761
+ value:
762
+ /** @type {any} */ (left.value) *
763
+ /** @type {any} */ (right.value),
764
+ }
765
+ case "/":
766
+ return {
767
+ value:
768
+ /** @type {any} */ (left.value) /
769
+ /** @type {any} */ (right.value),
770
+ }
771
+ case "%":
772
+ return {
773
+ value:
774
+ /** @type {any} */ (left.value) %
775
+ /** @type {any} */ (right.value),
776
+ }
777
+ case "**":
778
+ return {
779
+ value:
780
+ /** @type {any} */ (left.value) **
781
+ /** @type {any} */ (right.value),
782
+ }
783
+ case "|":
784
+ return {
785
+ value:
786
+ /** @type {any} */ (left.value) |
787
+ /** @type {any} */ (right.value),
788
+ }
789
+ case "^":
790
+ return {
791
+ value:
792
+ /** @type {any} */ (left.value) ^
793
+ /** @type {any} */ (right.value),
794
+ }
795
+ case "&":
796
+ return {
797
+ value:
798
+ /** @type {any} */ (left.value) &
799
+ /** @type {any} */ (right.value),
800
+ }
801
+
802
+ // no default
803
+ }
804
+ }
805
+
806
+ return null
807
+ },
808
+
809
+ CallExpression(node, initialScope) {
810
+ const calleeNode = node.callee;
811
+ const args = getElementValues(node.arguments, initialScope);
812
+
813
+ if (args != null) {
814
+ if (calleeNode.type === "MemberExpression") {
815
+ if (calleeNode.property.type === "PrivateIdentifier") {
816
+ return null
817
+ }
818
+ const object = getStaticValueR(calleeNode.object, initialScope);
819
+ if (object != null) {
820
+ if (
821
+ object.value == null &&
822
+ (object.optional || node.optional)
823
+ ) {
824
+ return { value: undefined, optional: true }
825
+ }
826
+ const property = getStaticPropertyNameValue(
827
+ calleeNode,
828
+ initialScope,
829
+ );
830
+
831
+ if (property != null) {
832
+ const receiver =
833
+ /** @type {Record<PropertyKey, (...args: any[]) => any>} */ (
834
+ object.value
835
+ );
836
+ const methodName = /** @type {PropertyKey} */ (
837
+ property.value
838
+ );
839
+ if (callAllowed.has(receiver[methodName])) {
840
+ return {
841
+ value: receiver[methodName](...args),
842
+ }
843
+ }
844
+ if (callPassThrough.has(receiver[methodName])) {
845
+ return { value: args[0] }
846
+ }
847
+ }
848
+ }
849
+ } else {
850
+ const callee = getStaticValueR(calleeNode, initialScope);
851
+ if (callee != null) {
852
+ if (callee.value == null && node.optional) {
853
+ return { value: undefined, optional: true }
854
+ }
855
+ const func = /** @type {(...args: any[]) => any} */ (
856
+ callee.value
857
+ );
858
+ if (callAllowed.has(func)) {
859
+ return { value: func(...args) }
860
+ }
861
+ if (callPassThrough.has(func)) {
862
+ return { value: args[0] }
863
+ }
864
+ }
865
+ }
866
+ }
867
+
868
+ return null
869
+ },
870
+
871
+ ConditionalExpression(node, initialScope) {
872
+ const test = getStaticValueR(node.test, initialScope);
873
+ if (test != null) {
874
+ return test.value
875
+ ? getStaticValueR(node.consequent, initialScope)
876
+ : getStaticValueR(node.alternate, initialScope)
877
+ }
878
+ return null
879
+ },
880
+
881
+ ExpressionStatement(node, initialScope) {
882
+ return getStaticValueR(node.expression, initialScope)
883
+ },
884
+
885
+ Identifier(node, initialScope) {
886
+ if (initialScope != null) {
887
+ const variable = findVariable(initialScope, node);
888
+
889
+ if (variable != null) {
890
+ // Built-in globals.
891
+ if (isBuiltinGlobal(variable)) {
892
+ return { value: globalObject[variable.name] }
893
+ }
894
+
895
+ // Constants.
896
+ if (canBeConsideredConst(variable)) {
897
+ const def = variable.defs[0];
898
+ if (
899
+ // TODO(mysticatea): don't support destructuring here.
900
+ def.node.id.type === "Identifier"
901
+ ) {
902
+ const init = getStaticValueR(
903
+ def.node.init,
904
+ initialScope,
905
+ );
906
+ if (
907
+ init &&
908
+ typeof init.value === "object" &&
909
+ init.value !== null
910
+ ) {
911
+ if (hasMutationInProperty(variable, initialScope)) {
912
+ // This variable has mutation in its property.
913
+ return null
914
+ }
915
+ }
916
+ return init
917
+ }
918
+ }
919
+ }
920
+ }
921
+ return null
922
+ },
923
+
924
+ Literal(node) {
925
+ const literal =
926
+ /** @type {Partial<Literal> & Partial<RegExpLiteral> & Partial<BigIntLiteral>} */ (
927
+ node
928
+ );
929
+ //istanbul ignore if : this is implementation-specific behavior.
930
+ if (
931
+ (literal.regex != null || literal.bigint != null) &&
932
+ literal.value == null
933
+ ) {
934
+ // It was a RegExp/BigInt literal, but Node.js didn't support it.
935
+ return null
936
+ }
937
+ return { value: literal.value }
938
+ },
939
+
940
+ LogicalExpression(node, initialScope) {
941
+ const left = getStaticValueR(node.left, initialScope);
942
+ if (left != null) {
943
+ if (
944
+ (node.operator === "||" && Boolean(left.value) === true) ||
945
+ (node.operator === "&&" && Boolean(left.value) === false) ||
946
+ (node.operator === "??" && left.value != null)
947
+ ) {
948
+ return left
949
+ }
950
+
951
+ const right = getStaticValueR(node.right, initialScope);
952
+ if (right != null) {
953
+ return right
954
+ }
955
+ }
956
+
957
+ return null
958
+ },
959
+
960
+ MemberExpression(node, initialScope) {
961
+ if (node.property.type === "PrivateIdentifier") {
962
+ return null
963
+ }
964
+ const object = getStaticValueR(node.object, initialScope);
965
+ if (object != null) {
966
+ if (object.value == null && (object.optional || node.optional)) {
967
+ return { value: undefined, optional: true }
968
+ }
969
+ const property = getStaticPropertyNameValue(node, initialScope);
970
+
971
+ if (property != null) {
972
+ if (
973
+ !isGetter(
974
+ /** @type {object} */ (object.value),
975
+ /** @type {PropertyKey} */ (property.value),
976
+ )
977
+ ) {
978
+ return {
979
+ value: /** @type {Record<PropertyKey, unknown>} */ (
980
+ object.value
981
+ )[/** @type {PropertyKey} */ (property.value)],
982
+ }
983
+ }
984
+
985
+ for (const [classFn, allowed] of getterAllowed) {
986
+ if (
987
+ object.value instanceof classFn &&
988
+ allowed.has(/** @type {string} */ (property.value))
989
+ ) {
990
+ return {
991
+ value: /** @type {Record<PropertyKey, unknown>} */ (
992
+ object.value
993
+ )[/** @type {PropertyKey} */ (property.value)],
994
+ }
995
+ }
996
+ }
997
+ }
998
+ }
999
+ return null
1000
+ },
1001
+
1002
+ ChainExpression(node, initialScope) {
1003
+ const expression = getStaticValueR(node.expression, initialScope);
1004
+ if (expression != null) {
1005
+ return { value: expression.value }
1006
+ }
1007
+ return null
1008
+ },
1009
+
1010
+ NewExpression(node, initialScope) {
1011
+ const callee = getStaticValueR(node.callee, initialScope);
1012
+ const args = getElementValues(node.arguments, initialScope);
1013
+
1014
+ if (callee != null && args != null) {
1015
+ const Func = /** @type {new (...args: any[]) => any} */ (
1016
+ callee.value
1017
+ );
1018
+ if (callAllowed.has(Func)) {
1019
+ return { value: new Func(...args) }
1020
+ }
1021
+ }
1022
+
1023
+ return null
1024
+ },
1025
+
1026
+ ObjectExpression(node, initialScope) {
1027
+ /** @type {Record<PropertyKey, unknown>} */
1028
+ const object = {};
1029
+
1030
+ for (const propertyNode of node.properties) {
1031
+ if (propertyNode.type === "Property") {
1032
+ if (propertyNode.kind !== "init") {
1033
+ return null
1034
+ }
1035
+ const key = getStaticPropertyNameValue(
1036
+ propertyNode,
1037
+ initialScope,
1038
+ );
1039
+ const value = getStaticValueR(propertyNode.value, initialScope);
1040
+ if (key == null || value == null) {
1041
+ return null
1042
+ }
1043
+ object[/** @type {PropertyKey} */ (key.value)] = value.value;
1044
+ } else if (
1045
+ propertyNode.type === "SpreadElement" ||
1046
+ // @ts-expect-error -- Backward compatibility
1047
+ propertyNode.type === "ExperimentalSpreadProperty"
1048
+ ) {
1049
+ const argument = getStaticValueR(
1050
+ propertyNode.argument,
1051
+ initialScope,
1052
+ );
1053
+ if (argument == null) {
1054
+ return null
1055
+ }
1056
+ Object.assign(object, argument.value);
1057
+ } else {
1058
+ return null
1059
+ }
1060
+ }
1061
+
1062
+ return { value: object }
1063
+ },
1064
+
1065
+ SequenceExpression(node, initialScope) {
1066
+ const last = node.expressions[node.expressions.length - 1];
1067
+ return getStaticValueR(last, initialScope)
1068
+ },
1069
+
1070
+ TaggedTemplateExpression(node, initialScope) {
1071
+ const tag = getStaticValueR(node.tag, initialScope);
1072
+ const expressions = getElementValues(
1073
+ node.quasi.expressions,
1074
+ initialScope,
1075
+ );
1076
+
1077
+ if (tag != null && expressions != null) {
1078
+ const func = /** @type {(...args: any[]) => any} */ (tag.value);
1079
+ /** @type {any[] & { raw?: string[] }} */
1080
+ const strings = node.quasi.quasis.map((q) => q.value.cooked);
1081
+ strings.raw = node.quasi.quasis.map((q) => q.value.raw);
1082
+
1083
+ if (func === String.raw) {
1084
+ return { value: func(strings, ...expressions) }
1085
+ }
1086
+ }
1087
+
1088
+ return null
1089
+ },
1090
+
1091
+ TemplateLiteral(node, initialScope) {
1092
+ const expressions = getElementValues(node.expressions, initialScope);
1093
+ if (expressions != null) {
1094
+ let value = node.quasis[0].value.cooked;
1095
+ for (let i = 0; i < expressions.length; ++i) {
1096
+ value += expressions[i];
1097
+ value += /** @type {string} */ (node.quasis[i + 1].value.cooked);
1098
+ }
1099
+ return { value }
1100
+ }
1101
+ return null
1102
+ },
1103
+
1104
+ UnaryExpression(node, initialScope) {
1105
+ if (node.operator === "delete") {
1106
+ // Not supported.
1107
+ return null
1108
+ }
1109
+ if (node.operator === "void") {
1110
+ return { value: undefined }
1111
+ }
1112
+
1113
+ const arg = getStaticValueR(node.argument, initialScope);
1114
+ if (arg != null) {
1115
+ switch (node.operator) {
1116
+ case "-":
1117
+ return { value: -(/** @type {any} */ (arg.value)) }
1118
+ case "+":
1119
+ return { value: +(/** @type {any} */ (arg.value)) } //eslint-disable-line no-implicit-coercion
1120
+ case "!":
1121
+ return { value: !arg.value }
1122
+ case "~":
1123
+ return { value: ~(/** @type {any} */ (arg.value)) }
1124
+ case "typeof":
1125
+ return { value: typeof arg.value }
1126
+
1127
+ // no default
1128
+ }
1129
+ }
1130
+
1131
+ return null
1132
+ },
1133
+ TSAsExpression(node, initialScope) {
1134
+ return getStaticValueR(node.expression, initialScope)
1135
+ },
1136
+ TSSatisfiesExpression(node, initialScope) {
1137
+ return getStaticValueR(node.expression, initialScope)
1138
+ },
1139
+ TSTypeAssertion(node, initialScope) {
1140
+ return getStaticValueR(node.expression, initialScope)
1141
+ },
1142
+ TSNonNullExpression(node, initialScope) {
1143
+ return getStaticValueR(node.expression, initialScope)
1144
+ },
1145
+ TSInstantiationExpression(node, initialScope) {
1146
+ return getStaticValueR(node.expression, initialScope)
1147
+ },
1148
+ });
1149
+
1150
+ /**
1151
+ * Get the value of a given node if it's a static value.
1152
+ * @param {Node|TSESTreeNode|null|undefined} node The node to get.
1153
+ * @param {Scope|undefined|null} initialScope The scope to start finding variable.
1154
+ * @returns {StaticValue|null} The static value of the node, or `null`.
1155
+ */
1156
+ function getStaticValueR(node, initialScope) {
1157
+ if (node != null && Object.hasOwnProperty.call(operations, node.type)) {
1158
+ return /** @type {VisitorCallback<any>} */ (operations[node.type])(
1159
+ /** @type {TSESTreeNode} */ (node),
1160
+ initialScope,
1161
+ )
1162
+ }
1163
+ return null
1164
+ }
1165
+
1166
+ /**
1167
+ * Get the static value of property name from a MemberExpression node or a Property node.
1168
+ * @param {MemberExpression|Property} node The node to get.
1169
+ * @param {Scope|null} [initialScope] The scope to start finding variable. Optional. If the node is a computed property node and this scope was given, this checks the computed property name by the `getStringIfConstant` function with the scope, and returns the value of it.
1170
+ * @returns {StaticValue|null} The static value of the property name of the node, or `null`.
1171
+ */
1172
+ function getStaticPropertyNameValue(node, initialScope) {
1173
+ const nameNode = node.type === "Property" ? node.key : node.property;
1174
+
1175
+ if (node.computed) {
1176
+ return getStaticValueR(nameNode, initialScope)
1177
+ }
1178
+
1179
+ if (nameNode.type === "Identifier") {
1180
+ return { value: nameNode.name }
1181
+ }
1182
+
1183
+ if (nameNode.type === "Literal") {
1184
+ if (/** @type {Partial<BigIntLiteral>} */ (nameNode).bigint) {
1185
+ return { value: /** @type {BigIntLiteral} */ (nameNode).bigint }
1186
+ }
1187
+ return { value: String(nameNode.value) }
1188
+ }
1189
+
1190
+ return null
1191
+ }
1192
+
1193
+ /**
1194
+ * Get the value of a given node if it's a static value.
1195
+ * @param {Node} node The node to get.
1196
+ * @param {Scope|null} [initialScope] The scope to start finding variable. Optional. If this scope was given, this tries to resolve identifier references which are in the given node as much as possible.
1197
+ * @returns {StaticValue | null} The static value of the node, or `null`.
1198
+ */
1199
+ function getStaticValue(node, initialScope = null) {
1200
+ try {
1201
+ return getStaticValueR(node, initialScope)
1202
+ } catch (_error) {
1203
+ return null
1204
+ }
1205
+ }
1206
+
1207
+ /** @typedef {import("eslint").Scope.Scope} Scope */
1208
+ /** @typedef {import("estree").Node} Node */
1209
+ /** @typedef {import("estree").RegExpLiteral} RegExpLiteral */
1210
+ /** @typedef {import("estree").BigIntLiteral} BigIntLiteral */
1211
+ /** @typedef {import("estree").SimpleLiteral} SimpleLiteral */
1212
+
1213
+ /**
1214
+ * Get the value of a given node if it's a literal or a template literal.
1215
+ * @param {Node} node The node to get.
1216
+ * @param {Scope|null} [initialScope] The scope to start finding variable. Optional. If the node is an Identifier node and this scope was given, this checks the variable of the identifier, and returns the value of it if the variable is a constant.
1217
+ * @returns {string|null} The value of the node, or `null`.
1218
+ */
1219
+ function getStringIfConstant(node, initialScope = null) {
1220
+ // Handle the literals that the platform doesn't support natively.
1221
+ if (node && node.type === "Literal" && node.value === null) {
1222
+ const literal =
1223
+ /** @type {Partial<SimpleLiteral> & Partial<RegExpLiteral> & Partial<BigIntLiteral>} */ (
1224
+ node
1225
+ );
1226
+ if (literal.regex) {
1227
+ return `/${literal.regex.pattern}/${literal.regex.flags}`
1228
+ }
1229
+ if (literal.bigint) {
1230
+ return literal.bigint
1231
+ }
1232
+ }
1233
+
1234
+ const evaluated = getStaticValue(node, initialScope);
1235
+
1236
+ if (evaluated) {
1237
+ // `String(Symbol.prototype)` throws error
1238
+ try {
1239
+ return String(evaluated.value)
1240
+ } catch {
1241
+ // No op
1242
+ }
1243
+ }
1244
+
1245
+ return null
1246
+ }
1247
+
1248
+ /** @typedef {import("eslint").Scope.Scope} Scope */
1249
+ /** @typedef {import("estree").MemberExpression} MemberExpression */
1250
+ /** @typedef {import("estree").MethodDefinition} MethodDefinition */
1251
+ /** @typedef {import("estree").Property} Property */
1252
+ /** @typedef {import("estree").PropertyDefinition} PropertyDefinition */
1253
+ /** @typedef {import("estree").Identifier} Identifier */
1254
+
1255
+ /**
1256
+ * Get the property name from a MemberExpression node or a Property node.
1257
+ * @param {MemberExpression | MethodDefinition | Property | PropertyDefinition} node The node to get.
1258
+ * @param {Scope} [initialScope] The scope to start finding variable. Optional. If the node is a computed property node and this scope was given, this checks the computed property name by the `getStringIfConstant` function with the scope, and returns the value of it.
1259
+ * @returns {string|null|undefined} The property name of the node.
1260
+ */
1261
+ function getPropertyName(node, initialScope) {
1262
+ switch (node.type) {
1263
+ case "MemberExpression":
1264
+ if (node.computed) {
1265
+ return getStringIfConstant(node.property, initialScope)
1266
+ }
1267
+ if (node.property.type === "PrivateIdentifier") {
1268
+ return null
1269
+ }
1270
+ return /** @type {Partial<Identifier>} */ (node.property).name
1271
+
1272
+ case "Property":
1273
+ case "MethodDefinition":
1274
+ case "PropertyDefinition":
1275
+ if (node.computed) {
1276
+ return getStringIfConstant(node.key, initialScope)
1277
+ }
1278
+ if (node.key.type === "Literal") {
1279
+ return String(node.key.value)
1280
+ }
1281
+ if (node.key.type === "PrivateIdentifier") {
1282
+ return null
1283
+ }
1284
+ return /** @type {Partial<Identifier>} */ (node.key).name
1285
+ }
1286
+
1287
+ return null
1288
+ }
1289
+
1290
+ /** @typedef {import("eslint").Rule.Node} RuleNode */
1291
+ /** @typedef {import("eslint").SourceCode} SourceCode */
1292
+ /** @typedef {import("estree").Function} FunctionNode */
1293
+ /** @typedef {import("estree").FunctionDeclaration} FunctionDeclaration */
1294
+ /** @typedef {import("estree").FunctionExpression} FunctionExpression */
1295
+ /** @typedef {import("estree").Identifier} Identifier */
1296
+
1297
+ /**
1298
+ * Get the name and kind of the given function node.
1299
+ * @param {FunctionNode} node - The function node to get.
1300
+ * @param {SourceCode} [sourceCode] The source code object to get the code of computed property keys.
1301
+ * @returns {string} The name and kind of the function node.
1302
+ */
1303
+ // eslint-disable-next-line complexity
1304
+ function getFunctionNameWithKind(node, sourceCode) {
1305
+ const parent = /** @type {RuleNode} */ (node).parent;
1306
+
1307
+ if (!parent) {
1308
+ return ""
1309
+ }
1310
+
1311
+ const tokens = [];
1312
+ const isObjectMethod = parent.type === "Property" && parent.value === node;
1313
+ const isClassMethod =
1314
+ parent.type === "MethodDefinition" && parent.value === node;
1315
+ const isClassFieldMethod =
1316
+ parent.type === "PropertyDefinition" && parent.value === node;
1317
+
1318
+ // Modifiers.
1319
+ if (isClassMethod || isClassFieldMethod) {
1320
+ if (parent.static) {
1321
+ tokens.push("static");
1322
+ }
1323
+ if (parent.key.type === "PrivateIdentifier") {
1324
+ tokens.push("private");
1325
+ }
1326
+ }
1327
+ if (node.async) {
1328
+ tokens.push("async");
1329
+ }
1330
+ if (node.generator) {
1331
+ tokens.push("generator");
1332
+ }
1333
+
1334
+ // Kinds.
1335
+ if (isObjectMethod || isClassMethod) {
1336
+ if (parent.kind === "constructor") {
1337
+ return "constructor"
1338
+ }
1339
+ if (parent.kind === "get") {
1340
+ tokens.push("getter");
1341
+ } else if (parent.kind === "set") {
1342
+ tokens.push("setter");
1343
+ } else {
1344
+ tokens.push("method");
1345
+ }
1346
+ } else if (isClassFieldMethod) {
1347
+ tokens.push("method");
1348
+ } else {
1349
+ if (node.type === "ArrowFunctionExpression") {
1350
+ tokens.push("arrow");
1351
+ }
1352
+ tokens.push("function");
1353
+ }
1354
+
1355
+ // Names.
1356
+ if (isObjectMethod || isClassMethod || isClassFieldMethod) {
1357
+ if (parent.key.type === "PrivateIdentifier") {
1358
+ tokens.push(`#${parent.key.name}`);
1359
+ } else {
1360
+ const name = getPropertyName(parent);
1361
+ if (name) {
1362
+ tokens.push(`'${name}'`);
1363
+ } else if (sourceCode) {
1364
+ const keyText = sourceCode.getText(parent.key);
1365
+ if (!keyText.includes("\n")) {
1366
+ tokens.push(`[${keyText}]`);
1367
+ }
1368
+ }
1369
+ }
1370
+ } else if (hasId(node)) {
1371
+ tokens.push(`'${node.id.name}'`);
1372
+ } else if (
1373
+ parent.type === "VariableDeclarator" &&
1374
+ parent.id &&
1375
+ parent.id.type === "Identifier"
1376
+ ) {
1377
+ tokens.push(`'${parent.id.name}'`);
1378
+ } else if (
1379
+ (parent.type === "AssignmentExpression" ||
1380
+ parent.type === "AssignmentPattern") &&
1381
+ parent.left &&
1382
+ parent.left.type === "Identifier"
1383
+ ) {
1384
+ tokens.push(`'${parent.left.name}'`);
1385
+ } else if (
1386
+ parent.type === "ExportDefaultDeclaration" &&
1387
+ parent.declaration === node
1388
+ ) {
1389
+ tokens.push("'default'");
1390
+ }
1391
+
1392
+ return tokens.join(" ")
1393
+ }
1394
+
1395
+ /**
1396
+ * @param {FunctionNode} node
1397
+ * @returns {node is FunctionDeclaration | FunctionExpression & { id: Identifier }}
1398
+ */
1399
+ function hasId(node) {
1400
+ return Boolean(
1401
+ /** @type {Partial<FunctionDeclaration | FunctionExpression>} */ (node)
1402
+ .id,
1403
+ )
1404
+ }
1405
+
1406
+ /** @typedef {import("estree").Node} Node */
1407
+ /** @typedef {import("eslint").SourceCode} SourceCode */
1408
+ /** @typedef {import("./types.mjs").HasSideEffectOptions} HasSideEffectOptions */
1409
+ /** @typedef {import("estree").BinaryExpression} BinaryExpression */
1410
+ /** @typedef {import("estree").MemberExpression} MemberExpression */
1411
+ /** @typedef {import("estree").MethodDefinition} MethodDefinition */
1412
+ /** @typedef {import("estree").Property} Property */
1413
+ /** @typedef {import("estree").PropertyDefinition} PropertyDefinition */
1414
+ /** @typedef {import("estree").UnaryExpression} UnaryExpression */
1415
+
1416
+ const typeConversionBinaryOps = Object.freeze(
1417
+ new Set([
1418
+ "==",
1419
+ "!=",
1420
+ "<",
1421
+ "<=",
1422
+ ">",
1423
+ ">=",
1424
+ "<<",
1425
+ ">>",
1426
+ ">>>",
1427
+ "+",
1428
+ "-",
1429
+ "*",
1430
+ "/",
1431
+ "%",
1432
+ "|",
1433
+ "^",
1434
+ "&",
1435
+ "in",
1436
+ ]),
1437
+ );
1438
+ const typeConversionUnaryOps = Object.freeze(new Set(["-", "+", "!", "~"]));
1439
+
1440
+ /**
1441
+ * Check whether the given value is an ASTNode or not.
1442
+ * @param {any} x The value to check.
1443
+ * @returns {x is Node} `true` if the value is an ASTNode.
1444
+ */
1445
+ function isNode(x) {
1446
+ return x !== null && typeof x === "object" && typeof x.type === "string"
1447
+ }
1448
+
1449
+ const visitor = Object.freeze(
1450
+ Object.assign(Object.create(null), {
1451
+ /**
1452
+ * @param {Node} node
1453
+ * @param {HasSideEffectOptions} options
1454
+ * @param {Record<string, string[]>} visitorKeys
1455
+ */
1456
+ $visit(node, options, visitorKeys) {
1457
+ const { type } = node;
1458
+
1459
+ if (typeof (/** @type {any} */ (this)[type]) === "function") {
1460
+ return /** @type {any} */ (this)[type](
1461
+ node,
1462
+ options,
1463
+ visitorKeys,
1464
+ )
1465
+ }
1466
+
1467
+ return this.$visitChildren(node, options, visitorKeys)
1468
+ },
1469
+
1470
+ /**
1471
+ * @param {Node} node
1472
+ * @param {HasSideEffectOptions} options
1473
+ * @param {Record<string, string[]>} visitorKeys
1474
+ */
1475
+ $visitChildren(node, options, visitorKeys) {
1476
+ const { type } = node;
1477
+
1478
+ for (const key of /** @type {(keyof Node)[]} */ (
1479
+ visitorKeys[type] || getKeys(node)
1480
+ )) {
1481
+ const value = node[key];
1482
+
1483
+ if (Array.isArray(value)) {
1484
+ for (const element of value) {
1485
+ if (
1486
+ isNode(element) &&
1487
+ this.$visit(element, options, visitorKeys)
1488
+ ) {
1489
+ return true
1490
+ }
1491
+ }
1492
+ } else if (
1493
+ isNode(value) &&
1494
+ this.$visit(value, options, visitorKeys)
1495
+ ) {
1496
+ return true
1497
+ }
1498
+ }
1499
+
1500
+ return false
1501
+ },
1502
+
1503
+ ArrowFunctionExpression() {
1504
+ return false
1505
+ },
1506
+ AssignmentExpression() {
1507
+ return true
1508
+ },
1509
+ AwaitExpression() {
1510
+ return true
1511
+ },
1512
+ /**
1513
+ * @param {BinaryExpression} node
1514
+ * @param {HasSideEffectOptions} options
1515
+ * @param {Record<string, string[]>} visitorKeys
1516
+ */
1517
+ BinaryExpression(node, options, visitorKeys) {
1518
+ if (
1519
+ options.considerImplicitTypeConversion &&
1520
+ typeConversionBinaryOps.has(node.operator) &&
1521
+ (node.left.type !== "Literal" || node.right.type !== "Literal")
1522
+ ) {
1523
+ return true
1524
+ }
1525
+ return this.$visitChildren(node, options, visitorKeys)
1526
+ },
1527
+ CallExpression() {
1528
+ return true
1529
+ },
1530
+ FunctionExpression() {
1531
+ return false
1532
+ },
1533
+ ImportExpression() {
1534
+ return true
1535
+ },
1536
+ /**
1537
+ * @param {MemberExpression} node
1538
+ * @param {HasSideEffectOptions} options
1539
+ * @param {Record<string, string[]>} visitorKeys
1540
+ */
1541
+ MemberExpression(node, options, visitorKeys) {
1542
+ if (options.considerGetters) {
1543
+ return true
1544
+ }
1545
+ if (
1546
+ options.considerImplicitTypeConversion &&
1547
+ node.computed &&
1548
+ node.property.type !== "Literal"
1549
+ ) {
1550
+ return true
1551
+ }
1552
+ return this.$visitChildren(node, options, visitorKeys)
1553
+ },
1554
+ /**
1555
+ * @param {MethodDefinition} node
1556
+ * @param {HasSideEffectOptions} options
1557
+ * @param {Record<string, string[]>} visitorKeys
1558
+ */
1559
+ MethodDefinition(node, options, visitorKeys) {
1560
+ if (
1561
+ options.considerImplicitTypeConversion &&
1562
+ node.computed &&
1563
+ node.key.type !== "Literal"
1564
+ ) {
1565
+ return true
1566
+ }
1567
+ return this.$visitChildren(node, options, visitorKeys)
1568
+ },
1569
+ NewExpression() {
1570
+ return true
1571
+ },
1572
+ /**
1573
+ * @param {Property} node
1574
+ * @param {HasSideEffectOptions} options
1575
+ * @param {Record<string, string[]>} visitorKeys
1576
+ */
1577
+ Property(node, options, visitorKeys) {
1578
+ if (
1579
+ options.considerImplicitTypeConversion &&
1580
+ node.computed &&
1581
+ node.key.type !== "Literal"
1582
+ ) {
1583
+ return true
1584
+ }
1585
+ return this.$visitChildren(node, options, visitorKeys)
1586
+ },
1587
+ /**
1588
+ * @param {PropertyDefinition} node
1589
+ * @param {HasSideEffectOptions} options
1590
+ * @param {Record<string, string[]>} visitorKeys
1591
+ */
1592
+ PropertyDefinition(node, options, visitorKeys) {
1593
+ if (
1594
+ options.considerImplicitTypeConversion &&
1595
+ node.computed &&
1596
+ node.key.type !== "Literal"
1597
+ ) {
1598
+ return true
1599
+ }
1600
+ return this.$visitChildren(node, options, visitorKeys)
1601
+ },
1602
+ /**
1603
+ * @param {UnaryExpression} node
1604
+ * @param {HasSideEffectOptions} options
1605
+ * @param {Record<string, string[]>} visitorKeys
1606
+ */
1607
+ UnaryExpression(node, options, visitorKeys) {
1608
+ if (node.operator === "delete") {
1609
+ return true
1610
+ }
1611
+ if (
1612
+ options.considerImplicitTypeConversion &&
1613
+ typeConversionUnaryOps.has(node.operator) &&
1614
+ node.argument.type !== "Literal"
1615
+ ) {
1616
+ return true
1617
+ }
1618
+ return this.$visitChildren(node, options, visitorKeys)
1619
+ },
1620
+ UpdateExpression() {
1621
+ return true
1622
+ },
1623
+ YieldExpression() {
1624
+ return true
1625
+ },
1626
+ }),
1627
+ );
1628
+
1629
+ /**
1630
+ * Check whether a given node has any side effect or not.
1631
+ * @param {Node} node The node to get.
1632
+ * @param {SourceCode} sourceCode The source code object.
1633
+ * @param {HasSideEffectOptions} [options] The option object.
1634
+ * @returns {boolean} `true` if the node has a certain side effect.
1635
+ */
1636
+ function hasSideEffect(node, sourceCode, options = {}) {
1637
+ const { considerGetters = false, considerImplicitTypeConversion = false } =
1638
+ options;
1639
+ return visitor.$visit(
1640
+ node,
1641
+ { considerGetters, considerImplicitTypeConversion },
1642
+ sourceCode.visitorKeys || KEYS,
1643
+ )
1644
+ }
1645
+
1646
+ /** @typedef {import("estree").Node} Node */
1647
+ /** @typedef {import("@typescript-eslint/types").TSESTree.NewExpression} TSNewExpression */
1648
+ /** @typedef {import("@typescript-eslint/types").TSESTree.CallExpression} TSCallExpression */
1649
+ /** @typedef {import("eslint").SourceCode} SourceCode */
1650
+ /** @typedef {import("eslint").AST.Token} Token */
1651
+ /** @typedef {import("eslint").Rule.Node} RuleNode */
1652
+
1653
+ /**
1654
+ * Get the left parenthesis of the parent node syntax if it exists.
1655
+ * E.g., `if (a) {}` then the `(`.
1656
+ * @param {Node} node The AST node to check.
1657
+ * @param {SourceCode} sourceCode The source code object to get tokens.
1658
+ * @returns {Token|null} The left parenthesis of the parent node syntax
1659
+ */
1660
+ // eslint-disable-next-line complexity
1661
+ function getParentSyntaxParen(node, sourceCode) {
1662
+ const parent = /** @type {RuleNode} */ (node).parent;
1663
+
1664
+ if (!parent) {
1665
+ return null
1666
+ }
1667
+
1668
+ switch (parent.type) {
1669
+ case "CallExpression":
1670
+ case "NewExpression":
1671
+ if (parent.arguments.length === 1 && parent.arguments[0] === node) {
1672
+ return sourceCode.getTokenAfter(
1673
+ // @ts-expect-error https://github.com/typescript-eslint/typescript-eslint/pull/5384
1674
+ parent.typeArguments ||
1675
+ /** @type {RuleNode} */ (
1676
+ /** @type {unknown} */ (
1677
+ /** @type {TSNewExpression | TSCallExpression} */ (
1678
+ parent
1679
+ ).typeParameters
1680
+ )
1681
+ ) ||
1682
+ parent.callee,
1683
+ isOpeningParenToken,
1684
+ )
1685
+ }
1686
+ return null
1687
+
1688
+ case "DoWhileStatement":
1689
+ if (parent.test === node) {
1690
+ return sourceCode.getTokenAfter(
1691
+ parent.body,
1692
+ isOpeningParenToken,
1693
+ )
1694
+ }
1695
+ return null
1696
+
1697
+ case "IfStatement":
1698
+ case "WhileStatement":
1699
+ if (parent.test === node) {
1700
+ return sourceCode.getFirstToken(parent, 1)
1701
+ }
1702
+ return null
1703
+
1704
+ case "ImportExpression":
1705
+ if (parent.source === node) {
1706
+ return sourceCode.getFirstToken(parent, 1)
1707
+ }
1708
+ return null
1709
+
1710
+ case "SwitchStatement":
1711
+ if (parent.discriminant === node) {
1712
+ return sourceCode.getFirstToken(parent, 1)
1713
+ }
1714
+ return null
1715
+
1716
+ case "WithStatement":
1717
+ if (parent.object === node) {
1718
+ return sourceCode.getFirstToken(parent, 1)
1719
+ }
1720
+ return null
1721
+
1722
+ default:
1723
+ return null
1724
+ }
1725
+ }
1726
+
1727
+ /**
1728
+ * Check whether a given node is parenthesized or not.
1729
+ * @param {number} times The number of parantheses.
1730
+ * @param {Node} node The AST node to check.
1731
+ * @param {SourceCode} sourceCode The source code object to get tokens.
1732
+ * @returns {boolean} `true` if the node is parenthesized the given times.
1733
+ */
1734
+ /**
1735
+ * Check whether a given node is parenthesized or not.
1736
+ * @param {Node} node The AST node to check.
1737
+ * @param {SourceCode} sourceCode The source code object to get tokens.
1738
+ * @returns {boolean} `true` if the node is parenthesized.
1739
+ */
1740
+ /**
1741
+ * Check whether a given node is parenthesized or not.
1742
+ * @param {Node|number} timesOrNode The first parameter.
1743
+ * @param {Node|SourceCode} nodeOrSourceCode The second parameter.
1744
+ * @param {SourceCode} [optionalSourceCode] The third parameter.
1745
+ * @returns {boolean} `true` if the node is parenthesized.
1746
+ */
1747
+ function isParenthesized(
1748
+ timesOrNode,
1749
+ nodeOrSourceCode,
1750
+ optionalSourceCode,
1751
+ ) {
1752
+ /** @type {number} */
1753
+ let times,
1754
+ /** @type {RuleNode} */
1755
+ node,
1756
+ /** @type {SourceCode} */
1757
+ sourceCode,
1758
+ maybeLeftParen,
1759
+ maybeRightParen;
1760
+ if (typeof timesOrNode === "number") {
1761
+ times = timesOrNode | 0;
1762
+ node = /** @type {RuleNode} */ (nodeOrSourceCode);
1763
+ sourceCode = /** @type {SourceCode} */ (optionalSourceCode);
1764
+ if (!(times >= 1)) {
1765
+ throw new TypeError("'times' should be a positive integer.")
1766
+ }
1767
+ } else {
1768
+ times = 1;
1769
+ node = /** @type {RuleNode} */ (timesOrNode);
1770
+ sourceCode = /** @type {SourceCode} */ (nodeOrSourceCode);
1771
+ }
1772
+
1773
+ if (
1774
+ node == null ||
1775
+ // `Program` can't be parenthesized
1776
+ node.parent == null ||
1777
+ // `CatchClause.param` can't be parenthesized, example `try {} catch (error) {}`
1778
+ (node.parent.type === "CatchClause" && node.parent.param === node)
1779
+ ) {
1780
+ return false
1781
+ }
1782
+
1783
+ maybeLeftParen = maybeRightParen = node;
1784
+ do {
1785
+ maybeLeftParen = sourceCode.getTokenBefore(maybeLeftParen);
1786
+ maybeRightParen = sourceCode.getTokenAfter(maybeRightParen);
1787
+ } while (
1788
+ maybeLeftParen != null &&
1789
+ maybeRightParen != null &&
1790
+ isOpeningParenToken(maybeLeftParen) &&
1791
+ isClosingParenToken(maybeRightParen) &&
1792
+ // Avoid false positive such as `if (a) {}`
1793
+ maybeLeftParen !== getParentSyntaxParen(node, sourceCode) &&
1794
+ --times > 0
1795
+ )
1796
+
1797
+ return times === 0
1798
+ }
1799
+
1800
+ /**
1801
+ * @author Toru Nagashima <https://github.com/mysticatea>
1802
+ * See LICENSE file in root directory for full license.
1803
+ */
1804
+
1805
+ const placeholder = /\$(?:[$&`']|[1-9][0-9]?)/gu;
1806
+
1807
+ /** @type {WeakMap<PatternMatcher, {pattern:RegExp,escaped:boolean}>} */
1808
+ const internal = new WeakMap();
1809
+
1810
+ /**
1811
+ * Check whether a given character is escaped or not.
1812
+ * @param {string} str The string to check.
1813
+ * @param {number} index The location of the character to check.
1814
+ * @returns {boolean} `true` if the character is escaped.
1815
+ */
1816
+ function isEscaped(str, index) {
1817
+ let escaped = false;
1818
+ for (let i = index - 1; i >= 0 && str.charCodeAt(i) === 0x5c; --i) {
1819
+ escaped = !escaped;
1820
+ }
1821
+ return escaped
1822
+ }
1823
+
1824
+ /**
1825
+ * Replace a given string by a given matcher.
1826
+ * @param {PatternMatcher} matcher The pattern matcher.
1827
+ * @param {string} str The string to be replaced.
1828
+ * @param {string} replacement The new substring to replace each matched part.
1829
+ * @returns {string} The replaced string.
1830
+ */
1831
+ function replaceS(matcher, str, replacement) {
1832
+ const chunks = [];
1833
+ let index = 0;
1834
+
1835
+ /**
1836
+ * @param {string} key The placeholder.
1837
+ * @param {RegExpExecArray} match The matched information.
1838
+ * @returns {string} The replaced string.
1839
+ */
1840
+ function replacer(key, match) {
1841
+ switch (key) {
1842
+ case "$$":
1843
+ return "$"
1844
+ case "$&":
1845
+ return match[0]
1846
+ case "$`":
1847
+ return str.slice(0, match.index)
1848
+ case "$'":
1849
+ return str.slice(match.index + match[0].length)
1850
+ default: {
1851
+ const i = key.slice(1);
1852
+ if (i in match) {
1853
+ return match[/** @type {any} */ (i)]
1854
+ }
1855
+ return key
1856
+ }
1857
+ }
1858
+ }
1859
+
1860
+ for (const match of matcher.execAll(str)) {
1861
+ chunks.push(str.slice(index, match.index));
1862
+ chunks.push(
1863
+ replacement.replace(placeholder, (key) => replacer(key, match)),
1864
+ );
1865
+ index = match.index + match[0].length;
1866
+ }
1867
+ chunks.push(str.slice(index));
1868
+
1869
+ return chunks.join("")
1870
+ }
1871
+
1872
+ /**
1873
+ * Replace a given string by a given matcher.
1874
+ * @param {PatternMatcher} matcher The pattern matcher.
1875
+ * @param {string} str The string to be replaced.
1876
+ * @param {(substring: string, ...args: any[]) => string} replace The function to replace each matched part.
1877
+ * @returns {string} The replaced string.
1878
+ */
1879
+ function replaceF(matcher, str, replace) {
1880
+ const chunks = [];
1881
+ let index = 0;
1882
+
1883
+ for (const match of matcher.execAll(str)) {
1884
+ chunks.push(str.slice(index, match.index));
1885
+ chunks.push(
1886
+ String(
1887
+ replace(
1888
+ .../** @type {[string, ...string[]]} */ (
1889
+ /** @type {string[]} */ (match)
1890
+ ),
1891
+ match.index,
1892
+ match.input,
1893
+ ),
1894
+ ),
1895
+ );
1896
+ index = match.index + match[0].length;
1897
+ }
1898
+ chunks.push(str.slice(index));
1899
+
1900
+ return chunks.join("")
1901
+ }
1902
+
1903
+ /**
1904
+ * The class to find patterns as considering escape sequences.
1905
+ */
1906
+ class PatternMatcher {
1907
+ /**
1908
+ * Initialize this matcher.
1909
+ * @param {RegExp} pattern The pattern to match.
1910
+ * @param {{escaped?:boolean}} [options] The options.
1911
+ */
1912
+ constructor(pattern, options = {}) {
1913
+ const { escaped = false } = options;
1914
+ if (!(pattern instanceof RegExp)) {
1915
+ throw new TypeError("'pattern' should be a RegExp instance.")
1916
+ }
1917
+ if (!pattern.flags.includes("g")) {
1918
+ throw new Error("'pattern' should contains 'g' flag.")
1919
+ }
1920
+
1921
+ internal.set(this, {
1922
+ pattern: new RegExp(pattern.source, pattern.flags),
1923
+ escaped: Boolean(escaped),
1924
+ });
1925
+ }
1926
+
1927
+ /**
1928
+ * Find the pattern in a given string.
1929
+ * @param {string} str The string to find.
1930
+ * @returns {IterableIterator<RegExpExecArray>} The iterator which iterate the matched information.
1931
+ */
1932
+ *execAll(str) {
1933
+ const { pattern, escaped } =
1934
+ /** @type {{pattern:RegExp,escaped:boolean}} */ (internal.get(this));
1935
+ let match = null;
1936
+ let lastIndex = 0;
1937
+
1938
+ pattern.lastIndex = 0;
1939
+ while ((match = pattern.exec(str)) != null) {
1940
+ if (escaped || !isEscaped(str, match.index)) {
1941
+ lastIndex = pattern.lastIndex;
1942
+ yield match;
1943
+ pattern.lastIndex = lastIndex;
1944
+ }
1945
+ }
1946
+ }
1947
+
1948
+ /**
1949
+ * Check whether the pattern is found in a given string.
1950
+ * @param {string} str The string to check.
1951
+ * @returns {boolean} `true` if the pattern was found in the string.
1952
+ */
1953
+ test(str) {
1954
+ const it = this.execAll(str);
1955
+ const ret = it.next();
1956
+ return !ret.done
1957
+ }
1958
+
1959
+ /**
1960
+ * Replace a given string.
1961
+ * @param {string} str The string to be replaced.
1962
+ * @param {(string|((...strs:string[])=>string))} replacer The string or function to replace. This is the same as the 2nd argument of `String.prototype.replace`.
1963
+ * @returns {string} The replaced string.
1964
+ */
1965
+ [Symbol.replace](str, replacer) {
1966
+ return typeof replacer === "function"
1967
+ ? replaceF(this, String(str), replacer)
1968
+ : replaceS(this, String(str), String(replacer))
1969
+ }
1970
+ }
1971
+
1972
+ /** @typedef {import("eslint").Scope.Scope} Scope */
1973
+ /** @typedef {import("eslint").Scope.Variable} Variable */
1974
+ /** @typedef {import("eslint").Rule.Node} RuleNode */
1975
+ /** @typedef {import("estree").Node} Node */
1976
+ /** @typedef {import("estree").Expression} Expression */
1977
+ /** @typedef {import("estree").Pattern} Pattern */
1978
+ /** @typedef {import("estree").Identifier} Identifier */
1979
+ /** @typedef {import("estree").SimpleCallExpression} CallExpression */
1980
+ /** @typedef {import("estree").Program} Program */
1981
+ /** @typedef {import("estree").ImportDeclaration} ImportDeclaration */
1982
+ /** @typedef {import("estree").ExportAllDeclaration} ExportAllDeclaration */
1983
+ /** @typedef {import("estree").ExportDefaultDeclaration} ExportDefaultDeclaration */
1984
+ /** @typedef {import("estree").ExportNamedDeclaration} ExportNamedDeclaration */
1985
+ /** @typedef {import("estree").ImportSpecifier} ImportSpecifier */
1986
+ /** @typedef {import("estree").ImportDefaultSpecifier} ImportDefaultSpecifier */
1987
+ /** @typedef {import("estree").ImportNamespaceSpecifier} ImportNamespaceSpecifier */
1988
+ /** @typedef {import("estree").ExportSpecifier} ExportSpecifier */
1989
+ /** @typedef {import("estree").Property} Property */
1990
+ /** @typedef {import("estree").AssignmentProperty} AssignmentProperty */
1991
+ /** @typedef {import("estree").Literal} Literal */
1992
+ /** @typedef {import("@typescript-eslint/types").TSESTree.Node} TSESTreeNode */
1993
+ /** @typedef {import("./types.mjs").ReferenceTrackerOptions} ReferenceTrackerOptions */
1994
+ /**
1995
+ * @template T
1996
+ * @typedef {import("./types.mjs").TraceMap<T>} TraceMap
1997
+ */
1998
+ /**
1999
+ * @template T
2000
+ * @typedef {import("./types.mjs").TraceMapObject<T>} TraceMapObject
2001
+ */
2002
+ /**
2003
+ * @template T
2004
+ * @typedef {import("./types.mjs").TrackedReferences<T>} TrackedReferences
2005
+ */
2006
+
2007
+ const IMPORT_TYPE = /^(?:Import|Export(?:All|Default|Named))Declaration$/u;
2008
+
2009
+ /**
2010
+ * Check whether a given node is an import node or not.
2011
+ * @param {Node} node
2012
+ * @returns {node is ImportDeclaration|ExportAllDeclaration|ExportNamedDeclaration&{source: Literal}} `true` if the node is an import node.
2013
+ */
2014
+ function isHasSource(node) {
2015
+ return (
2016
+ IMPORT_TYPE.test(node.type) &&
2017
+ /** @type {ImportDeclaration|ExportAllDeclaration|ExportNamedDeclaration} */ (
2018
+ node
2019
+ ).source != null
2020
+ )
2021
+ }
2022
+ const has =
2023
+ /** @type {<T>(traceMap: TraceMap<unknown>, v: T) => v is (string extends T ? string : T)} */ (
2024
+ Function.call.bind(Object.hasOwnProperty)
2025
+ );
2026
+
2027
+ const READ = Symbol("read");
2028
+ const CALL = Symbol("call");
2029
+ const CONSTRUCT = Symbol("construct");
2030
+ const ESM = Symbol("esm");
2031
+
2032
+ const requireCall = { require: { [CALL]: true } };
2033
+
2034
+ /**
2035
+ * Check whether a given variable is modified or not.
2036
+ * @param {Variable|undefined} variable The variable to check.
2037
+ * @returns {boolean} `true` if the variable is modified.
2038
+ */
2039
+ function isModifiedGlobal(variable) {
2040
+ return (
2041
+ variable == null ||
2042
+ variable.defs.length !== 0 ||
2043
+ variable.references.some((r) => r.isWrite())
2044
+ )
2045
+ }
2046
+
2047
+ /**
2048
+ * Check if the value of a given node is passed through to the parent syntax as-is.
2049
+ * For example, `a` and `b` in (`a || b` and `c ? a : b`) are passed through.
2050
+ * @param {Node} node A node to check.
2051
+ * @returns {node is RuleNode & {parent: Expression}} `true` if the node is passed through.
2052
+ */
2053
+ function isPassThrough(node) {
2054
+ const parent = /** @type {TSESTreeNode} */ (node).parent;
2055
+
2056
+ if (parent) {
2057
+ switch (parent.type) {
2058
+ case "ConditionalExpression":
2059
+ return parent.consequent === node || parent.alternate === node
2060
+ case "LogicalExpression":
2061
+ return true
2062
+ case "SequenceExpression":
2063
+ return (
2064
+ parent.expressions[parent.expressions.length - 1] === node
2065
+ )
2066
+ case "ChainExpression":
2067
+ return true
2068
+ case "TSAsExpression":
2069
+ case "TSSatisfiesExpression":
2070
+ case "TSTypeAssertion":
2071
+ case "TSNonNullExpression":
2072
+ case "TSInstantiationExpression":
2073
+ return true
2074
+
2075
+ default:
2076
+ return false
2077
+ }
2078
+ }
2079
+ return false
2080
+ }
2081
+
2082
+ /**
2083
+ * The reference tracker.
2084
+ */
2085
+ class ReferenceTracker {
2086
+ /**
2087
+ * Initialize this tracker.
2088
+ * @param {Scope} globalScope The global scope.
2089
+ * @param {object} [options] The options.
2090
+ * @param {"legacy"|"strict"} [options.mode="strict"] The mode to determine the ImportDeclaration's behavior for CJS modules.
2091
+ * @param {string[]} [options.globalObjectNames=["global","globalThis","self","window"]] The variable names for Global Object.
2092
+ */
2093
+ constructor(globalScope, options = {}) {
2094
+ const {
2095
+ mode = "strict",
2096
+ globalObjectNames = ["global", "globalThis", "self", "window"],
2097
+ } = options;
2098
+ /** @private @type {Variable[]} */
2099
+ this.variableStack = [];
2100
+ /** @private */
2101
+ this.globalScope = globalScope;
2102
+ /** @private */
2103
+ this.mode = mode;
2104
+ /** @private */
2105
+ this.globalObjectNames = globalObjectNames.slice(0);
2106
+ }
2107
+
2108
+ /**
2109
+ * Iterate the references of global variables.
2110
+ * @template T
2111
+ * @param {TraceMap<T>} traceMap The trace map.
2112
+ * @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate references.
2113
+ */
2114
+ *iterateGlobalReferences(traceMap) {
2115
+ for (const key of Object.keys(traceMap)) {
2116
+ const nextTraceMap = traceMap[key];
2117
+ const path = [key];
2118
+ const variable = this.globalScope.set.get(key);
2119
+
2120
+ if (isModifiedGlobal(variable)) {
2121
+ continue
2122
+ }
2123
+
2124
+ yield* this._iterateVariableReferences(
2125
+ /** @type {Variable} */ (variable),
2126
+ path,
2127
+ nextTraceMap,
2128
+ true,
2129
+ );
2130
+ }
2131
+
2132
+ for (const key of this.globalObjectNames) {
2133
+ /** @type {string[]} */
2134
+ const path = [];
2135
+ const variable = this.globalScope.set.get(key);
2136
+
2137
+ if (isModifiedGlobal(variable)) {
2138
+ continue
2139
+ }
2140
+
2141
+ yield* this._iterateVariableReferences(
2142
+ /** @type {Variable} */ (variable),
2143
+ path,
2144
+ traceMap,
2145
+ false,
2146
+ );
2147
+ }
2148
+ }
2149
+
2150
+ /**
2151
+ * Iterate the references of CommonJS modules.
2152
+ * @template T
2153
+ * @param {TraceMap<T>} traceMap The trace map.
2154
+ * @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate references.
2155
+ */
2156
+ *iterateCjsReferences(traceMap) {
2157
+ for (const { node } of this.iterateGlobalReferences(requireCall)) {
2158
+ const key = getStringIfConstant(
2159
+ /** @type {CallExpression} */ (node).arguments[0],
2160
+ );
2161
+ if (key == null || !has(traceMap, key)) {
2162
+ continue
2163
+ }
2164
+
2165
+ const nextTraceMap = traceMap[key];
2166
+ const path = [key];
2167
+
2168
+ if (nextTraceMap[READ]) {
2169
+ yield {
2170
+ node,
2171
+ path,
2172
+ type: READ,
2173
+ info: nextTraceMap[READ],
2174
+ };
2175
+ }
2176
+ yield* this._iteratePropertyReferences(
2177
+ /** @type {CallExpression} */ (node),
2178
+ path,
2179
+ nextTraceMap,
2180
+ );
2181
+ }
2182
+ }
2183
+
2184
+ /**
2185
+ * Iterate the references of ES modules.
2186
+ * @template T
2187
+ * @param {TraceMap<T>} traceMap The trace map.
2188
+ * @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate references.
2189
+ */
2190
+ *iterateEsmReferences(traceMap) {
2191
+ const programNode = /** @type {Program} */ (this.globalScope.block);
2192
+
2193
+ for (const node of programNode.body) {
2194
+ if (!isHasSource(node)) {
2195
+ continue
2196
+ }
2197
+ const moduleId = /** @type {string} */ (node.source.value);
2198
+
2199
+ if (!has(traceMap, moduleId)) {
2200
+ continue
2201
+ }
2202
+ const nextTraceMap = traceMap[moduleId];
2203
+ const path = [moduleId];
2204
+
2205
+ if (nextTraceMap[READ]) {
2206
+ yield {
2207
+ // eslint-disable-next-line object-shorthand -- apply type
2208
+ node: /** @type {RuleNode} */ (node),
2209
+ path,
2210
+ type: READ,
2211
+ info: nextTraceMap[READ],
2212
+ };
2213
+ }
2214
+
2215
+ if (node.type === "ExportAllDeclaration") {
2216
+ for (const key of Object.keys(nextTraceMap)) {
2217
+ const exportTraceMap = nextTraceMap[key];
2218
+ if (exportTraceMap[READ]) {
2219
+ yield {
2220
+ // eslint-disable-next-line object-shorthand -- apply type
2221
+ node: /** @type {RuleNode} */ (node),
2222
+ path: path.concat(key),
2223
+ type: READ,
2224
+ info: exportTraceMap[READ],
2225
+ };
2226
+ }
2227
+ }
2228
+ } else {
2229
+ for (const specifier of node.specifiers) {
2230
+ const esm = has(nextTraceMap, ESM);
2231
+ const it = this._iterateImportReferences(
2232
+ specifier,
2233
+ path,
2234
+ esm
2235
+ ? nextTraceMap
2236
+ : this.mode === "legacy"
2237
+ ? { default: nextTraceMap, ...nextTraceMap }
2238
+ : { default: nextTraceMap },
2239
+ );
2240
+
2241
+ if (esm) {
2242
+ yield* it;
2243
+ } else {
2244
+ for (const report of it) {
2245
+ report.path = report.path.filter(exceptDefault);
2246
+ if (
2247
+ report.path.length >= 2 ||
2248
+ report.type !== READ
2249
+ ) {
2250
+ yield report;
2251
+ }
2252
+ }
2253
+ }
2254
+ }
2255
+ }
2256
+ }
2257
+ }
2258
+
2259
+ /**
2260
+ * Iterate the property references for a given expression AST node.
2261
+ * @template T
2262
+ * @param {Expression} node The expression AST node to iterate property references.
2263
+ * @param {TraceMap<T>} traceMap The trace map.
2264
+ * @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate property references.
2265
+ */
2266
+ *iteratePropertyReferences(node, traceMap) {
2267
+ yield* this._iteratePropertyReferences(node, [], traceMap);
2268
+ }
2269
+
2270
+ /**
2271
+ * Iterate the references for a given variable.
2272
+ * @private
2273
+ * @template T
2274
+ * @param {Variable} variable The variable to iterate that references.
2275
+ * @param {string[]} path The current path.
2276
+ * @param {TraceMapObject<T>} traceMap The trace map.
2277
+ * @param {boolean} shouldReport = The flag to report those references.
2278
+ * @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate references.
2279
+ */
2280
+ *_iterateVariableReferences(variable, path, traceMap, shouldReport) {
2281
+ if (this.variableStack.includes(variable)) {
2282
+ return
2283
+ }
2284
+ this.variableStack.push(variable);
2285
+ try {
2286
+ for (const reference of variable.references) {
2287
+ if (!reference.isRead()) {
2288
+ continue
2289
+ }
2290
+ const node = /** @type {RuleNode & Identifier} */ (
2291
+ reference.identifier
2292
+ );
2293
+
2294
+ if (shouldReport && traceMap[READ]) {
2295
+ yield { node, path, type: READ, info: traceMap[READ] };
2296
+ }
2297
+ yield* this._iteratePropertyReferences(node, path, traceMap);
2298
+ }
2299
+ } finally {
2300
+ this.variableStack.pop();
2301
+ }
2302
+ }
2303
+
2304
+ /**
2305
+ * Iterate the references for a given AST node.
2306
+ * @private
2307
+ * @template T
2308
+ * @param {Expression} rootNode The AST node to iterate references.
2309
+ * @param {string[]} path The current path.
2310
+ * @param {TraceMapObject<T>} traceMap The trace map.
2311
+ * @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate references.
2312
+ */
2313
+ //eslint-disable-next-line complexity
2314
+ *_iteratePropertyReferences(rootNode, path, traceMap) {
2315
+ let node = rootNode;
2316
+ while (isPassThrough(node)) {
2317
+ node = node.parent;
2318
+ }
2319
+
2320
+ const parent = /** @type {RuleNode} */ (node).parent;
2321
+ if (!parent) {
2322
+ return
2323
+ }
2324
+ if (parent.type === "MemberExpression") {
2325
+ if (parent.object === node) {
2326
+ const key = getPropertyName(parent);
2327
+ if (key == null || !has(traceMap, key)) {
2328
+ return
2329
+ }
2330
+
2331
+ path = path.concat(key); //eslint-disable-line no-param-reassign
2332
+ const nextTraceMap = traceMap[key];
2333
+ if (nextTraceMap[READ]) {
2334
+ yield {
2335
+ node: parent,
2336
+ path,
2337
+ type: READ,
2338
+ info: nextTraceMap[READ],
2339
+ };
2340
+ }
2341
+ yield* this._iteratePropertyReferences(
2342
+ parent,
2343
+ path,
2344
+ nextTraceMap,
2345
+ );
2346
+ }
2347
+ return
2348
+ }
2349
+ if (parent.type === "CallExpression") {
2350
+ if (parent.callee === node && traceMap[CALL]) {
2351
+ yield { node: parent, path, type: CALL, info: traceMap[CALL] };
2352
+ }
2353
+ return
2354
+ }
2355
+ if (parent.type === "NewExpression") {
2356
+ if (parent.callee === node && traceMap[CONSTRUCT]) {
2357
+ yield {
2358
+ node: parent,
2359
+ path,
2360
+ type: CONSTRUCT,
2361
+ info: traceMap[CONSTRUCT],
2362
+ };
2363
+ }
2364
+ return
2365
+ }
2366
+ if (parent.type === "AssignmentExpression") {
2367
+ if (parent.right === node) {
2368
+ yield* this._iterateLhsReferences(parent.left, path, traceMap);
2369
+ yield* this._iteratePropertyReferences(parent, path, traceMap);
2370
+ }
2371
+ return
2372
+ }
2373
+ if (parent.type === "AssignmentPattern") {
2374
+ if (parent.right === node) {
2375
+ yield* this._iterateLhsReferences(parent.left, path, traceMap);
2376
+ }
2377
+ return
2378
+ }
2379
+ if (parent.type === "VariableDeclarator") {
2380
+ if (parent.init === node) {
2381
+ yield* this._iterateLhsReferences(parent.id, path, traceMap);
2382
+ }
2383
+ }
2384
+ }
2385
+
2386
+ /**
2387
+ * Iterate the references for a given Pattern node.
2388
+ * @private
2389
+ * @template T
2390
+ * @param {Pattern} patternNode The Pattern node to iterate references.
2391
+ * @param {string[]} path The current path.
2392
+ * @param {TraceMapObject<T>} traceMap The trace map.
2393
+ * @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate references.
2394
+ */
2395
+ *_iterateLhsReferences(patternNode, path, traceMap) {
2396
+ if (patternNode.type === "Identifier") {
2397
+ const variable = findVariable(this.globalScope, patternNode);
2398
+ if (variable != null) {
2399
+ yield* this._iterateVariableReferences(
2400
+ variable,
2401
+ path,
2402
+ traceMap,
2403
+ false,
2404
+ );
2405
+ }
2406
+ return
2407
+ }
2408
+ if (patternNode.type === "ObjectPattern") {
2409
+ for (const property of patternNode.properties) {
2410
+ const key = getPropertyName(
2411
+ /** @type {AssignmentProperty} */ (property),
2412
+ );
2413
+
2414
+ if (key == null || !has(traceMap, key)) {
2415
+ continue
2416
+ }
2417
+
2418
+ const nextPath = path.concat(key);
2419
+ const nextTraceMap = traceMap[key];
2420
+ if (nextTraceMap[READ]) {
2421
+ yield {
2422
+ node: /** @type {RuleNode} */ (property),
2423
+ path: nextPath,
2424
+ type: READ,
2425
+ info: nextTraceMap[READ],
2426
+ };
2427
+ }
2428
+ yield* this._iterateLhsReferences(
2429
+ /** @type {AssignmentProperty} */ (property).value,
2430
+ nextPath,
2431
+ nextTraceMap,
2432
+ );
2433
+ }
2434
+ return
2435
+ }
2436
+ if (patternNode.type === "AssignmentPattern") {
2437
+ yield* this._iterateLhsReferences(patternNode.left, path, traceMap);
2438
+ }
2439
+ }
2440
+
2441
+ /**
2442
+ * Iterate the references for a given ModuleSpecifier node.
2443
+ * @private
2444
+ * @template T
2445
+ * @param {ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier} specifierNode The ModuleSpecifier node to iterate references.
2446
+ * @param {string[]} path The current path.
2447
+ * @param {TraceMapObject<T>} traceMap The trace map.
2448
+ * @returns {IterableIterator<TrackedReferences<T>>} The iterator to iterate references.
2449
+ */
2450
+ *_iterateImportReferences(specifierNode, path, traceMap) {
2451
+ const type = specifierNode.type;
2452
+
2453
+ if (type === "ImportSpecifier" || type === "ImportDefaultSpecifier") {
2454
+ const key =
2455
+ type === "ImportDefaultSpecifier"
2456
+ ? "default"
2457
+ : specifierNode.imported.type === "Identifier"
2458
+ ? specifierNode.imported.name
2459
+ : specifierNode.imported.value;
2460
+ if (!has(traceMap, key)) {
2461
+ return
2462
+ }
2463
+
2464
+ path = path.concat(key); //eslint-disable-line no-param-reassign
2465
+ const nextTraceMap = traceMap[key];
2466
+ if (nextTraceMap[READ]) {
2467
+ yield {
2468
+ node: /** @type {RuleNode} */ (specifierNode),
2469
+ path,
2470
+ type: READ,
2471
+ info: nextTraceMap[READ],
2472
+ };
2473
+ }
2474
+ yield* this._iterateVariableReferences(
2475
+ /** @type {Variable} */ (
2476
+ findVariable(this.globalScope, specifierNode.local)
2477
+ ),
2478
+ path,
2479
+ nextTraceMap,
2480
+ false,
2481
+ );
2482
+
2483
+ return
2484
+ }
2485
+
2486
+ if (type === "ImportNamespaceSpecifier") {
2487
+ yield* this._iterateVariableReferences(
2488
+ /** @type {Variable} */ (
2489
+ findVariable(this.globalScope, specifierNode.local)
2490
+ ),
2491
+ path,
2492
+ traceMap,
2493
+ false,
2494
+ );
2495
+ return
2496
+ }
2497
+
2498
+ if (type === "ExportSpecifier") {
2499
+ const key =
2500
+ specifierNode.local.type === "Identifier"
2501
+ ? specifierNode.local.name
2502
+ : specifierNode.local.value;
2503
+ if (!has(traceMap, key)) {
2504
+ return
2505
+ }
2506
+
2507
+ path = path.concat(key); //eslint-disable-line no-param-reassign
2508
+ const nextTraceMap = traceMap[key];
2509
+ if (nextTraceMap[READ]) {
2510
+ yield {
2511
+ node: /** @type {RuleNode} */ (specifierNode),
2512
+ path,
2513
+ type: READ,
2514
+ info: nextTraceMap[READ],
2515
+ };
2516
+ }
2517
+ }
2518
+ }
2519
+ }
2520
+
2521
+ ReferenceTracker.READ = READ;
2522
+ ReferenceTracker.CALL = CALL;
2523
+ ReferenceTracker.CONSTRUCT = CONSTRUCT;
2524
+ ReferenceTracker.ESM = ESM;
2525
+
2526
+ /**
2527
+ * This is a predicate function for Array#filter.
2528
+ * @param {string} name A name part.
2529
+ * @param {number} index The index of the name.
2530
+ * @returns {boolean} `false` if it's default.
2531
+ */
2532
+ function exceptDefault(name, index) {
2533
+ return !(index === 1 && name === "default")
2534
+ }
2535
+
2536
+ /** @typedef {import("./types.mjs").StaticValue} StaticValue */
2537
+
2538
+ var index = {
2539
+ CALL,
2540
+ CONSTRUCT,
2541
+ ESM,
2542
+ findVariable,
2543
+ getFunctionHeadLocation,
2544
+ getFunctionNameWithKind,
2545
+ getInnermostScope,
2546
+ getPropertyName,
2547
+ getStaticValue,
2548
+ getStringIfConstant,
2549
+ hasSideEffect,
2550
+ isArrowToken,
2551
+ isClosingBraceToken,
2552
+ isClosingBracketToken,
2553
+ isClosingParenToken,
2554
+ isColonToken,
2555
+ isCommaToken,
2556
+ isCommentToken,
2557
+ isNotArrowToken,
2558
+ isNotClosingBraceToken,
2559
+ isNotClosingBracketToken,
2560
+ isNotClosingParenToken,
2561
+ isNotColonToken,
2562
+ isNotCommaToken,
2563
+ isNotCommentToken,
2564
+ isNotOpeningBraceToken,
2565
+ isNotOpeningBracketToken,
2566
+ isNotOpeningParenToken,
2567
+ isNotSemicolonToken,
2568
+ isOpeningBraceToken,
2569
+ isOpeningBracketToken,
2570
+ isOpeningParenToken,
2571
+ isParenthesized,
2572
+ isSemicolonToken,
2573
+ PatternMatcher,
2574
+ READ,
2575
+ ReferenceTracker,
2576
+ };
2577
+
2578
+ export { CALL, CONSTRUCT, ESM, PatternMatcher, READ, ReferenceTracker, index as default, findVariable, getFunctionHeadLocation, getFunctionNameWithKind, getInnermostScope, getPropertyName, getStaticValue, getStringIfConstant, hasSideEffect, isArrowToken, isClosingBraceToken, isClosingBracketToken, isClosingParenToken, isColonToken, isCommaToken, isCommentToken, isNotArrowToken, isNotClosingBraceToken, isNotClosingBracketToken, isNotClosingParenToken, isNotColonToken, isNotCommaToken, isNotCommentToken, isNotOpeningBraceToken, isNotOpeningBracketToken, isNotOpeningParenToken, isNotSemicolonToken, isOpeningBraceToken, isOpeningBracketToken, isOpeningParenToken, isParenthesized, isSemicolonToken };
2579
+ //# sourceMappingURL=index.mjs.map
node_modules/@eslint-community/eslint-utils/index.mjs.map ADDED
The diff for this file is too large to render. See raw diff
 
node_modules/@eslint-community/eslint-utils/package.json ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@eslint-community/eslint-utils",
3
+ "version": "4.9.1",
4
+ "description": "Utilities for ESLint plugins.",
5
+ "keywords": [
6
+ "eslint"
7
+ ],
8
+ "homepage": "https://github.com/eslint-community/eslint-utils#readme",
9
+ "bugs": {
10
+ "url": "https://github.com/eslint-community/eslint-utils/issues"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/eslint-community/eslint-utils"
15
+ },
16
+ "license": "MIT",
17
+ "author": "Toru Nagashima",
18
+ "sideEffects": false,
19
+ "exports": {
20
+ ".": {
21
+ "import": "./index.mjs",
22
+ "require": "./index.js"
23
+ },
24
+ "./package.json": "./package.json"
25
+ },
26
+ "main": "index",
27
+ "module": "index.mjs",
28
+ "files": [
29
+ "index.*"
30
+ ],
31
+ "scripts": {
32
+ "prebuild": "npm run -s clean",
33
+ "build": "npm run build:dts && npm run build:rollup",
34
+ "build:dts": "tsc -p tsconfig.build.json",
35
+ "build:rollup": "rollup -c",
36
+ "clean": "rimraf .nyc_output coverage index.* dist",
37
+ "coverage": "opener ./coverage/lcov-report/index.html",
38
+ "docs:build": "vitepress build docs",
39
+ "docs:watch": "vitepress dev docs",
40
+ "format": "npm run -s format:prettier -- --write",
41
+ "format:prettier": "prettier .",
42
+ "format:check": "npm run -s format:prettier -- --check",
43
+ "lint:eslint": "eslint .",
44
+ "lint:format": "npm run -s format:check",
45
+ "lint:installed-check": "installed-check -v -i installed-check -i npm-run-all2 -i knip -i rollup-plugin-dts",
46
+ "lint:knip": "knip",
47
+ "lint": "run-p lint:*",
48
+ "test-coverage": "c8 mocha --reporter dot \"test/*.mjs\"",
49
+ "test": "mocha --reporter dot \"test/*.mjs\"",
50
+ "preversion": "npm run test-coverage && npm run -s build",
51
+ "postversion": "git push && git push --tags",
52
+ "prewatch": "npm run -s clean",
53
+ "watch": "warun \"{src,test}/**/*.mjs\" -- npm run -s test:mocha"
54
+ },
55
+ "dependencies": {
56
+ "eslint-visitor-keys": "^3.4.3"
57
+ },
58
+ "devDependencies": {
59
+ "@eslint-community/eslint-plugin-mysticatea": "^15.6.1",
60
+ "@types/eslint": "^9.6.1",
61
+ "@types/estree": "^1.0.7",
62
+ "@typescript-eslint/parser": "^5.62.0",
63
+ "@typescript-eslint/types": "^5.62.0",
64
+ "c8": "^8.0.1",
65
+ "dot-prop": "^7.2.0",
66
+ "eslint": "^8.57.1",
67
+ "installed-check": "^8.0.1",
68
+ "knip": "^5.33.3",
69
+ "mocha": "^9.2.2",
70
+ "npm-run-all2": "^6.2.3",
71
+ "opener": "^1.5.2",
72
+ "prettier": "2.8.8",
73
+ "rimraf": "^3.0.2",
74
+ "rollup": "^2.79.2",
75
+ "rollup-plugin-dts": "^4.2.3",
76
+ "rollup-plugin-sourcemaps": "^0.6.3",
77
+ "semver": "^7.6.3",
78
+ "typescript": "^4.9.5",
79
+ "vitepress": "^1.4.1",
80
+ "warun": "^1.0.0"
81
+ },
82
+ "peerDependencies": {
83
+ "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0"
84
+ },
85
+ "engines": {
86
+ "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
87
+ },
88
+ "funding": "https://opencollective.com/eslint"
89
+ }
node_modules/@eslint-community/regexpp/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.
node_modules/@eslint-community/regexpp/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@^12.0.0 || ^14.0.0 || >=16.0.0.
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?, flags?)
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
+ - `flags?` (`{ unicode?: boolean, unicodeSets?: boolean }`) The flags to enable Unicode mode, and Unicode Set 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, flags)
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
+ - `flags?` (`{ unicode?: boolean, unicodeSets?: boolean }`) The flags to enable Unicode mode, and Unicode Set 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#L743
176
+ [`RegExpValidator.Options`]: src/validator.ts#L220
177
+ [`RegExpVisitor.Handlers`]: src/visitor.ts#L291
node_modules/@eslint-community/regexpp/index.d.ts ADDED
@@ -0,0 +1,1163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Generated by dts-bundle v0.7.3
2
+
3
+ declare module "@eslint-community/regexpp" {
4
+ import * as AST from "@eslint-community/regexpp/ast";
5
+ import { RegExpParser } from "@eslint-community/regexpp/parser";
6
+ import { RegExpValidator } from "@eslint-community/regexpp/validator";
7
+ import { RegExpVisitor } from "@eslint-community/regexpp/visitor";
8
+ export { RegExpSyntaxError } from "@eslint-community/regexpp/regexp-syntax-error";
9
+ export { AST, RegExpParser, RegExpValidator };
10
+ /**
11
+ * Parse a given regular expression literal then make AST object.
12
+ * @param source The source code to parse.
13
+ * @param options The options to parse.
14
+ * @returns The AST of the regular expression.
15
+ */
16
+ export function parseRegExpLiteral(
17
+ source: RegExp | string,
18
+ options?: RegExpParser.Options
19
+ ): AST.RegExpLiteral;
20
+ /**
21
+ * Validate a given regular expression literal.
22
+ * @param source The source code to validate.
23
+ * @param options The options to validate.
24
+ */
25
+ export function validateRegExpLiteral(
26
+ source: string,
27
+ options?: RegExpValidator.Options
28
+ ): void;
29
+ export function visitRegExpAST(
30
+ node: AST.Node,
31
+ handlers: RegExpVisitor.Handlers
32
+ ): void;
33
+ }
34
+
35
+ declare module "@eslint-community/regexpp/ast" {
36
+ /**
37
+ * The type which includes all nodes.
38
+ */
39
+ export type Node = BranchNode | LeafNode;
40
+ /**
41
+ * The type which includes all branch nodes.
42
+ */
43
+ export type BranchNode =
44
+ | Alternative
45
+ | CapturingGroup
46
+ | CharacterClass
47
+ | CharacterClassRange
48
+ | ClassIntersection
49
+ | ClassStringDisjunction
50
+ | ClassSubtraction
51
+ | ExpressionCharacterClass
52
+ | Group
53
+ | LookaroundAssertion
54
+ | Modifiers
55
+ | Pattern
56
+ | Quantifier
57
+ | RegExpLiteral
58
+ | StringAlternative;
59
+ /**
60
+ * The type which includes all leaf nodes.
61
+ */
62
+ export type LeafNode =
63
+ | Backreference
64
+ | BoundaryAssertion
65
+ | Character
66
+ | CharacterSet
67
+ | Flags
68
+ | ModifierFlags;
69
+ /**
70
+ * The type which includes all atom nodes.
71
+ */
72
+ export type Element = Assertion | QuantifiableElement | Quantifier;
73
+ /**
74
+ * The type which includes all atom nodes that Quantifier node can have as children.
75
+ */
76
+ export type QuantifiableElement =
77
+ | Backreference
78
+ | CapturingGroup
79
+ | Character
80
+ | CharacterClass
81
+ | CharacterSet
82
+ | ExpressionCharacterClass
83
+ | Group
84
+ | LookaheadAssertion;
85
+ /**
86
+ * The type which includes all character class atom nodes.
87
+ */
88
+ export type CharacterClassElement =
89
+ | ClassRangesCharacterClassElement
90
+ | UnicodeSetsCharacterClassElement;
91
+ export type ClassRangesCharacterClassElement =
92
+ | Character
93
+ | CharacterClassRange
94
+ | CharacterUnicodePropertyCharacterSet
95
+ | EscapeCharacterSet;
96
+ export type UnicodeSetsCharacterClassElement =
97
+ | Character
98
+ | CharacterClassRange
99
+ | ClassStringDisjunction
100
+ | EscapeCharacterSet
101
+ | ExpressionCharacterClass
102
+ | UnicodePropertyCharacterSet
103
+ | UnicodeSetsCharacterClass;
104
+ /**
105
+ * The type which defines common properties for all node types.
106
+ */
107
+ export interface NodeBase {
108
+ /** The node type. */
109
+ type: Node["type"];
110
+ /** The parent node. */
111
+ parent: Node["parent"];
112
+ /** The 0-based index that this node starts. */
113
+ start: number;
114
+ /** The 0-based index that this node ends. */
115
+ end: number;
116
+ /** The raw text of this node. */
117
+ raw: string;
118
+ }
119
+ /**
120
+ * The root node.
121
+ */
122
+ export interface RegExpLiteral extends NodeBase {
123
+ type: "RegExpLiteral";
124
+ parent: null;
125
+ pattern: Pattern;
126
+ flags: Flags;
127
+ }
128
+ /**
129
+ * The pattern.
130
+ */
131
+ export interface Pattern extends NodeBase {
132
+ type: "Pattern";
133
+ parent: RegExpLiteral | null;
134
+ alternatives: Alternative[];
135
+ }
136
+ /**
137
+ * The alternative.
138
+ * E.g. `a|b`
139
+ */
140
+ export interface Alternative extends NodeBase {
141
+ type: "Alternative";
142
+ parent: CapturingGroup | Group | LookaroundAssertion | Pattern;
143
+ elements: Element[];
144
+ }
145
+ /**
146
+ * The uncapturing group.
147
+ * E.g. `(?:ab)`
148
+ */
149
+ export interface Group extends NodeBase {
150
+ type: "Group";
151
+ parent: Alternative | Quantifier;
152
+ modifiers: Modifiers | null;
153
+ alternatives: Alternative[];
154
+ }
155
+ /**
156
+ * The capturing group.
157
+ * E.g. `(ab)`, `(?<name>ab)`
158
+ */
159
+ export interface CapturingGroup extends NodeBase {
160
+ type: "CapturingGroup";
161
+ parent: Alternative | Quantifier;
162
+ name: string | null;
163
+ alternatives: Alternative[];
164
+ references: Backreference[];
165
+ }
166
+ /**
167
+ * The lookaround assertion.
168
+ */
169
+ export type LookaroundAssertion = LookaheadAssertion | LookbehindAssertion;
170
+ /**
171
+ * The lookahead assertion.
172
+ * E.g. `(?=ab)`, `(?!ab)`
173
+ */
174
+ export interface LookaheadAssertion extends NodeBase {
175
+ type: "Assertion";
176
+ parent: Alternative | Quantifier;
177
+ kind: "lookahead";
178
+ negate: boolean;
179
+ alternatives: Alternative[];
180
+ }
181
+ /**
182
+ * The lookbehind assertion.
183
+ * E.g. `(?<=ab)`, `(?<!ab)`
184
+ */
185
+ export interface LookbehindAssertion extends NodeBase {
186
+ type: "Assertion";
187
+ parent: Alternative;
188
+ kind: "lookbehind";
189
+ negate: boolean;
190
+ alternatives: Alternative[];
191
+ }
192
+ /**
193
+ * The quantifier.
194
+ * E.g. `a?`, `a*`, `a+`, `a{1,2}`, `a??`, `a*?`, `a+?`, `a{1,2}?`
195
+ */
196
+ export interface Quantifier extends NodeBase {
197
+ type: "Quantifier";
198
+ parent: Alternative;
199
+ min: number;
200
+ max: number;
201
+ greedy: boolean;
202
+ element: QuantifiableElement;
203
+ }
204
+ /**
205
+ * The character class.
206
+ * E.g. `[ab]`, `[^ab]`
207
+ */
208
+ export type CharacterClass =
209
+ | ClassRangesCharacterClass
210
+ | UnicodeSetsCharacterClass;
211
+ interface BaseCharacterClass extends NodeBase {
212
+ type: "CharacterClass";
213
+ parent:
214
+ | Alternative
215
+ | ClassIntersection
216
+ | ClassSubtraction
217
+ | Quantifier
218
+ | UnicodeSetsCharacterClass;
219
+ unicodeSets: boolean;
220
+ negate: boolean;
221
+ elements: CharacterClassElement[];
222
+ }
223
+ /**
224
+ * The character class used in legacy (neither `u` nor `v` flag) and Unicode mode (`u` flag).
225
+ *
226
+ * This character class is guaranteed to **not** contain strings.
227
+ *
228
+ * In Unicode sets mode (`v` flag), {@link UnicodeSetsCharacterClass} is used.
229
+ */
230
+ export interface ClassRangesCharacterClass extends BaseCharacterClass {
231
+ parent: Alternative | Quantifier;
232
+ unicodeSets: false;
233
+ elements: ClassRangesCharacterClassElement[];
234
+ }
235
+ /**
236
+ * The character class used in Unicode sets mode (`v` flag).
237
+ *
238
+ * This character class may contain strings.
239
+ */
240
+ export interface UnicodeSetsCharacterClass extends BaseCharacterClass {
241
+ parent:
242
+ | Alternative
243
+ | ClassIntersection
244
+ | ClassSubtraction
245
+ | Quantifier
246
+ | UnicodeSetsCharacterClass;
247
+ unicodeSets: true;
248
+ elements: UnicodeSetsCharacterClassElement[];
249
+ }
250
+ /**
251
+ * The character class.
252
+ * E.g. `[a-b]`
253
+ */
254
+ export interface CharacterClassRange extends NodeBase {
255
+ type: "CharacterClassRange";
256
+ parent: CharacterClass;
257
+ min: Character;
258
+ max: Character;
259
+ }
260
+ /**
261
+ * The assertion.
262
+ */
263
+ export type Assertion = BoundaryAssertion | LookaroundAssertion;
264
+ /**
265
+ * The boundary assertion.
266
+ */
267
+ export type BoundaryAssertion = EdgeAssertion | WordBoundaryAssertion;
268
+ /**
269
+ * The edge boundary assertion.
270
+ * E.g. `^`, `$`
271
+ */
272
+ export interface EdgeAssertion extends NodeBase {
273
+ type: "Assertion";
274
+ parent: Alternative | Quantifier;
275
+ kind: "end" | "start";
276
+ }
277
+ /**
278
+ * The word bondary assertion.
279
+ * E.g. `\b`, `\B`
280
+ */
281
+ export interface WordBoundaryAssertion extends NodeBase {
282
+ type: "Assertion";
283
+ parent: Alternative | Quantifier;
284
+ kind: "word";
285
+ negate: boolean;
286
+ }
287
+ /**
288
+ * The character set.
289
+ */
290
+ export type CharacterSet =
291
+ | AnyCharacterSet
292
+ | EscapeCharacterSet
293
+ | UnicodePropertyCharacterSet;
294
+ /**
295
+ * The dot.
296
+ * E.g. `.`
297
+ */
298
+ export interface AnyCharacterSet extends NodeBase {
299
+ type: "CharacterSet";
300
+ parent: Alternative | Quantifier;
301
+ kind: "any";
302
+ }
303
+ /**
304
+ * The character class escape.
305
+ * E.g. `\d`, `\s`, `\w`, `\D`, `\S`, `\W`
306
+ */
307
+ export interface EscapeCharacterSet extends NodeBase {
308
+ type: "CharacterSet";
309
+ parent:
310
+ | Alternative
311
+ | CharacterClass
312
+ | ClassIntersection
313
+ | ClassSubtraction
314
+ | Quantifier;
315
+ kind: "digit" | "space" | "word";
316
+ negate: boolean;
317
+ }
318
+ /**
319
+ * The unicode property escape.
320
+ * E.g. `\p{ASCII}`, `\P{ASCII}`, `\p{Script=Hiragana}`
321
+ */
322
+ export type UnicodePropertyCharacterSet =
323
+ | CharacterUnicodePropertyCharacterSet
324
+ | StringsUnicodePropertyCharacterSet;
325
+ interface BaseUnicodePropertyCharacterSet extends NodeBase {
326
+ type: "CharacterSet";
327
+ parent:
328
+ | Alternative
329
+ | CharacterClass
330
+ | ClassIntersection
331
+ | ClassSubtraction
332
+ | Quantifier;
333
+ kind: "property";
334
+ strings: boolean;
335
+ key: string;
336
+ value: string | null;
337
+ negate: boolean;
338
+ }
339
+ export interface CharacterUnicodePropertyCharacterSet
340
+ extends BaseUnicodePropertyCharacterSet {
341
+ strings: false;
342
+ value: string | null;
343
+ negate: boolean;
344
+ }
345
+ /** StringsUnicodePropertyCharacterSet is Unicode property escape with property of strings. */
346
+ export interface StringsUnicodePropertyCharacterSet
347
+ extends BaseUnicodePropertyCharacterSet {
348
+ parent:
349
+ | Alternative
350
+ | ClassIntersection
351
+ | ClassSubtraction
352
+ | Quantifier
353
+ | UnicodeSetsCharacterClass;
354
+ strings: true;
355
+ value: null;
356
+ negate: false;
357
+ }
358
+ /**
359
+ * The expression character class.
360
+ * E.g. `[a--b]`, `[a&&b]`,`[^a--b]`, `[^a&&b]`
361
+ */
362
+ export interface ExpressionCharacterClass extends NodeBase {
363
+ type: "ExpressionCharacterClass";
364
+ parent:
365
+ | Alternative
366
+ | ClassIntersection
367
+ | ClassSubtraction
368
+ | Quantifier
369
+ | UnicodeSetsCharacterClass;
370
+ negate: boolean;
371
+ expression: ClassIntersection | ClassSubtraction;
372
+ }
373
+ export type ClassSetOperand =
374
+ | Character
375
+ | ClassStringDisjunction
376
+ | EscapeCharacterSet
377
+ | ExpressionCharacterClass
378
+ | UnicodePropertyCharacterSet
379
+ | UnicodeSetsCharacterClass;
380
+ /**
381
+ * The character class intersection.
382
+ * E.g. `a&&b`
383
+ */
384
+ export interface ClassIntersection extends NodeBase {
385
+ type: "ClassIntersection";
386
+ parent: ClassIntersection | ExpressionCharacterClass;
387
+ left: ClassIntersection | ClassSetOperand;
388
+ right: ClassSetOperand;
389
+ }
390
+ /**
391
+ * The character class subtraction.
392
+ * E.g. `a--b`
393
+ */
394
+ export interface ClassSubtraction extends NodeBase {
395
+ type: "ClassSubtraction";
396
+ parent: ClassSubtraction | ExpressionCharacterClass;
397
+ left: ClassSetOperand | ClassSubtraction;
398
+ right: ClassSetOperand;
399
+ }
400
+ /**
401
+ * The character class string disjunction.
402
+ * E.g. `\q{a|b}`
403
+ */
404
+ export interface ClassStringDisjunction extends NodeBase {
405
+ type: "ClassStringDisjunction";
406
+ parent: ClassIntersection | ClassSubtraction | UnicodeSetsCharacterClass;
407
+ alternatives: StringAlternative[];
408
+ }
409
+ /** StringAlternative is only used for `\q{alt}`({@link ClassStringDisjunction}). */
410
+ export interface StringAlternative extends NodeBase {
411
+ type: "StringAlternative";
412
+ parent: ClassStringDisjunction;
413
+ elements: Character[];
414
+ }
415
+ /**
416
+ * The character.
417
+ * This includes escape sequences which mean a character.
418
+ * E.g. `a`, `あ`, `✿`, `\x65`, `\u0065`, `\u{65}`, `\/`
419
+ */
420
+ export interface Character extends NodeBase {
421
+ type: "Character";
422
+ parent:
423
+ | Alternative
424
+ | CharacterClass
425
+ | CharacterClassRange
426
+ | ClassIntersection
427
+ | ClassSubtraction
428
+ | Quantifier
429
+ | StringAlternative;
430
+ value: number;
431
+ }
432
+ /**
433
+ * The backreference.
434
+ * E.g. `\1`, `\k<name>`
435
+ */
436
+ export type Backreference = AmbiguousBackreference | UnambiguousBackreference;
437
+ interface BaseBackreference extends NodeBase {
438
+ type: "Backreference";
439
+ parent: Alternative | Quantifier;
440
+ ref: number | string;
441
+ ambiguous: boolean;
442
+ resolved: CapturingGroup | CapturingGroup[];
443
+ }
444
+ export interface AmbiguousBackreference extends BaseBackreference {
445
+ ref: string;
446
+ ambiguous: true;
447
+ resolved: CapturingGroup[];
448
+ }
449
+ export interface UnambiguousBackreference extends BaseBackreference {
450
+ ambiguous: false;
451
+ resolved: CapturingGroup;
452
+ }
453
+ /**
454
+ * The modifiers.
455
+ */
456
+ export interface Modifiers extends NodeBase {
457
+ type: "Modifiers";
458
+ parent: Group;
459
+ /**
460
+ * The add modifier flags.
461
+ */
462
+ add: ModifierFlags;
463
+ /**
464
+ * The remove modifier flags.
465
+ *
466
+ * `null` means no remove modifier flags. e.g. `(?ims:x)`
467
+ * The reason for `null` is that there is no position where the remove modifier flags appears. Must be behind the minus mark.
468
+ */
469
+ remove: ModifierFlags | null;
470
+ }
471
+ /**
472
+ * The modifier flags.
473
+ */
474
+ export interface ModifierFlags extends NodeBase {
475
+ type: "ModifierFlags";
476
+ parent: Modifiers;
477
+ dotAll: boolean;
478
+ ignoreCase: boolean;
479
+ multiline: boolean;
480
+ }
481
+ /**
482
+ * The flags.
483
+ */
484
+ export interface Flags extends NodeBase {
485
+ type: "Flags";
486
+ parent: RegExpLiteral | null;
487
+ dotAll: boolean;
488
+ global: boolean;
489
+ hasIndices: boolean;
490
+ ignoreCase: boolean;
491
+ multiline: boolean;
492
+ sticky: boolean;
493
+ unicode: boolean;
494
+ unicodeSets: boolean;
495
+ }
496
+ export {};
497
+ }
498
+
499
+ declare module "@eslint-community/regexpp/parser" {
500
+ import type {
501
+ Flags,
502
+ RegExpLiteral,
503
+ Pattern,
504
+ } from "@eslint-community/regexpp/ast";
505
+ import type { EcmaVersion } from "@eslint-community/regexpp/ecma-versions";
506
+ export namespace RegExpParser {
507
+ /**
508
+ * The options for RegExpParser construction.
509
+ */
510
+ interface Options {
511
+ /**
512
+ * The flag to disable Annex B syntax. Default is `false`.
513
+ */
514
+ strict?: boolean;
515
+ /**
516
+ * ECMAScript version. Default is `2025`.
517
+ * - `2015` added `u` and `y` flags.
518
+ * - `2018` added `s` flag, Named Capturing Group, Lookbehind Assertion,
519
+ * and Unicode Property Escape.
520
+ * - `2019`, `2020`, and `2021` added more valid Unicode Property Escapes.
521
+ * - `2022` added `d` flag.
522
+ * - `2023` added more valid Unicode Property Escapes.
523
+ * - `2024` added `v` flag.
524
+ * - `2025` added duplicate named capturing groups, modifiers.
525
+ */
526
+ ecmaVersion?: EcmaVersion;
527
+ }
528
+ }
529
+ export class RegExpParser {
530
+ /**
531
+ * Initialize this parser.
532
+ * @param options The options of parser.
533
+ */
534
+ constructor(options?: RegExpParser.Options);
535
+ /**
536
+ * Parse a regular expression literal. E.g. "/abc/g"
537
+ * @param source The source code to parse.
538
+ * @param start The start index in the source code.
539
+ * @param end The end index in the source code.
540
+ * @returns The AST of the given regular expression.
541
+ */
542
+ parseLiteral(source: string, start?: number, end?: number): RegExpLiteral;
543
+ /**
544
+ * Parse a regular expression flags. E.g. "gim"
545
+ * @param source The source code to parse.
546
+ * @param start The start index in the source code.
547
+ * @param end The end index in the source code.
548
+ * @returns The AST of the given flags.
549
+ */
550
+ parseFlags(source: string, start?: number, end?: number): Flags;
551
+ /**
552
+ * Parse a regular expression pattern. E.g. "abc"
553
+ * @param source The source code to parse.
554
+ * @param start The start index in the source code.
555
+ * @param end The end index in the source code.
556
+ * @param flags The flags.
557
+ * @returns The AST of the given pattern.
558
+ */
559
+ parsePattern(
560
+ source: string,
561
+ start?: number,
562
+ end?: number,
563
+ flags?: {
564
+ unicode?: boolean;
565
+ unicodeSets?: boolean;
566
+ }
567
+ ): Pattern;
568
+ /**
569
+ * @deprecated Backward compatibility
570
+ * Use object `flags` instead of boolean `uFlag`.
571
+ *
572
+ * @param source The source code to parse.
573
+ * @param start The start index in the source code.
574
+ * @param end The end index in the source code.
575
+ * @param uFlag The flag to set unicode mode.
576
+ * @returns The AST of the given pattern.
577
+ */
578
+ parsePattern(
579
+ source: string,
580
+ start?: number,
581
+ end?: number,
582
+ uFlag?: boolean
583
+ ): Pattern;
584
+ }
585
+ }
586
+
587
+ declare module "@eslint-community/regexpp/validator" {
588
+ import type { EcmaVersion } from "@eslint-community/regexpp/ecma-versions";
589
+ export type RegExpValidatorSourceContext = {
590
+ readonly source: string;
591
+ readonly start: number;
592
+ readonly end: number;
593
+ readonly kind: "flags" | "literal" | "pattern";
594
+ };
595
+ export namespace RegExpValidator {
596
+ /**
597
+ * The options for RegExpValidator construction.
598
+ */
599
+ interface Options {
600
+ /**
601
+ * The flag to disable Annex B syntax. Default is `false`.
602
+ */
603
+ strict?: boolean;
604
+ /**
605
+ * ECMAScript version. Default is `2025`.
606
+ * - `2015` added `u` and `y` flags.
607
+ * - `2018` added `s` flag, Named Capturing Group, Lookbehind Assertion,
608
+ * and Unicode Property Escape.
609
+ * - `2019`, `2020`, and `2021` added more valid Unicode Property Escapes.
610
+ * - `2022` added `d` flag.
611
+ * - `2023` added more valid Unicode Property Escapes.
612
+ * - `2024` added `v` flag.
613
+ * - `2025` added duplicate named capturing groups, modifiers.
614
+ */
615
+ ecmaVersion?: EcmaVersion;
616
+ /**
617
+ * A function that is called when the validator entered a RegExp literal.
618
+ * @param start The 0-based index of the first character.
619
+ */
620
+ onLiteralEnter?: (start: number) => void;
621
+ /**
622
+ * A function that is called when the validator left a RegExp literal.
623
+ * @param start The 0-based index of the first character.
624
+ * @param end The next 0-based index of the last character.
625
+ */
626
+ onLiteralLeave?: (start: number, end: number) => void;
627
+ /**
628
+ * A function that is called when the validator found flags.
629
+ * @param start The 0-based index of the first character.
630
+ * @param end The next 0-based index of the last character.
631
+ * @param flags.global `g` flag.
632
+ * @param flags.ignoreCase `i` flag.
633
+ * @param flags.multiline `m` flag.
634
+ * @param flags.unicode `u` flag.
635
+ * @param flags.sticky `y` flag.
636
+ * @param flags.dotAll `s` flag.
637
+ * @param flags.hasIndices `d` flag.
638
+ * @param flags.unicodeSets `v` flag.
639
+ */
640
+ onRegExpFlags?: (
641
+ start: number,
642
+ end: number,
643
+ flags: {
644
+ global: boolean;
645
+ ignoreCase: boolean;
646
+ multiline: boolean;
647
+ unicode: boolean;
648
+ sticky: boolean;
649
+ dotAll: boolean;
650
+ hasIndices: boolean;
651
+ unicodeSets: boolean;
652
+ }
653
+ ) => void;
654
+ /**
655
+ * A function that is called when the validator found flags.
656
+ * @param start The 0-based index of the first character.
657
+ * @param end The next 0-based index of the last character.
658
+ * @param global `g` flag.
659
+ * @param ignoreCase `i` flag.
660
+ * @param multiline `m` flag.
661
+ * @param unicode `u` flag.
662
+ * @param sticky `y` flag.
663
+ * @param dotAll `s` flag.
664
+ * @param hasIndices `d` flag.
665
+ *
666
+ * @deprecated Use `onRegExpFlags` instead.
667
+ */
668
+ onFlags?: (
669
+ start: number,
670
+ end: number,
671
+ global: boolean,
672
+ ignoreCase: boolean,
673
+ multiline: boolean,
674
+ unicode: boolean,
675
+ sticky: boolean,
676
+ dotAll: boolean,
677
+ hasIndices: boolean
678
+ ) => void;
679
+ /**
680
+ * A function that is called when the validator entered a pattern.
681
+ * @param start The 0-based index of the first character.
682
+ */
683
+ onPatternEnter?: (start: number) => void;
684
+ /**
685
+ * A function that is called when the validator left a pattern.
686
+ * @param start The 0-based index of the first character.
687
+ * @param end The next 0-based index of the last character.
688
+ */
689
+ onPatternLeave?: (start: number, end: number) => void;
690
+ /**
691
+ * A function that is called when the validator entered a disjunction.
692
+ * @param start The 0-based index of the first character.
693
+ */
694
+ onDisjunctionEnter?: (start: number) => void;
695
+ /**
696
+ * A function that is called when the validator left a disjunction.
697
+ * @param start The 0-based index of the first character.
698
+ * @param end The next 0-based index of the last character.
699
+ */
700
+ onDisjunctionLeave?: (start: number, end: number) => void;
701
+ /**
702
+ * A function that is called when the validator entered an alternative.
703
+ * @param start The 0-based index of the first character.
704
+ * @param index The 0-based index of alternatives in a disjunction.
705
+ */
706
+ onAlternativeEnter?: (start: number, index: number) => void;
707
+ /**
708
+ * A function that is called when the validator left an alternative.
709
+ * @param start The 0-based index of the first character.
710
+ * @param end The next 0-based index of the last character.
711
+ * @param index The 0-based index of alternatives in a disjunction.
712
+ */
713
+ onAlternativeLeave?: (start: number, end: number, index: number) => void;
714
+ /**
715
+ * A function that is called when the validator entered an uncapturing group.
716
+ * @param start The 0-based index of the first character.
717
+ */
718
+ onGroupEnter?: (start: number) => void;
719
+ /**
720
+ * A function that is called when the validator left an uncapturing group.
721
+ * @param start The 0-based index of the first character.
722
+ * @param end The next 0-based index of the last character.
723
+ */
724
+ onGroupLeave?: (start: number, end: number) => void;
725
+ /**
726
+ * A function that is called when the validator entered a modifiers.
727
+ * @param start The 0-based index of the first character.
728
+ */
729
+ onModifiersEnter?: (start: number) => void;
730
+ /**
731
+ * A function that is called when the validator left a modifiers.
732
+ * @param start The 0-based index of the first character.
733
+ * @param end The next 0-based index of the last character.
734
+ */
735
+ onModifiersLeave?: (start: number, end: number) => void;
736
+ /**
737
+ * A function that is called when the validator found an add modifiers.
738
+ * @param start The 0-based index of the first character.
739
+ * @param end The next 0-based index of the last character.
740
+ * @param flags flags.
741
+ * @param flags.ignoreCase `i` flag.
742
+ * @param flags.multiline `m` flag.
743
+ * @param flags.dotAll `s` flag.
744
+ */
745
+ onAddModifiers?: (
746
+ start: number,
747
+ end: number,
748
+ flags: {
749
+ ignoreCase: boolean;
750
+ multiline: boolean;
751
+ dotAll: boolean;
752
+ }
753
+ ) => void;
754
+ /**
755
+ * A function that is called when the validator found a remove modifiers.
756
+ * @param start The 0-based index of the first character.
757
+ * @param end The next 0-based index of the last character.
758
+ * @param flags flags.
759
+ * @param flags.ignoreCase `i` flag.
760
+ * @param flags.multiline `m` flag.
761
+ * @param flags.dotAll `s` flag.
762
+ */
763
+ onRemoveModifiers?: (
764
+ start: number,
765
+ end: number,
766
+ flags: {
767
+ ignoreCase: boolean;
768
+ multiline: boolean;
769
+ dotAll: boolean;
770
+ }
771
+ ) => void;
772
+ /**
773
+ * A function that is called when the validator entered a capturing group.
774
+ * @param start The 0-based index of the first character.
775
+ * @param name The group name.
776
+ */
777
+ onCapturingGroupEnter?: (start: number, name: string | null) => void;
778
+ /**
779
+ * A function that is called when the validator left a capturing group.
780
+ * @param start The 0-based index of the first character.
781
+ * @param end The next 0-based index of the last character.
782
+ * @param name The group name.
783
+ */
784
+ onCapturingGroupLeave?: (
785
+ start: number,
786
+ end: number,
787
+ name: string | null
788
+ ) => void;
789
+ /**
790
+ * A function that is called when the validator found a quantifier.
791
+ * @param start The 0-based index of the first character.
792
+ * @param end The next 0-based index of the last character.
793
+ * @param min The minimum number of repeating.
794
+ * @param max The maximum number of repeating.
795
+ * @param greedy The flag to choose the longest matching.
796
+ */
797
+ onQuantifier?: (
798
+ start: number,
799
+ end: number,
800
+ min: number,
801
+ max: number,
802
+ greedy: boolean
803
+ ) => void;
804
+ /**
805
+ * A function that is called when the validator entered a lookahead/lookbehind assertion.
806
+ * @param start The 0-based index of the first character.
807
+ * @param kind The kind of the assertion.
808
+ * @param negate The flag which represents that the assertion is negative.
809
+ */
810
+ onLookaroundAssertionEnter?: (
811
+ start: number,
812
+ kind: "lookahead" | "lookbehind",
813
+ negate: boolean
814
+ ) => void;
815
+ /**
816
+ * A function that is called when the validator left a lookahead/lookbehind assertion.
817
+ * @param start The 0-based index of the first character.
818
+ * @param end The next 0-based index of the last character.
819
+ * @param kind The kind of the assertion.
820
+ * @param negate The flag which represents that the assertion is negative.
821
+ */
822
+ onLookaroundAssertionLeave?: (
823
+ start: number,
824
+ end: number,
825
+ kind: "lookahead" | "lookbehind",
826
+ negate: boolean
827
+ ) => void;
828
+ /**
829
+ * A function that is called when the validator found an edge boundary assertion.
830
+ * @param start The 0-based index of the first character.
831
+ * @param end The next 0-based index of the last character.
832
+ * @param kind The kind of the assertion.
833
+ */
834
+ onEdgeAssertion?: (
835
+ start: number,
836
+ end: number,
837
+ kind: "end" | "start"
838
+ ) => void;
839
+ /**
840
+ * A function that is called when the validator found a word boundary assertion.
841
+ * @param start The 0-based index of the first character.
842
+ * @param end The next 0-based index of the last character.
843
+ * @param kind The kind of the assertion.
844
+ * @param negate The flag which represents that the assertion is negative.
845
+ */
846
+ onWordBoundaryAssertion?: (
847
+ start: number,
848
+ end: number,
849
+ kind: "word",
850
+ negate: boolean
851
+ ) => void;
852
+ /**
853
+ * A function that is called when the validator found a dot.
854
+ * @param start The 0-based index of the first character.
855
+ * @param end The next 0-based index of the last character.
856
+ * @param kind The kind of the character set.
857
+ */
858
+ onAnyCharacterSet?: (start: number, end: number, kind: "any") => void;
859
+ /**
860
+ * A function that is called when the validator found a character set escape.
861
+ * @param start The 0-based index of the first character.
862
+ * @param end The next 0-based index of the last character.
863
+ * @param kind The kind of the character set.
864
+ * @param negate The flag which represents that the character set is negative.
865
+ */
866
+ onEscapeCharacterSet?: (
867
+ start: number,
868
+ end: number,
869
+ kind: "digit" | "space" | "word",
870
+ negate: boolean
871
+ ) => void;
872
+ /**
873
+ * A function that is called when the validator found a Unicode proerty escape.
874
+ * @param start The 0-based index of the first character.
875
+ * @param end The next 0-based index of the last character.
876
+ * @param kind The kind of the character set.
877
+ * @param key The property name.
878
+ * @param value The property value.
879
+ * @param negate The flag which represents that the character set is negative.
880
+ * @param strings If true, the given property is property of strings.
881
+ */
882
+ onUnicodePropertyCharacterSet?: (
883
+ start: number,
884
+ end: number,
885
+ kind: "property",
886
+ key: string,
887
+ value: string | null,
888
+ negate: boolean,
889
+ strings: boolean
890
+ ) => void;
891
+ /**
892
+ * A function that is called when the validator found a character.
893
+ * @param start The 0-based index of the first character.
894
+ * @param end The next 0-based index of the last character.
895
+ * @param value The code point of the character.
896
+ */
897
+ onCharacter?: (start: number, end: number, value: number) => void;
898
+ /**
899
+ * A function that is called when the validator found a backreference.
900
+ * @param start The 0-based index of the first character.
901
+ * @param end The next 0-based index of the last character.
902
+ * @param ref The key of the referred capturing group.
903
+ */
904
+ onBackreference?: (
905
+ start: number,
906
+ end: number,
907
+ ref: number | string
908
+ ) => void;
909
+ /**
910
+ * A function that is called when the validator entered a character class.
911
+ * @param start The 0-based index of the first character.
912
+ * @param negate The flag which represents that the character class is negative.
913
+ * @param unicodeSets `true` if unicodeSets mode.
914
+ */
915
+ onCharacterClassEnter?: (
916
+ start: number,
917
+ negate: boolean,
918
+ unicodeSets: boolean
919
+ ) => void;
920
+ /**
921
+ * A function that is called when the validator left a character class.
922
+ * @param start The 0-based index of the first character.
923
+ * @param end The next 0-based index of the last character.
924
+ * @param negate The flag which represents that the character class is negative.
925
+ */
926
+ onCharacterClassLeave?: (
927
+ start: number,
928
+ end: number,
929
+ negate: boolean
930
+ ) => void;
931
+ /**
932
+ * A function that is called when the validator found a character class range.
933
+ * @param start The 0-based index of the first character.
934
+ * @param end The next 0-based index of the last character.
935
+ * @param min The minimum code point of the range.
936
+ * @param max The maximum code point of the range.
937
+ */
938
+ onCharacterClassRange?: (
939
+ start: number,
940
+ end: number,
941
+ min: number,
942
+ max: number
943
+ ) => void;
944
+ /**
945
+ * A function that is called when the validator found a class intersection.
946
+ * @param start The 0-based index of the first character.
947
+ * @param end The next 0-based index of the last character.
948
+ */
949
+ onClassIntersection?: (start: number, end: number) => void;
950
+ /**
951
+ * A function that is called when the validator found a class subtraction.
952
+ * @param start The 0-based index of the first character.
953
+ * @param end The next 0-based index of the last character.
954
+ */
955
+ onClassSubtraction?: (start: number, end: number) => void;
956
+ /**
957
+ * A function that is called when the validator entered a class string disjunction.
958
+ * @param start The 0-based index of the first character.
959
+ */
960
+ onClassStringDisjunctionEnter?: (start: number) => void;
961
+ /**
962
+ * A function that is called when the validator left a class string disjunction.
963
+ * @param start The 0-based index of the first character.
964
+ * @param end The next 0-based index of the last character.
965
+ */
966
+ onClassStringDisjunctionLeave?: (start: number, end: number) => void;
967
+ /**
968
+ * A function that is called when the validator entered a string alternative.
969
+ * @param start The 0-based index of the first character.
970
+ * @param index The 0-based index of alternatives in a disjunction.
971
+ */
972
+ onStringAlternativeEnter?: (start: number, index: number) => void;
973
+ /**
974
+ * A function that is called when the validator left a string alternative.
975
+ * @param start The 0-based index of the first character.
976
+ * @param end The next 0-based index of the last character.
977
+ * @param index The 0-based index of alternatives in a disjunction.
978
+ */
979
+ onStringAlternativeLeave?: (
980
+ start: number,
981
+ end: number,
982
+ index: number
983
+ ) => void;
984
+ }
985
+ }
986
+ /**
987
+ * The regular expression validator.
988
+ */
989
+ export class RegExpValidator {
990
+ /**
991
+ * Initialize this validator.
992
+ * @param options The options of validator.
993
+ */
994
+ constructor(options?: RegExpValidator.Options);
995
+ /**
996
+ * Validate a regular expression literal. E.g. "/abc/g"
997
+ * @param source The source code to validate.
998
+ * @param start The start index in the source code.
999
+ * @param end The end index in the source code.
1000
+ */
1001
+ validateLiteral(source: string, start?: number, end?: number): void;
1002
+ /**
1003
+ * Validate a regular expression flags. E.g. "gim"
1004
+ * @param source The source code to validate.
1005
+ * @param start The start index in the source code.
1006
+ * @param end The end index in the source code.
1007
+ */
1008
+ validateFlags(source: string, start?: number, end?: number): void;
1009
+ /**
1010
+ * Validate a regular expression pattern. E.g. "abc"
1011
+ * @param source The source code to validate.
1012
+ * @param start The start index in the source code.
1013
+ * @param end The end index in the source code.
1014
+ * @param flags The flags.
1015
+ */
1016
+ validatePattern(
1017
+ source: string,
1018
+ start?: number,
1019
+ end?: number,
1020
+ flags?: {
1021
+ unicode?: boolean;
1022
+ unicodeSets?: boolean;
1023
+ }
1024
+ ): void;
1025
+ /**
1026
+ * @deprecated Backward compatibility
1027
+ * Use object `flags` instead of boolean `uFlag`.
1028
+ * @param source The source code to validate.
1029
+ * @param start The start index in the source code.
1030
+ * @param end The end index in the source code.
1031
+ * @param uFlag The flag to set unicode mode.
1032
+ */
1033
+ validatePattern(
1034
+ source: string,
1035
+ start?: number,
1036
+ end?: number,
1037
+ uFlag?: boolean
1038
+ ): void;
1039
+ }
1040
+ }
1041
+
1042
+ declare module "@eslint-community/regexpp/visitor" {
1043
+ import type {
1044
+ Alternative,
1045
+ Assertion,
1046
+ Backreference,
1047
+ CapturingGroup,
1048
+ Character,
1049
+ CharacterClass,
1050
+ CharacterClassRange,
1051
+ CharacterSet,
1052
+ ClassIntersection,
1053
+ ClassStringDisjunction,
1054
+ ClassSubtraction,
1055
+ ExpressionCharacterClass,
1056
+ Flags,
1057
+ Group,
1058
+ ModifierFlags,
1059
+ Modifiers,
1060
+ Node,
1061
+ Pattern,
1062
+ Quantifier,
1063
+ RegExpLiteral,
1064
+ StringAlternative,
1065
+ } from "@eslint-community/regexpp/ast";
1066
+ /**
1067
+ * The visitor to walk on AST.
1068
+ */
1069
+ export class RegExpVisitor {
1070
+ /**
1071
+ * Initialize this visitor.
1072
+ * @param handlers Callbacks for each node.
1073
+ */
1074
+ constructor(handlers: RegExpVisitor.Handlers);
1075
+ /**
1076
+ * Visit a given node and descendant nodes.
1077
+ * @param node The root node to visit tree.
1078
+ */
1079
+ visit(node: Node): void;
1080
+ }
1081
+ export namespace RegExpVisitor {
1082
+ interface Handlers {
1083
+ onAlternativeEnter?: (node: Alternative) => void;
1084
+ onAlternativeLeave?: (node: Alternative) => void;
1085
+ onAssertionEnter?: (node: Assertion) => void;
1086
+ onAssertionLeave?: (node: Assertion) => void;
1087
+ onBackreferenceEnter?: (node: Backreference) => void;
1088
+ onBackreferenceLeave?: (node: Backreference) => void;
1089
+ onCapturingGroupEnter?: (node: CapturingGroup) => void;
1090
+ onCapturingGroupLeave?: (node: CapturingGroup) => void;
1091
+ onCharacterEnter?: (node: Character) => void;
1092
+ onCharacterLeave?: (node: Character) => void;
1093
+ onCharacterClassEnter?: (node: CharacterClass) => void;
1094
+ onCharacterClassLeave?: (node: CharacterClass) => void;
1095
+ onCharacterClassRangeEnter?: (node: CharacterClassRange) => void;
1096
+ onCharacterClassRangeLeave?: (node: CharacterClassRange) => void;
1097
+ onCharacterSetEnter?: (node: CharacterSet) => void;
1098
+ onCharacterSetLeave?: (node: CharacterSet) => void;
1099
+ onClassIntersectionEnter?: (node: ClassIntersection) => void;
1100
+ onClassIntersectionLeave?: (node: ClassIntersection) => void;
1101
+ onClassStringDisjunctionEnter?: (node: ClassStringDisjunction) => void;
1102
+ onClassStringDisjunctionLeave?: (node: ClassStringDisjunction) => void;
1103
+ onClassSubtractionEnter?: (node: ClassSubtraction) => void;
1104
+ onClassSubtractionLeave?: (node: ClassSubtraction) => void;
1105
+ onExpressionCharacterClassEnter?: (
1106
+ node: ExpressionCharacterClass
1107
+ ) => void;
1108
+ onExpressionCharacterClassLeave?: (
1109
+ node: ExpressionCharacterClass
1110
+ ) => void;
1111
+ onFlagsEnter?: (node: Flags) => void;
1112
+ onFlagsLeave?: (node: Flags) => void;
1113
+ onGroupEnter?: (node: Group) => void;
1114
+ onGroupLeave?: (node: Group) => void;
1115
+ onModifierFlagsEnter?: (node: ModifierFlags) => void;
1116
+ onModifierFlagsLeave?: (node: ModifierFlags) => void;
1117
+ onModifiersEnter?: (node: Modifiers) => void;
1118
+ onModifiersLeave?: (node: Modifiers) => void;
1119
+ onPatternEnter?: (node: Pattern) => void;
1120
+ onPatternLeave?: (node: Pattern) => void;
1121
+ onQuantifierEnter?: (node: Quantifier) => void;
1122
+ onQuantifierLeave?: (node: Quantifier) => void;
1123
+ onRegExpLiteralEnter?: (node: RegExpLiteral) => void;
1124
+ onRegExpLiteralLeave?: (node: RegExpLiteral) => void;
1125
+ onStringAlternativeEnter?: (node: StringAlternative) => void;
1126
+ onStringAlternativeLeave?: (node: StringAlternative) => void;
1127
+ }
1128
+ }
1129
+ }
1130
+
1131
+ declare module "@eslint-community/regexpp/regexp-syntax-error" {
1132
+ import type { RegExpValidatorSourceContext } from "@eslint-community/regexpp/validator";
1133
+ export class RegExpSyntaxError extends SyntaxError {
1134
+ index: number;
1135
+ constructor(message: string, index: number);
1136
+ }
1137
+ export function newRegExpSyntaxError(
1138
+ srcCtx: RegExpValidatorSourceContext,
1139
+ flags: {
1140
+ unicode: boolean;
1141
+ unicodeSets: boolean;
1142
+ },
1143
+ index: number,
1144
+ message: string
1145
+ ): RegExpSyntaxError;
1146
+ }
1147
+
1148
+ declare module "@eslint-community/regexpp/ecma-versions" {
1149
+ export type EcmaVersion =
1150
+ | 5
1151
+ | 2015
1152
+ | 2016
1153
+ | 2017
1154
+ | 2018
1155
+ | 2019
1156
+ | 2020
1157
+ | 2021
1158
+ | 2022
1159
+ | 2023
1160
+ | 2024
1161
+ | 2025;
1162
+ export const latestEcmaVersion = 2025;
1163
+ }
node_modules/@eslint-community/regexpp/index.js ADDED
The diff for this file is too large to render. See raw diff
 
node_modules/@eslint-community/regexpp/index.js.map ADDED
The diff for this file is too large to render. See raw diff
 
node_modules/@eslint-community/regexpp/index.mjs ADDED
The diff for this file is too large to render. See raw diff
 
node_modules/@eslint-community/regexpp/index.mjs.map ADDED
The diff for this file is too large to render. See raw diff
 
node_modules/@eslint-community/regexpp/package.json ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@eslint-community/regexpp",
3
+ "version": "4.12.2",
4
+ "description": "Regular expression parser for ECMAScript.",
5
+ "keywords": [
6
+ "regexp",
7
+ "regular",
8
+ "expression",
9
+ "parser",
10
+ "validator",
11
+ "ast",
12
+ "abstract",
13
+ "syntax",
14
+ "tree",
15
+ "ecmascript",
16
+ "es2015",
17
+ "es2016",
18
+ "es2017",
19
+ "es2018",
20
+ "es2019",
21
+ "es2020",
22
+ "es2021",
23
+ "annexB"
24
+ ],
25
+ "homepage": "https://github.com/eslint-community/regexpp#readme",
26
+ "bugs": {
27
+ "url": "https://github.com/eslint-community/regexpp/issues"
28
+ },
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "https://github.com/eslint-community/regexpp"
32
+ },
33
+ "license": "MIT",
34
+ "author": "Toru Nagashima",
35
+ "exports": {
36
+ ".": {
37
+ "types": "./index.d.ts",
38
+ "import": "./index.mjs",
39
+ "default": "./index.js"
40
+ },
41
+ "./package.json": "./package.json"
42
+ },
43
+ "main": "index",
44
+ "files": [
45
+ "index.*"
46
+ ],
47
+ "scripts": {
48
+ "prebuild": "npm run -s clean",
49
+ "build": "run-s build:*",
50
+ "build:tsc": "tsc --module es2015",
51
+ "build:rollup": "rollup -c",
52
+ "build:dts": "npm run -s build:tsc -- --removeComments false && dts-bundle --name @eslint-community/regexpp --main .temp/index.d.ts --out ../index.d.ts && prettier --write index.d.ts",
53
+ "clean": "rimraf .temp index.*",
54
+ "lint": "eslint . --ext .ts",
55
+ "test": "nyc _mocha \"test/*.ts\" --reporter dot --timeout 10000",
56
+ "debug": "mocha --require ts-node/register/transpile-only \"test/*.ts\" --reporter dot --timeout 10000",
57
+ "update:test": "ts-node scripts/update-fixtures.ts",
58
+ "update:unicode": "run-s update:unicode:*",
59
+ "update:unicode:ids": "ts-node scripts/update-unicode-ids.ts",
60
+ "update:unicode:props": "ts-node scripts/update-unicode-properties.ts",
61
+ "update:test262:extract": "ts-node -T scripts/extract-test262.ts",
62
+ "preversion": "npm test && npm run -s build",
63
+ "postversion": "git push && git push --tags",
64
+ "prewatch": "npm run -s clean",
65
+ "watch": "_mocha \"test/*.ts\" --require ts-node/register --reporter dot --timeout 10000 --watch-extensions ts --watch --growl"
66
+ },
67
+ "dependencies": {},
68
+ "devDependencies": {
69
+ "@eslint-community/eslint-plugin-mysticatea": "^15.5.1",
70
+ "@rollup/plugin-node-resolve": "^14.1.0",
71
+ "@types/eslint": "^8.44.3",
72
+ "@types/jsdom": "^16.2.15",
73
+ "@types/mocha": "^9.1.1",
74
+ "@types/node": "^12.20.55",
75
+ "dts-bundle": "^0.7.3",
76
+ "eslint": "^8.50.0",
77
+ "js-tokens": "^8.0.2",
78
+ "jsdom": "^19.0.0",
79
+ "mocha": "^9.2.2",
80
+ "npm-run-all2": "^6.2.2",
81
+ "nyc": "^14.1.1",
82
+ "rimraf": "^3.0.2",
83
+ "rollup": "^2.79.1",
84
+ "rollup-plugin-sourcemaps": "^0.6.3",
85
+ "ts-node": "^10.9.1",
86
+ "typescript": "~5.0.2"
87
+ },
88
+ "engines": {
89
+ "node": "^12.0.0 || ^14.0.0 || >=16.0.0"
90
+ }
91
+ }
node_modules/@eslint/compat/LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
node_modules/@eslint/compat/README.md ADDED
@@ -0,0 +1,213 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ESLint Compatibility Utilities
2
+
3
+ ## Overview
4
+
5
+ This package contains functions that allow you to wrap existing ESLint rules, plugins, and configurations that were intended for use with ESLint v8.x or v9.x to allow them to work as-is in ESLint v9.x and v10.x.
6
+
7
+ **Note:** All plugins are not guaranteed to work in ESLint v9.x or v10.x. This package fixes the most common issues but can't fix everything.
8
+
9
+ ## Installation
10
+
11
+ For Node.js and compatible runtimes:
12
+
13
+ ```shell
14
+ npm install @eslint/compat -D
15
+ # or
16
+ yarn add @eslint/compat -D
17
+ # or
18
+ pnpm install @eslint/compat -D
19
+ # or
20
+ bun add @eslint/compat -D
21
+ ```
22
+
23
+ For Deno:
24
+
25
+ ```shell
26
+ deno add @eslint/compat
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ This package exports the following functions in both ESM and CommonJS format:
32
+
33
+ - `fixupRule(rule)` - wraps the given rule in a compatibility layer and returns the result
34
+ - `fixupPluginRules(plugin)` - wraps each rule in the given plugin using `fixupRule()` and returns a new object that represents the plugin with the fixed-up rules
35
+ - `fixupConfigRules(configs)` - wraps all plugins found in an array of config objects using `fixupPluginRules()`
36
+ - `includeIgnoreFile(path)` (deprecated) - reads an ignore file (like `.gitignore`) and converts the patterns into the correct format for the config file
37
+
38
+ ### Fixing Rules
39
+
40
+ If you have a rule that you'd like to make compatible with ESLint v9.x or v10.x, you can do so using the `fixupRule()` function:
41
+
42
+ ```js
43
+ // ESM example
44
+ import { fixupRule } from "@eslint/compat";
45
+
46
+ // Step 1: Import your rule
47
+ import myRule from "./local-rule.js";
48
+
49
+ // Step 2: Create backwards-compatible rule
50
+ const compatRule = fixupRule(myRule);
51
+
52
+ // Step 3 (optional): Export fixed rule
53
+ export default compatRule;
54
+ ```
55
+
56
+ Or in CommonJS:
57
+
58
+ ```js
59
+ // CommonJS example
60
+ const { fixupRule } = require("@eslint/compat");
61
+
62
+ // Step 1: Import your rule
63
+ const myRule = require("./local-rule.js");
64
+
65
+ // Step 2: Create backwards-compatible rule
66
+ const compatRule = fixupRule(myRule);
67
+
68
+ // Step 3 (optional): Export fixed rule
69
+ module.exports = compatRule;
70
+ ```
71
+
72
+ ### Fixing Plugins
73
+
74
+ If you are using a plugin in your `eslint.config.js` that is not yet compatible with ESLint v9.x or v10.x, you can wrap it using the `fixupPluginRules()` function:
75
+
76
+ ```js
77
+ // eslint.config.js - ESM example
78
+ import { defineConfig } from "eslint/config";
79
+ import { fixupPluginRules } from "@eslint/compat";
80
+ import somePlugin from "eslint-plugin-some-plugin";
81
+
82
+ export default defineConfig([
83
+ {
84
+ plugins: {
85
+ // insert the fixed plugin instead of the original
86
+ somePlugin: fixupPluginRules(somePlugin),
87
+ },
88
+ rules: {
89
+ "somePlugin/rule-name": "error",
90
+ },
91
+ },
92
+ ]);
93
+ ```
94
+
95
+ Or in CommonJS:
96
+
97
+ ```js
98
+ // eslint.config.js - CommonJS example
99
+ const { defineConfig } = require("eslint/config");
100
+ const { fixupPluginRules } = require("@eslint/compat");
101
+ const somePlugin = require("eslint-plugin-some-plugin");
102
+
103
+ module.exports = defineConfig([
104
+ {
105
+ plugins: {
106
+ // insert the fixed plugin instead of the original
107
+ somePlugin: fixupPluginRules(somePlugin),
108
+ },
109
+ rules: {
110
+ "somePlugin/rule-name": "error",
111
+ },
112
+ },
113
+ ]);
114
+ ```
115
+
116
+ ### Fixing Configs
117
+
118
+ If you are importing other configs into your `eslint.config.js` that use plugins that are not yet compatible with ESLint v9.x or v10.x, you can wrap the entire array or a single object using the `fixupConfigRules()` function:
119
+
120
+ ```js
121
+ // eslint.config.js - ESM example
122
+ import { defineConfig } from "eslint/config";
123
+ import { fixupConfigRules } from "@eslint/compat";
124
+ import someConfig from "eslint-config-some-config";
125
+
126
+ export default defineConfig([
127
+ ...fixupConfigRules(someConfig),
128
+ {
129
+ // your overrides
130
+ },
131
+ ]);
132
+ ```
133
+
134
+ Or in CommonJS:
135
+
136
+ ```js
137
+ // eslint.config.js - CommonJS example
138
+ const { defineConfig } = require("eslint/config");
139
+ const { fixupConfigRules } = require("@eslint/compat");
140
+ const someConfig = require("eslint-config-some-config");
141
+
142
+ module.exports = defineConfig([
143
+ ...fixupConfigRules(someConfig),
144
+ {
145
+ // your overrides
146
+ },
147
+ ]);
148
+ ```
149
+
150
+ ### Including Ignore Files
151
+
152
+ **Deprecated**: The `includeIgnoreFile()` exported by this package has been deprecated ([eslint/rewrite#329](https://github.com/eslint/rewrite/issues/329)). Use the `includeIgnoreFile()` function exported by `@eslint/config-helpers` instead (also available at `eslint/config`). This section is only preserved for historical reference.
153
+
154
+ If you were using an alternate ignore file in ESLint v8.x, such as using `--ignore-path .gitignore` on the command line, you can include those patterns programmatically in your config file using the `includeIgnoreFile()` function.
155
+
156
+ The `includeIgnoreFile()` function also accepts a second optional `name` parameter that allows you to set a custom name for this configuration object. If not specified, it defaults to `"Imported .gitignore patterns"`. For example:
157
+
158
+ ```js
159
+ // eslint.config.js - ESM example
160
+ import { defineConfig } from "eslint/config";
161
+ import { includeIgnoreFile } from "@eslint/compat";
162
+ import path from "node:path";
163
+
164
+ const gitignorePath = path.resolve(import.meta.dirname, ".gitignore");
165
+
166
+ export default defineConfig([
167
+ includeIgnoreFile(gitignorePath, "Imported .gitignore patterns"), // second argument is optional.
168
+ {
169
+ // your overrides
170
+ },
171
+ ]);
172
+ ```
173
+
174
+ Or in CommonJS:
175
+
176
+ ```js
177
+ // eslint.config.js - CommonJS example
178
+ const { defineConfig } = require("eslint/config");
179
+ const { includeIgnoreFile } = require("@eslint/compat");
180
+ const path = require("node:path");
181
+ const gitignorePath = path.resolve(__dirname, ".gitignore");
182
+
183
+ module.exports = defineConfig([
184
+ includeIgnoreFile(gitignorePath, "Imported .gitignore patterns"), // second argument is optional.
185
+ {
186
+ // your overrides
187
+ },
188
+ ]);
189
+ ```
190
+
191
+ **Limitation:** This works without modification when the ignore file is in the same directory as your config file. If the ignore file is in a different directory, you may need to modify the patterns manually.
192
+
193
+ ## License
194
+
195
+ Apache 2.0
196
+
197
+ <!-- NOTE: This section is autogenerated. Do not manually edit.-->
198
+ <!--sponsorsstart-->
199
+
200
+ ## Sponsors
201
+
202
+ The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://eslint.org/donate)
203
+ to get your logo on our READMEs and [website](https://eslint.org/sponsors).
204
+
205
+ <h3>Platinum Sponsors</h3>
206
+ <p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="128"></a></p><h3>Gold Sponsors</h3>
207
+ <p><a href="https://qlty.sh/"><img src="https://images.opencollective.com/qltysh/33d157d/logo.png" alt="Qlty Software" height="96"></a></p><h3>Silver Sponsors</h3>
208
+ <p><a href="https://vite.dev/"><img src="https://images.opencollective.com/vite/d472863/logo.png" alt="Vite" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/2d6c3b6/logo.png" alt="Liftoff" height="64"></a> <a href="https://stackblitz.com"><img src="https://avatars.githubusercontent.com/u/28635252" alt="StackBlitz" height="64"></a></p><h3>Bronze Sponsors</h3>
209
+ <p><a href="https://cybozu.co.jp/"><img src="https://images.opencollective.com/cybozu/933e46d/logo.png" alt="Cybozu" height="32"></a> <a href="https://opensource.sap.com"><img src="https://avatars.githubusercontent.com/u/2531208" alt="SAP" height="32"></a> <a href="https://www.crawljobs.com/"><img src="https://images.opencollective.com/crawljobs-poland/fa43a17/logo.png" alt="CrawlJobs" height="32"></a> <a href="https://depot.dev"><img src="https://images.opencollective.com/depot/39125a1/logo.png" alt="Depot" height="32"></a> <a href="https://icons8.com/"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://www.gitbook.com"><img src="https://avatars.githubusercontent.com/u/7111340" alt="GitBook" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774" alt="HeroCoders" height="32"></a> <a href="https://citadel.co.jp"><img src="https://avatars.githubusercontent.com/u/75781367" alt="Citadel AI" height="32"></a> <a href="https://www.lambdatest.com"><img src="https://avatars.githubusercontent.com/u/171592363" alt="TestMu AI Open Source Office (Formerly LambdaTest)" height="32"></a></p>
210
+ <h3>Technology Sponsors</h3>
211
+ Technology sponsors allow us to use their products and services for free as part of a contribution to the open source ecosystem and our work.
212
+ <p><a href="https://netlify.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/netlify-icon.svg" alt="Netlify" height="32"></a> <a href="https://algolia.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/algolia-icon.svg" alt="Algolia" height="32"></a> <a href="https://1password.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/1password-icon.svg" alt="1Password" height="32"></a></p>
213
+ <!--sponsorsend-->
node_modules/@eslint/compat/package.json ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@eslint/compat",
3
+ "version": "2.1.0",
4
+ "description": "Compatibility utilities for ESLint",
5
+ "type": "module",
6
+ "main": "dist/esm/index.js",
7
+ "types": "dist/esm/index.d.ts",
8
+ "exports": {
9
+ "require": {
10
+ "types": "./dist/cjs/index.d.cts",
11
+ "default": "./dist/cjs/index.cjs"
12
+ },
13
+ "import": {
14
+ "types": "./dist/esm/index.d.ts",
15
+ "default": "./dist/esm/index.js"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist"
20
+ ],
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
24
+ "directories": {
25
+ "test": "tests"
26
+ },
27
+ "scripts": {
28
+ "build:cts": "node ../../tools/build-cts.js dist/esm/index.d.ts dist/cjs/index.d.cts",
29
+ "build": "rollup -c && tsc -p tsconfig.esm.json && npm run build:cts",
30
+ "lint:types": "attw --pack",
31
+ "pretest": "npm run build",
32
+ "test": "npm run test:unit",
33
+ "test:coverage": "c8 npm run test:unit",
34
+ "test:jsr": "npx -y jsr@latest publish --dry-run",
35
+ "test:unit": "mocha \"tests/**/*.test.js\""
36
+ },
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "git+https://github.com/eslint/rewrite.git",
40
+ "directory": "packages/compat"
41
+ },
42
+ "keywords": [
43
+ "eslint",
44
+ "compatibility",
45
+ "eslintplugin",
46
+ "eslint-plugin"
47
+ ],
48
+ "author": "Nicholas C. Zakas",
49
+ "license": "Apache-2.0",
50
+ "bugs": {
51
+ "url": "https://github.com/eslint/rewrite/issues"
52
+ },
53
+ "homepage": "https://github.com/eslint/rewrite/tree/main/packages/compat#readme",
54
+ "dependencies": {
55
+ "@eslint/core": "^1.2.1"
56
+ },
57
+ "devDependencies": {
58
+ "@types/node": "^24.7.2",
59
+ "eslint": "^10.0.3"
60
+ },
61
+ "peerDependencies": {
62
+ "eslint": "^8.40 || 9 || 10"
63
+ },
64
+ "peerDependenciesMeta": {
65
+ "eslint": {
66
+ "optional": true
67
+ }
68
+ },
69
+ "engines": {
70
+ "node": "^20.19.0 || ^22.13.0 || >=24"
71
+ }
72
+ }
node_modules/@eslint/config-array/LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
node_modules/@eslint/config-array/README.md ADDED
@@ -0,0 +1,369 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Config Array
2
+
3
+ ## Description
4
+
5
+ A config array is a way of managing configurations that are based on glob pattern matching of filenames. Each config array contains the information needed to determine the correct configuration for any file based on the filename.
6
+
7
+ **Note:** This is a generic package that can be used outside of ESLint. It contains no ESLint-specific functionality.
8
+
9
+ ## Installation
10
+
11
+ For Node.js and compatible runtimes:
12
+
13
+ ```shell
14
+ npm install @eslint/config-array
15
+ # or
16
+ yarn add @eslint/config-array
17
+ # or
18
+ pnpm install @eslint/config-array
19
+ # or
20
+ bun add @eslint/config-array
21
+ ```
22
+
23
+ For Deno:
24
+
25
+ ```shell
26
+ deno add @eslint/config-array
27
+ ```
28
+
29
+ ## Background
30
+
31
+ The basic idea is that all configuration, including overrides, can be represented by a single array where each item in the array is a config object. Config objects appearing later in the array override config objects appearing earlier in the array. You can calculate a config for a given file by traversing all config objects in the array to find the ones that match the filename. Matching is done by specifying glob patterns in `files` and `ignores` properties on each config object. Here's an example:
32
+
33
+ ```js
34
+ export default [
35
+ // match all JSON files
36
+ {
37
+ name: "JSON Handler",
38
+ files: ["**/*.json"],
39
+ handler: jsonHandler,
40
+ },
41
+
42
+ // match only package.json
43
+ {
44
+ name: "package.json Handler",
45
+ files: ["package.json"],
46
+ handler: packageJsonHandler,
47
+ },
48
+ ];
49
+ ```
50
+
51
+ In this example, there are two config objects: the first matches all JSON files in all directories and the second matches just `package.json` in the base path directory (all the globs are evaluated as relative to a base path that can be specified). When you retrieve a configuration for `foo.json`, only the first config object matches so `handler` is equal to `jsonHandler`; when you retrieve a configuration for `package.json`, `handler` is equal to `packageJsonHandler` (because both config objects match, the second one wins).
52
+
53
+ ## Usage
54
+
55
+ First, import the `ConfigArray` constructor:
56
+
57
+ ```js
58
+ import { ConfigArray } from "@eslint/config-array";
59
+
60
+ // or using CommonJS
61
+
62
+ const { ConfigArray } = require("@eslint/config-array");
63
+ ```
64
+
65
+ When you create a new instance of `ConfigArray`, you must pass in two arguments: an array of configs and an options object. The array of configs is most likely read in from a configuration file, so here's a typical example:
66
+
67
+ ```js
68
+ import path from "node:path";
69
+ import { pathToFileURL } from "node:url";
70
+ import { ConfigArray } from "@eslint/config-array";
71
+
72
+ const configFilename = path.resolve(process.cwd(), "my.config.js");
73
+ const { default: rawConfigs } = await import(pathToFileURL(configFilename));
74
+
75
+ const configs = new ConfigArray(rawConfigs, {
76
+ // the path to match filenames from
77
+ basePath: process.cwd(),
78
+
79
+ // additional items in each config
80
+ schema: mySchema,
81
+ });
82
+ ```
83
+
84
+ This example reads in an object or array from `my.config.js` and passes it into the `ConfigArray` constructor as the first argument. The second argument is an object specifying the `basePath` (the directory in which `my.config.js` is found) and a `schema` to define the additional properties of a config object beyond `files`, `ignores`, `basePath`, and `name`.
85
+
86
+ ### Specifying a Schema
87
+
88
+ The `schema` option is required for you to use additional properties in config objects. The schema is an object that follows the format of an [`ObjectSchema`](https://npmjs.com/package/@eslint/object-schema). The schema specifies both validation and merge rules that the `ConfigArray` instance needs to combine configs when there are multiple matches. Here's an example:
89
+
90
+ ```js
91
+ const configFilename = path.resolve(process.cwd(), "my.config.js");
92
+ const { default: rawConfigs } = await import(pathToFileURL(configFilename));
93
+
94
+ const mySchema = {
95
+ // define the handler key in configs
96
+ handler: {
97
+ required: true,
98
+ merge(a, b) {
99
+ return b ?? a;
100
+ },
101
+ validate(value) {
102
+ if (typeof value !== "function") {
103
+ throw new TypeError("Function expected.");
104
+ }
105
+ },
106
+ },
107
+ };
108
+
109
+ const configs = new ConfigArray(rawConfigs, {
110
+ // the path to match filenames from
111
+ basePath: process.cwd(),
112
+
113
+ // additional item schemas in each config
114
+ schema: mySchema,
115
+
116
+ // additional config types supported (default: [])
117
+ extraConfigTypes: ["array", "function"],
118
+ });
119
+ ```
120
+
121
+ ### Config Arrays
122
+
123
+ Config arrays can be multidimensional, so it's possible for a config array to contain another config array when `extraConfigTypes` contains `"array"`, such as:
124
+
125
+ ```js
126
+ export default [
127
+ // JS config
128
+ {
129
+ files: ["**/*.js"],
130
+ handler: jsHandler,
131
+ },
132
+
133
+ // JSON configs
134
+ [
135
+ // match all JSON files
136
+ {
137
+ name: "JSON Handler",
138
+ files: ["**/*.json"],
139
+ handler: jsonHandler,
140
+ },
141
+
142
+ // match only package.json
143
+ {
144
+ name: "package.json Handler",
145
+ files: ["package.json"],
146
+ handler: packageJsonHandler,
147
+ },
148
+ ],
149
+
150
+ // filename must match function
151
+ {
152
+ files: [filePath => filePath.endsWith(".md")],
153
+ handler: markdownHandler,
154
+ },
155
+
156
+ // filename must match all patterns in subarray
157
+ {
158
+ files: [["*.test.*", "*.js"]],
159
+ handler: jsTestHandler,
160
+ },
161
+
162
+ // filename must not match patterns beginning with !
163
+ {
164
+ name: "Non-JS files",
165
+ files: ["!*.js"],
166
+ settings: {
167
+ js: false,
168
+ },
169
+ },
170
+
171
+ // specific settings for files inside `src` directory
172
+ {
173
+ name: "Source files",
174
+ basePath: "src",
175
+ files: ["**/*"],
176
+ settings: {
177
+ source: true,
178
+ },
179
+ },
180
+ ];
181
+ ```
182
+
183
+ In this example, the array contains both config objects and a config array. When a config array is normalized (see details below), it is flattened so only config objects remain. However, the order of evaluation remains the same.
184
+
185
+ If the `files` array contains a function, then that function is called with the path of the file as it was passed in. The function is expected to return `true` if there is a match and `false` if not. (The `ignores` array can also contain functions.)
186
+
187
+ If the `files` array contains an item that is an array of strings and functions, then all patterns must match in order for the config to match. In the preceding examples, both `*.test.*` and `*.js` must match in order for the config object to be used.
188
+
189
+ If a pattern in the files array begins with `!` then it excludes that pattern. In the preceding example, any filename that doesn't end with `.js` will automatically get a `settings.js` property set to `false`.
190
+
191
+ You can also specify an `ignores` key that will force files matching those patterns to not be included. If the `ignores` key is in a config object without any other keys, then those ignores will always be applied; otherwise those ignores act as exclusions. Here's an example:
192
+
193
+ ```js
194
+ export default [
195
+ // Always ignored
196
+ {
197
+ ignores: ["**/.git/**", "**/node_modules/**"],
198
+ },
199
+
200
+ // .eslintrc.js file is ignored only when .js file matches
201
+ {
202
+ files: ["**/*.js"],
203
+ ignores: [".eslintrc.js"],
204
+ handler: jsHandler,
205
+ },
206
+ ];
207
+ ```
208
+
209
+ You can use negated patterns in `ignores` to exclude a file that was already ignored, such as:
210
+
211
+ ```js
212
+ export default [
213
+ // Ignore all JSON files except tsconfig.json
214
+ {
215
+ files: ["**/*"],
216
+ ignores: ["**/*.json", "!tsconfig.json"],
217
+ },
218
+ ];
219
+ ```
220
+
221
+ ### Config Functions
222
+
223
+ Config arrays can also include config functions when `extraConfigTypes` contains `"function"`. A config function accepts a single parameter, `context` (defined by you), and must return either a config object or a config array (it cannot return another function). Config functions allow end users to execute code in the creation of appropriate config objects. Here's an example:
224
+
225
+ ```js
226
+ export default [
227
+ // JS config
228
+ {
229
+ files: ["**/*.js"],
230
+ handler: jsHandler,
231
+ },
232
+
233
+ // JSON configs
234
+ function (context) {
235
+ return [
236
+ // match all JSON files
237
+ {
238
+ name: context.name + " JSON Handler",
239
+ files: ["**/*.json"],
240
+ handler: jsonHandler,
241
+ },
242
+
243
+ // match only package.json
244
+ {
245
+ name: context.name + " package.json Handler",
246
+ files: ["package.json"],
247
+ handler: packageJsonHandler,
248
+ },
249
+ ];
250
+ },
251
+ ];
252
+ ```
253
+
254
+ When a config array is normalized, each function is executed and replaced in the config array with the return value.
255
+
256
+ **Note:** Config functions can also be async.
257
+
258
+ ### Normalizing Config Arrays
259
+
260
+ Once a config array has been created and loaded with all of the raw config data, it must be normalized before it can be used. The normalization process goes through and flattens the config array as well as executing all config functions to get their final values.
261
+
262
+ To normalize a config array, call the `normalize()` method and pass in a context object:
263
+
264
+ ```js
265
+ await configs.normalize({
266
+ name: "MyApp",
267
+ });
268
+ ```
269
+
270
+ The `normalize()` method returns a promise, so be sure to use the `await` operator. The config array instance is normalized in-place, so you don't need to create a new variable.
271
+
272
+ If you want to disallow async config functions, you can call `normalizeSync()` instead. This method is completely synchronous and does not require using the `await` operator as it does not return a promise:
273
+
274
+ ```js
275
+ configs.normalizeSync({
276
+ name: "MyApp",
277
+ });
278
+ ```
279
+
280
+ **Important:** Once a `ConfigArray` is normalized, it cannot be changed further. You can, however, create a new `ConfigArray` and pass in the normalized instance to create an unnormalized copy.
281
+
282
+ ### Getting Config for a File
283
+
284
+ To get the config for a file, use the `getConfig()` method on a normalized config array and pass in the filename to get a config for:
285
+
286
+ ```js
287
+ // pass in filename
288
+ const fileConfig = configs.getConfig(
289
+ path.resolve(process.cwd(), "package.json"),
290
+ );
291
+ ```
292
+
293
+ The config array always returns an object, even if there are no configs matching the given filename. You can then inspect the returned config object to determine how to proceed.
294
+
295
+ A few things to keep in mind:
296
+
297
+ - If a filename is not an absolute path, it will be resolved relative to the base path directory.
298
+ - The returned config object never has `files`, `ignores`, `basePath`, or `name` properties; the only properties on the object will be the other configuration options specified.
299
+ - The config array caches configs, so subsequent calls to `getConfig()` with the same filename will return in a fast lookup rather than another calculation.
300
+ - A config will only be generated if the filename matches an entry in a `files` key. A config will not be generated without matching a `files` key (configs without a `files` key are only applied when another config with a `files` key is applied; configs without `files` are never applied on their own). Any config with a `files` key entry that is `*` or ends with `/**` or `/*` will only be applied if another entry in the same `files` key matches or another config matches.
301
+
302
+ ## Determining Ignored Paths
303
+
304
+ You can determine if a file is ignored by using the `isFileIgnored()` method and passing in the path of any file, as in this example:
305
+
306
+ ```js
307
+ const ignored = configs.isFileIgnored("/foo/bar/baz.txt");
308
+ ```
309
+
310
+ A file is considered ignored if any of the following is true:
311
+
312
+ - **Its parent directory is ignored.** For example, if `foo` is in `ignores`, then `foo/a.js` is considered ignored.
313
+ - **It has an ancestor directory that is ignored.** For example, if `foo` is in `ignores`, then `foo/baz/a.js` is considered ignored.
314
+ - **It matches an ignored file pattern.** For example, if `**/a.js` is in `ignores`, then `foo/a.js` and `foo/baz/a.js` are considered ignored.
315
+ - **If it matches an entry in `files` and also in `ignores`.** For example, if `**/*.js` is in `files` and `**/a.js` is in `ignores`, then `foo/a.js` and `foo/baz/a.js` are considered ignored.
316
+ - **The file is outside the `basePath`.** If the `basePath` is `/usr/me`, then `/foo/a.js` is considered ignored.
317
+
318
+ For directories, use the `isDirectoryIgnored()` method and pass in the path of any directory, as in this example:
319
+
320
+ ```js
321
+ const ignored = configs.isDirectoryIgnored("/foo/bar/");
322
+ ```
323
+
324
+ A directory is considered ignored if any of the following is true:
325
+
326
+ - **Its parent directory is ignored.** For example, if `foo` is in `ignores`, then `foo/baz` is considered ignored.
327
+ - **It has an ancestor directory that is ignored.** For example, if `foo` is in `ignores`, then `foo/bar/baz/a.js` is considered ignored.
328
+ - **It matches an ignored file pattern.** For example, if `**/a.js` is in `ignores`, then `foo/a.js` and `foo/baz/a.js` are considered ignored.
329
+ - **If it matches an entry in `files` and also in `ignores`.** For example, if `**/*.js` is in `files` and `**/a.js` is in `ignores`, then `foo/a.js` and `foo/baz/a.js` are considered ignored.
330
+ - **The file is outside the `basePath`.** If the `basePath` is `/usr/me`, then `/foo/a.js` is considered ignored.
331
+
332
+ **Important:** A pattern such as `foo/**` means that `foo` and `foo/` are _not_ ignored whereas `foo/bar` is ignored. If you want to ignore `foo` and all of its subdirectories, use the pattern `foo` or `foo/` in `ignores`.
333
+
334
+ ## Caching Mechanisms
335
+
336
+ Each `ConfigArray` aggressively caches configuration objects to avoid unnecessary work. This caching occurs in two ways:
337
+
338
+ 1. **File-based Caching.** For each filename that is passed into a method, the resulting config is cached against that filename so you're always guaranteed to get the same object returned from `getConfig()` whenever you pass the same filename in.
339
+ 2. **Index-based Caching.** Whenever a config is calculated, the config elements that were used to create the config are also cached. So if a given filename matches elements 1, 5, and 7, the resulting config is cached with a key of `1,5,7`. That way, if another file is passed that matches the same config elements, the result is already known and doesn't have to be recalculated. That means two files that match all the same elements will return the same config from `getConfig()`.
340
+
341
+ ## Acknowledgements
342
+
343
+ The design of this project was influenced by feedback on the ESLint RFC, and incorporates ideas from:
344
+
345
+ - Teddy Katz (@not-an-aardvark)
346
+ - Toru Nagashima (@mysticatea)
347
+ - Kai Cataldo (@kaicataldo)
348
+
349
+ ## License
350
+
351
+ Apache 2.0
352
+
353
+ <!-- NOTE: This section is autogenerated. Do not manually edit.-->
354
+ <!--sponsorsstart-->
355
+
356
+ ## Sponsors
357
+
358
+ The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://eslint.org/donate)
359
+ to get your logo on our READMEs and [website](https://eslint.org/sponsors).
360
+
361
+ <h3>Platinum Sponsors</h3>
362
+ <p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="128"></a></p><h3>Gold Sponsors</h3>
363
+ <p><a href="https://qlty.sh/"><img src="https://images.opencollective.com/qltysh/33d157d/logo.png" alt="Qlty Software" height="96"></a></p><h3>Silver Sponsors</h3>
364
+ <p><a href="https://vite.dev/"><img src="https://images.opencollective.com/vite/d472863/logo.png" alt="Vite" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/2d6c3b6/logo.png" alt="Liftoff" height="64"></a> <a href="https://stackblitz.com"><img src="https://avatars.githubusercontent.com/u/28635252" alt="StackBlitz" height="64"></a></p><h3>Bronze Sponsors</h3>
365
+ <p><a href="https://cybozu.co.jp/"><img src="https://images.opencollective.com/cybozu/933e46d/logo.png" alt="Cybozu" height="32"></a> <a href="https://opensource.sap.com"><img src="https://avatars.githubusercontent.com/u/2531208" alt="SAP" height="32"></a> <a href="https://www.crawljobs.com/"><img src="https://images.opencollective.com/crawljobs-poland/fa43a17/logo.png" alt="CrawlJobs" height="32"></a> <a href="#"><img src="https://images.opencollective.com/aeriusventilations-org/avatar.png" alt="aeriusventilation's Org" height="32"></a> <a href="https://depot.dev"><img src="https://images.opencollective.com/depot/39125a1/logo.png" alt="Depot" height="32"></a> <a href="https://icons8.com/"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://www.gitbook.com"><img src="https://avatars.githubusercontent.com/u/7111340" alt="GitBook" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774" alt="HeroCoders" height="32"></a> <a href="https://www.lambdatest.com"><img src="https://avatars.githubusercontent.com/u/171592363" alt="TestMu AI Open Source Office (Formerly LambdaTest)" height="32"></a></p>
366
+ <h3>Technology Sponsors</h3>
367
+ Technology sponsors allow us to use their products and services for free as part of a contribution to the open source ecosystem and our work.
368
+ <p><a href="https://netlify.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/netlify-icon.svg" alt="Netlify" height="32"></a> <a href="https://algolia.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/algolia-icon.svg" alt="Algolia" height="32"></a> <a href="https://1password.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/1password-icon.svg" alt="1Password" height="32"></a></p>
369
+ <!--sponsorsend-->
node_modules/@eslint/config-array/package.json ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@eslint/config-array",
3
+ "version": "0.23.5",
4
+ "description": "General purpose glob-based configuration matching.",
5
+ "author": "Nicholas C. Zakas",
6
+ "type": "module",
7
+ "main": "dist/esm/index.js",
8
+ "types": "dist/esm/index.d.ts",
9
+ "exports": {
10
+ "require": {
11
+ "types": "./dist/cjs/index.d.cts",
12
+ "default": "./dist/cjs/index.cjs"
13
+ },
14
+ "import": {
15
+ "types": "./dist/esm/index.d.ts",
16
+ "default": "./dist/esm/index.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/eslint/rewrite.git",
28
+ "directory": "packages/config-array"
29
+ },
30
+ "bugs": {
31
+ "url": "https://github.com/eslint/rewrite/issues"
32
+ },
33
+ "homepage": "https://github.com/eslint/rewrite/tree/main/packages/config-array#readme",
34
+ "scripts": {
35
+ "build:dedupe-types": "node ../../tools/dedupe-types.js dist/cjs/index.cjs dist/esm/index.js",
36
+ "build:cts": "node ../../tools/build-cts.js dist/esm/index.d.ts dist/cjs/index.d.cts",
37
+ "build:std__path": "rollup -c rollup.std__path-config.js && node fix-std__path-imports",
38
+ "build": "rollup -c && npm run build:dedupe-types && tsc -p tsconfig.esm.json && npm run build:cts && npm run build:std__path",
39
+ "lint:types": "attw --pack",
40
+ "pretest": "npm run build",
41
+ "test": "npm run test:types && npm run test:unit",
42
+ "test:coverage": "npm run build && c8 npm run test:unit",
43
+ "test:jsr": "npx -y jsr@latest publish --dry-run",
44
+ "test:types": "tsc -p tests/types/tsconfig.json",
45
+ "test:unit": "mocha \"tests/**/*.test.js\""
46
+ },
47
+ "keywords": [
48
+ "configuration",
49
+ "configarray",
50
+ "config file"
51
+ ],
52
+ "license": "Apache-2.0",
53
+ "dependencies": {
54
+ "@eslint/object-schema": "^3.0.5",
55
+ "debug": "^4.3.1",
56
+ "minimatch": "^10.2.4"
57
+ },
58
+ "devDependencies": {
59
+ "@jsr/std__path": "^1.0.4",
60
+ "rollup-plugin-copy": "^3.5.0"
61
+ },
62
+ "engines": {
63
+ "node": "^20.19.0 || ^22.13.0 || >=24"
64
+ }
65
+ }
node_modules/@eslint/config-helpers/LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
node_modules/@eslint/config-helpers/README.md ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # @eslint/config-helpers
2
+
3
+ ## Description
4
+
5
+ Helper utilities for creating ESLint configuration.
6
+
7
+ ## Installation
8
+
9
+ For Node.js and compatible runtimes:
10
+
11
+ ```shell
12
+ npm install @eslint/config-helpers
13
+ # or
14
+ yarn add @eslint/config-helpers
15
+ # or
16
+ pnpm install @eslint/config-helpers
17
+ # or
18
+ bun add @eslint/config-helpers
19
+ ```
20
+
21
+ For Deno:
22
+
23
+ ```shell
24
+ deno add @eslint/config-helpers
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ ### `defineConfig()`
30
+
31
+ The `defineConfig()` function allows you to specify an ESLint configuration with full type checking and additional capabilities, such as `extends`. Here's an example:
32
+
33
+ ```js
34
+ // eslint.config.js
35
+ import { defineConfig } from "@eslint/config-helpers";
36
+ import js from "@eslint/js";
37
+
38
+ export default defineConfig([
39
+ {
40
+ files: ["src/**/*.js"],
41
+ plugins: { js },
42
+ extends: ["js/recommended"],
43
+ rules: {
44
+ "no-var": "error",
45
+ "prefer-const": "error",
46
+ },
47
+ },
48
+ {
49
+ files: ["test/**/*.js"],
50
+ rules: {
51
+ "no-console": "off",
52
+ },
53
+ },
54
+ ]);
55
+ ```
56
+
57
+ ### `globalIgnores()`
58
+
59
+ The `globalIgnores()` function allows you to specify patterns for files and directories that should be globally ignored by ESLint. This is useful for excluding files that you don't want to lint, such as build directories or third-party libraries. Here's an example:
60
+
61
+ ```js
62
+ // eslint.config.js
63
+ import { defineConfig, globalIgnores } from "@eslint/config-helpers";
64
+
65
+ export default defineConfig([
66
+ {
67
+ files: ["src/**/*.js"],
68
+ rules: {
69
+ "no-var": "error",
70
+ "prefer-const": "error",
71
+ },
72
+ },
73
+ globalIgnores(["node_modules/", "dist/", "coverage/"]),
74
+ ]);
75
+ ```
76
+
77
+ ### `includeIgnoreFile()`
78
+
79
+ The `includeIgnoreFile()` function reads a file with gitignore-style patterns (such as a `.gitignore`) and returns a config object with the patterns converted to a global ignores object. Pass the absolute path to the ignore file as the first argument:
80
+
81
+ ```js
82
+ // eslint.config.js
83
+
84
+ import { defineConfig, includeIgnoreFile } from "@eslint/config-helpers";
85
+ import path from "node:path";
86
+
87
+ const ignorePath = path.join(import.meta.dirname, ".gitignore");
88
+
89
+ export default defineConfig([
90
+ includeIgnoreFile(ignorePath, {
91
+ gitignoreResolution: true,
92
+ }),
93
+ // ...
94
+ ]);
95
+ ```
96
+
97
+ #### Options
98
+
99
+ The second argument is an optional options object:
100
+
101
+ - **`gitignoreResolution`** (`boolean`): Controls how ignore patterns are interpreted.
102
+ - `false` (default) — patterns are resolved relative to the location of the configuration file.
103
+ - `true` — patterns are resolved relative to the location of the ignore file, matching the behavior of `.gitignore` files.
104
+ - **`name`** (`string`): A custom name for the resulting config object.
105
+
106
+ For backwards compatibility with `includeIgnoreFile()` from `@eslint/compat`, passing a string instead of an object as the second argument is treated as equivalent to providing a value for `name`.
107
+
108
+ #### Multiple files
109
+
110
+ You can also pass an array of absolute paths to include multiple ignore files at once. In this case an array of config objects is returned:
111
+
112
+ ```js
113
+ // eslint.config.js
114
+
115
+ import { defineConfig, includeIgnoreFile } from "@eslint/config-helpers";
116
+ import path from "node:path";
117
+
118
+ export default defineConfig([
119
+ includeIgnoreFile(
120
+ [
121
+ path.join(import.meta.dirname, ".gitignore"),
122
+ path.join(import.meta.dirname, "packages/lib/.gitignore"),
123
+ ],
124
+ { gitignoreResolution: true },
125
+ ),
126
+ // ...
127
+ ]);
128
+ ```
129
+
130
+ ## License
131
+
132
+ Apache 2.0
133
+
134
+ <!-- NOTE: This section is autogenerated. Do not manually edit.-->
135
+ <!--sponsorsstart-->
136
+
137
+ ## Sponsors
138
+
139
+ The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://eslint.org/donate)
140
+ to get your logo on our READMEs and [website](https://eslint.org/sponsors).
141
+
142
+ <h3>Platinum Sponsors</h3>
143
+ <p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="128"></a></p><h3>Gold Sponsors</h3>
144
+ <p><a href="https://qlty.sh/"><img src="https://images.opencollective.com/qltysh/33d157d/logo.png" alt="Qlty Software" height="96"></a></p><h3>Silver Sponsors</h3>
145
+ <p><a href="https://vite.dev/"><img src="https://images.opencollective.com/vite/d472863/logo.png" alt="Vite" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/2d6c3b6/logo.png" alt="Liftoff" height="64"></a> <a href="https://stackblitz.com"><img src="https://avatars.githubusercontent.com/u/28635252" alt="StackBlitz" height="64"></a></p><h3>Bronze Sponsors</h3>
146
+ <p><a href="https://cybozu.co.jp/"><img src="https://images.opencollective.com/cybozu/933e46d/logo.png" alt="Cybozu" height="32"></a> <a href="https://opensource.sap.com"><img src="https://avatars.githubusercontent.com/u/2531208" alt="SAP" height="32"></a> <a href="https://www.crawljobs.com/"><img src="https://images.opencollective.com/crawljobs-poland/fa43a17/logo.png" alt="CrawlJobs" height="32"></a> <a href="https://depot.dev"><img src="https://images.opencollective.com/depot/39125a1/logo.png" alt="Depot" height="32"></a> <a href="https://icons8.com/"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://www.gitbook.com"><img src="https://avatars.githubusercontent.com/u/7111340" alt="GitBook" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774" alt="HeroCoders" height="32"></a> <a href="https://citadel.co.jp"><img src="https://avatars.githubusercontent.com/u/75781367" alt="Citadel AI" height="32"></a> <a href="https://www.lambdatest.com"><img src="https://avatars.githubusercontent.com/u/171592363" alt="TestMu AI Open Source Office (Formerly LambdaTest)" height="32"></a></p>
147
+ <h3>Technology Sponsors</h3>
148
+ Technology sponsors allow us to use their products and services for free as part of a contribution to the open source ecosystem and our work.
149
+ <p><a href="https://netlify.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/netlify-icon.svg" alt="Netlify" height="32"></a> <a href="https://algolia.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/algolia-icon.svg" alt="Algolia" height="32"></a> <a href="https://1password.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/1password-icon.svg" alt="1Password" height="32"></a></p>
150
+ <!--sponsorsend-->
node_modules/@eslint/config-helpers/package.json ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@eslint/config-helpers",
3
+ "version": "0.6.0",
4
+ "description": "Helper utilities for creating ESLint configuration",
5
+ "type": "module",
6
+ "main": "dist/esm/index.js",
7
+ "types": "dist/esm/index.d.ts",
8
+ "exports": {
9
+ "require": {
10
+ "types": "./dist/cjs/index.d.cts",
11
+ "default": "./dist/cjs/index.cjs"
12
+ },
13
+ "import": {
14
+ "types": "./dist/esm/index.d.ts",
15
+ "default": "./dist/esm/index.js"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist"
20
+ ],
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
24
+ "directories": {
25
+ "test": "tests"
26
+ },
27
+ "scripts": {
28
+ "build:dedupe-types": "node ../../tools/dedupe-types.js dist/cjs/index.cjs dist/esm/index.js",
29
+ "build:cts": "node ../../tools/build-cts.js dist/esm/index.d.ts dist/cjs/index.d.cts",
30
+ "build": "rollup -c && npm run build:dedupe-types && tsc -p tsconfig.esm.json && npm run build:cts",
31
+ "lint:types": "attw --pack",
32
+ "pretest": "npm run build",
33
+ "test": "npm run test:types && npm run test:unit",
34
+ "test:coverage": "c8 npm run test:unit",
35
+ "test:jsr": "npx -y jsr@latest publish --dry-run",
36
+ "test:pnpm": "cd tests/pnpm && pnpm install && pnpm exec tsc",
37
+ "test:types": "tsc -p tests/types/tsconfig.json",
38
+ "test:unit": "mocha \"tests/**/*.test.js\""
39
+ },
40
+ "repository": {
41
+ "type": "git",
42
+ "url": "git+https://github.com/eslint/rewrite.git",
43
+ "directory": "packages/config-helpers"
44
+ },
45
+ "keywords": [
46
+ "eslint"
47
+ ],
48
+ "license": "Apache-2.0",
49
+ "bugs": {
50
+ "url": "https://github.com/eslint/rewrite/issues"
51
+ },
52
+ "homepage": "https://github.com/eslint/rewrite/tree/main/packages/config-helpers#readme",
53
+ "dependencies": {
54
+ "@eslint/core": "^1.2.1"
55
+ },
56
+ "devDependencies": {
57
+ "rollup-plugin-copy": "^3.5.0"
58
+ },
59
+ "engines": {
60
+ "node": "^20.19.0 || ^22.13.0 || >=24"
61
+ }
62
+ }
node_modules/@eslint/core/LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
node_modules/@eslint/core/README.md ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ESLint Core
2
+
3
+ ## Overview
4
+
5
+ This package is the future home of the rewritten, runtime-agnostic ESLint core.
6
+
7
+ Right now, it exports the core types necessary to implement language plugins.
8
+
9
+ ## License
10
+
11
+ Apache 2.0
12
+
13
+ <!-- NOTE: This section is autogenerated. Do not manually edit.-->
14
+ <!--sponsorsstart-->
15
+
16
+ ## Sponsors
17
+
18
+ The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://eslint.org/donate)
19
+ to get your logo on our READMEs and [website](https://eslint.org/sponsors).
20
+
21
+ <h3>Platinum Sponsors</h3>
22
+ <p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="128"></a></p><h3>Gold Sponsors</h3>
23
+ <p><a href="https://qlty.sh/"><img src="https://images.opencollective.com/qltysh/33d157d/logo.png" alt="Qlty Software" height="96"></a></p><h3>Silver Sponsors</h3>
24
+ <p><a href="https://vite.dev/"><img src="https://images.opencollective.com/vite/d472863/logo.png" alt="Vite" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/2d6c3b6/logo.png" alt="Liftoff" height="64"></a> <a href="https://stackblitz.com"><img src="https://avatars.githubusercontent.com/u/28635252" alt="StackBlitz" height="64"></a></p><h3>Bronze Sponsors</h3>
25
+ <p><a href="https://cybozu.co.jp/"><img src="https://images.opencollective.com/cybozu/933e46d/logo.png" alt="Cybozu" height="32"></a> <a href="https://opensource.sap.com"><img src="https://avatars.githubusercontent.com/u/2531208" alt="SAP" height="32"></a> <a href="https://www.crawljobs.com/"><img src="https://images.opencollective.com/crawljobs-poland/fa43a17/logo.png" alt="CrawlJobs" height="32"></a> <a href="#"><img src="https://images.opencollective.com/aeriusventilations-org/avatar.png" alt="aeriusventilation's Org" height="32"></a> <a href="https://depot.dev"><img src="https://images.opencollective.com/depot/39125a1/logo.png" alt="Depot" height="32"></a> <a href="https://icons8.com/"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://www.gitbook.com"><img src="https://avatars.githubusercontent.com/u/7111340" alt="GitBook" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774" alt="HeroCoders" height="32"></a> <a href="https://www.lambdatest.com"><img src="https://avatars.githubusercontent.com/u/171592363" alt="TestMu AI Open Source Office (Formerly LambdaTest)" height="32"></a></p>
26
+ <h3>Technology Sponsors</h3>
27
+ Technology sponsors allow us to use their products and services for free as part of a contribution to the open source ecosystem and our work.
28
+ <p><a href="https://netlify.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/netlify-icon.svg" alt="Netlify" height="32"></a> <a href="https://algolia.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/algolia-icon.svg" alt="Algolia" height="32"></a> <a href="https://1password.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/1password-icon.svg" alt="1Password" height="32"></a></p>
29
+ <!--sponsorsend-->
node_modules/@eslint/core/package.json ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@eslint/core",
3
+ "version": "1.2.1",
4
+ "description": "Runtime-agnostic core of ESLint",
5
+ "type": "module",
6
+ "types": "./dist/esm/types.d.ts",
7
+ "exports": {
8
+ "types": {
9
+ "import": "./dist/esm/types.d.ts",
10
+ "require": "./dist/cjs/types.d.cts"
11
+ }
12
+ },
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "scripts": {
20
+ "build:cts": "node -e \"fs.cpSync('dist/esm/types.d.ts', 'dist/cjs/types.d.cts')\"",
21
+ "build": "tsc && npm run build:cts",
22
+ "lint:types": "attw --pack",
23
+ "pretest": "npm run build",
24
+ "test": "npm run test:types",
25
+ "test:jsr": "npx -y jsr@latest publish --dry-run",
26
+ "test:types": "tsc -p tests/types/tsconfig.json"
27
+ },
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/eslint/rewrite.git",
31
+ "directory": "packages/core"
32
+ },
33
+ "keywords": [
34
+ "eslint",
35
+ "core"
36
+ ],
37
+ "author": "Nicholas C. Zakas",
38
+ "license": "Apache-2.0",
39
+ "bugs": {
40
+ "url": "https://github.com/eslint/rewrite/issues"
41
+ },
42
+ "homepage": "https://github.com/eslint/rewrite/tree/main/packages/core#readme",
43
+ "dependencies": {
44
+ "@types/json-schema": "^7.0.15"
45
+ },
46
+ "devDependencies": {
47
+ "json-schema": "^0.4.0"
48
+ },
49
+ "engines": {
50
+ "node": "^20.19.0 || ^22.13.0 || >=24"
51
+ }
52
+ }
node_modules/@eslint/eslintrc/LICENSE ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright OpenJS Foundation and other contributors, <www.openjsf.org>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
node_modules/@eslint/eslintrc/README.md ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ESLintRC Library
2
+
3
+ This repository contains the legacy ESLintRC configuration file format for ESLint. This package is not intended for use outside of the ESLint ecosystem. It is ESLint-specific and not intended for use in other programs.
4
+
5
+ **Note:** This package is frozen except for critical bug fixes as ESLint moves to a new config system.
6
+
7
+ ## Installation
8
+
9
+ You can install the package as follows:
10
+
11
+ ```shell
12
+ npm install @eslint/eslintrc -D
13
+ # or
14
+ yarn add @eslint/eslintrc -D
15
+ # or
16
+ pnpm install @eslint/eslintrc -D
17
+ # or
18
+ bun install @eslint/eslintrc -D
19
+ ```
20
+
21
+ ## Usage (ESM)
22
+
23
+ The primary class in this package is `FlatCompat`, which is a utility to translate ESLintRC-style configs into flat configs. Here's how you use it inside of your `eslint.config.js` file:
24
+
25
+ ```js
26
+ import { FlatCompat } from "@eslint/eslintrc";
27
+ import js from "@eslint/js";
28
+ import path from "path";
29
+ import { fileURLToPath } from "url";
30
+
31
+ // mimic CommonJS variables -- not needed if using CommonJS
32
+ const __filename = fileURLToPath(import.meta.url);
33
+ const __dirname = path.dirname(__filename);
34
+
35
+ const compat = new FlatCompat({
36
+ baseDirectory: __dirname, // optional; default: process.cwd()
37
+ resolvePluginsRelativeTo: __dirname, // optional
38
+ recommendedConfig: js.configs.recommended, // optional unless you're using "eslint:recommended"
39
+ allConfig: js.configs.all, // optional unless you're using "eslint:all"
40
+ });
41
+
42
+ export default [
43
+
44
+ // mimic ESLintRC-style extends
45
+ ...compat.extends("standard", "example", "plugin:react/recommended"),
46
+
47
+ // mimic environments
48
+ ...compat.env({
49
+ es2020: true,
50
+ node: true
51
+ }),
52
+
53
+ // mimic plugins
54
+ ...compat.plugins("jsx-a11y", "react"),
55
+
56
+ // translate an entire config
57
+ ...compat.config({
58
+ plugins: ["jsx-a11y", "react"],
59
+ extends: "standard",
60
+ env: {
61
+ es2020: true,
62
+ node: true
63
+ },
64
+ rules: {
65
+ semi: "error"
66
+ }
67
+ })
68
+ ];
69
+ ```
70
+
71
+ ## Usage (CommonJS)
72
+
73
+ Using `FlatCompat` in CommonJS files is similar to ESM, but you'll use `require()` and `module.exports` instead of `import` and `export`. Here's how you use it inside of your `eslint.config.js` CommonJS file:
74
+
75
+ ```js
76
+ const { FlatCompat } = require("@eslint/eslintrc");
77
+ const js = require("@eslint/js");
78
+
79
+ const compat = new FlatCompat({
80
+ baseDirectory: __dirname, // optional; default: process.cwd()
81
+ resolvePluginsRelativeTo: __dirname, // optional
82
+ recommendedConfig: js.configs.recommended, // optional unless using "eslint:recommended"
83
+ allConfig: js.configs.all, // optional unless using "eslint:all"
84
+ });
85
+
86
+ module.exports = [
87
+
88
+ // mimic ESLintRC-style extends
89
+ ...compat.extends("standard", "example", "plugin:react/recommended"),
90
+
91
+ // mimic environments
92
+ ...compat.env({
93
+ es2020: true,
94
+ node: true
95
+ }),
96
+
97
+ // mimic plugins
98
+ ...compat.plugins("jsx-a11y", "react"),
99
+
100
+ // translate an entire config
101
+ ...compat.config({
102
+ plugins: ["jsx-a11y", "react"],
103
+ extends: "standard",
104
+ env: {
105
+ es2020: true,
106
+ node: true
107
+ },
108
+ rules: {
109
+ semi: "error"
110
+ }
111
+ })
112
+ ];
113
+ ```
114
+
115
+ ## Troubleshooting
116
+
117
+ **TypeError: Missing parameter 'recommendedConfig' in FlatCompat constructor**
118
+
119
+ The `recommendedConfig` option is required when any config uses `eslint:recommended`, including any config in an `extends` clause. To fix this, follow the example above using `@eslint/js` to provide the `eslint:recommended` config.
120
+
121
+ **TypeError: Missing parameter 'allConfig' in FlatCompat constructor**
122
+
123
+ The `allConfig` option is required when any config uses `eslint:all`, including any config in an `extends` clause. To fix this, follow the example above using `@eslint/js` to provide the `eslint:all` config.
124
+
125
+ ## License
126
+
127
+ MIT License
128
+
129
+ <!-- NOTE: This section is autogenerated. Do not manually edit.-->
130
+ <!--sponsorsstart-->
131
+
132
+ ## Sponsors
133
+
134
+ The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://eslint.org/donate)
135
+ to get your logo on our READMEs and [website](https://eslint.org/sponsors).
136
+
137
+ <h3>Platinum Sponsors</h3>
138
+ <p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="128"></a></p><h3>Gold Sponsors</h3>
139
+ <p><a href="https://qlty.sh/"><img src="https://images.opencollective.com/qltysh/33d157d/logo.png" alt="Qlty Software" height="96"></a></p><h3>Silver Sponsors</h3>
140
+ <p><a href="https://vite.dev/"><img src="https://images.opencollective.com/vite/d472863/logo.png" alt="Vite" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/2d6c3b6/logo.png" alt="Liftoff" height="64"></a> <a href="https://stackblitz.com"><img src="https://avatars.githubusercontent.com/u/28635252" alt="StackBlitz" height="64"></a></p><h3>Bronze Sponsors</h3>
141
+ <p><a href="https://cybozu.co.jp/"><img src="https://images.opencollective.com/cybozu/933e46d/logo.png" alt="Cybozu" height="32"></a> <a href="https://opensource.sap.com"><img src="https://avatars.githubusercontent.com/u/2531208" alt="SAP" height="32"></a> <a href="https://www.crawljobs.com/"><img src="https://images.opencollective.com/crawljobs-poland/fa43a17/logo.png" alt="CrawlJobs" height="32"></a> <a href="https://depot.dev"><img src="https://images.opencollective.com/depot/39125a1/logo.png" alt="Depot" height="32"></a> <a href="https://www.n-ix.com/"><img src="https://images.opencollective.com/n-ix-ltd/575a7a5/logo.png" alt="N-iX Ltd" height="32"></a> <a href="https://icons8.com/"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://www.gitbook.com"><img src="https://avatars.githubusercontent.com/u/7111340" alt="GitBook" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774" alt="HeroCoders" height="32"></a> <a href="https://www.lambdatest.com"><img src="https://avatars.githubusercontent.com/u/171592363" alt="TestMu AI Open Source Office (Formerly LambdaTest)" height="32"></a></p>
142
+ <h3>Technology Sponsors</h3>
143
+ Technology sponsors allow us to use their products and services for free as part of a contribution to the open source ecosystem and our work.
144
+ <p><a href="https://netlify.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/netlify-icon.svg" alt="Netlify" height="32"></a> <a href="https://algolia.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/algolia-icon.svg" alt="Algolia" height="32"></a> <a href="https://1password.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/1password-icon.svg" alt="1Password" height="32"></a></p>
145
+ <!--sponsorsend-->
node_modules/@eslint/eslintrc/conf/config-schema.js ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Defines a schema for configs.
3
+ * @author Sylvan Mably
4
+ */
5
+
6
+ const baseConfigProperties = {
7
+ $schema: { type: "string" },
8
+ env: { type: "object" },
9
+ extends: { $ref: "#/definitions/stringOrStrings" },
10
+ globals: { type: "object" },
11
+ overrides: {
12
+ type: "array",
13
+ items: { $ref: "#/definitions/overrideConfig" },
14
+ additionalItems: false
15
+ },
16
+ parser: { type: ["string", "null"] },
17
+ parserOptions: { type: "object" },
18
+ plugins: { type: "array" },
19
+ processor: { type: "string" },
20
+ rules: { type: "object" },
21
+ settings: { type: "object" },
22
+ noInlineConfig: { type: "boolean" },
23
+ reportUnusedDisableDirectives: { type: "boolean" },
24
+
25
+ ecmaFeatures: { type: "object" } // deprecated; logs a warning when used
26
+ };
27
+
28
+ const configSchema = {
29
+ definitions: {
30
+ stringOrStrings: {
31
+ oneOf: [
32
+ { type: "string" },
33
+ {
34
+ type: "array",
35
+ items: { type: "string" },
36
+ additionalItems: false
37
+ }
38
+ ]
39
+ },
40
+ stringOrStringsRequired: {
41
+ oneOf: [
42
+ { type: "string" },
43
+ {
44
+ type: "array",
45
+ items: { type: "string" },
46
+ additionalItems: false,
47
+ minItems: 1
48
+ }
49
+ ]
50
+ },
51
+
52
+ // Config at top-level.
53
+ objectConfig: {
54
+ type: "object",
55
+ properties: {
56
+ root: { type: "boolean" },
57
+ ignorePatterns: { $ref: "#/definitions/stringOrStrings" },
58
+ ...baseConfigProperties
59
+ },
60
+ additionalProperties: false
61
+ },
62
+
63
+ // Config in `overrides`.
64
+ overrideConfig: {
65
+ type: "object",
66
+ properties: {
67
+ excludedFiles: { $ref: "#/definitions/stringOrStrings" },
68
+ files: { $ref: "#/definitions/stringOrStringsRequired" },
69
+ ...baseConfigProperties
70
+ },
71
+ required: ["files"],
72
+ additionalProperties: false
73
+ }
74
+ },
75
+
76
+ $ref: "#/definitions/objectConfig"
77
+ };
78
+
79
+ export default configSchema;