Leon4gr45 commited on
Commit
c1adaf0
·
verified ·
1 Parent(s): 0b7ff57

Include updated package-lock.json (part 20)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +1 -0
  2. node_modules/eslint-config-flat-gitignore/LICENSE +21 -0
  3. node_modules/eslint-config-flat-gitignore/README.md +113 -0
  4. node_modules/eslint-config-flat-gitignore/package.json +67 -0
  5. node_modules/eslint-config-prettier/LICENSE +21 -0
  6. node_modules/eslint-config-prettier/README.md +928 -0
  7. node_modules/eslint-config-prettier/bin/cli.js +240 -0
  8. node_modules/eslint-config-prettier/bin/validators.js +86 -0
  9. node_modules/eslint-config-prettier/flat.d.ts +7 -0
  10. node_modules/eslint-config-prettier/flat.js +6 -0
  11. node_modules/eslint-config-prettier/index.d.ts +5 -0
  12. node_modules/eslint-config-prettier/index.js +395 -0
  13. node_modules/eslint-config-prettier/package.json +51 -0
  14. node_modules/eslint-config-prettier/prettier.d.ts +1 -0
  15. node_modules/eslint-config-prettier/prettier.js +10 -0
  16. node_modules/eslint-plugin-prettier/LICENSE.md +24 -0
  17. node_modules/eslint-plugin-prettier/README.md +199 -0
  18. node_modules/eslint-plugin-prettier/eslint-plugin-prettier.d.ts +5 -0
  19. node_modules/eslint-plugin-prettier/eslint-plugin-prettier.js +306 -0
  20. node_modules/eslint-plugin-prettier/package.json +60 -0
  21. node_modules/eslint-plugin-prettier/recommended.d.ts +12 -0
  22. node_modules/eslint-plugin-prettier/recommended.js +18 -0
  23. node_modules/eslint-plugin-prettier/worker.mjs +187 -0
  24. node_modules/eslint-plugin-react-hooks/LICENSE +21 -0
  25. node_modules/eslint-plugin-react-hooks/README.md +150 -0
  26. node_modules/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.d.ts +101 -0
  27. node_modules/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js +0 -0
  28. node_modules/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.production.js +0 -0
  29. node_modules/eslint-plugin-react-hooks/index.d.ts +10 -0
  30. node_modules/eslint-plugin-react-hooks/index.js +26 -0
  31. node_modules/eslint-plugin-react-hooks/package.json +68 -0
  32. node_modules/eslint-plugin-react-refresh/LICENSE +21 -0
  33. node_modules/eslint-plugin-react-refresh/README.md +222 -0
  34. node_modules/eslint-plugin-react-refresh/index.d.ts +40 -0
  35. node_modules/eslint-plugin-react-refresh/index.js +344 -0
  36. node_modules/eslint-plugin-react-refresh/package.json +25 -0
  37. node_modules/eslint-scope/LICENSE +22 -0
  38. node_modules/eslint-scope/README.md +207 -0
  39. node_modules/eslint-scope/lib/assert.js +17 -0
  40. node_modules/eslint-scope/lib/definition.js +85 -0
  41. node_modules/eslint-scope/lib/index.d.cts +1152 -0
  42. node_modules/eslint-scope/lib/index.d.ts +6 -0
  43. node_modules/eslint-scope/lib/index.js +175 -0
  44. node_modules/eslint-scope/lib/pattern-visitor.js +157 -0
  45. node_modules/eslint-scope/lib/reference.js +173 -0
  46. node_modules/eslint-scope/lib/referencer.js +817 -0
  47. node_modules/eslint-scope/lib/scope-manager.js +298 -0
  48. node_modules/eslint-scope/lib/scope.js +852 -0
  49. node_modules/eslint-scope/lib/variable.js +90 -0
  50. node_modules/eslint-scope/package.json +66 -0
.gitattributes CHANGED
@@ -61,3 +61,4 @@ node_modules/bare-url/prebuilds/win32-arm64/bare-url.bare filter=lfs diff=lfs me
61
  node_modules/bare-url/prebuilds/win32-x64/bare-url.bare filter=lfs diff=lfs merge=lfs -text
62
  node_modules/better-sqlite3/build/Release/better_sqlite3.node filter=lfs diff=lfs merge=lfs -text
63
  node_modules/concurrently/docs/demo.gif filter=lfs diff=lfs merge=lfs -text
 
 
61
  node_modules/bare-url/prebuilds/win32-x64/bare-url.bare filter=lfs diff=lfs merge=lfs -text
62
  node_modules/better-sqlite3/build/Release/better_sqlite3.node filter=lfs diff=lfs merge=lfs -text
63
  node_modules/concurrently/docs/demo.gif filter=lfs diff=lfs merge=lfs -text
64
+ node_modules/exif-parser/test/starfish.jpg filter=lfs diff=lfs merge=lfs -text
node_modules/eslint-config-flat-gitignore/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Anthony Fu <https://github.com/antfu>
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-config-flat-gitignore/README.md ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # eslint-config-flat-gitignore
2
+
3
+ [![npm version][npm-version-src]][npm-version-href]
4
+ [![npm downloads][npm-downloads-src]][npm-downloads-href]
5
+ [![bundle][bundle-src]][bundle-href]
6
+ [![JSDocs][jsdocs-src]][jsdocs-href]
7
+ [![License][license-src]][license-href]
8
+
9
+ `.gitignore` support for [ESLint Flat Config](https://eslint.org/docs/latest/use/configure/configuration-files-new).
10
+
11
+ ## Usage
12
+
13
+ ```bash
14
+ npm i -D eslint-config-flat-gitignore
15
+ ```
16
+
17
+ ```js
18
+ // eslint.config.js
19
+ import gitignore from 'eslint-config-flat-gitignore'
20
+
21
+ export default [
22
+ // recommended putting it at the first
23
+ gitignore(),
24
+ // your other configs here
25
+ ]
26
+ ```
27
+
28
+ By default it will only looks for `.gitignore` but NOT `.eslintignore`, as we would recommended move away from `.eslintignore` to declare directly in `eslint.config.js` for single source of truth. If you still want it, you can pass the `files` option to specify the files to look for.
29
+
30
+ ```js
31
+ gitignore({
32
+ files: [
33
+ '.gitignore',
34
+ '.eslintignore',
35
+ ]
36
+ })
37
+ ```
38
+
39
+ By default, this plugin throws if any of the ignore files are missing. This can be disabled by passing setting the `strict` option to `false`.
40
+
41
+ ```js
42
+ gitignore({
43
+ files: [
44
+ '.gitignore',
45
+ '.eslintignore',
46
+ ],
47
+ strict: false,
48
+ })
49
+ ```
50
+
51
+ By default, this plugin will try to look up the directory tree and match the first `.gitignore` file. You can disable this by setting the `root` option to `true`, or specify the `files` option to a specific path.
52
+
53
+ ```js
54
+ gitignore({
55
+ root: true
56
+ })
57
+ ```
58
+
59
+ If you want to include recursive `.gitignore` files (for example in monorepos), enable the `recursive` option.
60
+
61
+ ```js
62
+ gitignore({
63
+ recursive: true,
64
+ })
65
+ ```
66
+
67
+ If you want recursive discovery but need to skip specific directory names, pass an object to `recursive` with `skipDirs`.
68
+
69
+ ```js
70
+ gitignore({
71
+ recursive: {
72
+ // Skip any directory with this name at any depth
73
+ skipDirs: ['dist', 'coverage'],
74
+ },
75
+ })
76
+ ```
77
+
78
+ `skipDirs` matches directory names (not paths) and applies in addition to the built-in skipped directories: `.git` and `node_modules`.
79
+
80
+ This plugin will also automatically detect git submodule file `.gitmodules` and ignore all files under the submodule dirs. If you want to disable or customize this behavior, you can pass the `filesGitModules` option.
81
+
82
+ <!-- eslint-skip -->
83
+ ```js
84
+ gitignore({
85
+ filesGitModules: [], // disable
86
+ filesGitModules: ['path/to/.gitmodules'], // customize
87
+ })
88
+ ```
89
+
90
+ ## Sponsors
91
+
92
+ <p align="center">
93
+ <a href="https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg">
94
+ <img src='https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg' alt='Sponsors' />
95
+ </a>
96
+ </p>
97
+
98
+ ## License
99
+
100
+ [MIT](./LICENSE) License © 2023-PRESENT [Anthony Fu](https://github.com/antfu)
101
+
102
+ <!-- Badges -->
103
+
104
+ [npm-version-src]: https://img.shields.io/npm/v/eslint-config-flat-gitignore?style=flat&colorA=080f12&colorB=1fa669
105
+ [npm-version-href]: https://npmjs.com/package/eslint-config-flat-gitignore
106
+ [npm-downloads-src]: https://img.shields.io/npm/dm/eslint-config-flat-gitignore?style=flat&colorA=080f12&colorB=1fa669
107
+ [npm-downloads-href]: https://npmjs.com/package/eslint-config-flat-gitignore
108
+ [bundle-src]: https://img.shields.io/bundlephobia/minzip/eslint-config-flat-gitignore?style=flat&colorA=080f12&colorB=1fa669&label=minzip
109
+ [bundle-href]: https://bundlephobia.com/result?p=eslint-config-flat-gitignore
110
+ [license-src]: https://img.shields.io/github/license/antfu/eslint-config-flat-gitignore.svg?style=flat&colorA=080f12&colorB=1fa669
111
+ [license-href]: https://github.com/antfu/eslint-config-flat-gitignore/blob/main/LICENSE
112
+ [jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-080f12?style=flat&colorA=080f12&colorB=1fa669
113
+ [jsdocs-href]: https://www.jsdocs.io/package/eslint-config-flat-gitignore
node_modules/eslint-config-flat-gitignore/package.json ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "eslint-config-flat-gitignore",
3
+ "type": "module",
4
+ "version": "2.3.0",
5
+ "description": ".gitignore support for ESLint Flat Config",
6
+ "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
+ "license": "MIT",
8
+ "funding": "https://github.com/sponsors/antfu",
9
+ "homepage": "https://github.com/antfu/eslint-config-flat-gitignore#readme",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/antfu/eslint-config-flat-gitignore.git"
13
+ },
14
+ "bugs": "https://github.com/antfu/eslint-config-flat-gitignore/issues",
15
+ "keywords": [
16
+ "eslint-config",
17
+ "eslint-flat-config"
18
+ ],
19
+ "sideEffects": false,
20
+ "exports": {
21
+ ".": "./dist/index.mjs"
22
+ },
23
+ "main": "./dist/index.mjs",
24
+ "module": "./dist/index.mjs",
25
+ "types": "./dist/index.d.mts",
26
+ "files": [
27
+ "dist"
28
+ ],
29
+ "peerDependencies": {
30
+ "eslint": "^9.5.0 || ^10.0.0"
31
+ },
32
+ "dependencies": {
33
+ "@eslint/compat": "^2.0.3"
34
+ },
35
+ "devDependencies": {
36
+ "@antfu/eslint-config": "^7.7.3",
37
+ "@antfu/ni": "^30.0.0",
38
+ "@antfu/utils": "^9.3.0",
39
+ "@types/node": "^25.5.0",
40
+ "bumpp": "^11.0.1",
41
+ "eslint": "^10.1.0",
42
+ "find-up-simple": "^1.0.1",
43
+ "lint-staged": "^16.4.0",
44
+ "pnpm": "^10.32.1",
45
+ "simple-git-hooks": "^2.13.1",
46
+ "tsx": "^4.21.0",
47
+ "typescript": "^5.9.3",
48
+ "unbuild": "^3.6.1",
49
+ "vite": "^8.0.2",
50
+ "vitest": "^4.1.1"
51
+ },
52
+ "simple-git-hooks": {
53
+ "pre-commit": "pnpm lint-staged"
54
+ },
55
+ "lint-staged": {
56
+ "*": "eslint --fix"
57
+ },
58
+ "scripts": {
59
+ "build": "unbuild",
60
+ "dev": "unbuild --stub",
61
+ "lint": "eslint .",
62
+ "release": "bumpp",
63
+ "start": "tsx src/index.ts",
64
+ "test": "vitest --pool=forks",
65
+ "typecheck": "tsc --noEmit"
66
+ }
67
+ }
node_modules/eslint-config-prettier/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017, 2018, 2019, 2020, 2021, 2022, 2023 Simon Lydell and contributors
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
13
+ all 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
21
+ THE SOFTWARE.
node_modules/eslint-config-prettier/README.md ADDED
@@ -0,0 +1,928 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # eslint-config-prettier
2
+
3
+ Turns off all rules that are unnecessary or might conflict with [Prettier].
4
+
5
+ This lets you use your favorite shareable config without letting its stylistic choices get in the way when using Prettier.
6
+
7
+ Note that this config _only_ turns rules _off,_ so it only makes sense using it together with some other config.
8
+
9
+ [prettier]: https://github.com/prettier/prettier
10
+
11
+ ## Installation
12
+
13
+ 1. Install eslint-config-prettier:
14
+
15
+ ```shell
16
+ npm i -D eslint-config-prettier
17
+ ```
18
+
19
+ ```shell
20
+ yarn add -D eslint-config-prettier
21
+ ```
22
+
23
+ ```shell
24
+ pnpm add -D eslint-config-prettier
25
+ ```
26
+
27
+ ```shell
28
+ bun add -D eslint-config-prettier
29
+ ```
30
+
31
+ 2. Add eslint-config-prettier to your ESLint configuration – either to [eslintrc] or to [eslint.config.js (flat config)].
32
+
33
+ - eslintrc: Add `"prettier"` to the "extends" array in your `.eslintrc.*` file. Make sure to put it **last,** so it gets the chance to override other configs.
34
+
35
+ <!-- prettier-ignore -->
36
+ ```json
37
+ {
38
+ "extends": [
39
+ "some-other-config-you-use",
40
+ "prettier"
41
+ ]
42
+ }
43
+ ```
44
+
45
+ - eslint.config.js (flat config): Import eslint-config-prettier, and put it in the configuration array – **after** other configs that you want to override.
46
+
47
+ <!-- prettier-ignore -->
48
+ ```js
49
+ import someConfig from "some-other-config-you-use";
50
+ // Note the `/flat` suffix here, the difference from default entry is that
51
+ // `/flat` added `name` property to the exported object to improve
52
+ // [config-inspector](https://eslint.org/blog/2024/04/eslint-config-inspector/) experience.
53
+ import eslintConfigPrettier from "eslint-config-prettier/flat";
54
+
55
+ export default [
56
+ someConfig,
57
+ eslintConfigPrettier,
58
+ ];
59
+ ```
60
+
61
+ 3. Finally, run the [CLI helper tool](#cli-helper-tool) to find problems in the `"rules"` sections of your config.
62
+
63
+ > 👉 Using [eslint-plugin-prettier]? Check out [eslint-plugin-prettier’s recommended config][eslint-plugin-prettier-recommended].
64
+
65
+ ### Plugins
66
+
67
+ eslint-config-prettier not only turns off _core_ rules, but also some from these plugins automatically:
68
+
69
+ - [@babel/eslint-plugin]
70
+ - [@stylistic/eslint-plugin]
71
+ - [@typescript-eslint/eslint-plugin]
72
+ - [eslint-plugin-babel]
73
+ - [eslint-plugin-flowtype]
74
+ - [eslint-plugin-react]
75
+ - [eslint-plugin-standard]
76
+ - [eslint-plugin-unicorn]
77
+ - [eslint-plugin-vue]
78
+
79
+ > ℹ️ Note: You might find guides on the Internet saying you should also extend stuff like `"prettier/react"`. Since version 8.0.0 of eslint-config-prettier, all you need to extend is `"prettier"`! That includes all plugins.
80
+
81
+ #### eslint.config.js (flat config) plugin caveat
82
+
83
+ With flat config, _you_ get to decide the plugin name! For example:
84
+
85
+ ```js
86
+ import typescriptEslint from "@typescript-eslint/eslint-plugin";
87
+ import eslintConfigPrettier from "eslint-config-prettier/flat";
88
+
89
+ export default [
90
+ {
91
+ plugins: {
92
+ // You’d typically use one of the following two:
93
+ // typescriptEslint: typescriptEslint,
94
+ // typescriptEslint,
95
+ // But in this example we give it another name.
96
+ // It might be tempting to use something shorter like “ts”:
97
+ ts: typescriptEslint, // 🚨 Don’t do this!
98
+ },
99
+ rules: {
100
+ // With eslintrc, this is _always_ called:
101
+ // @typescript-eslint/indent
102
+ // But in eslint.config.js (flat config), the name chosen above in `plugins` is used.
103
+ "ts/indent": "error", // 🚨 Don’t do this!
104
+ },
105
+ },
106
+ eslintConfigPrettier,
107
+ ];
108
+ ```
109
+
110
+ You might expect eslint-config-prettier to turn off `ts/indent`, but it won’t! Because eslint-config-prettier only turns off `@typescript-eslint/indent`. It cannot know what you chose to call the plugin. Same thing for the CLI helper tool.
111
+
112
+ Simply stick to the official plugin names and you’ll be all good.
113
+
114
+ If you encounter a shared _config_ that uses a non-standard plugin name, please ask them to use the standard name instead.
115
+
116
+ ### Excluding deprecated rules
117
+
118
+ Some of the rules that eslint-config-prettier turns off may be deprecated, or even removed from ESLint. **This is perfectly fine,** but if you really need to omit the deprecated and removed rules, you can do so by setting the `ESLINT_CONFIG_PRETTIER_NO_DEPRECATED` environment variable to a non-empty value. For example:
119
+
120
+ ```
121
+ env ESLINT_CONFIG_PRETTIER_NO_DEPRECATED=true npx eslint-find-rules --deprecated index.js
122
+ ```
123
+
124
+ ## CLI helper tool
125
+
126
+ eslint-config-prettier also ships with a little CLI tool to help you check if your configuration contains any rules that are unnecessary or conflict with Prettier. Here’s how to run it:
127
+
128
+ ```
129
+ npx eslint-config-prettier path/to/main.js
130
+ ```
131
+
132
+ (Change `path/to/main.js` to a file that exists in your project.)
133
+
134
+ ### What and why
135
+
136
+ Now, let’s have a look at what it does and why you might want to use it.
137
+
138
+ 🚨 This eslintrc example has a **conflicting rule** `"indent"` enabled:
139
+
140
+ <!-- prettier-ignore -->
141
+ ```json
142
+ {
143
+ "extends": [
144
+ "some-other-config-you-use",
145
+ "prettier"
146
+ ],
147
+ "rules": {
148
+ "indent": "error"
149
+ }
150
+ }
151
+ ```
152
+
153
+ For eslintrc, while the `"prettier"` config can disable problematic rules in `"some-other-config-you-use"`, it cannot touch `"rules"`! (That’s how ESLint works – it lets you override configs you extend.) The CLI helper tool reports that `"indent"` conflicts with Prettier, so you can remove it. (Which is nice – simplifying your config!)
154
+
155
+ 🚨 This eslint.config.js (flat config) example also has a **conflicting rule** `"indent"` enabled:
156
+
157
+ ```js
158
+ import someConfig from "some-other-config-you-use";
159
+ import eslintConfigPrettier from "eslint-config-prettier/flat";
160
+
161
+ export default [
162
+ someConfig,
163
+ eslintConfigPrettier,
164
+ {
165
+ rules: {
166
+ indent: "error",
167
+ },
168
+ },
169
+ ];
170
+ ```
171
+
172
+ With the new ESLint “flat config” format, you can control what things override what yourself. One way of solving the above conflict is to reorder the config objects so that eslint-config-prettier is last:
173
+
174
+ ```js
175
+ import someConfig from "some-other-config-you-use";
176
+ import eslintConfigPrettier from "eslint-config-prettier/flat";
177
+
178
+ export default [
179
+ someConfig,
180
+ {
181
+ rules: {
182
+ indent: "error",
183
+ },
184
+ },
185
+ eslintConfigPrettier, // eslint-config-prettier last
186
+ ];
187
+ ```
188
+
189
+ However, looking at the above config might feel confusing. It looks like we enable the `indent` rule, but in reality it’s disabled thanks to the `eslintConfigPrettier` line below it. Instead you might want to actually have your own rules _after_ eslint-config-prettier and run the CLI helper tool to find out about problems, so you can remove conflicting rules from the config file altogether (simplifying your config).
190
+
191
+ ### Checking multiple files
192
+
193
+ In theory you need to run the tool for every single file in your project to be 100% sure that there are no conflicting rules, because ESLint supports having different rules for different files. Usually you’ll have about the same rules for all files, so it is good enough to run the command on one file. But if you use [multiple configuration files] or [overrides], you can provide several files to check:
194
+
195
+ ```
196
+ npx eslint-config-prettier index.js test/index.js legacy/main.js
197
+ ```
198
+
199
+ ### Exit codes
200
+
201
+ - 0: No problems found.
202
+ - 1: Unexpected error.
203
+ - 2: Conflicting rules found.
204
+
205
+ ### ESLINT_USE_FLAT_CONFIG environment variable
206
+
207
+ Just like ESLint itself, you can control the eslint-config-prettier CLI helper tool using the `ESLINT_USE_FLAT_CONFIG` environment variable:
208
+
209
+ - `ESLINT_USE_FLAT_CONFIG=true`: Only use eslint.config.js (flat config).
210
+ - `ESLINT_USE_FLAT_CONFIG=false`: Only use eslintrc files.
211
+ - Unset or any other value: First try eslint.config.js, then eslintrc.
212
+
213
+ > **Warning**
214
+ > For eslint.config.js (flat config), the CLI helper tool imports `eslint/use-at-your-own-risk` which may break at any time.
215
+
216
+ ### Legacy
217
+
218
+ eslint-config-prettier versions before 7.0.0 had a slightly different CLI tool that was run in a different way. For example:
219
+
220
+ ```
221
+ npx eslint --print-config index.js | npx eslint-config-prettier-check
222
+ ```
223
+
224
+ If you find something like that in a tutorial, this is what the command looks like in 7.0.0 or later:
225
+
226
+ ```
227
+ npx eslint-config-prettier index.js
228
+ ```
229
+
230
+ ## Special rules
231
+
232
+ There a few rules that eslint-config-prettier disables that actually can be enabled in some cases.
233
+
234
+ - Some require certain options. The CLI helper tool validates this.
235
+ - Some require special attention when writing code. The CLI helper tool warns you if any of those rules are enabled, but can’t tell if anything is problematic.
236
+ - Some can cause problems if using [eslint-plugin-prettier] and `--fix`.
237
+
238
+ For maximum ease of use, the special rules are disabled by default (provided that you include all needed things in `"extends"`). If you want them, you need to explicitly specify them in your ESLint config.
239
+
240
+ ### [arrow-body-style] and [prefer-arrow-callback]
241
+
242
+ **These rules might cause problems if using [eslint-plugin-prettier] and `--fix`.**
243
+
244
+ See the [`arrow-body-style` and `prefer-arrow-callback` issue][eslint-plugin-prettier-autofix-issue] for details.
245
+
246
+ There are a couple of ways to turn these rules off:
247
+
248
+ - Put `"plugin:prettier/recommended"` in your `"extends"`. That’s [eslint-<strong>plugin</strong>-prettier’s recommended config][eslint-plugin-prettier-recommended].
249
+ - Put `"prettier/prettier"` in your `"extends"`. (Yes, there’s both a _rule_ called `"prettier/prettier"` and a _config_ called `"prettier/prettier"`.)
250
+ - Remove them from your config or turn them off manually.
251
+
252
+ It doesn’t matter which approach you use. `"plugin:prettier/recommended"` is probably the easiest.
253
+
254
+ Note: The CLI tool only reports these as problematic if the `"prettier/prettier"` _rule_ is enabled for the same file.
255
+
256
+ These rules are safe to use if you don’t use [eslint-plugin-prettier]. In other words, if you run `eslint --fix` and `prettier --write` as separate steps.
257
+
258
+ ### [curly]
259
+
260
+ **This rule requires certain options.**
261
+
262
+ If a block (for example after `if`, `else`, `for` or `while`) contains only one statement, JavaScript allows omitting the curly braces around that statement. This rule enforces if or when those optional curly braces should be omitted.
263
+
264
+ If you use the `"multi-line"` or `"multi-or-nest"` option, the rule can conflict with Prettier.
265
+
266
+ For example, the `"multi-line"` option allows this line:
267
+
268
+ <!-- prettier-ignore -->
269
+ ```js
270
+ if (cart.items && cart.items[0] && cart.items[0].quantity === 0) updateCart(cart);
271
+ ```
272
+
273
+ However, Prettier might consider the line too long and turn it into the following, which the `"multi-line"` option does _not_ allow:
274
+
275
+ <!-- prettier-ignore -->
276
+ ```js
277
+ if (cart.items && cart.items[0] && cart.items[0].quantity === 0)
278
+ updateCart(cart);
279
+ ```
280
+
281
+ If you like this rule, it can be used just fine with Prettier as long as you don’t use the `"multi-line"` or `"multi-or-nest"` option.
282
+
283
+ Example ESLint configuration:
284
+
285
+ <!-- prettier-ignore -->
286
+ ```json
287
+ {
288
+ "rules": {
289
+ "curly": ["error", "all"]
290
+ }
291
+ }
292
+ ```
293
+
294
+ ### [lines-around-comment] \(deprecated)
295
+
296
+ (The following applies to [@stylistic/lines-around-comment], [@stylistic/js/lines-around-comment], [@stylistic/ts/lines-around-comment], and [@typescript-eslint/lines-around-comment] as well.)
297
+
298
+ **This rule can be used with certain options.**
299
+
300
+ This rule requires empty lines before and/or after comments. Prettier preserves blank lines, with two exceptions:
301
+
302
+ - Several blank lines in a row are collapsed into a single blank line. This is fine.
303
+ - Blank lines at the beginning and end of blocks, objects and arrays are always removed. This may lead to conflicts.
304
+
305
+ By default, ESLint requires a blank line above the comment is this case:
306
+
307
+ <!-- prettier-ignore -->
308
+ ```js
309
+ if (result) {
310
+
311
+ /* comment */
312
+ return result;
313
+ }
314
+ ```
315
+
316
+ However, Prettier removes the blank line:
317
+
318
+ <!-- prettier-ignore -->
319
+ ```js
320
+ if (result) {
321
+ /* comment */
322
+ return result;
323
+ }
324
+ ```
325
+
326
+ If you like this rule, it can be used just fine with Prettier as long as you add some extra configuration to allow comments at the start and end of blocks, objects and arrays.
327
+
328
+ Example ESLint configuration:
329
+
330
+ <!-- prettier-ignore -->
331
+ ```json
332
+ {
333
+ "rules": {
334
+ "lines-around-comment": [
335
+ "error",
336
+ {
337
+ "beforeBlockComment": true,
338
+ "afterBlockComment": true,
339
+ "beforeLineComment": true,
340
+ "afterLineComment": true,
341
+ "allowBlockStart": true,
342
+ "allowBlockEnd": true,
343
+ "allowObjectStart": true,
344
+ "allowObjectEnd": true,
345
+ "allowArrayStart": true,
346
+ "allowArrayEnd": true
347
+ }
348
+ ]
349
+ }
350
+ }
351
+ ```
352
+
353
+ ### [max-len] \(deprecated)
354
+
355
+ (The following applies to [@stylistic/max-len], [@stylistic/js/max-len], and [vue/max-len] as well.)
356
+
357
+ **This rule requires special attention when writing code.**
358
+
359
+ Usually, Prettier takes care of following a maximum line length automatically. However, there are cases where Prettier can’t do anything, such as for long strings, regular expressions and comments. Those need to be split up by a human.
360
+
361
+ If you’d like to enforce an even stricter maximum line length policy than Prettier can provide automatically, you can enable this rule. Just remember to keep `max-len`’s options and Prettier’s `printWidth` option in sync.
362
+
363
+ Keep in mind that you might have to refactor code slightly if Prettier formats lines in a way that the `max-len` rule does not approve of.
364
+
365
+ Example ESLint configuration:
366
+
367
+ <!-- prettier-ignore -->
368
+ ```json
369
+ {
370
+ "rules": {
371
+ "max-len": ["error", {"code": 80, "ignoreUrls": true}]
372
+ }
373
+ }
374
+ ```
375
+
376
+ ### [no-confusing-arrow] \(deprecated)
377
+
378
+ (The following applies to [@stylistic/no-confusing-arrow] and [@stylistic/js/no-confusing-arrow] as well.)
379
+
380
+ **This rule requires certain options.**
381
+
382
+ For example, the rule could warn about this line:
383
+
384
+ <!-- prettier-ignore -->
385
+ ```js
386
+ var x = a => 1 ? 2 : 3;
387
+ ```
388
+
389
+ With `{allowParens: true}` (the default since ESLint 6.0.0), adding parentheses is considered a valid way to avoid the arrow confusion:
390
+
391
+ <!-- prettier-ignore -->
392
+ ```js
393
+ var x = a => (1 ? 2 : 3);
394
+ ```
395
+
396
+ While Prettier keeps those parentheses, it removes them if the line is long enough to introduce a line break:
397
+
398
+ <!-- prettier-ignore -->
399
+ ```js
400
+ EnterpriseCalculator.prototype.calculateImportantNumbers = inputNumber =>
401
+ 1 ? 2 : 3;
402
+ ```
403
+
404
+ With `{allowParens: false}`, ESLint instead suggests switching to an explicit return:
405
+
406
+ <!-- prettier-ignore -->
407
+ ```js
408
+ var x = a => { return 1 ? 2 : 3; };
409
+ ```
410
+
411
+ That causes no problems with Prettier.
412
+
413
+ If you like this rule, it can be used just fine with Prettier as long as the `allowParens` option is off.
414
+
415
+ Example ESLint configuration:
416
+
417
+ <!-- prettier-ignore -->
418
+ ```json
419
+ {
420
+ "rules": {
421
+ "no-confusing-arrow": ["error", { "allowParens": false }]
422
+ }
423
+ }
424
+ ```
425
+
426
+ (Note: The CLI helper tool considers `{allowParens: true}` to be the default, which is the case since ESLint 6.0.0. The tool will produce a warning if you use the default even if you use an older version of ESLint. It doesn’t hurt to explicitly set `{allowParens: false}` even though it is technically redundant. This way you are prepared for a future ESLint upgrade and the CLI tool can be kept simple.)
427
+
428
+ ### [no-mixed-operators] \(deprecated)
429
+
430
+ (The following applies to [@stylistic/no-mixed-operators] and [@stylistic/js/no-mixed-operators] as well.)
431
+
432
+ **This rule requires special attention when writing code.**
433
+
434
+ This rule forbids mixing certain operators, such as `&&` and `||`.
435
+
436
+ For example, the rule could warn about this line:
437
+
438
+ <!-- prettier-ignore -->
439
+ ```js
440
+ var foo = a + b * c;
441
+ ```
442
+
443
+ The rule suggests adding parentheses, like this:
444
+
445
+ <!-- prettier-ignore -->
446
+ ```js
447
+ var foo = a + (b * c);
448
+ ```
449
+
450
+ However, Prettier removes many “unnecessary” parentheses, turning it back to:
451
+
452
+ <!-- prettier-ignore -->
453
+ ```js
454
+ var foo = a + b * c;
455
+ ```
456
+
457
+ If you want to use this rule with Prettier, you need to split the expression into another variable:
458
+
459
+ <!-- prettier-ignore -->
460
+ ```js
461
+ var bar = b * c;
462
+ var foo = a + bar;
463
+ ```
464
+
465
+ Keep in mind that Prettier prints _some_ “unnecessary” parentheses, though:
466
+
467
+ <!-- prettier-ignore -->
468
+ ```js
469
+ var foo = (a && b) || c;
470
+ ```
471
+
472
+ Example ESLint configuration:
473
+
474
+ <!-- prettier-ignore -->
475
+ ```json
476
+ {
477
+ "rules": {
478
+ "no-mixed-operators": "error"
479
+ }
480
+ }
481
+ ```
482
+
483
+ ### [no-tabs] \(deprecated)
484
+
485
+ (The following applies to [@stylistic/no-tabs] and [@stylistic/js/no-tabs] as well.)
486
+
487
+ **This rule requires certain options.**
488
+
489
+ This rule disallows the use of tab characters. By default the rule forbids _all_ tab characters. That can be used just fine with Prettier as long as you don’t configure Prettier to indent using tabs.
490
+
491
+ Luckily, it’s possible to configure the rule so that it works regardless of whether Prettier uses spaces or tabs: Set `allowIndentationTabs` to `true`. This way Prettier takes care of your indentation, while the `no-tabs` takes care of potential tab characters anywhere else in your code.
492
+
493
+ Example ESLint configuration:
494
+
495
+ <!-- prettier-ignore -->
496
+ ```json
497
+ {
498
+ "rules": {
499
+ "no-tabs": ["error", {"allowIndentationTabs": true}]
500
+ }
501
+ }
502
+ ```
503
+
504
+ ### [no-unexpected-multiline]
505
+
506
+ **This rule requires special attention when writing code.**
507
+
508
+ This rule disallows confusing multiline expressions where a newline looks like it is ending a statement, but is not.
509
+
510
+ For example, the rule could warn about this:
511
+
512
+ <!-- prettier-ignore -->
513
+ ```js
514
+ var hello = "world"
515
+ [1, 2, 3].forEach(addNumber)
516
+ ```
517
+
518
+ Prettier usually formats this in a way that makes it obvious that a semicolon was missing:
519
+
520
+ <!-- prettier-ignore -->
521
+ ```js
522
+ var hello = "world"[(1, 2, 3)].forEach(addNumber);
523
+ ```
524
+
525
+ However, there are cases where Prettier breaks things into several lines such that the `no-unexpected-multiline` conflicts.
526
+
527
+ <!-- prettier-ignore -->
528
+ ```js
529
+ const value = text.trim().split("\n")[position].toLowerCase();
530
+ ```
531
+
532
+ Prettier breaks it up into several lines, though, causing a conflict:
533
+
534
+ <!-- prettier-ignore -->
535
+ ```js
536
+ const value = text
537
+ .trim()
538
+ .split("\n")
539
+ [position].toLowerCase();
540
+ ```
541
+
542
+ If you like this rule, it can usually be used with Prettier without problems, but occasionally you might need to either temporarily disable the rule or refactor your code.
543
+
544
+ <!-- prettier-ignore -->
545
+ ```js
546
+ const value = text
547
+ .trim()
548
+ .split("\n")
549
+ // eslint-disable-next-line no-unexpected-multiline
550
+ [position].toLowerCase();
551
+
552
+ // Or:
553
+
554
+ const lines = text.trim().split("\n");
555
+ const value = lines[position].toLowerCase();
556
+ ```
557
+
558
+ **Note:** If you _do_ enable this rule, you have to run ESLint and Prettier as two separate steps (and ESLint first) in order to get any value out of it. Otherwise Prettier might reformat your code in such a way that ESLint never gets a chance to report anything (as seen in the first example).
559
+
560
+ Example configuration:
561
+
562
+ <!-- prettier-ignore -->
563
+ ```json
564
+ {
565
+ "rules": {
566
+ "no-unexpected-multiline": "error"
567
+ }
568
+ }
569
+ ```
570
+
571
+ ### [quotes] \(deprecated)
572
+
573
+ (The following applies to [babel/quotes], [@stylistic/quotes], [@stylistic/js/quotes], [@stylistic/ts/quotes], and [@typescript-eslint/quotes] as well.)
574
+
575
+ **This rule requires certain options and certain Prettier options.**
576
+
577
+ Usually, you don’t need this rule at all. But there are two cases where it could be useful:
578
+
579
+ - To enforce the use of backticks rather than single or double quotes for strings.
580
+ - To forbid backticks where regular strings could have been used.
581
+
582
+ #### Enforce backticks
583
+
584
+ If you’d like all strings to use backticks (never quotes), enable the `"backtick"` option.
585
+
586
+ Example ESLint configuration:
587
+
588
+ <!-- prettier-ignore -->
589
+ ```json
590
+ {
591
+ "rules": {
592
+ "quotes": ["error", "backtick"]
593
+ }
594
+ }
595
+ ```
596
+
597
+ #### Forbid unnecessary backticks
598
+
599
+ In the following example, the first array item could have been written with quotes instead of backticks.
600
+
601
+ <!-- prettier-ignore -->
602
+ ```js
603
+ const strings = [
604
+ `could have been a regular string`,
605
+ `
606
+ multiple
607
+ lines
608
+ `,
609
+ `uses ${interpolation}`,
610
+ String.raw`\tagged/`,
611
+ ];
612
+ ```
613
+
614
+ If you’d like ESLint to enforce `` `could have been a regular string` `` being written as either `"could have been a regular string"` or `'could have been a regular string'`, you need to use some specific configuration. The `quotes` rule has two options, a string option and an object option.
615
+
616
+ - The first (string) option needs to be set to `"single"` or `"double"` and be kept in sync with Prettier’s [singleQuote] option.
617
+ - The second (object) option needs the following properties:
618
+ - `"avoidEscape": true` to follow Prettier’s [string formatting rules].
619
+ - `"allowTemplateLiterals": false` to disallow unnecessary backticks.
620
+
621
+ ##### Example double quote configuration
622
+
623
+ ESLint:
624
+
625
+ <!-- prettier-ignore -->
626
+ ```json
627
+ {
628
+ "rules": {
629
+ "quotes": [
630
+ "error",
631
+ "double",
632
+ { "avoidEscape": true, "allowTemplateLiterals": false }
633
+ ]
634
+ }
635
+ }
636
+ ```
637
+
638
+ Prettier (this is the default, so adding this is not required):
639
+
640
+ <!-- prettier-ignore -->
641
+ ```json
642
+ {
643
+ "singleQuote": false
644
+ }
645
+ ```
646
+
647
+ ##### Example single quote configuration
648
+
649
+ ESLint:
650
+
651
+ <!-- prettier-ignore -->
652
+ ```json
653
+ {
654
+ "rules": {
655
+ "quotes": [
656
+ "error",
657
+ "single",
658
+ { "avoidEscape": true, "allowTemplateLiterals": false }
659
+ ]
660
+ }
661
+ }
662
+ ```
663
+
664
+ Prettier:
665
+
666
+ <!-- prettier-ignore -->
667
+ ```json
668
+ {
669
+ "singleQuote": true
670
+ }
671
+ ```
672
+
673
+ ### [unicorn/template-indent]
674
+
675
+ **This rule can be used with certain options.**
676
+
677
+ This rule will automatically fix the indentation of multiline string templates, to keep them in alignment with the code they are found in. A configurable whitelist is used to ensure no whitespace-sensitive strings are edited.
678
+
679
+ Prettier deals with:
680
+
681
+ - HTML
682
+ - CSS
683
+ - GraphQL
684
+ - markdown
685
+
686
+ Using various tags, functions and comments.
687
+
688
+ `unicorn/template-indent` by default formats some of the same tagged templates, which can cause conflicts. For example, the rule and Prettier disagree about indentation in ternaries:
689
+
690
+ ```js
691
+ condition
692
+ ? null
693
+ : html`
694
+ <p>
695
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam in dui
696
+ mauris.
697
+ </p>
698
+ `;
699
+ ```
700
+
701
+ If you like this rule, it can be used just fine with Prettier as long as you configure the rule to not deal with the same templates as Prettier.
702
+
703
+ Example ESLint configuration:
704
+
705
+ <!-- prettier-ignore -->
706
+ ```json
707
+ {
708
+ "rules": {
709
+ "unicorn/template-indent": [
710
+ "error",
711
+ {
712
+ "tags": [
713
+ "outdent",
714
+ "dedent",
715
+ "sql",
716
+ "styled"
717
+ ],
718
+ "functions": [
719
+ "dedent",
720
+ "stripIndent"
721
+ ],
722
+ "selectors": [],
723
+ "comments": [
724
+ "indent"
725
+ ]
726
+ }
727
+ ]
728
+ }
729
+ }
730
+ ```
731
+
732
+ Note: If you use `"selectors"`, the CLI helper tool cannot detect if your selectors might cause conflicts.
733
+
734
+ ### [vue/html-self-closing]
735
+
736
+ **This rule requires certain options.**
737
+
738
+ This rule enforces whether elements should be self-closing or not.
739
+
740
+ Prettier generally preserves the way you wrote your elements:
741
+
742
+ <!-- prettier-ignore -->
743
+ ```vue
744
+ <div />
745
+ <div></div>
746
+ <MyComponent />
747
+ <MyComponent></MyComponent>
748
+ <svg><path d="" /></svg>
749
+ <svg><path d=""></path></svg>
750
+ ```
751
+
752
+ But for known _void_ HTML elements, Prettier always uses the self-closing style. For example, `<img>` is turned into `<img />`.
753
+
754
+ If you like this rule, it can be used just fine with Prettier as long as you set `html.void` to `"any"`.
755
+
756
+ Example ESLint configuration:
757
+
758
+ <!-- prettier-ignore -->
759
+ ```json
760
+ {
761
+ "rules": {
762
+ "vue/html-self-closing": [
763
+ "error",
764
+ {
765
+ "html": {
766
+ "void": "any"
767
+ }
768
+ }
769
+ ]
770
+ }
771
+ }
772
+ ```
773
+
774
+ ## Other rules worth mentioning
775
+
776
+ These rules don’t conflict with Prettier, but have some gotchas when used with Prettier.
777
+
778
+ ### [no-sequences]
779
+
780
+ This rule forbids using JavaScript’s confusing comma operator (sequence expressions). This piece of code is not doing what it looks like:
781
+
782
+ <!-- prettier-ignore -->
783
+ ```js
784
+ matrix[4, 7];
785
+ ```
786
+
787
+ Prettier adds parentheses to the above to make it clear that a sequence expression is used:
788
+
789
+ <!-- prettier-ignore -->
790
+ ```js
791
+ matrix[(4, 7)];
792
+ ```
793
+
794
+ However, the `no-sequences` rule allows comma operators if the expression sequence is explicitly wrapped in parentheses. Since Prettier automatically wraps them in parentheses, you might never see any warnings from ESLint about comma operators.
795
+
796
+ Ending up with an accidental sequence expression can easily happen while refactoring. If you want ESLint to catch such mistakes, it is recommended to forbid sequence expressions entirely using [no-restricted-syntax] \([as mentioned in the `no-sequences` documentation][no-sequences-full]):
797
+
798
+ <!-- prettier-ignore -->
799
+ ```json
800
+ {
801
+ "rules": {
802
+ "no-restricted-syntax": ["error", "SequenceExpression"]
803
+ }
804
+ }
805
+ ```
806
+
807
+ If you still need to use the comma operator for some edge case, you can place an `// eslint-disable-next-line no-restricted-syntax` comment on the line above the expression. `no-sequences` can safely be disabled if you use the `no-restricted-syntax` approach.
808
+
809
+ You can also supply a custom message if you want:
810
+
811
+ <!-- prettier-ignore -->
812
+ ```json
813
+ {
814
+ "rules": {
815
+ "no-restricted-syntax": [
816
+ "error",
817
+ {
818
+ "selector": "SequenceExpression",
819
+ "message": "The comma operator is confusing and a common mistake. Don’t use it!"
820
+ }
821
+ ]
822
+ }
823
+ }
824
+ ```
825
+
826
+ ## Contributing
827
+
828
+ See [package.json] for the exact versions of ESLint, Prettier and ESLint plugins that eslint-config-prettier has been tested with.
829
+
830
+ Have new rules been added since those versions? Have we missed any rules? Is there a plugin you would like to see exclusions for? Open an issue or a pull request!
831
+
832
+ If you’d like to add support for eslint-plugin-foobar, this is how you’d go about it:
833
+
834
+ First, add rules to `index.js`:
835
+
836
+ <!-- prettier-ignore -->
837
+ ```js
838
+ "foobar/some-rule": "off"
839
+ ```
840
+
841
+ Then, create `test-lint/foobar.js`:
842
+
843
+ <!-- prettier-ignore -->
844
+ ```js
845
+ /* eslint-disable quotes */
846
+ "use strict";
847
+
848
+ // Prettier does not want spaces before the parentheses, but
849
+ // `plugin:foobar/recommended` wants one.
850
+ console.log();
851
+ ```
852
+
853
+ `test-lint/foobar.js` must fail when used with eslint-plugin-foobar and eslint-plugin-prettier at the same time – until eslint-config-prettier is added to the ESLint config. The file should be formatted according to Prettier, and that formatting should disagree with the plugin.
854
+
855
+ Finally, you need to mention the plugin in several places:
856
+
857
+ - Add eslint-plugin-foobar to the "devDependencies" field in `package.json`.
858
+ - Make sure that at least one rule from eslint-plugin-foobar gets used in `.eslintrc.base.js` and `eslint.base.config.js`.
859
+ - Add it to the lists of supported plugins in this `README.md`.
860
+
861
+ When you’re done, run `npm test` to verify that you got it all right. It runs several other npm scripts:
862
+
863
+ - `"test:prettier"` checks that Prettier has been run on all files.
864
+ - `"test:eslint"` makes sure that the files in `test-lint/` pass ESLint when the exclusions from eslint-config-prettier are used. It also lints the code of eslint-config-prettier itself.
865
+ - `"test:lint-verify-fail"` is run by a test in `test/lint-verify-fail.test.js`.
866
+ - `"test:lint-rules"` is run by a test in `test/rules.test.js`.
867
+ - `"test:jest"` runs unit tests that check a number of things:
868
+ - That eslint-plugin-foobar is mentioned in all the places shown above.
869
+ - That no unknown rules are turned off. This helps catching typos, for example.
870
+ - That the CLI works.
871
+ - `"test:cli-sanity"` and `"test:cli-sanity-warning"` are sanity checks for the CLI.
872
+
873
+ ## License
874
+
875
+ [MIT](LICENSE).
876
+
877
+ [@babel/eslint-plugin]: https://github.com/babel/babel/tree/main/eslint/babel-eslint-plugin
878
+ [@stylistic/eslint-plugin]: https://github.com/eslint-stylistic/eslint-stylistic
879
+ [@stylistic/lines-around-comment]: https://eslint.style/rules/default/lines-around-comment
880
+ [@stylistic/js/lines-around-comment]: https://eslint.style/rules/js/lines-around-comment
881
+ [@stylistic/ts/lines-around-comment]: https://eslint.style/rules/ts/lines-around-comment
882
+ [@stylistic/max-len]: https://eslint.style/rules/default/max-len
883
+ [@stylistic/js/max-len]: https://eslint.style/rules/js/max-len
884
+ [@stylistic/no-confusing-arrow]: https://eslint.style/rules/default/no-confusing-arrow
885
+ [@stylistic/js/no-confusing-arrow]: https://eslint.style/rules/js/no-confusing-arrow
886
+ [@stylistic/no-mixed-operators]: https://eslint.style/rules/default/no-mixed-operators
887
+ [@stylistic/js/no-mixed-operators]: https://eslint.style/rules/js/no-mixed-operators
888
+ [@stylistic/no-tabs]: https://eslint.style/rules/default/no-tabs
889
+ [@stylistic/js/no-tabs]: https://eslint.style/rules/js/no-tabs
890
+ [@stylistic/quotes]: https://eslint.style/rules/default/quotes
891
+ [@stylistic/js/quotes]: https://eslint.style/rules/js/quotes
892
+ [@stylistic/ts/quotes]: https://eslint.style/rules/ts/quotes
893
+ [@typescript-eslint/eslint-plugin]: https://github.com/typescript-eslint/typescript-eslint
894
+ [@typescript-eslint/lines-around-comment]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/lines-around-comment.md
895
+ [@typescript-eslint/quotes]: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/quotes.md
896
+ [arrow-body-style]: https://eslint.org/docs/rules/arrow-body-style
897
+ [babel/quotes]: https://github.com/babel/eslint-plugin-babel#rules
898
+ [curly]: https://eslint.org/docs/rules/curly
899
+ [eslint-plugin-babel]: https://github.com/babel/eslint-plugin-babel
900
+ [eslint-plugin-flowtype]: https://github.com/gajus/eslint-plugin-flowtype
901
+ [eslint-plugin-prettier-autofix-issue]: https://github.com/prettier/eslint-plugin-prettier#arrow-body-style-and-prefer-arrow-callback-issue
902
+ [eslint-plugin-prettier-recommended]: https://github.com/prettier/eslint-plugin-prettier#recommended-configuration
903
+ [eslint-plugin-prettier]: https://github.com/prettier/eslint-plugin-prettier
904
+ [eslint-plugin-react]: https://github.com/yannickcr/eslint-plugin-react
905
+ [eslint-plugin-standard]: https://github.com/xjamundx/eslint-plugin-standard
906
+ [eslint-plugin-unicorn]: https://github.com/sindresorhus/eslint-plugin-unicorn
907
+ [eslint-plugin-vue]: https://github.com/vuejs/eslint-plugin-vue
908
+ [eslint.config.js (flat config)]: https://eslint.org/docs/latest/use/configure/configuration-files-new
909
+ [eslintrc]: https://eslint.org/docs/latest/use/configure/configuration-files
910
+ [lines-around-comment]: https://eslint.org/docs/rules/lines-around-comment
911
+ [max-len]: https://eslint.org/docs/rules/max-len
912
+ [multiple configuration files]: https://eslint.org/docs/user-guide/configuring#configuration-cascading-and-hierarchy
913
+ [no-confusing-arrow]: https://eslint.org/docs/rules/no-confusing-arrow
914
+ [no-mixed-operators]: https://eslint.org/docs/rules/no-mixed-operators
915
+ [no-restricted-syntax]: https://eslint.org/docs/rules/no-restricted-syntax
916
+ [no-sequences-full]: https://eslint.org/docs/rules/no-sequences#when-not-to-use-it
917
+ [no-sequences]: https://eslint.org/docs/rules/no-sequences
918
+ [no-tabs]: https://eslint.org/docs/rules/no-tabs
919
+ [no-unexpected-multiline]: https://eslint.org/docs/rules/no-unexpected-multiline
920
+ [overrides]: https://eslint.org/docs/user-guide/configuring#configuration-based-on-glob-patterns
921
+ [package.json]: https://github.com/prettier/eslint-config-prettier/blob/main/package.json
922
+ [prefer-arrow-callback]: https://eslint.org/docs/rules/prefer-arrow-callback
923
+ [quotes]: https://eslint.org/docs/rules/quotes
924
+ [singlequote]: https://prettier.io/docs/en/options.html#quotes
925
+ [string formatting rules]: https://prettier.io/docs/en/rationale.html#strings
926
+ [unicorn/template-indent]: https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/template-indent.md
927
+ [vue/html-self-closing]: https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/html-self-closing.md
928
+ [vue/max-len]: https://github.com/vuejs/eslint-plugin-vue/blob/master/docs/rules/max-len.md
node_modules/eslint-config-prettier/bin/cli.js ADDED
@@ -0,0 +1,240 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env node
2
+
3
+ "use strict";
4
+
5
+ const validators = require("./validators");
6
+ const config = require("..");
7
+ const prettier = require("../prettier");
8
+
9
+ // Require locally installed eslint, for `npx eslint-config-prettier` support
10
+ // with no local eslint-config-prettier installation.
11
+ const localRequire = (request) =>
12
+ require(
13
+ require.resolve(request, {
14
+ paths: [process.cwd(), ...require.resolve.paths("eslint")],
15
+ })
16
+ );
17
+
18
+ let experimentalApi = {};
19
+ try {
20
+ experimentalApi = localRequire("eslint/use-at-your-own-risk");
21
+ } catch (_error) {}
22
+
23
+ const { ESLint, FlatESLint = experimentalApi.FlatESLint } =
24
+ localRequire("eslint");
25
+
26
+ const SPECIAL_RULES_URL =
27
+ "https://github.com/prettier/eslint-config-prettier#special-rules";
28
+
29
+ const PRETTIER_RULES_URL =
30
+ "https://github.com/prettier/eslint-config-prettier#arrow-body-style-and-prefer-arrow-callback";
31
+
32
+ if (module === require.main) {
33
+ const args = process.argv.slice(2);
34
+
35
+ if (args.length === 0) {
36
+ console.error(help());
37
+ process.exit(1);
38
+ }
39
+
40
+ const eslint = new ESLint();
41
+ const flatESLint = FlatESLint === undefined ? undefined : new FlatESLint();
42
+
43
+ Promise.all(
44
+ args.map((file) => {
45
+ switch (process.env.ESLINT_USE_FLAT_CONFIG) {
46
+ case "true": {
47
+ return flatESLint.calculateConfigForFile(file);
48
+ }
49
+ case "false": {
50
+ return eslint.calculateConfigForFile(file);
51
+ }
52
+ default: {
53
+ // This turns synchronous errors (such as `.calculateConfigForFile` not existing)
54
+ // and turns them into promise rejections.
55
+ return Promise.resolve()
56
+ .then(() => flatESLint.calculateConfigForFile(file))
57
+ .catch(() => eslint.calculateConfigForFile(file));
58
+ }
59
+ }
60
+ })
61
+ )
62
+ .then((configs) => {
63
+ const rules = configs.flatMap(
64
+ (
65
+ // Initializing config and rules for files that aren't included in the flat config,
66
+ // which is a very unlikely scenario, but should still be treated as a success
67
+ { rules = {} } = {},
68
+ index
69
+ ) => Object.entries(rules).map((entry) => [...entry, args[index]])
70
+ );
71
+ const result = processRules(rules);
72
+ if (result.stderr) {
73
+ console.error(result.stderr);
74
+ }
75
+ if (result.stdout) {
76
+ console.error(result.stdout);
77
+ }
78
+ process.exit(result.code);
79
+ })
80
+ .catch((error) => {
81
+ console.error(error.message);
82
+ process.exit(1);
83
+ });
84
+ }
85
+
86
+ function help() {
87
+ return `
88
+ Usage: npx eslint-config-prettier FILE...
89
+
90
+ Resolves an ESLint configuration for every given FILE and checks if they
91
+ contain rules that are unnecessary or conflict with Prettier. Example:
92
+
93
+ npx eslint-config-prettier index.js test/index.js other/file/to/check.js
94
+
95
+ Exit codes:
96
+
97
+ 0: No automatically detectable problems found.
98
+ 1: General error.
99
+ 2: Conflicting rules found.
100
+
101
+ For more information, see:
102
+ https://github.com/prettier/eslint-config-prettier#cli-helper-tool
103
+ `.trim();
104
+ }
105
+
106
+ function processRules(configRules) {
107
+ const regularRules = filterRules(config.rules, (_, value) => value === "off");
108
+ const optionsRules = filterRules(
109
+ config.rules,
110
+ (ruleName, value) => value === 0 && ruleName in validators
111
+ );
112
+ const specialRules = filterRules(
113
+ config.rules,
114
+ (ruleName, value) => value === 0 && !(ruleName in validators)
115
+ );
116
+
117
+ const enabledRules = configRules
118
+ .map(([ruleName, value, source]) => {
119
+ const arrayValue = Array.isArray(value) ? value : [value];
120
+ const [level, ...options] = arrayValue;
121
+ const isOff = level === "off" || level === 0;
122
+ return isOff ? null : { ruleName, options, source };
123
+ })
124
+ .filter(Boolean);
125
+
126
+ const flaggedRules = enabledRules.filter(
127
+ ({ ruleName }) => ruleName in config.rules
128
+ );
129
+
130
+ const regularFlaggedRuleNames = filterRuleNames(
131
+ flaggedRules,
132
+ ({ ruleName }) => ruleName in regularRules
133
+ );
134
+ const optionsFlaggedRuleNames = filterRuleNames(
135
+ flaggedRules,
136
+ ({ ruleName, ...rule }) =>
137
+ ruleName in optionsRules && !validators[ruleName](rule)
138
+ );
139
+ const specialFlaggedRuleNames = filterRuleNames(
140
+ flaggedRules,
141
+ ({ ruleName }) => ruleName in specialRules
142
+ );
143
+ const prettierFlaggedRuleNames = filterRuleNames(
144
+ enabledRules,
145
+ ({ ruleName, source }) =>
146
+ ruleName in prettier.rules &&
147
+ enabledRules.some(
148
+ (rule) =>
149
+ rule.ruleName === "prettier/prettier" && rule.source === source
150
+ )
151
+ );
152
+
153
+ const regularMessage = [
154
+ "The following rules are unnecessary or might conflict with Prettier:",
155
+ "",
156
+ printRuleNames(regularFlaggedRuleNames),
157
+ ].join("\n");
158
+
159
+ const optionsMessage = [
160
+ "The following rules are enabled with config that might conflict with Prettier. See:",
161
+ SPECIAL_RULES_URL,
162
+ "",
163
+ printRuleNames(optionsFlaggedRuleNames),
164
+ ].join("\n");
165
+
166
+ const specialMessage = [
167
+ "The following rules are enabled but cannot be automatically checked. See:",
168
+ SPECIAL_RULES_URL,
169
+ "",
170
+ printRuleNames(specialFlaggedRuleNames),
171
+ ].join("\n");
172
+
173
+ const prettierMessage = [
174
+ "The following rules can cause issues when using eslint-plugin-prettier at the same time.",
175
+ "Only enable them if you know what you are doing! See:",
176
+ PRETTIER_RULES_URL,
177
+ "",
178
+ printRuleNames(prettierFlaggedRuleNames),
179
+ ].join("\n");
180
+
181
+ if (
182
+ regularFlaggedRuleNames.length === 0 &&
183
+ optionsFlaggedRuleNames.length === 0
184
+ ) {
185
+ const message =
186
+ specialFlaggedRuleNames.length === 0 &&
187
+ prettierFlaggedRuleNames.length === 0
188
+ ? "No rules that are unnecessary or conflict with Prettier were found."
189
+ : [
190
+ specialFlaggedRuleNames.length === 0 ? null : specialMessage,
191
+ prettierFlaggedRuleNames.length === 0 ? null : prettierMessage,
192
+ "Other than that, no rules that are unnecessary or conflict with Prettier were found.",
193
+ ]
194
+ .filter(Boolean)
195
+ .join("\n\n");
196
+
197
+ return {
198
+ stdout: message,
199
+ code: 0,
200
+ };
201
+ }
202
+
203
+ const message = [
204
+ regularFlaggedRuleNames.length === 0 ? null : regularMessage,
205
+ optionsFlaggedRuleNames.length === 0 ? null : optionsMessage,
206
+ specialFlaggedRuleNames.length === 0 ? null : specialMessage,
207
+ prettierFlaggedRuleNames.length === 0 ? null : prettierMessage,
208
+ ]
209
+ .filter(Boolean)
210
+ .join("\n\n");
211
+
212
+ return {
213
+ stdout: message,
214
+ code: 2,
215
+ };
216
+ }
217
+
218
+ function filterRules(rules, fn) {
219
+ return Object.fromEntries(
220
+ Object.entries(rules)
221
+ .filter(([ruleName, value]) => fn(ruleName, value))
222
+ .map(([ruleName]) => [ruleName, true])
223
+ );
224
+ }
225
+
226
+ function filterRuleNames(rules, fn) {
227
+ return [
228
+ ...new Set(rules.filter((rule) => fn(rule)).map((rule) => rule.ruleName)),
229
+ ];
230
+ }
231
+
232
+ function printRuleNames(ruleNames) {
233
+ return ruleNames
234
+ .slice()
235
+ .sort()
236
+ .map((ruleName) => `- ${ruleName}`)
237
+ .join("\n");
238
+ }
239
+
240
+ exports.processRules = processRules;
node_modules/eslint-config-prettier/bin/validators.js ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+
3
+ // These validator functions answer the question “Is the config valid?” – return
4
+ // `false` if the options DO conflict with Prettier, and `true` if they don’t.
5
+
6
+ module.exports = {
7
+ "curly"({ options }) {
8
+ if (options.length === 0) {
9
+ return true;
10
+ }
11
+
12
+ const firstOption = options[0];
13
+ return firstOption !== "multi-line" && firstOption !== "multi-or-nest";
14
+ },
15
+
16
+ "lines-around-comment"({ options }) {
17
+ if (options.length === 0) {
18
+ return false;
19
+ }
20
+
21
+ const firstOption = options[0];
22
+ return Boolean(
23
+ firstOption &&
24
+ firstOption.allowBlockStart &&
25
+ firstOption.allowBlockEnd &&
26
+ firstOption.allowObjectStart &&
27
+ firstOption.allowObjectEnd &&
28
+ firstOption.allowArrayStart &&
29
+ firstOption.allowArrayEnd
30
+ );
31
+ },
32
+
33
+ "no-confusing-arrow"({ options }) {
34
+ if (options.length === 0) {
35
+ return false;
36
+ }
37
+
38
+ const firstOption = options[0];
39
+ return firstOption ? firstOption.allowParens === false : false;
40
+ },
41
+
42
+ "no-tabs"({ options }) {
43
+ if (options.length === 0) {
44
+ return false;
45
+ }
46
+
47
+ const firstOption = options[0];
48
+ return Boolean(firstOption && firstOption.allowIndentationTabs);
49
+ },
50
+
51
+ "unicorn/template-indent"({ options }) {
52
+ if (options.length === 0) {
53
+ return false;
54
+ }
55
+
56
+ const { comments = [], tags = [] } = options[0] || {};
57
+
58
+ return (
59
+ Array.isArray(comments) &&
60
+ Array.isArray(tags) &&
61
+ !(
62
+ comments.includes("GraphQL") ||
63
+ comments.includes("HTML") ||
64
+ tags.includes("css") ||
65
+ tags.includes("graphql") ||
66
+ tags.includes("gql") ||
67
+ tags.includes("html") ||
68
+ tags.includes("markdown") ||
69
+ tags.includes("md")
70
+ )
71
+ );
72
+ },
73
+
74
+ "vue/html-self-closing"({ options }) {
75
+ if (options.length === 0) {
76
+ return false;
77
+ }
78
+
79
+ const firstOption = options[0];
80
+ return Boolean(
81
+ firstOption && firstOption.html && firstOption.html.void === "any"
82
+ // Enable when Prettier supports SVG: https://github.com/prettier/prettier/issues/5322
83
+ // && firstOption.svg === "any"
84
+ );
85
+ },
86
+ };
node_modules/eslint-config-prettier/flat.d.ts ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ import eslintConfigPrettier from "./index.js";
2
+
3
+ declare const eslintConfigPrettierFlat: typeof eslintConfigPrettier & {
4
+ name: "config-prettier";
5
+ };
6
+
7
+ export = eslintConfigPrettierFlat;
node_modules/eslint-config-prettier/flat.js ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ "use strict";
2
+
3
+ const { rules } = require("./index.js");
4
+
5
+ exports.name = "config-prettier";
6
+ exports.rules = rules;
node_modules/eslint-config-prettier/index.d.ts ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ declare const eslintConfigPrettier: {
2
+ rules: Record<string, 0 | "off">;
3
+ };
4
+
5
+ export = eslintConfigPrettier;
node_modules/eslint-config-prettier/index.js ADDED
@@ -0,0 +1,395 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+
3
+ const includeDeprecated = !process.env.ESLINT_CONFIG_PRETTIER_NO_DEPRECATED;
4
+
5
+ const specialRule = 0;
6
+
7
+ exports.rules = {
8
+ // The following rules can be used in some cases. See the README for more
9
+ // information. These are marked with `0` instead of `"off"` so that a
10
+ // script can distinguish them. Note that there are a few more of these
11
+ // in the deprecated section below.
12
+ "curly": specialRule,
13
+ "no-unexpected-multiline": specialRule,
14
+ "@stylistic/lines-around-comment": specialRule,
15
+ "@stylistic/max-len": specialRule,
16
+ "@stylistic/no-confusing-arrow": specialRule,
17
+ "@stylistic/no-mixed-operators": specialRule,
18
+ "@stylistic/no-tabs": specialRule,
19
+ "@stylistic/quotes": specialRule,
20
+ "@stylistic/js/lines-around-comment": specialRule,
21
+ "@stylistic/js/max-len": specialRule,
22
+ "@stylistic/js/no-confusing-arrow": specialRule,
23
+ "@stylistic/js/no-mixed-operators": specialRule,
24
+ "@stylistic/js/no-tabs": specialRule,
25
+ "@stylistic/js/quotes": specialRule,
26
+ "@stylistic/ts/lines-around-comment": specialRule,
27
+ "@stylistic/ts/quotes": specialRule,
28
+ "@typescript-eslint/lines-around-comment": specialRule,
29
+ "@typescript-eslint/quotes": specialRule,
30
+ "babel/quotes": specialRule,
31
+ "unicorn/template-indent": specialRule,
32
+ "vue/html-self-closing": specialRule,
33
+ "vue/max-len": specialRule,
34
+
35
+ // The rest are rules that you never need to enable when using Prettier.
36
+ "@babel/object-curly-spacing": "off",
37
+ "@babel/semi": "off",
38
+ "@stylistic/array-bracket-newline": "off",
39
+ "@stylistic/array-bracket-spacing": "off",
40
+ "@stylistic/array-element-newline": "off",
41
+ "@stylistic/arrow-parens": "off",
42
+ "@stylistic/arrow-spacing": "off",
43
+ "@stylistic/block-spacing": "off",
44
+ "@stylistic/brace-style": "off",
45
+ "@stylistic/comma-dangle": "off",
46
+ "@stylistic/comma-spacing": "off",
47
+ "@stylistic/comma-style": "off",
48
+ "@stylistic/computed-property-spacing": "off",
49
+ "@stylistic/dot-location": "off",
50
+ "@stylistic/eol-last": "off",
51
+ "@stylistic/func-call-spacing": "off",
52
+ "@stylistic/function-call-argument-newline": "off",
53
+ "@stylistic/function-call-spacing": "off",
54
+ "@stylistic/function-paren-newline": "off",
55
+ "@stylistic/generator-star-spacing": "off",
56
+ "@stylistic/implicit-arrow-linebreak": "off",
57
+ "@stylistic/indent": "off",
58
+ "@stylistic/jsx-quotes": "off",
59
+ "@stylistic/key-spacing": "off",
60
+ "@stylistic/keyword-spacing": "off",
61
+ "@stylistic/linebreak-style": "off",
62
+ "@stylistic/max-statements-per-line": "off",
63
+ "@stylistic/multiline-ternary": "off",
64
+ "@stylistic/new-parens": "off",
65
+ "@stylistic/newline-per-chained-call": "off",
66
+ "@stylistic/no-extra-parens": "off",
67
+ "@stylistic/no-extra-semi": "off",
68
+ "@stylistic/no-floating-decimal": "off",
69
+ "@stylistic/no-mixed-spaces-and-tabs": "off",
70
+ "@stylistic/no-multi-spaces": "off",
71
+ "@stylistic/no-multiple-empty-lines": "off",
72
+ "@stylistic/no-trailing-spaces": "off",
73
+ "@stylistic/no-whitespace-before-property": "off",
74
+ "@stylistic/nonblock-statement-body-position": "off",
75
+ "@stylistic/object-curly-newline": "off",
76
+ "@stylistic/object-curly-spacing": "off",
77
+ "@stylistic/object-property-newline": "off",
78
+ "@stylistic/one-var-declaration-per-line": "off",
79
+ "@stylistic/operator-linebreak": "off",
80
+ "@stylistic/padded-blocks": "off",
81
+ "@stylistic/quote-props": "off",
82
+ "@stylistic/rest-spread-spacing": "off",
83
+ "@stylistic/semi": "off",
84
+ "@stylistic/semi-spacing": "off",
85
+ "@stylistic/semi-style": "off",
86
+ "@stylistic/space-before-blocks": "off",
87
+ "@stylistic/space-before-function-paren": "off",
88
+ "@stylistic/space-in-parens": "off",
89
+ "@stylistic/space-infix-ops": "off",
90
+ "@stylistic/space-unary-ops": "off",
91
+ "@stylistic/switch-colon-spacing": "off",
92
+ "@stylistic/template-curly-spacing": "off",
93
+ "@stylistic/template-tag-spacing": "off",
94
+ "@stylistic/wrap-iife": "off",
95
+ "@stylistic/wrap-regex": "off",
96
+ "@stylistic/yield-star-spacing": "off",
97
+ "@stylistic/member-delimiter-style": "off",
98
+ "@stylistic/type-annotation-spacing": "off",
99
+ "@stylistic/jsx-child-element-spacing": "off",
100
+ "@stylistic/jsx-closing-bracket-location": "off",
101
+ "@stylistic/jsx-closing-tag-location": "off",
102
+ "@stylistic/jsx-curly-newline": "off",
103
+ "@stylistic/jsx-curly-spacing": "off",
104
+ "@stylistic/jsx-equals-spacing": "off",
105
+ "@stylistic/jsx-first-prop-new-line": "off",
106
+ "@stylistic/jsx-indent": "off",
107
+ "@stylistic/jsx-indent-props": "off",
108
+ "@stylistic/jsx-max-props-per-line": "off",
109
+ "@stylistic/jsx-newline": "off",
110
+ "@stylistic/jsx-one-expression-per-line": "off",
111
+ "@stylistic/jsx-props-no-multi-spaces": "off",
112
+ "@stylistic/jsx-tag-spacing": "off",
113
+ "@stylistic/jsx-wrap-multilines": "off",
114
+ "@stylistic/indent-binary-ops": "off",
115
+ "@stylistic/type-generic-spacing": "off",
116
+ "@stylistic/type-named-tuple-spacing": "off",
117
+ "@stylistic/js/array-bracket-newline": "off",
118
+ "@stylistic/js/array-bracket-spacing": "off",
119
+ "@stylistic/js/array-element-newline": "off",
120
+ "@stylistic/js/arrow-parens": "off",
121
+ "@stylistic/js/arrow-spacing": "off",
122
+ "@stylistic/js/block-spacing": "off",
123
+ "@stylistic/js/brace-style": "off",
124
+ "@stylistic/js/comma-dangle": "off",
125
+ "@stylistic/js/comma-spacing": "off",
126
+ "@stylistic/js/comma-style": "off",
127
+ "@stylistic/js/computed-property-spacing": "off",
128
+ "@stylistic/js/dot-location": "off",
129
+ "@stylistic/js/eol-last": "off",
130
+ "@stylistic/js/func-call-spacing": "off",
131
+ "@stylistic/js/function-call-argument-newline": "off",
132
+ "@stylistic/js/function-call-spacing": "off",
133
+ "@stylistic/js/function-paren-newline": "off",
134
+ "@stylistic/js/generator-star-spacing": "off",
135
+ "@stylistic/js/implicit-arrow-linebreak": "off",
136
+ "@stylistic/js/indent": "off",
137
+ "@stylistic/js/jsx-quotes": "off",
138
+ "@stylistic/js/key-spacing": "off",
139
+ "@stylistic/js/keyword-spacing": "off",
140
+ "@stylistic/js/linebreak-style": "off",
141
+ "@stylistic/js/max-statements-per-line": "off",
142
+ "@stylistic/js/multiline-ternary": "off",
143
+ "@stylistic/js/new-parens": "off",
144
+ "@stylistic/js/newline-per-chained-call": "off",
145
+ "@stylistic/js/no-extra-parens": "off",
146
+ "@stylistic/js/no-extra-semi": "off",
147
+ "@stylistic/js/no-floating-decimal": "off",
148
+ "@stylistic/js/no-mixed-spaces-and-tabs": "off",
149
+ "@stylistic/js/no-multi-spaces": "off",
150
+ "@stylistic/js/no-multiple-empty-lines": "off",
151
+ "@stylistic/js/no-trailing-spaces": "off",
152
+ "@stylistic/js/no-whitespace-before-property": "off",
153
+ "@stylistic/js/nonblock-statement-body-position": "off",
154
+ "@stylistic/js/object-curly-newline": "off",
155
+ "@stylistic/js/object-curly-spacing": "off",
156
+ "@stylistic/js/object-property-newline": "off",
157
+ "@stylistic/js/one-var-declaration-per-line": "off",
158
+ "@stylistic/js/operator-linebreak": "off",
159
+ "@stylistic/js/padded-blocks": "off",
160
+ "@stylistic/js/quote-props": "off",
161
+ "@stylistic/js/rest-spread-spacing": "off",
162
+ "@stylistic/js/semi": "off",
163
+ "@stylistic/js/semi-spacing": "off",
164
+ "@stylistic/js/semi-style": "off",
165
+ "@stylistic/js/space-before-blocks": "off",
166
+ "@stylistic/js/space-before-function-paren": "off",
167
+ "@stylistic/js/space-in-parens": "off",
168
+ "@stylistic/js/space-infix-ops": "off",
169
+ "@stylistic/js/space-unary-ops": "off",
170
+ "@stylistic/js/switch-colon-spacing": "off",
171
+ "@stylistic/js/template-curly-spacing": "off",
172
+ "@stylistic/js/template-tag-spacing": "off",
173
+ "@stylistic/js/wrap-iife": "off",
174
+ "@stylistic/js/wrap-regex": "off",
175
+ "@stylistic/js/yield-star-spacing": "off",
176
+ "@stylistic/ts/block-spacing": "off",
177
+ "@stylistic/ts/brace-style": "off",
178
+ "@stylistic/ts/comma-dangle": "off",
179
+ "@stylistic/ts/comma-spacing": "off",
180
+ "@stylistic/ts/func-call-spacing": "off",
181
+ "@stylistic/ts/function-call-spacing": "off",
182
+ "@stylistic/ts/indent": "off",
183
+ "@stylistic/ts/key-spacing": "off",
184
+ "@stylistic/ts/keyword-spacing": "off",
185
+ "@stylistic/ts/member-delimiter-style": "off",
186
+ "@stylistic/ts/no-extra-parens": "off",
187
+ "@stylistic/ts/no-extra-semi": "off",
188
+ "@stylistic/ts/object-curly-spacing": "off",
189
+ "@stylistic/ts/semi": "off",
190
+ "@stylistic/ts/space-before-blocks": "off",
191
+ "@stylistic/ts/space-before-function-paren": "off",
192
+ "@stylistic/ts/space-infix-ops": "off",
193
+ "@stylistic/ts/type-annotation-spacing": "off",
194
+ "@stylistic/jsx/jsx-child-element-spacing": "off",
195
+ "@stylistic/jsx/jsx-closing-bracket-location": "off",
196
+ "@stylistic/jsx/jsx-closing-tag-location": "off",
197
+ "@stylistic/jsx/jsx-curly-newline": "off",
198
+ "@stylistic/jsx/jsx-curly-spacing": "off",
199
+ "@stylistic/jsx/jsx-equals-spacing": "off",
200
+ "@stylistic/jsx/jsx-first-prop-new-line": "off",
201
+ "@stylistic/jsx/jsx-indent": "off",
202
+ "@stylistic/jsx/jsx-indent-props": "off",
203
+ "@stylistic/jsx/jsx-max-props-per-line": "off",
204
+ "@typescript-eslint/block-spacing": "off",
205
+ "@typescript-eslint/brace-style": "off",
206
+ "@typescript-eslint/comma-dangle": "off",
207
+ "@typescript-eslint/comma-spacing": "off",
208
+ "@typescript-eslint/func-call-spacing": "off",
209
+ "@typescript-eslint/indent": "off",
210
+ "@typescript-eslint/key-spacing": "off",
211
+ "@typescript-eslint/keyword-spacing": "off",
212
+ "@typescript-eslint/member-delimiter-style": "off",
213
+ "@typescript-eslint/no-extra-parens": "off",
214
+ "@typescript-eslint/no-extra-semi": "off",
215
+ "@typescript-eslint/object-curly-spacing": "off",
216
+ "@typescript-eslint/semi": "off",
217
+ "@typescript-eslint/space-before-blocks": "off",
218
+ "@typescript-eslint/space-before-function-paren": "off",
219
+ "@typescript-eslint/space-infix-ops": "off",
220
+ "@typescript-eslint/type-annotation-spacing": "off",
221
+ "babel/object-curly-spacing": "off",
222
+ "babel/semi": "off",
223
+ "flowtype/boolean-style": "off",
224
+ "flowtype/delimiter-dangle": "off",
225
+ "flowtype/generic-spacing": "off",
226
+ "flowtype/object-type-curly-spacing": "off",
227
+ "flowtype/object-type-delimiter": "off",
228
+ "flowtype/quotes": "off",
229
+ "flowtype/semi": "off",
230
+ "flowtype/space-after-type-colon": "off",
231
+ "flowtype/space-before-generic-bracket": "off",
232
+ "flowtype/space-before-type-colon": "off",
233
+ "flowtype/union-intersection-spacing": "off",
234
+ "react/jsx-child-element-spacing": "off",
235
+ "react/jsx-closing-bracket-location": "off",
236
+ "react/jsx-closing-tag-location": "off",
237
+ "react/jsx-curly-newline": "off",
238
+ "react/jsx-curly-spacing": "off",
239
+ "react/jsx-equals-spacing": "off",
240
+ "react/jsx-first-prop-new-line": "off",
241
+ "react/jsx-indent": "off",
242
+ "react/jsx-indent-props": "off",
243
+ "react/jsx-max-props-per-line": "off",
244
+ "react/jsx-newline": "off",
245
+ "react/jsx-one-expression-per-line": "off",
246
+ "react/jsx-props-no-multi-spaces": "off",
247
+ "react/jsx-tag-spacing": "off",
248
+ "react/jsx-wrap-multilines": "off",
249
+ "standard/array-bracket-even-spacing": "off",
250
+ "standard/computed-property-even-spacing": "off",
251
+ "standard/object-curly-even-spacing": "off",
252
+ "unicorn/empty-brace-spaces": "off",
253
+ "unicorn/no-nested-ternary": "off",
254
+ "unicorn/number-literal-case": "off",
255
+ "vue/array-bracket-newline": "off",
256
+ "vue/array-bracket-spacing": "off",
257
+ "vue/array-element-newline": "off",
258
+ "vue/arrow-spacing": "off",
259
+ "vue/block-spacing": "off",
260
+ "vue/block-tag-newline": "off",
261
+ "vue/brace-style": "off",
262
+ "vue/comma-dangle": "off",
263
+ "vue/comma-spacing": "off",
264
+ "vue/comma-style": "off",
265
+ "vue/dot-location": "off",
266
+ "vue/func-call-spacing": "off",
267
+ "vue/html-closing-bracket-newline": "off",
268
+ "vue/html-closing-bracket-spacing": "off",
269
+ "vue/html-end-tags": "off",
270
+ "vue/html-indent": "off",
271
+ "vue/html-quotes": "off",
272
+ "vue/key-spacing": "off",
273
+ "vue/keyword-spacing": "off",
274
+ "vue/max-attributes-per-line": "off",
275
+ "vue/multiline-html-element-content-newline": "off",
276
+ "vue/multiline-ternary": "off",
277
+ "vue/mustache-interpolation-spacing": "off",
278
+ "vue/no-extra-parens": "off",
279
+ "vue/no-multi-spaces": "off",
280
+ "vue/no-spaces-around-equal-signs-in-attribute": "off",
281
+ "vue/object-curly-newline": "off",
282
+ "vue/object-curly-spacing": "off",
283
+ "vue/object-property-newline": "off",
284
+ "vue/operator-linebreak": "off",
285
+ "vue/quote-props": "off",
286
+ "vue/script-indent": "off",
287
+ "vue/singleline-html-element-content-newline": "off",
288
+ "vue/space-in-parens": "off",
289
+ "vue/space-infix-ops": "off",
290
+ "vue/space-unary-ops": "off",
291
+ "vue/template-curly-spacing": "off",
292
+
293
+ ...(includeDeprecated && {
294
+ // Removed in version 0.10.0.
295
+ // https://eslint.org/docs/latest/rules/space-unary-word-ops
296
+ "space-unary-word-ops": "off",
297
+
298
+ // Removed in version 1.0.0.
299
+ // https://github.com/eslint/eslint/issues/1898
300
+ "generator-star": "off",
301
+ "no-comma-dangle": "off",
302
+ "no-reserved-keys": "off",
303
+ "no-space-before-semi": "off",
304
+ "no-wrap-func": "off",
305
+ "space-after-function-name": "off",
306
+ "space-before-function-parentheses": "off",
307
+ "space-in-brackets": "off",
308
+
309
+ // Removed in version 2.0.0.
310
+ // https://github.com/eslint/eslint/issues/5032
311
+ "no-arrow-condition": "off",
312
+ "space-after-keywords": "off",
313
+ "space-before-keywords": "off",
314
+ "space-return-throw-case": "off",
315
+
316
+ // Deprecated since version 3.3.0.
317
+ // https://eslint.org/docs/rules/no-spaced-func
318
+ "no-spaced-func": "off",
319
+
320
+ // Deprecated since version 4.0.0.
321
+ // https://github.com/eslint/eslint/pull/8286
322
+ "indent-legacy": "off",
323
+
324
+ // Deprecated since version 8.53.0.
325
+ // https://eslint.org/blog/2023/10/deprecating-formatting-rules/
326
+ "array-bracket-newline": "off",
327
+ "array-bracket-spacing": "off",
328
+ "array-element-newline": "off",
329
+ "arrow-parens": "off",
330
+ "arrow-spacing": "off",
331
+ "block-spacing": "off",
332
+ "brace-style": "off",
333
+ "comma-dangle": "off",
334
+ "comma-spacing": "off",
335
+ "comma-style": "off",
336
+ "computed-property-spacing": "off",
337
+ "dot-location": "off",
338
+ "eol-last": "off",
339
+ "func-call-spacing": "off",
340
+ "function-call-argument-newline": "off",
341
+ "function-paren-newline": "off",
342
+ "generator-star-spacing": "off",
343
+ "implicit-arrow-linebreak": "off",
344
+ "indent": "off",
345
+ "jsx-quotes": "off",
346
+ "key-spacing": "off",
347
+ "keyword-spacing": "off",
348
+ "linebreak-style": "off",
349
+ "lines-around-comment": specialRule,
350
+ "max-len": specialRule,
351
+ "max-statements-per-line": "off",
352
+ "multiline-ternary": "off",
353
+ "new-parens": "off",
354
+ "newline-per-chained-call": "off",
355
+ "no-confusing-arrow": specialRule,
356
+ "no-extra-parens": "off",
357
+ "no-extra-semi": "off",
358
+ "no-floating-decimal": "off",
359
+ "no-mixed-operators": specialRule,
360
+ "no-mixed-spaces-and-tabs": "off",
361
+ "no-multi-spaces": "off",
362
+ "no-multiple-empty-lines": "off",
363
+ "no-tabs": specialRule,
364
+ "no-trailing-spaces": "off",
365
+ "no-whitespace-before-property": "off",
366
+ "nonblock-statement-body-position": "off",
367
+ "object-curly-newline": "off",
368
+ "object-curly-spacing": "off",
369
+ "object-property-newline": "off",
370
+ "one-var-declaration-per-line": "off",
371
+ "operator-linebreak": "off",
372
+ "padded-blocks": "off",
373
+ "quote-props": "off",
374
+ "quotes": specialRule,
375
+ "rest-spread-spacing": "off",
376
+ "semi": "off",
377
+ "semi-spacing": "off",
378
+ "semi-style": "off",
379
+ "space-before-blocks": "off",
380
+ "space-before-function-paren": "off",
381
+ "space-in-parens": "off",
382
+ "space-infix-ops": "off",
383
+ "space-unary-ops": "off",
384
+ "switch-colon-spacing": "off",
385
+ "template-curly-spacing": "off",
386
+ "template-tag-spacing": "off",
387
+ "wrap-iife": "off",
388
+ "wrap-regex": "off",
389
+ "yield-star-spacing": "off",
390
+
391
+ // Deprecated since version 7.0.0.
392
+ // https://github.com/yannickcr/eslint-plugin-react/blob/master/CHANGELOG.md#700---2017-05-06
393
+ "react/jsx-space-before-closing": "off",
394
+ }),
395
+ };
node_modules/eslint-config-prettier/package.json ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "eslint-config-prettier",
3
+ "version": "10.1.8",
4
+ "type": "commonjs",
5
+ "description": "Turns off all rules that are unnecessary or might conflict with Prettier.",
6
+ "repository": "prettier/eslint-config-prettier",
7
+ "homepage": "https://github.com/prettier/eslint-config-prettier#readme",
8
+ "author": "Simon Lydell",
9
+ "maintainers": [
10
+ "JounQin (https://www.1stG.me) <admin@1stg.me>"
11
+ ],
12
+ "funding": "https://opencollective.com/eslint-config-prettier",
13
+ "license": "MIT",
14
+ "bin": "bin/cli.js",
15
+ "main": "index.js",
16
+ "types": "index.d.ts",
17
+ "exports": {
18
+ ".": {
19
+ "types": "./index.d.ts",
20
+ "default": "./index.js"
21
+ },
22
+ "./flat": {
23
+ "types": "./flat.d.ts",
24
+ "default": "./flat.js"
25
+ },
26
+ "./prettier": {
27
+ "types": "./prettier.d.ts",
28
+ "default": "./prettier.js"
29
+ },
30
+ "./package.json": "./package.json"
31
+ },
32
+ "files": [
33
+ "bin",
34
+ "flat.d.ts",
35
+ "flat.js",
36
+ "index.d.ts",
37
+ "index.js",
38
+ "prettier.d.ts",
39
+ "prettier.js"
40
+ ],
41
+ "keywords": [
42
+ "eslint",
43
+ "eslintconfig",
44
+ "eslint-config",
45
+ "eslint-prettier",
46
+ "prettier"
47
+ ],
48
+ "peerDependencies": {
49
+ "eslint": ">=7.0.0"
50
+ }
51
+ }
node_modules/eslint-config-prettier/prettier.d.ts ADDED
@@ -0,0 +1 @@
 
 
1
+ export const rules: Record<string, 0>;
node_modules/eslint-config-prettier/prettier.js ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+
3
+ exports.rules = {
4
+ // These are safe to use as long as the `"prettier/prettier"` rule from
5
+ // eslint-plugin-prettier isn’t enabled.
6
+ // These are also included in `"plugin:prettier/recommended"`:
7
+ // https://github.com/prettier/eslint-plugin-prettier#recommended-configuration
8
+ "arrow-body-style": 0,
9
+ "prefer-arrow-callback": 0,
10
+ };
node_modules/eslint-plugin-prettier/LICENSE.md ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # The MIT License (MIT)
2
+
3
+ Copyright © 2017 Andres Suarez and Teddy Katz
4
+
5
+ Permission is hereby granted, free of charge, to any person
6
+ obtaining a copy of this software and associated documentation
7
+ files (the “Software”), to deal in the Software without
8
+ restriction, including without limitation the rights to use,
9
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the
11
+ Software is furnished to do so, subject to the following
12
+ conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24
+ OTHER DEALINGS IN THE SOFTWARE.
node_modules/eslint-plugin-prettier/README.md ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # eslint-plugin-prettier [![Build Status](https://github.com/prettier/eslint-plugin-prettier/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/prettier/eslint-plugin-prettier/actions?query=workflow%3ACI+branch%3Amain)
2
+
3
+ Runs [Prettier](https://github.com/prettier/prettier) as an [ESLint](https://eslint.org) rule and reports differences as individual ESLint issues.
4
+
5
+ If your desired formatting does not match Prettier’s output, you should use a different tool such as [prettier-eslint](https://github.com/prettier/prettier-eslint) instead.
6
+
7
+ Please read [Integrating with linters](https://prettier.io/docs/en/integrating-with-linters.html) before installing.
8
+
9
+ ## TOC <!-- omit in toc -->
10
+
11
+ - [Sample](#sample)
12
+ - [Installation](#installation)
13
+ - [Configuration (legacy: `.eslintrc*`)](#configuration-legacy-eslintrc)
14
+ - [Configuration (new: `eslint.config.js`)](#configuration-new-eslintconfigjs)
15
+ - [`Svelte` support](#svelte-support)
16
+ - [`arrow-body-style` and `prefer-arrow-callback` issue](#arrow-body-style-and-prefer-arrow-callback-issue)
17
+ - [Options](#options)
18
+ - [Sponsors](#sponsors)
19
+ - [Backers](#backers)
20
+ - [Contributing](#contributing)
21
+ - [Changelog](#changelog)
22
+ - [License](#license)
23
+
24
+ ## Sample
25
+
26
+ ```js
27
+ error: Insert `,` (prettier/prettier) at pkg/commons-atom/ActiveEditorRegistry.js:22:25:
28
+ 20 | import {
29
+ 21 | observeActiveEditorsDebounced,
30
+ > 22 | editorChangesDebounced
31
+ | ^
32
+ 23 | } from './debounced';;
33
+ 24 |
34
+ 25 | import {observableFromSubscribeFunction} from '../commons-node/event';
35
+
36
+
37
+ error: Delete `;` (prettier/prettier) at pkg/commons-atom/ActiveEditorRegistry.js:23:21:
38
+ 21 | observeActiveEditorsDebounced,
39
+ 22 | editorChangesDebounced
40
+ > 23 | } from './debounced';;
41
+ | ^
42
+ 24 |
43
+ 25 | import {observableFromSubscribeFunction} from '../commons-node/event';
44
+ 26 | import {cacheWhileSubscribed} from '../commons-node/observable';
45
+
46
+
47
+ 2 errors found.
48
+ ```
49
+
50
+ > `./node_modules/.bin/eslint --format codeframe pkg/commons-atom/ActiveEditorRegistry.js` (code from [nuclide](https://github.com/facebook/nuclide)).
51
+
52
+ ## Installation
53
+
54
+ ```sh
55
+ npm install --save-dev eslint-plugin-prettier eslint-config-prettier
56
+ npm install --save-dev --save-exact prettier
57
+ ```
58
+
59
+ **_`eslint-plugin-prettier` does not install Prettier or ESLint for you._** _You must install these yourself._
60
+
61
+ This plugin works best if you disable all other ESLint rules relating to code formatting, and only enable rules that detect potential bugs. If another active ESLint rule disagrees with `prettier` about how code should be formatted, it will be impossible to avoid lint errors. Our recommended configuration automatically enables [`eslint-config-prettier`](https://github.com/prettier/eslint-config-prettier) to disable all formatting-related ESLint rules.
62
+
63
+ ## Configuration (legacy: `.eslintrc*`)
64
+
65
+ For [legacy configuration](https://eslint.org/docs/latest/use/configure/configuration-files-deprecated), this plugin ships with a `plugin:prettier/recommended` config that sets up both `eslint-plugin-prettier` and [`eslint-config-prettier`](https://github.com/prettier/eslint-config-prettier) in one go.
66
+
67
+ Add `plugin:prettier/recommended` as the _last_ item in the extends array in your `.eslintrc*` config file, so that `eslint-config-prettier` has the opportunity to override other configs:
68
+
69
+ ```json
70
+ {
71
+ "extends": ["plugin:prettier/recommended"]
72
+ }
73
+ ```
74
+
75
+ This will:
76
+
77
+ - Enable the `prettier/prettier` rule.
78
+ - Disable the `arrow-body-style` and `prefer-arrow-callback` rules which are problematic with this plugin - see the below for why.
79
+ - Enable the `eslint-config-prettier` config which will turn off ESLint rules that conflict with Prettier.
80
+
81
+ ## Configuration (new: `eslint.config.js`)
82
+
83
+ For [flat configuration](https://eslint.org/docs/latest/use/configure/configuration-files-new), this plugin ships with an `eslint-plugin-prettier/recommended` config that sets up both `eslint-plugin-prettier` and [`eslint-config-prettier`](https://github.com/prettier/eslint-config-prettier) in one go.
84
+
85
+ Import `eslint-plugin-prettier/recommended` and add it as the _last_ item in the configuration array in your `eslint.config.js` file so that `eslint-config-prettier` has the opportunity to override other configs:
86
+
87
+ ```js
88
+ const eslintPluginPrettierRecommended = require('eslint-plugin-prettier/recommended');
89
+
90
+ module.exports = [
91
+ // Any other config imports go at the top
92
+ eslintPluginPrettierRecommended,
93
+ ];
94
+ ```
95
+
96
+ This will:
97
+
98
+ - Enable the `prettier/prettier` rule.
99
+ - Disable the `arrow-body-style` and `prefer-arrow-callback` rules which are problematic with this plugin - see the below for why.
100
+ - Enable the `eslint-config-prettier` config which will turn off ESLint rules that conflict with Prettier.
101
+
102
+ ## `Svelte` support
103
+
104
+ We recommend to use [`eslint-plugin-svelte`](https://github.com/ota-meshi/eslint-plugin-svelte) instead of [`eslint-plugin-svelte3`](https://github.com/sveltejs/eslint-plugin-svelte3) because `eslint-plugin-svelte` has a correct [`eslint-svelte-parser`](https://github.com/ota-meshi/svelte-eslint-parser) instead of hacking.
105
+
106
+ When use with `eslint-plugin-svelte3`, `eslint-plugin-prettier` will just ignore the text passed by `eslint-plugin-svelte3`, because the text has been modified.
107
+
108
+ If you still decide to use `eslint-plugin-svelte3`, you'll need to run `prettier --write *.svelte` manually.
109
+
110
+ ## `arrow-body-style` and `prefer-arrow-callback` issue
111
+
112
+ If you use [arrow-body-style](https://eslint.org/docs/rules/arrow-body-style) or [prefer-arrow-callback](https://eslint.org/docs/rules/prefer-arrow-callback) together with the `prettier/prettier` rule from this plugin, you can in some cases end up with invalid code due to a bug in ESLint’s autofix – see [issue #65](https://github.com/prettier/eslint-plugin-prettier/issues/65).
113
+
114
+ For this reason, it’s recommended to turn off these rules. The `plugin:prettier/recommended` config does that for you.
115
+
116
+ You _can_ still use these rules together with this plugin if you want, because the bug does not occur _all the time._ But if you do, you need to keep in mind that you might end up with invalid code, where you manually have to insert a missing closing parenthesis to get going again.
117
+
118
+ If you’re fixing large of amounts of previously unformatted code, consider temporarily disabling the `prettier/prettier` rule and running `eslint --fix` and `prettier --write` separately.
119
+
120
+ ## Options
121
+
122
+ > Note: While it is possible to pass options to Prettier via your ESLint configuration file, it is not recommended because editor extensions such as `prettier-atom` and `prettier-vscode` **will** read [`.prettierrc`](https://prettier.io/docs/en/configuration.html), but **won't** read settings from ESLint, which can lead to an inconsistent experience.
123
+
124
+ - The first option:
125
+ - An object representing [options](https://prettier.io/docs/en/options.html) that will be passed into prettier. Example:
126
+
127
+ ```json
128
+ {
129
+ "prettier/prettier": [
130
+ "error",
131
+ {
132
+ "singleQuote": true,
133
+ "parser": "flow"
134
+ }
135
+ ]
136
+ }
137
+ ```
138
+
139
+ NB: This option will merge and override any config set with `.prettierrc` files
140
+
141
+ - The second option:
142
+ - An object with the following options
143
+ - `usePrettierrc`: Enables loading of the Prettier configuration file, (default: `true`). May be useful if you are using multiple tools that conflict with each other, or do not wish to mix your ESLint settings with your Prettier configuration. And also, it is possible to run prettier without loading the prettierrc config file [via the CLI's --no-config option](https://prettier.io/docs/en/cli.html#--no-config) or through the API by [calling prettier.format() without passing through the options generated by calling resolveConfig](https://prettier.io/docs/en/api.html#prettierresolveconfigfilepath--options).
144
+
145
+ ```json
146
+ {
147
+ "prettier/prettier": [
148
+ "error",
149
+ {},
150
+ {
151
+ "usePrettierrc": false
152
+ }
153
+ ]
154
+ }
155
+ ```
156
+
157
+ - `fileInfoOptions`: Options that are passed to [prettier.getFileInfo](https://prettier.io/docs/en/api.html#prettiergetfileinfofilepath--options) to decide whether a file needs to be formatted. Can be used for example to opt-out from ignoring files located in `node_modules` directories.
158
+
159
+ ```json
160
+ {
161
+ "prettier/prettier": [
162
+ "error",
163
+ {},
164
+ {
165
+ "fileInfoOptions": {
166
+ "withNodeModules": true
167
+ }
168
+ }
169
+ ]
170
+ }
171
+ ```
172
+
173
+ - The rule is auto fixable -- if you run `eslint` with the `--fix` flag, your code will be formatted according to `prettier` style.
174
+
175
+ ---
176
+
177
+ ## Sponsors
178
+
179
+ | @prettier/plugin-eslint | eslint-config-prettier | eslint-plugin-prettier | prettier-eslint | prettier-eslint-cli |
180
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
181
+ | [![@prettier/plugin-eslint Open Collective sponsors](https://opencollective.com/prettier-plugin-eslint/tiers/sponsors.svg)](https://opencollective.com/prettier-plugin-eslint) | [![eslint-config-prettier Open Collective backers](https://opencollective.com/eslint-config-prettier/tiers/sponsors.svg)](https://opencollective.com/eslint-config-prettier) | [![eslint-plugin-prettier Open Collective backers](https://opencollective.com/eslint-plugin-prettier/tiers/sponsors.svg)](https://opencollective.com/rxts) | [![prettier-eslint Open Collective sponsors](https://opencollective.com/prettier-eslint/tiers/sponsors.svg)](https://opencollective.com/prettier-eslint) | [![prettier-eslint-cli Open Collective backers](https://opencollective.com/prettier-eslint-cli/tiers/sponsors.svg)](https://opencollective.com/prettier-eslint-cli) |
182
+
183
+ ## Backers
184
+
185
+ | @prettier/plugin-eslint | eslint-config-prettier | eslint-plugin-prettier | prettier-eslint | prettier-eslint-cli |
186
+ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
187
+ | [![@prettier/plugin-eslint Open Collective backers](https://opencollective.com/prettier-plugin-eslint/tiers/backers.svg)](https://opencollective.com/prettier-plugin-eslint) | [![eslint-config-prettier Open Collective backers](https://opencollective.com/eslint-config-prettier/tiers/backers.svg)](https://opencollective.com/eslint-config-prettier) | [![eslint-plugin-prettier Open Collective backers](https://opencollective.com/eslint-plugin-prettier/tiers/backers.svg)](https://opencollective.com/rxts) | [![prettier-eslint Open Collective backers](https://opencollective.com/prettier-eslint/tiers/backers.svg)](https://opencollective.com/prettier-eslint) | [![prettier-eslint-cli Open Collective backers](https://opencollective.com/prettier-eslint-cli/tiers/backers.svg)](https://opencollective.com/prettier-eslint-cli) |
188
+
189
+ ## Contributing
190
+
191
+ See [CONTRIBUTING.md](https://github.com/prettier/eslint-plugin-prettier/blob/main/CONTRIBUTING.md)
192
+
193
+ ## Changelog
194
+
195
+ Detailed changes for each release are documented in [CHANGELOG.md](./CHANGELOG.md).
196
+
197
+ ## License
198
+
199
+ [MIT](http://opensource.org/licenses/MIT)
node_modules/eslint-plugin-prettier/eslint-plugin-prettier.d.ts ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ import { ESLint } from 'eslint';
2
+
3
+ declare const eslintPluginPrettier: ESLint.Plugin;
4
+
5
+ export = eslintPluginPrettier;
node_modules/eslint-plugin-prettier/eslint-plugin-prettier.js ADDED
@@ -0,0 +1,306 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @file Runs `prettier` as an ESLint rule.
3
+ * @author Andres Suarez
4
+ */
5
+
6
+ // @ts-check
7
+
8
+ /**
9
+ * @import {AST, ESLint, Linter, Rule, SourceCode} from 'eslint'
10
+ * @import {Position} from 'estree'
11
+ * @import {FileInfoOptions, Options as PrettierOptions} from 'prettier'
12
+ * @import {Difference} from 'prettier-linter-helpers'
13
+ */
14
+
15
+ /**
16
+ * @typedef {PrettierOptions & {
17
+ * onDiskFilepath: string;
18
+ * parserMeta?: ESLint.ObjectMetaProperties['meta'];
19
+ * parserPath?: string;
20
+ * usePrettierrc?: boolean;
21
+ * }} Options
22
+ *
23
+ *
24
+ * @typedef {(
25
+ * source: string,
26
+ * options: Options,
27
+ * fileInfoOptions: FileInfoOptions,
28
+ * ) => string} PrettierFormat
29
+ */
30
+
31
+ 'use strict';
32
+
33
+ // ------------------------------------------------------------------------------
34
+ // Requirements
35
+ // ------------------------------------------------------------------------------
36
+
37
+ const {
38
+ showInvisibles,
39
+ generateDifferences,
40
+ } = require('prettier-linter-helpers');
41
+ const { name, version } = require('./package.json');
42
+
43
+ // ------------------------------------------------------------------------------
44
+ // Constants
45
+ // ------------------------------------------------------------------------------
46
+
47
+ const { INSERT, DELETE, REPLACE } = generateDifferences;
48
+
49
+ // ------------------------------------------------------------------------------
50
+ // Privates
51
+ // ------------------------------------------------------------------------------
52
+
53
+ // Lazily-loaded Prettier.
54
+ /** @type {PrettierFormat} */
55
+ let prettierFormat;
56
+
57
+ // ------------------------------------------------------------------------------
58
+ // Rule Definition
59
+ // ------------------------------------------------------------------------------
60
+
61
+ /** @type {WeakMap<SourceCode, number[]>} */
62
+ const lineIndexesCache = new WeakMap();
63
+
64
+ /**
65
+ * Ponyfill `sourceCode.getLocFromIndex` when it's unavailable.
66
+ *
67
+ * See also `getLocFromIndex` in `@eslint/js`.
68
+ *
69
+ * @param {SourceCode} sourceCode
70
+ * @param {number} index
71
+ * @returns {Position}
72
+ */
73
+ function getLocFromIndex(sourceCode, index) {
74
+ if (typeof sourceCode.getLocFromIndex === 'function') {
75
+ return sourceCode.getLocFromIndex(index);
76
+ }
77
+
78
+ let lineIndexes = lineIndexesCache.get(sourceCode);
79
+ if (!lineIndexes) {
80
+ lineIndexes = [...sourceCode.text.matchAll(/\r?\n/g)].map(
81
+ match => match.index,
82
+ );
83
+ // first line in the file starts at byte offset 0
84
+ lineIndexes.unshift(0);
85
+ lineIndexesCache.set(sourceCode, lineIndexes);
86
+ }
87
+
88
+ let line = 0;
89
+ while (line + 1 < lineIndexes.length && lineIndexes[line + 1] < index) {
90
+ line += 1;
91
+ }
92
+ const column = index - lineIndexes[line];
93
+
94
+ return { line: line + 1, column };
95
+ }
96
+
97
+ /**
98
+ * Reports a difference.
99
+ *
100
+ * @param {Rule.RuleContext} context - The ESLint rule context.
101
+ * @param {Difference} difference - The difference object.
102
+ * @returns {void}
103
+ */
104
+ function reportDifference(context, difference) {
105
+ const { operation, offset } = difference;
106
+ const insertText = 'insertText' in difference ? difference.insertText : '';
107
+ const deleteText = 'deleteText' in difference ? difference.deleteText : '';
108
+ /** @type {AST.Range} */
109
+ const range = [offset, offset + deleteText.length];
110
+ // `context.getSourceCode()` was deprecated in ESLint v8.40.0 and replaced
111
+ // with the `sourceCode` property.
112
+ // TODO: Only use property when our eslint peerDependency is >=8.40.0.
113
+ const sourceCode = context.sourceCode ?? context.getSourceCode();
114
+
115
+ const [start, end] = range.map(index => getLocFromIndex(sourceCode, index));
116
+
117
+ context.report({
118
+ messageId: operation,
119
+ data: {
120
+ deleteText: showInvisibles(deleteText),
121
+ insertText: showInvisibles(insertText),
122
+ },
123
+ loc: { start, end },
124
+ fix: fixer => fixer.replaceTextRange(range, insertText),
125
+ });
126
+ }
127
+
128
+ // ------------------------------------------------------------------------------
129
+ // Module Definition
130
+ // ------------------------------------------------------------------------------
131
+
132
+ /** @type {ESLint.Plugin} */
133
+ const eslintPluginPrettier = {
134
+ meta: { name, version },
135
+ configs: {
136
+ recommended: {
137
+ extends: ['prettier'],
138
+ plugins: ['prettier'],
139
+ rules: {
140
+ 'prettier/prettier': 'error',
141
+ 'arrow-body-style': 'off',
142
+ 'prefer-arrow-callback': 'off',
143
+ },
144
+ },
145
+ },
146
+ rules: {
147
+ prettier: {
148
+ meta: {
149
+ docs: {
150
+ url: 'https://github.com/prettier/eslint-plugin-prettier#options',
151
+ },
152
+ type: 'layout',
153
+ fixable: 'code',
154
+ schema: [
155
+ // Prettier options:
156
+ {
157
+ type: 'object',
158
+ properties: {},
159
+ additionalProperties: true,
160
+ },
161
+ {
162
+ type: 'object',
163
+ properties: {
164
+ usePrettierrc: { type: 'boolean' },
165
+ fileInfoOptions: {
166
+ type: 'object',
167
+ properties: {},
168
+ additionalProperties: true,
169
+ },
170
+ },
171
+ additionalProperties: false,
172
+ },
173
+ ],
174
+ messages: {
175
+ [INSERT]: 'Insert `{{ insertText }}`',
176
+ [DELETE]: 'Delete `{{ deleteText }}`',
177
+ [REPLACE]: 'Replace `{{ deleteText }}` with `{{ insertText }}`',
178
+ },
179
+ },
180
+ create(context) {
181
+ const options = /** @type {Options | undefined} */ (context.options[1]);
182
+ const usePrettierrc = !options || options.usePrettierrc !== false;
183
+ /** @type {FileInfoOptions} */
184
+ const fileInfoOptions = options?.fileInfoOptions || {};
185
+
186
+ // `context.getSourceCode()` was deprecated in ESLint v8.40.0 and replaced
187
+ // with the `sourceCode` property.
188
+ // TODO: Only use property when our eslint peerDependency is >=8.40.0.
189
+ const sourceCode = /** @type {SourceCode} */ (
190
+ context.sourceCode ?? context.getSourceCode()
191
+ );
192
+ // `context.getFilename()` was deprecated in ESLint v8.40.0 and replaced
193
+ // with the `filename` property.
194
+ // TODO: Only use property when our eslint peerDependency is >=8.40.0.
195
+ const filepath = context.filename ?? context.getFilename();
196
+
197
+ // Processors that extract content from a file, such as the markdown
198
+ // plugin extracting fenced code blocks may choose to specify virtual
199
+ // file paths. If this is the case then we need to resolve prettier
200
+ // config and file info using the on-disk path instead of the virtual
201
+ // path.
202
+ // `context.getPhysicalFilename()` was deprecated in ESLint v8.40.0 and replaced
203
+ // with the `physicalFilename` property.
204
+ // TODO: Only use property when our eslint peerDependency is >=8.40.0.
205
+ const onDiskFilepath =
206
+ context.physicalFilename ?? context.getPhysicalFilename();
207
+ const source = sourceCode.text;
208
+
209
+ return {
210
+ /** @param {unknown} node */
211
+ [sourceCode.ast.type](node) {
212
+ if (!prettierFormat) {
213
+ // Prettier is expensive to load, so only load it if needed.
214
+ prettierFormat = /** @type {PrettierFormat} */ (
215
+ require('synckit').createSyncFn(require.resolve('./worker.mjs'))
216
+ );
217
+ }
218
+
219
+ /** @type {PrettierOptions} */
220
+ const eslintPrettierOptions = context.options[0] || {};
221
+
222
+ const parser = /** @type {Linter.Parser | undefined} */ (
223
+ context.languageOptions?.parser
224
+ );
225
+
226
+ // prettier.format() may throw a SyntaxError if it cannot parse the
227
+ // source code it is given. Usually for JS files this isn't a
228
+ // problem as ESLint will report invalid syntax before trying to
229
+ // pass it to the prettier plugin. However this might be a problem
230
+ // for non-JS languages that are handled by a plugin. Notably Vue
231
+ // files throw an error if they contain unclosed elements, such as
232
+ // `<template><div></template>. In this case report an error at the
233
+ // point at which parsing failed.
234
+ /** @type {string} */
235
+ let prettierSource;
236
+ try {
237
+ prettierSource = prettierFormat(
238
+ source,
239
+ {
240
+ ...eslintPrettierOptions,
241
+ filepath,
242
+ onDiskFilepath,
243
+ parserMeta:
244
+ parser &&
245
+ (parser.meta ?? {
246
+ name: parser.name,
247
+ version: parser.version,
248
+ }),
249
+ parserPath: context.parserPath,
250
+ usePrettierrc,
251
+ },
252
+ fileInfoOptions,
253
+ );
254
+ } catch (err) {
255
+ if (!(err instanceof SyntaxError)) {
256
+ throw err;
257
+ }
258
+
259
+ let message = 'Parsing error: ' + err.message;
260
+
261
+ const error = /**
262
+ * @type {SyntaxError & {
263
+ * codeFrame: string;
264
+ * loc?: AST.SourceLocation;
265
+ * }}
266
+ */ (err);
267
+
268
+ // Prettier's message contains a codeframe style preview of the
269
+ // invalid code and the line/column at which the error occurred.
270
+ // ESLint shows those pieces of information elsewhere already so
271
+ // remove them from the message
272
+ if (error.codeFrame) {
273
+ message = message.replace(`\n${error.codeFrame}`, '');
274
+ }
275
+ if (error.loc) {
276
+ message = message.replace(/ \(\d+:\d+\)$/, '');
277
+ context.report({ message, loc: error.loc });
278
+ } else {
279
+ context.report({ message, node });
280
+ }
281
+
282
+ return;
283
+ }
284
+
285
+ if (prettierSource == null) {
286
+ return;
287
+ }
288
+
289
+ if (source !== prettierSource) {
290
+ const differences = generateDifferences(source, prettierSource);
291
+
292
+ for (const difference of differences) {
293
+ reportDifference(
294
+ /** @type {Rule.RuleContext} */ (context),
295
+ difference,
296
+ );
297
+ }
298
+ }
299
+ },
300
+ };
301
+ },
302
+ },
303
+ },
304
+ };
305
+
306
+ module.exports = eslintPluginPrettier;
node_modules/eslint-plugin-prettier/package.json ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "eslint-plugin-prettier",
3
+ "version": "5.5.6",
4
+ "description": "Runs prettier as an eslint rule",
5
+ "repository": "https://github.com/prettier/eslint-plugin-prettier.git",
6
+ "homepage": "https://github.com/prettier/eslint-plugin-prettier#readme",
7
+ "author": "Teddy Katz",
8
+ "maintainers": [
9
+ "JounQin <admin@1stg.me> (https://github.com/JounQin)"
10
+ ],
11
+ "funding": "https://opencollective.com/eslint-plugin-prettier",
12
+ "license": "MIT",
13
+ "engines": {
14
+ "node": "^14.18.0 || >=16.0.0"
15
+ },
16
+ "main": "eslint-plugin-prettier.js",
17
+ "types": "eslint-plugin-prettier.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./eslint-plugin-prettier.d.ts",
21
+ "default": "./eslint-plugin-prettier.js"
22
+ },
23
+ "./recommended": {
24
+ "types": "./recommended.d.ts",
25
+ "default": "./recommended.js"
26
+ },
27
+ "./package.json": "./package.json"
28
+ },
29
+ "files": [
30
+ "eslint-plugin-prettier.d.ts",
31
+ "eslint-plugin-prettier.js",
32
+ "recommended.d.ts",
33
+ "recommended.js",
34
+ "worker.mjs"
35
+ ],
36
+ "keywords": [
37
+ "eslint",
38
+ "eslintplugin",
39
+ "eslint-plugin",
40
+ "prettier"
41
+ ],
42
+ "peerDependencies": {
43
+ "@types/eslint": ">=8.0.0",
44
+ "eslint": ">=8.0.0",
45
+ "eslint-config-prettier": ">= 7.0.0 <10.0.0 || >=10.1.0",
46
+ "prettier": ">=3.0.0"
47
+ },
48
+ "peerDependenciesMeta": {
49
+ "@types/eslint": {
50
+ "optional": true
51
+ },
52
+ "eslint-config-prettier": {
53
+ "optional": true
54
+ }
55
+ },
56
+ "dependencies": {
57
+ "prettier-linter-helpers": "^1.0.1",
58
+ "synckit": "^0.11.13"
59
+ }
60
+ }
node_modules/eslint-plugin-prettier/recommended.d.ts ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { Linter } from 'eslint';
2
+
3
+ // prettier-ignore
4
+ type IfEqual<A, B, X = A, Y = B> =
5
+ (<G>() => G extends A & G | G ? 1 : 2) extends
6
+ (<G>() => G extends B & G | G ? 1 : 2)
7
+ ? X
8
+ : Y;
9
+
10
+ declare const recommendedConfig: IfEqual<Linter.Config, Linter.FlatConfig>;
11
+
12
+ export = recommendedConfig;
node_modules/eslint-plugin-prettier/recommended.js ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const { rules: configPrettierRules } = require('eslint-config-prettier');
2
+ const {
3
+ rules: configPrettierOverridesRules,
4
+ } = require('eslint-config-prettier/prettier');
5
+ const eslintPluginPrettier = require('./eslint-plugin-prettier');
6
+
7
+ // Merge the contents of eslint-config-prettier into config
8
+ module.exports = {
9
+ name: 'eslint-plugin-prettier/recommended',
10
+ plugins: {
11
+ prettier: eslintPluginPrettier,
12
+ },
13
+ rules: {
14
+ ...configPrettierRules,
15
+ ...configPrettierOverridesRules,
16
+ 'prettier/prettier': 'error',
17
+ },
18
+ };
node_modules/eslint-plugin-prettier/worker.mjs ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // @ts-check
2
+
3
+ /**
4
+ * @typedef {PrettierOptions & {
5
+ * onDiskFilepath: string;
6
+ * parserMeta?: ESLint.ObjectMetaProperties['meta'];
7
+ * parserPath?: string;
8
+ * usePrettierrc?: boolean;
9
+ * }} Options
10
+ * @import {FileInfoOptions, Options as PrettierOptions} from 'prettier'
11
+ * @import {ESLint} from 'eslint'
12
+ */
13
+
14
+ import prettier from 'prettier';
15
+ import { runAsWorker } from 'synckit';
16
+
17
+ runAsWorker(
18
+ /**
19
+ * @param {string} source - The source code to format.
20
+ * @param {Options} options - The prettier options.
21
+ * @param {FileInfoOptions} eslintFileInfoOptions - The file info options.
22
+ * @returns {Promise<string | undefined>} The formatted source code.
23
+ */
24
+ async (
25
+ source,
26
+ {
27
+ filepath,
28
+ onDiskFilepath,
29
+ parserMeta,
30
+ parserPath,
31
+ usePrettierrc,
32
+ ...eslintPrettierOptions
33
+ },
34
+ eslintFileInfoOptions,
35
+ ) => {
36
+ const prettierRcOptions = usePrettierrc
37
+ ? await prettier.resolveConfig(onDiskFilepath, {
38
+ editorconfig: true,
39
+ })
40
+ : null;
41
+
42
+ const { ignored, inferredParser } = await prettier.getFileInfo(
43
+ onDiskFilepath,
44
+ {
45
+ resolveConfig: false,
46
+ withNodeModules: false,
47
+ ignorePath: '.prettierignore',
48
+ ...prettierRcOptions,
49
+ ...eslintFileInfoOptions,
50
+ },
51
+ );
52
+
53
+ // Skip if file is ignored using a .prettierignore file
54
+ if (ignored) {
55
+ return;
56
+ }
57
+
58
+ const initialOptions = { parser: inferredParser ?? 'babel' };
59
+
60
+ // ESLint supports processors that let you extract and lint JS
61
+ // fragments within a non-JS language. In the cases where prettier
62
+ // supports the same language as a processor, we want to process
63
+ // the provided source code as javascript (as ESLint provides the
64
+ // rules with fragments of JS) instead of guessing the parser
65
+ // based off the filename. Otherwise, for instance, on a .md file we
66
+ // end up trying to run prettier over a fragment of JS using the
67
+ // markdown parser, which throws an error.
68
+ // Processors may set virtual filenames for these extracted blocks.
69
+ // If they do so then we want to trust the file extension they
70
+ // provide, and no override is needed.
71
+ // If the processor does not set any virtual filename (signified by
72
+ // `filepath` and `onDiskFilepath` being equal) AND we can't
73
+ // infer the parser from the filename, either because no filename
74
+ // was provided or because there is no parser found for the
75
+ // filename, use javascript.
76
+ // This is added to the options first, so that
77
+ // prettierRcOptions and eslintPrettierOptions can still override
78
+ // the parser.
79
+ //
80
+ // `parserBlocklist` should contain the list of prettier parser
81
+ // names for file types where:
82
+ // * Prettier supports parsing the file type
83
+ // * There is an ESLint processor that extracts JavaScript snippets
84
+ // from the file type.
85
+ if (filepath === onDiskFilepath) {
86
+ // The following list means the plugin process source into js content
87
+ // but with same filename, so we need to change the parser to `babel`
88
+ // by default.
89
+ // Related ESLint plugins are:
90
+ // 1. `eslint-plugin-graphql` (replacement: `@graphql-eslint/eslint-plugin`)
91
+ // 2. `eslint-plugin-html`
92
+ // 3. `eslint-plugin-markdown@1` (replacement: `eslint-plugin-markdown@2+`)
93
+ // 4. `eslint-plugin-svelte3` (replacement: `eslint-plugin-svelte@2+`)
94
+ let inferParserToBabel = false;
95
+
96
+ switch (inferredParser) {
97
+ // it could be processed by `@graphql-eslint/eslint-plugin` or `eslint-plugin-graphql`
98
+ case 'graphql': {
99
+ if (
100
+ // for `eslint-plugin-graphql`, see https://github.com/apollographql/eslint-plugin-graphql/blob/64c524cd6607358803d5fcb7cead0a383a125ccb/src/index.js#L416
101
+ source.startsWith('ESLintPluginGraphQLFile`')
102
+ ) {
103
+ inferParserToBabel = true;
104
+ }
105
+ break;
106
+ }
107
+ case 'html': {
108
+ // it could be processed by `eslint-plugin-html` or correctly parsed by `@html-eslint/parser`
109
+ if (
110
+ (typeof parserMeta !== 'undefined' &&
111
+ parserMeta.name !== '@html-eslint/parser') ||
112
+ (typeof parserPath === 'string' &&
113
+ !/([\\/])@html-eslint\1parser\1/.test(parserPath))
114
+ ) {
115
+ inferParserToBabel = true;
116
+ }
117
+ break;
118
+ }
119
+ case 'markdown': {
120
+ // it could be processed by `eslint-plugin-markdown@1` or correctly parsed by `eslint-mdx`
121
+ if (
122
+ (typeof parserMeta !== 'undefined' &&
123
+ parserMeta.name !== 'eslint-mdx') ||
124
+ (typeof parserPath === 'string' &&
125
+ !/([\\/])eslint-mdx\1/.test(parserPath))
126
+ ) {
127
+ inferParserToBabel = true;
128
+ }
129
+ break;
130
+ }
131
+ // it could be processed by `@ota-meshi/eslint-plugin-svelte`, `eslint-plugin-svelte` or `eslint-plugin-svelte3`
132
+ case 'svelte': {
133
+ // The `source` would be modified by `eslint-plugin-svelte3`
134
+ if (
135
+ typeof parserPath === 'string' &&
136
+ !/([\\/])svelte-eslint-parser\1/.test(parserPath)
137
+ ) {
138
+ // We do not support `eslint-plugin-svelte3`,
139
+ // the users should run `prettier` on `.svelte` files manually
140
+ return;
141
+ }
142
+ }
143
+ }
144
+
145
+ if (inferParserToBabel) {
146
+ initialOptions.parser = 'babel';
147
+ }
148
+ } else {
149
+ // Similar to https://github.com/prettier/stylelint-prettier/pull/22
150
+ // In all of the following cases ESLint extracts a part of a file to
151
+ // be formatted and there exists a prettier parser for the whole file.
152
+ // If you're interested in prettier you'll want a fully formatted file so
153
+ // you're about to run prettier over the whole file anyway.
154
+ // Therefore running prettier over just the style section is wasteful, so
155
+ // skip it.
156
+ const parserBlocklist = [
157
+ 'babel',
158
+ 'babylon',
159
+ 'flow',
160
+ 'typescript',
161
+ 'vue',
162
+ 'markdown',
163
+ 'html',
164
+ 'mdx',
165
+ 'angular',
166
+ 'svelte',
167
+ 'pug',
168
+ 'oxc',
169
+ 'oxc-ts',
170
+ 'hermes',
171
+ ];
172
+ if (parserBlocklist.includes(/** @type {string} */ (inferredParser))) {
173
+ return;
174
+ }
175
+ }
176
+
177
+ /** @type {PrettierOptions} */
178
+ const prettierOptions = {
179
+ ...initialOptions,
180
+ ...prettierRcOptions,
181
+ ...eslintPrettierOptions,
182
+ filepath,
183
+ };
184
+
185
+ return prettier.format(source, prettierOptions);
186
+ },
187
+ );
node_modules/eslint-plugin-react-hooks/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) Meta Platforms, Inc. and affiliates.
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-plugin-react-hooks/README.md ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # `eslint-plugin-react-hooks`
2
+
3
+ The official ESLint plugin for [React](https://react.dev) which enforces the [Rules of React](https://react.dev/reference/eslint-plugin-react-hooks) and other best practices.
4
+
5
+ ## Installation
6
+
7
+ Assuming you already have ESLint installed, run:
8
+
9
+ ```sh
10
+ # npm
11
+ npm install eslint-plugin-react-hooks --save-dev
12
+
13
+ # yarn
14
+ yarn add eslint-plugin-react-hooks --dev
15
+ ```
16
+
17
+ ### Flat Config (eslint.config.js|ts)
18
+
19
+ Add the `recommended` config for all recommended rules:
20
+
21
+ ```js
22
+ // eslint.config.js
23
+ import reactHooks from 'eslint-plugin-react-hooks';
24
+ import { defineConfig } from 'eslint/config';
25
+
26
+ export default defineConfig([
27
+ reactHooks.configs.flat.recommended,
28
+ ]);
29
+ ```
30
+
31
+ If you want to try bleeding edge experimental compiler rules, use `recommended-latest`.
32
+
33
+ ```js
34
+ // eslint.config.js
35
+ import reactHooks from 'eslint-plugin-react-hooks';
36
+ import { defineConfig } from 'eslint/config';
37
+
38
+ export default defineConfig([
39
+ reactHooks.configs.flat['recommended-latest'],
40
+ ]);
41
+ ```
42
+
43
+ ### Legacy Config (.eslintrc)
44
+
45
+ If you are still using ESLint below 9.0.0, the `recommended` preset can also be used to enable all recommended rules.
46
+
47
+ ```js
48
+ {
49
+ "extends": ["plugin:react-hooks/recommended"],
50
+ // ...
51
+ }
52
+
53
+ ```
54
+
55
+ ### Custom Configuration
56
+
57
+ If you want more fine-grained configuration, you can instead choose to enable specific rules. However, we strongly encourage using the recommended presets — see above — so that you will automatically receive new recommended rules as we add them in future versions of the plugin.
58
+
59
+ #### Flat Config (eslint.config.js|ts)
60
+
61
+ ```js
62
+ import reactHooks from 'eslint-plugin-react-hooks';
63
+
64
+ export default [
65
+ {
66
+ files: ['**/*.{js,jsx}'],
67
+ plugins: { 'react-hooks': reactHooks },
68
+ // ...
69
+ rules: {
70
+ // Core hooks rules
71
+ 'react-hooks/rules-of-hooks': 'error',
72
+ 'react-hooks/exhaustive-deps': 'warn',
73
+
74
+ // React Compiler rules
75
+ 'react-hooks/config': 'error',
76
+ 'react-hooks/error-boundaries': 'error',
77
+ 'react-hooks/gating': 'error',
78
+ 'react-hooks/globals': 'error',
79
+ 'react-hooks/immutability': 'error',
80
+ 'react-hooks/preserve-manual-memoization': 'error',
81
+ 'react-hooks/purity': 'error',
82
+ 'react-hooks/refs': 'error',
83
+ 'react-hooks/set-state-in-effect': 'error',
84
+ 'react-hooks/set-state-in-render': 'error',
85
+ 'react-hooks/static-components': 'error',
86
+ 'react-hooks/unsupported-syntax': 'warn',
87
+ 'react-hooks/use-memo': 'error',
88
+ 'react-hooks/incompatible-library': 'warn',
89
+ }
90
+ },
91
+ ];
92
+ ```
93
+
94
+ #### Legacy Config (.eslintrc)
95
+ ```js
96
+ {
97
+ "plugins": [
98
+ // ...
99
+ "react-hooks"
100
+ ],
101
+ "rules": {
102
+ // ...
103
+ // Core hooks rules
104
+ "react-hooks/rules-of-hooks": "error",
105
+ "react-hooks/exhaustive-deps": "warn",
106
+
107
+ // React Compiler rules
108
+ "react-hooks/config": "error",
109
+ "react-hooks/error-boundaries": "error",
110
+ "react-hooks/gating": "error",
111
+ "react-hooks/globals": "error",
112
+ "react-hooks/immutability": "error",
113
+ "react-hooks/preserve-manual-memoization": "error",
114
+ "react-hooks/purity": "error",
115
+ "react-hooks/refs": "error",
116
+ "react-hooks/set-state-in-effect": "error",
117
+ "react-hooks/set-state-in-render": "error",
118
+ "react-hooks/static-components": "error",
119
+ "react-hooks/unsupported-syntax": "warn",
120
+ "react-hooks/use-memo": "error",
121
+ "react-hooks/incompatible-library": "warn"
122
+ }
123
+ }
124
+ ```
125
+
126
+ ## Advanced Configuration
127
+
128
+ `exhaustive-deps` can be configured to validate dependencies of custom Hooks with the `additionalHooks` option.
129
+ This option accepts a regex to match the names of custom Hooks that have dependencies.
130
+
131
+ ```js
132
+ {
133
+ rules: {
134
+ // ...
135
+ "react-hooks/exhaustive-deps": ["warn", {
136
+ additionalHooks: "(useMyCustomHook|useMyOtherCustomHook)"
137
+ }]
138
+ }
139
+ }
140
+ ```
141
+
142
+ We suggest to use this option **very sparingly, if at all**. Generally saying, we recommend most custom Hooks to not use the dependencies argument, and instead provide a higher-level API that is more focused around a specific use case.
143
+
144
+ ## Valid and Invalid Examples
145
+
146
+ Please refer to the [Rules of Hooks](https://react.dev/reference/rules/rules-of-hooks) documentation to learn more about this rule.
147
+
148
+ ## License
149
+
150
+ MIT
node_modules/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.d.ts ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as estree from 'estree';
2
+ import { Rule, Linter } from 'eslint';
3
+
4
+ type ReactHooksFlatConfig = {
5
+ plugins: {
6
+ react: any;
7
+ };
8
+ rules: Linter.RulesRecord;
9
+ };
10
+ declare const plugin: {
11
+ meta: {
12
+ name: string;
13
+ version: string;
14
+ };
15
+ rules: {
16
+ 'component-hook-factories': Rule.RuleModule;
17
+ 'exhaustive-deps': {
18
+ meta: {
19
+ type: "suggestion";
20
+ docs: {
21
+ description: string;
22
+ recommended: true;
23
+ url: string;
24
+ };
25
+ fixable: "code";
26
+ hasSuggestions: true;
27
+ schema: {
28
+ type: "object";
29
+ additionalProperties: false;
30
+ enableDangerousAutofixThisMayCauseInfiniteLoops: boolean;
31
+ properties: {
32
+ additionalHooks: {
33
+ type: "string";
34
+ };
35
+ enableDangerousAutofixThisMayCauseInfiniteLoops: {
36
+ type: "boolean";
37
+ };
38
+ experimental_autoDependenciesHooks: {
39
+ type: "array";
40
+ items: {
41
+ type: "string";
42
+ };
43
+ };
44
+ requireExplicitEffectDeps: {
45
+ type: "boolean";
46
+ };
47
+ };
48
+ }[];
49
+ };
50
+ create(context: Rule.RuleContext): {
51
+ CallExpression: (node: estree.CallExpression) => void;
52
+ };
53
+ };
54
+ 'rules-of-hooks': {
55
+ meta: {
56
+ type: "problem";
57
+ docs: {
58
+ description: string;
59
+ recommended: true;
60
+ url: string;
61
+ };
62
+ schema: {
63
+ type: "object";
64
+ additionalProperties: false;
65
+ properties: {
66
+ additionalHooks: {
67
+ type: "string";
68
+ };
69
+ };
70
+ }[];
71
+ };
72
+ create(context: Rule.RuleContext): {
73
+ '*'(node: any): void;
74
+ '*:exit'(node: any): void;
75
+ CallExpression(node: estree.CallExpression & Rule.NodeParentExtension): void;
76
+ Identifier(node: estree.Identifier & Rule.NodeParentExtension): void;
77
+ 'CallExpression:exit'(node: estree.CallExpression & Rule.NodeParentExtension): void;
78
+ FunctionDeclaration(node: estree.FunctionDeclaration & Rule.NodeParentExtension): void;
79
+ ArrowFunctionExpression(node: estree.ArrowFunctionExpression & Rule.NodeParentExtension): void;
80
+ ComponentDeclaration(node: any): void;
81
+ HookDeclaration(node: any): void;
82
+ };
83
+ };
84
+ };
85
+ configs: {
86
+ recommended: {
87
+ plugins: string[];
88
+ rules: Linter.RulesRecord;
89
+ };
90
+ 'recommended-latest': {
91
+ plugins: string[];
92
+ rules: Linter.RulesRecord;
93
+ };
94
+ flat: {
95
+ recommended: ReactHooksFlatConfig;
96
+ "recommended-latest": ReactHooksFlatConfig;
97
+ };
98
+ };
99
+ };
100
+
101
+ export { plugin as default };
node_modules/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js ADDED
The diff for this file is too large to render. See raw diff
 
node_modules/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.production.js ADDED
The diff for this file is too large to render. See raw diff
 
node_modules/eslint-plugin-react-hooks/index.d.ts ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import reactHooks from './cjs/eslint-plugin-react-hooks';
9
+
10
+ export = reactHooks;
node_modules/eslint-plugin-react-hooks/index.js ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ 'use strict';
9
+
10
+ // TODO: this doesn't make sense for an ESLint rule.
11
+ // We need to fix our build process to not create bundles for "raw" packages like this.
12
+ if (process.env.NODE_ENV === 'production') {
13
+ module.exports = require('./cjs/eslint-plugin-react-hooks.production.js');
14
+ } else {
15
+ module.exports = require('./cjs/eslint-plugin-react-hooks.development.js');
16
+ }
17
+
18
+ // Hint to Node’s cjs-module-lexer to make named imports work
19
+ // https://github.com/facebook/react/issues/34801#issuecomment-3433478810
20
+ // eslint-disable-next-line ft-flow/no-unused-expressions
21
+ 0 &&
22
+ (module.exports = {
23
+ meta: true,
24
+ rules: true,
25
+ configs: true,
26
+ });
node_modules/eslint-plugin-react-hooks/package.json ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "eslint-plugin-react-hooks",
3
+ "description": "ESLint rules for React Hooks",
4
+ "version": "7.1.1",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/facebook/react.git",
8
+ "directory": "packages/eslint-plugin-react-hooks"
9
+ },
10
+ "files": [
11
+ "LICENSE",
12
+ "README.md",
13
+ "cjs",
14
+ "index.js",
15
+ "index.d.ts"
16
+ ],
17
+ "keywords": [
18
+ "eslint",
19
+ "eslint-plugin",
20
+ "eslintplugin",
21
+ "react"
22
+ ],
23
+ "scripts": {
24
+ "build:compiler": "cd ../../compiler && yarn workspace babel-plugin-react-compiler build",
25
+ "test": "yarn build:compiler && jest",
26
+ "typecheck": "tsc --noEmit"
27
+ },
28
+ "license": "MIT",
29
+ "bugs": {
30
+ "url": "https://github.com/facebook/react/issues"
31
+ },
32
+ "main": "./index.js",
33
+ "types": "./index.d.ts",
34
+ "engines": {
35
+ "node": ">=18"
36
+ },
37
+ "homepage": "https://react.dev/",
38
+ "peerDependencies": {
39
+ "eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 || ^9.0.0 || ^10.0.0"
40
+ },
41
+ "dependencies": {
42
+ "@babel/core": "^7.24.4",
43
+ "@babel/parser": "^7.24.4",
44
+ "hermes-parser": "^0.25.1",
45
+ "zod": "^3.25.0 || ^4.0.0",
46
+ "zod-validation-error": "^3.5.0 || ^4.0.0"
47
+ },
48
+ "devDependencies": {
49
+ "@babel/eslint-parser": "^7.11.4",
50
+ "@babel/preset-typescript": "^7.26.0",
51
+ "@babel/types": "^7.19.0",
52
+ "@tsconfig/strictest": "^2.0.5",
53
+ "@types/eslint": "^9.6.1",
54
+ "@types/estree": "^1.0.6",
55
+ "@types/estree-jsx": "^1.0.5",
56
+ "@types/node": "^20.2.5",
57
+ "@typescript-eslint/parser-v2": "npm:@typescript-eslint/parser@^2.26.0",
58
+ "@typescript-eslint/parser-v3": "npm:@typescript-eslint/parser@^3.10.0",
59
+ "@typescript-eslint/parser-v4": "npm:@typescript-eslint/parser@^4.1.0",
60
+ "@typescript-eslint/parser-v5": "npm:@typescript-eslint/parser@^5.62.0",
61
+ "babel-eslint": "^10.0.3",
62
+ "eslint-v7": "npm:eslint@^7.7.0",
63
+ "eslint-v8": "npm:eslint@^8.57.1",
64
+ "eslint-v9": "npm:eslint@^9.0.0",
65
+ "jest": "^29.5.0",
66
+ "typescript": "^5.4.3"
67
+ }
68
+ }
node_modules/eslint-plugin-react-refresh/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) Arnaud Barré (https://github.com/ArnaudBarre)
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-plugin-react-refresh/README.md ADDED
@@ -0,0 +1,222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # eslint-plugin-react-refresh [![npm](https://img.shields.io/npm/v/eslint-plugin-react-refresh)](https://www.npmjs.com/package/eslint-plugin-react-refresh)
2
+
3
+ Validate that your components can safely be updated with Fast Refresh.
4
+
5
+ ## Explainer
6
+
7
+ "Fast Refresh", also known as "hot reloading", is a feature in many modern bundlers.
8
+ If you update some React component(s) on disk, then the bundler will know to update only the impacted parts of your page -- without a full page reload.
9
+
10
+ `eslint-plugin-react-refresh` enforces that your components are structured in a way that integrations such as [react-refresh](https://www.npmjs.com/package/react-refresh) expect.
11
+
12
+ ### Limitations
13
+
14
+ ⚠️ To avoid false positives, by default this plugin is only applied on `tsx` & `jsx` files. See [Options](#options) to run on JS files. ⚠️
15
+
16
+ The plugin relies on naming conventions (i.e. use PascalCase for components, camelCase for util functions). This is why there are some limitations:
17
+
18
+ - `export *` are not supported and will be reported as an error
19
+ - Anonymous function are not supported (i.e `export default function() {}`)
20
+ - Class components are not supported
21
+ - All-uppercase function export is considered an error when not using direct named export (ex `const CMS = () => <></>; export { CMS }`)
22
+
23
+ ## Installation
24
+
25
+ ```sh
26
+ npm i -D eslint-plugin-react-refresh
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ This plugin provides a single rule, `react-refresh/only-export-components`. There are multiple ways to enable it.
32
+
33
+ ### Recommended config
34
+
35
+ ```js
36
+ import { defineConfig } from "eslint/config";
37
+ import { reactRefresh } from "eslint-plugin-react-refresh";
38
+
39
+ export default defineConfig(
40
+ /* Main config */
41
+ reactRefresh.configs.recommended(),
42
+ );
43
+ ```
44
+
45
+ ### Vite config
46
+
47
+ This enables the `allowConstantExport` option which is supported by Vite React plugins.
48
+
49
+ ```js
50
+ import { defineConfig } from "eslint/config";
51
+ import { reactRefresh } from "eslint-plugin-react-refresh";
52
+
53
+ export default defineConfig(
54
+ /* Main config */
55
+ reactRefresh.configs.vite(),
56
+ );
57
+ ```
58
+
59
+ ### Next config
60
+
61
+ This allows exports like `fetchCache` and `revalidate` which are used in Page or Layout components and don't trigger a full page reload.
62
+
63
+ ```js
64
+ import { defineConfig } from "eslint/config";
65
+ import { reactRefresh } from "eslint-plugin-react-refresh";
66
+
67
+ export default defineConfig(
68
+ /* Main config */
69
+ reactRefresh.configs.next(),
70
+ );
71
+ ```
72
+
73
+ ### Without config
74
+
75
+ ```js
76
+ import { defineConfig } from "eslint/config";
77
+ import { reactRefresh } from "eslint-plugin-react-refresh";
78
+
79
+ export default defineConfig({
80
+ // in main config for TSX/JSX source files
81
+ plugins: {
82
+ "react-refresh": reactRefresh.plugin,
83
+ },
84
+ rules: {
85
+ "react-refresh/only-export-components": "error",
86
+ },
87
+ });
88
+ ```
89
+
90
+ ## Examples
91
+
92
+ These examples are from enabling `react-refresh/only-exports-components`.
93
+
94
+ ### Fail
95
+
96
+ ```jsx
97
+ export const foo = () => {};
98
+ export const Bar = () => <></>;
99
+ ```
100
+
101
+ ```jsx
102
+ export default function () {}
103
+ export default compose()(MainComponent)
104
+ ```
105
+
106
+ ```jsx
107
+ export * from "./foo";
108
+ ```
109
+
110
+ ```jsx
111
+ const Tab = () => {};
112
+ export const tabs = [<Tab />, <Tab />];
113
+ ```
114
+
115
+ ```jsx
116
+ const App = () => {};
117
+ createRoot(document.getElementById("root")).render(<App />);
118
+ ```
119
+
120
+ ### Pass
121
+
122
+ ```jsx
123
+ export default function Foo() {
124
+ return <></>;
125
+ }
126
+ ```
127
+
128
+ ```jsx
129
+ const foo = () => {};
130
+ export const Bar = () => <></>;
131
+ ```
132
+
133
+ ```jsx
134
+ import { App } from "./App";
135
+ createRoot(document.getElementById("root")).render(<App />);
136
+ ```
137
+
138
+ ## Options
139
+
140
+ These options are all present on `react-refresh/only-exports-components`.
141
+
142
+ ```ts
143
+ interface Options {
144
+ extraHOCs?: string[];
145
+ allowExportNames?: string[];
146
+ allowConstantExport?: boolean;
147
+ checkJS?: boolean;
148
+ }
149
+
150
+ const defaultOptions: Options = {
151
+ extraHOCs: [],
152
+ allowExportNames: [],
153
+ allowConstantExport: false,
154
+ checkJS: false,
155
+ };
156
+ ```
157
+
158
+ ### extraHOCs <small>(v0.5.0)</small>
159
+
160
+ If you're exporting components wrapped in non built-in React HOC (memo, forwardRef, lazy), you can use this option to avoid false positives.
161
+
162
+ ```json
163
+ {
164
+ "react-refresh/only-export-components": [
165
+ "error",
166
+ { "extraHOCs": ["observer", "withAuth"] }
167
+ ]
168
+ }
169
+ ```
170
+
171
+ ### allowExportNames <small>(v0.4.4)</small>
172
+
173
+ > Default: `[]`
174
+
175
+ If you use a framework that handles HMR of some specific exports, you can use this option to avoid warning for them.
176
+
177
+ Example for [Remix](https://remix.run/docs/en/main/discussion/hot-module-replacement#supported-exports):
178
+
179
+ ```json
180
+ {
181
+ "react-refresh/only-export-components": [
182
+ "error",
183
+ { "allowExportNames": ["meta", "links", "headers", "loader", "action"] }
184
+ ]
185
+ }
186
+ ```
187
+
188
+ ### allowConstantExport <small>(v0.4.0)</small>
189
+
190
+ > Default: `false` (`true` in `vite` config)
191
+
192
+ Don't warn when a constant (string, number, boolean, templateLiteral) is exported aside one or more components.
193
+
194
+ This should be enabled if the fast refresh implementation correctly handles this case (HMR when the constant doesn't change, propagate update to importers when the constant changes.). Vite supports it, PR welcome if you notice other integrations works well.
195
+
196
+ ```json
197
+ {
198
+ "react-refresh/only-export-components": [
199
+ "error",
200
+ { "allowConstantExport": true }
201
+ ]
202
+ }
203
+ ```
204
+
205
+ Enabling this option allows code such as the following:
206
+
207
+ ```jsx
208
+ export const CONSTANT = 3;
209
+ export const Foo = () => <></>;
210
+ ```
211
+
212
+ ### checkJS <small>(v0.3.3)</small>
213
+
214
+ > Default: `false`
215
+
216
+ If you're using JSX inside `.js` files (which I don't recommend because it forces you to configure every tool you use to switch the parser), you can still use the plugin by enabling this option. To reduce the number of false positive, only files importing `react` are checked.
217
+
218
+ ```json
219
+ {
220
+ "react-refresh/only-export-components": ["error", { "checkJS": true }]
221
+ }
222
+ ```
node_modules/eslint-plugin-react-refresh/index.d.ts ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ type Rules = { "only-export-components": any };
2
+
3
+ export type OnlyExportComponentsOptions = {
4
+ extraHOCs?: string[];
5
+ allowExportNames?: string[];
6
+ allowConstantExport?: boolean;
7
+ checkJS?: boolean;
8
+ };
9
+
10
+ type Config = {
11
+ name: string;
12
+ plugins: { "react-refresh": { rules: Rules } };
13
+ rules: Rules;
14
+ };
15
+ type ConfigFn = (options?: OnlyExportComponentsOptions) => {
16
+ name: string;
17
+ plugins: { "react-refresh": { rules: Rules } };
18
+ rules: Rules;
19
+ };
20
+
21
+ export const reactRefresh: {
22
+ plugin: {
23
+ rules: Rules;
24
+ };
25
+ configs: {
26
+ recommended: ConfigFn;
27
+ vite: ConfigFn;
28
+ next: ConfigFn;
29
+ };
30
+ };
31
+
32
+ declare const _default: {
33
+ rules: Rules;
34
+ configs: {
35
+ recommended: Config;
36
+ vite: Config;
37
+ next: Config;
38
+ };
39
+ };
40
+ export default _default;
node_modules/eslint-plugin-react-refresh/index.js ADDED
@@ -0,0 +1,344 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // src/only-export-components.ts
2
+ var reactComponentNameRE = /^[A-Z][a-zA-Z0-9_]*$/u;
3
+ var onlyExportComponents = {
4
+ meta: {
5
+ messages: {
6
+ exportAll: "This rule can't verify that `export *` only exports components.",
7
+ namedExport: "Fast refresh only works when a file only exports components. Use a new file to share constants or functions between components.",
8
+ anonymousExport: "Fast refresh can't handle anonymous components. Add a name to your export.",
9
+ localComponents: "Fast refresh only works when a file only exports components. Move your component(s) to a separate file. If all exports are HOCs, add them to the `extraHOCs` option.",
10
+ noExport: "Fast refresh only works when a file has exports. Move your component(s) to a separate file.",
11
+ reactContext: "Fast refresh only works when a file only exports components. Move your React context(s) to a separate file."
12
+ },
13
+ type: "problem",
14
+ schema: [
15
+ {
16
+ type: "object",
17
+ properties: {
18
+ extraHOCs: { type: "array", items: { type: "string" } },
19
+ allowExportNames: { type: "array", items: { type: "string" } },
20
+ allowConstantExport: { type: "boolean" },
21
+ checkJS: { type: "boolean" }
22
+ },
23
+ additionalProperties: false
24
+ }
25
+ ]
26
+ },
27
+ defaultOptions: [],
28
+ create: (context) => {
29
+ const {
30
+ extraHOCs = [],
31
+ allowExportNames,
32
+ allowConstantExport = false,
33
+ checkJS = false
34
+ } = context.options[0] ?? {};
35
+ const filename = context.filename;
36
+ if (filename.includes(".test.") || filename.includes(".spec.") || filename.includes(".cy.") || filename.includes(".stories.")) {
37
+ return {};
38
+ }
39
+ const shouldScan = filename.endsWith(".jsx") || filename.endsWith(".tsx") || checkJS && filename.endsWith(".js");
40
+ if (!shouldScan) return {};
41
+ const allowExportNamesSet = allowExportNames ? new Set(allowExportNames) : void 0;
42
+ const validHOCs = ["memo", "forwardRef", "lazy", ...extraHOCs];
43
+ const getHocName = (node) => {
44
+ const callee = node.type === "CallExpression" ? node.callee : node.tag;
45
+ if (callee.type === "CallExpression") {
46
+ return getHocName(callee);
47
+ }
48
+ if (callee.type === "MemberExpression") {
49
+ if (callee.property.type === "Identifier" && validHOCs.includes(callee.property.name)) {
50
+ return callee.property.name;
51
+ }
52
+ if (callee.object.type === "Identifier" && validHOCs.includes(callee.object.name)) {
53
+ return callee.object.name;
54
+ }
55
+ if (callee.object.type === "CallExpression") {
56
+ return getHocName(callee.object);
57
+ }
58
+ }
59
+ if (callee.type === "Identifier") {
60
+ return callee.name;
61
+ }
62
+ return void 0;
63
+ };
64
+ const isCallExpressionReactComponent = (node) => {
65
+ const hocName = getHocName(node);
66
+ if (!hocName || !validHOCs.includes(hocName)) return false;
67
+ const validateArgument = hocName === "memo" || hocName === "forwardRef";
68
+ if (!validateArgument) return true;
69
+ if (node.arguments.length === 0) return false;
70
+ const arg = skipTSWrapper(node.arguments[0]);
71
+ switch (arg.type) {
72
+ case "Identifier":
73
+ return reactComponentNameRE.test(arg.name);
74
+ case "FunctionExpression":
75
+ case "ArrowFunctionExpression":
76
+ if (!arg.id) return "needName";
77
+ return reactComponentNameRE.test(arg.id.name);
78
+ case "CallExpression":
79
+ return isCallExpressionReactComponent(arg);
80
+ default:
81
+ return false;
82
+ }
83
+ };
84
+ const isExpressionReactComponent = (expressionParam) => {
85
+ const exp = skipTSWrapper(expressionParam);
86
+ if (exp.type === "Identifier") {
87
+ return reactComponentNameRE.test(exp.name);
88
+ }
89
+ if (exp.type === "ArrowFunctionExpression" || exp.type === "FunctionExpression") {
90
+ if (exp.params.length > 2) return false;
91
+ if (!exp.id?.name) return "needName";
92
+ return reactComponentNameRE.test(exp.id.name);
93
+ }
94
+ if (exp.type === "ConditionalExpression") {
95
+ const consequent = isExpressionReactComponent(exp.consequent);
96
+ const alternate = isExpressionReactComponent(exp.alternate);
97
+ if (consequent === false || alternate === false) return false;
98
+ if (consequent === "needName" || alternate === "needName") {
99
+ return "needName";
100
+ }
101
+ return true;
102
+ }
103
+ if (exp.type === "CallExpression") {
104
+ return isCallExpressionReactComponent(exp);
105
+ }
106
+ if (exp.type === "TaggedTemplateExpression") {
107
+ const hocName = getHocName(exp);
108
+ if (!hocName || !validHOCs.includes(hocName)) return false;
109
+ return "needName";
110
+ }
111
+ return false;
112
+ };
113
+ return {
114
+ Program(program) {
115
+ let hasExports = false;
116
+ let hasReactExport = false;
117
+ let reactIsInScope = false;
118
+ const localComponents = [];
119
+ const nonComponentExports = [];
120
+ const reactContextExports = [];
121
+ const handleExportIdentifier = (identifierNode, initParam) => {
122
+ if (identifierNode.type !== "Identifier") {
123
+ nonComponentExports.push(identifierNode);
124
+ return;
125
+ }
126
+ if (allowExportNamesSet?.has(identifierNode.name)) return;
127
+ if (!initParam) {
128
+ if (reactComponentNameRE.test(identifierNode.name)) {
129
+ hasReactExport = true;
130
+ } else {
131
+ nonComponentExports.push(identifierNode);
132
+ }
133
+ return;
134
+ }
135
+ const init = skipTSWrapper(initParam);
136
+ if (allowConstantExport && constantExportExpressions.has(init.type)) {
137
+ return;
138
+ }
139
+ if (init.type === "CallExpression" && (init.callee.type === "Identifier" && init.callee.name === "createContext" || init.callee.type === "MemberExpression" && init.callee.property.type === "Identifier" && init.callee.property.name === "createContext")) {
140
+ reactContextExports.push(identifierNode);
141
+ return;
142
+ }
143
+ const isReactComponent = reactComponentNameRE.test(identifierNode.name) && isExpressionReactComponent(init);
144
+ if (isReactComponent === false) {
145
+ nonComponentExports.push(identifierNode);
146
+ } else {
147
+ hasReactExport = true;
148
+ }
149
+ };
150
+ const handleExportDeclaration = (node) => {
151
+ if (node.type === "VariableDeclaration") {
152
+ for (const variable of node.declarations) {
153
+ if (variable.init === null) {
154
+ nonComponentExports.push(variable.id);
155
+ continue;
156
+ }
157
+ handleExportIdentifier(variable.id, variable.init);
158
+ }
159
+ } else if (node.type === "FunctionDeclaration") {
160
+ if (node.id === null) {
161
+ context.report({ messageId: "anonymousExport", node });
162
+ } else {
163
+ handleExportIdentifier(node.id);
164
+ }
165
+ } else if (node.type === "ClassDeclaration") {
166
+ if (node.id === null) {
167
+ context.report({ messageId: "anonymousExport", node });
168
+ } else if (reactComponentNameRE.test(node.id.name) && node.superClass !== null && node.body.body.some(
169
+ (item) => item.type === "MethodDefinition" && item.key.type === "Identifier" && item.key.name === "render"
170
+ )) {
171
+ hasReactExport = true;
172
+ } else {
173
+ nonComponentExports.push(node.id);
174
+ }
175
+ } else if (node.type === "CallExpression") {
176
+ const result = isCallExpressionReactComponent(node);
177
+ if (result === false) {
178
+ nonComponentExports.push(node);
179
+ } else if (result === "needName") {
180
+ context.report({ messageId: "anonymousExport", node });
181
+ } else {
182
+ hasReactExport = true;
183
+ }
184
+ } else {
185
+ nonComponentExports.push(node);
186
+ }
187
+ };
188
+ for (const node of program.body) {
189
+ if (node.type === "ExportAllDeclaration") {
190
+ if (node.exportKind === "type") continue;
191
+ hasExports = true;
192
+ context.report({ messageId: "exportAll", node });
193
+ } else if (node.type === "ExportDefaultDeclaration") {
194
+ hasExports = true;
195
+ const declaration = skipTSWrapper(node.declaration);
196
+ if (declaration.type === "VariableDeclaration" || declaration.type === "FunctionDeclaration" || declaration.type === "ClassDeclaration" || declaration.type === "CallExpression") {
197
+ handleExportDeclaration(declaration);
198
+ }
199
+ if (declaration.type === "Identifier") {
200
+ handleExportIdentifier(declaration);
201
+ }
202
+ if (declaration.type === "ArrowFunctionExpression") {
203
+ context.report({ messageId: "anonymousExport", node });
204
+ }
205
+ } else if (node.type === "ExportNamedDeclaration") {
206
+ if (node.exportKind === "type") continue;
207
+ const declaration = node.declaration ? skipTSWrapper(node.declaration) : null;
208
+ if (declaration?.type === "TSDeclareFunction") continue;
209
+ hasExports = true;
210
+ if (declaration) handleExportDeclaration(declaration);
211
+ for (const specifier of node.specifiers) {
212
+ if (specifier.local.type === "Identifier") {
213
+ const scope = context.sourceCode.getScope(node);
214
+ const localName = specifier.local.name;
215
+ const def = scope.variables.find((v) => v.name === localName)?.defs[0];
216
+ if (def?.type === "ClassName") {
217
+ handleExportDeclaration(def.node);
218
+ continue;
219
+ }
220
+ }
221
+ handleExportIdentifier(
222
+ specifier.exported.type === "Identifier" && specifier.exported.name === "default" ? specifier.local : specifier.exported
223
+ );
224
+ }
225
+ } else if (node.type === "VariableDeclaration") {
226
+ for (const variable of node.declarations) {
227
+ if (variable.id.type === "Identifier" && reactComponentNameRE.test(variable.id.name) && variable.init !== null && isExpressionReactComponent(variable.init) !== false) {
228
+ localComponents.push(variable.id);
229
+ }
230
+ }
231
+ } else if (node.type === "FunctionDeclaration") {
232
+ if (reactComponentNameRE.test(node.id.name)) {
233
+ localComponents.push(node.id);
234
+ }
235
+ } else if (node.type === "ImportDeclaration" && node.source.value === "react") {
236
+ reactIsInScope = true;
237
+ }
238
+ }
239
+ if (checkJS && !reactIsInScope) return;
240
+ if (hasExports) {
241
+ if (hasReactExport) {
242
+ for (const node of nonComponentExports) {
243
+ context.report({ messageId: "namedExport", node });
244
+ }
245
+ for (const node of reactContextExports) {
246
+ context.report({ messageId: "reactContext", node });
247
+ }
248
+ } else if (localComponents.length) {
249
+ for (const node of localComponents) {
250
+ context.report({ messageId: "localComponents", node });
251
+ }
252
+ }
253
+ } else if (localComponents.length) {
254
+ for (const node of localComponents) {
255
+ context.report({ messageId: "noExport", node });
256
+ }
257
+ }
258
+ }
259
+ };
260
+ }
261
+ };
262
+ var skipTSWrapper = (node) => {
263
+ if (node.type === "TSAsExpression" || node.type === "TSSatisfiesExpression" || node.type === "TSNonNullExpression" || node.type === "TSTypeAssertion" || node.type === "TSInstantiationExpression") {
264
+ return node.expression;
265
+ }
266
+ return node;
267
+ };
268
+ var constantExportExpressions = /* @__PURE__ */ new Set([
269
+ "Literal",
270
+ // 1, "foo"
271
+ "UnaryExpression",
272
+ // -1
273
+ "TemplateLiteral",
274
+ // `Some ${template}`
275
+ "BinaryExpression"
276
+ // 24 * 60
277
+ ]);
278
+
279
+ // src/index.ts
280
+ var rules = {
281
+ "only-export-components": onlyExportComponents
282
+ };
283
+ var plugin = { rules };
284
+ var buildConfig = ({
285
+ name,
286
+ baseOptions
287
+ }) => (options) => ({
288
+ name: `react-refresh/${name}`,
289
+ plugins: { "react-refresh": plugin },
290
+ rules: {
291
+ "react-refresh/only-export-components": [
292
+ "error",
293
+ { ...baseOptions, ...options }
294
+ ]
295
+ }
296
+ });
297
+ var configs = {
298
+ recommended: buildConfig({ name: "recommended", baseOptions: {} }),
299
+ vite: buildConfig({
300
+ name: "vite",
301
+ baseOptions: { allowConstantExport: true }
302
+ }),
303
+ next: buildConfig({
304
+ name: "next",
305
+ baseOptions: {
306
+ allowExportNames: [
307
+ // https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config
308
+ "experimental_ppr",
309
+ "dynamic",
310
+ "dynamicParams",
311
+ "revalidate",
312
+ "fetchCache",
313
+ "runtime",
314
+ "preferredRegion",
315
+ "maxDuration",
316
+ // https://nextjs.org/docs/app/api-reference/functions/generate-metadata
317
+ "metadata",
318
+ "generateMetadata",
319
+ // https://nextjs.org/docs/app/api-reference/functions/generate-viewport
320
+ "viewport",
321
+ "generateViewport",
322
+ // https://nextjs.org/docs/app/api-reference/functions/generate-image-metadata
323
+ "generateImageMetadata",
324
+ // https://nextjs.org/docs/app/api-reference/functions/generate-sitemaps
325
+ "generateSitemaps",
326
+ // https://nextjs.org/docs/app/api-reference/functions/generate-static-params
327
+ "generateStaticParams"
328
+ ]
329
+ }
330
+ })
331
+ };
332
+ var reactRefresh = { plugin, configs };
333
+ var index_default = {
334
+ rules,
335
+ configs: {
336
+ recommended: configs.recommended(),
337
+ vite: configs.vite(),
338
+ next: configs.next()
339
+ }
340
+ };
341
+ export {
342
+ index_default as default,
343
+ reactRefresh
344
+ };
node_modules/eslint-plugin-react-refresh/package.json ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "eslint-plugin-react-refresh",
3
+ "description": "Validate that your components can safely be updated with Fast Refresh",
4
+ "version": "0.5.3",
5
+ "type": "module",
6
+ "author": "Arnaud Barré (https://github.com/ArnaudBarre)",
7
+ "license": "MIT",
8
+ "repository": "github:ArnaudBarre/eslint-plugin-react-refresh",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./index.d.ts",
12
+ "default": "./index.js"
13
+ }
14
+ },
15
+ "keywords": [
16
+ "eslint",
17
+ "eslint-plugin",
18
+ "react",
19
+ "react-refresh",
20
+ "fast refresh"
21
+ ],
22
+ "peerDependencies": {
23
+ "eslint": "^9 || ^10"
24
+ }
25
+ }
node_modules/eslint-scope/LICENSE ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright JS Foundation and other contributors, https://js.foundation
2
+ Copyright (C) 2012-2013 Yusuke Suzuki (twitter: @Constellation) and other contributors.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright
10
+ notice, this list of conditions and the following disclaimer in the
11
+ documentation and/or other materials provided with the distribution.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
+ ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
17
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
node_modules/eslint-scope/README.md ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [![npm version](https://img.shields.io/npm/v/eslint-scope.svg)](https://www.npmjs.com/package/eslint-scope)
2
+ [![Downloads](https://img.shields.io/npm/dm/eslint-scope.svg)](https://www.npmjs.com/package/eslint-scope)
3
+ [![Build Status](https://github.com/eslint/js/workflows/CI/badge.svg)](https://github.com/eslint/js/actions)
4
+
5
+ # ESLint Scope
6
+
7
+ ESLint Scope is the [ECMAScript](http://www.ecma-international.org/publications/standards/Ecma-262.htm) scope analyzer used in ESLint. It is a fork of [escope](http://github.com/estools/escope).
8
+
9
+ ## Install
10
+
11
+ ```
12
+ npm i eslint-scope --save
13
+ ```
14
+
15
+ ## 📖 Usage
16
+
17
+ To use in an ESM file:
18
+
19
+ ```js
20
+ import * as eslintScope from "eslint-scope";
21
+ ```
22
+
23
+ To use in a CommonJS file:
24
+
25
+ ```js
26
+ const eslintScope = require("eslint-scope");
27
+ ```
28
+
29
+ In order to analyze scope, you'll need to have an [ESTree](https://github.com/estree/estree) compliant AST structure to run it on. The primary method is `eslintScope.analyze()`, which takes two arguments:
30
+
31
+ 1. `ast` - the ESTree-compliant AST structure to analyze.
32
+ 2. `options` (optional) - Options to adjust how the scope is analyzed, including:
33
+
34
+ - `ignoreEval` (default: `false`) - Set to `true` to ignore all `eval()` calls (which would normally create scopes).
35
+ - `nodejsScope` (default: `false`) - Set to `true` to create a top-level function scope needed for CommonJS evaluation.
36
+ - `impliedStrict` (default: `false`) - Set to `true` to evaluate the code in strict mode even outside of modules and without `"use strict"`.
37
+ - `ecmaVersion` (default: `5`) - The version of ECMAScript to use to evaluate the code.
38
+ - `sourceType` (default: `"script"`) - The type of JavaScript file to evaluate. Change to `"module"` for ECMAScript module code.
39
+ - `childVisitorKeys` (default: `null`) - An object with visitor key information (like [`eslint-visitor-keys`](https://github.com/eslint/js/tree/main/packages/eslint-visitor-keys)). Without this, `eslint-scope` finds child nodes to visit algorithmically. Providing this option is a performance enhancement.
40
+ - `fallback` (default: `"iteration"`) - The strategy to use when `childVisitorKeys` is not specified. May be a function.
41
+ - `optimistic` (default: `false`) - Set to `true` to enable optimistic scope analysis.
42
+ - `jsx` (default: `false`) - Enables the tracking of JSX components as variable references.
43
+
44
+ Example:
45
+
46
+ ```js
47
+ import * as eslintScope from "eslint-scope";
48
+ import * as espree from "espree";
49
+ import estraverse from "estraverse";
50
+
51
+ const options = {
52
+ ecmaVersion: 2022,
53
+ sourceType: "module",
54
+ };
55
+
56
+ const ast = espree.parse(code, { range: true, ...options });
57
+ const scopeManager = eslintScope.analyze(ast, options);
58
+
59
+ const currentScope = scopeManager.acquire(ast); // global scope
60
+
61
+ estraverse.traverse(ast, {
62
+ enter(node, parent) {
63
+ // do stuff
64
+
65
+ if (/Function/.test(node.type)) {
66
+ currentScope = scopeManager.acquire(node); // get current function scope
67
+ }
68
+ },
69
+ leave(node, parent) {
70
+ if (/Function/.test(node.type)) {
71
+ currentScope = currentScope.upper; // set to parent scope
72
+ }
73
+
74
+ // do stuff
75
+ },
76
+ });
77
+ ```
78
+
79
+ ## API
80
+
81
+ The following section describes the API for this package. You can also read [the docs](https://eslint.org/docs/latest/extend/scope-manager-interface).
82
+
83
+ ### ScopeManager
84
+
85
+ The `ScopeManager` class is at the core of eslint-scope and is returned when you call `eslintScope.analyze()`. It manages all scopes in a given AST.
86
+
87
+ #### Properties
88
+
89
+ - `scopes` - An array of all scopes.
90
+ - `globalScope` - Reference to the global scope.
91
+
92
+ #### Methods
93
+
94
+ - **`addGlobals(names)`**
95
+ Adds variables to the global scope and resolves references to them.
96
+ - `names` - An array of strings, the names of variables to add to the global scope.
97
+ - Returns: `undefined`.
98
+
99
+ - **`acquire(node, inner)`**
100
+ Acquires the appropriate scope for a given node.
101
+ - `node` - The AST node to acquire the scope from.
102
+ - `inner` - Optional boolean. When `true`, returns the innermost scope, otherwise returns the outermost scope. Default is `false`.
103
+ - Returns: The acquired scope or `null` if no scope is found.
104
+
105
+ - **`acquireAll(node)` (Deprecated)**
106
+ Acquires all scopes for a given node.
107
+ - `node` - The AST node to acquire scopes from.
108
+ - Returns: An array of scopes or `undefined` if none are found.
109
+
110
+ - **`release(node, inner)`**
111
+ Returns the upper scope for a given node.
112
+ - `node` - The AST node to release.
113
+ - `inner` - Optional boolean. When `true`, returns the innermost upper scope, otherwise returns the outermost upper scope. Default is `false`.
114
+ - Returns: The upper scope or `null` if no upper scope exists.
115
+
116
+ - **`getDeclaredVariables(node)`**
117
+ Get variables that are declared by the node.
118
+ - `node` - The AST node to get declarations from.
119
+ - Returns: An array of variable objects declared by the node. If the node doesn't declare any variables, it returns an empty array.
120
+
121
+ - **`isGlobalReturn()`**
122
+ Determines if the global return statement should be allowed.
123
+ - Returns: `true` if the global return is enabled.
124
+
125
+ - **`isModule()` (Deprecated)**
126
+ Checks if the code should be handled as an ECMAScript module.
127
+ - Returns: `true` if the sourceType is "module".
128
+
129
+ - **`isImpliedStrict()` (Deprecated)**
130
+ Checks if implied strict mode is enabled.
131
+ - Returns: `true` if implied strict mode is enabled.
132
+
133
+ - **`isStrictModeSupported()` (Deprecated)**
134
+ Checks if strict mode is supported based on ECMAScript version.
135
+ - Returns: `true` if the ECMAScript version supports strict mode.
136
+
137
+ ### Scope Objects
138
+
139
+ Scopes returned by the ScopeManager methods have the following properties:
140
+
141
+ - `type` - The type of scope (e.g., `"function"`, `"block"`, `"global"`).
142
+ - `isStrict` - `true` if this scope is in strict mode.
143
+ - `variables` - Array of variables declared in this scope.
144
+ - `set` - A Map of variable names to Variable objects for variables declared in this scope.
145
+ - `references` - Array of references in this scope.
146
+ - `through` - Array of references in this scope and its child scopes that aren't resolved in this scope or its child scopes.
147
+ - `functionExpressionScope` - `true` if this is a `"function-expression-name"` scope.
148
+ - `variableScope` - Reference to the closest variable scope.
149
+ - `upper` - Reference to the parent scope.
150
+ - `childScopes` - Array of child scopes.
151
+ - `block` - The AST node that created this scope.
152
+
153
+ ### GlobalScope
154
+
155
+ The `GlobalScope` class is a specialized scope representing the global execution context. It extends the base `Scope` class with additional functionality for handling implicitly defined global variables.
156
+
157
+ #### Properties
158
+
159
+ - **`implicit`** - Tracks implicitly defined global variables (those used without declaration).
160
+ - `set` - A Map of variable names to Variable objects for implicitly defined globals.
161
+ - `variables` - Array of implicit global Variable objects.
162
+ - `left` - Array of References that need to be linked to the variable they refer to.
163
+
164
+ ### Variable Objects
165
+
166
+ Each variable object has the following properties:
167
+
168
+ - `name` - The variable name.
169
+ - `identifiers` - Array of identifier nodes declaring this variable.
170
+ - `references` - Array of references to this variable.
171
+ - `defs` - Array of definition objects for this variable.
172
+ - `scope` - The scope object where this variable is defined.
173
+
174
+ ## Contributing
175
+
176
+ Issues and pull requests will be triaged and responded to as quickly as possible. We operate under the [ESLint Contributor Guidelines](http://eslint.org/docs/developer-guide/contributing), so please be sure to read them before contributing. If you're not sure where to dig in, check out the [issues](https://github.com/eslint/js/issues).
177
+
178
+ ## Security Policy
179
+
180
+ We work hard to ensure that ESLint Scope is safe for everyone and that security issues are addressed quickly and responsibly. Read the full [security policy](https://github.com/eslint/.github/blob/master/SECURITY.md).
181
+
182
+ ## Build Commands
183
+
184
+ - `npm test` - run all linting and tests
185
+ - `npm run lint` - run all linting
186
+
187
+ ## License
188
+
189
+ ESLint Scope is licensed under a permissive BSD 2-clause license.
190
+
191
+ <!-- NOTE: This section is autogenerated. Do not manually edit.-->
192
+ <!--sponsorsstart-->
193
+
194
+ ## Sponsors
195
+
196
+ The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://eslint.org/donate)
197
+ to get your logo on our READMEs and [website](https://eslint.org/sponsors).
198
+
199
+ <h3>Platinum Sponsors</h3>
200
+ <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>
201
+ <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>
202
+ <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>
203
+ <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>
204
+ <h3>Technology Sponsors</h3>
205
+ 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.
206
+ <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>
207
+ <!--sponsorsend-->
node_modules/eslint-scope/lib/assert.js ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview Assertion utilities.
3
+ * @author Nicholas C. Zakas
4
+ */
5
+
6
+ /**
7
+ * Throws an error if the given condition is not truthy.
8
+ * @param {boolean} condition The condition to check.
9
+ * @param {string} message The message to include with the error.
10
+ * @returns {void}
11
+ * @throws {Error} When the condition is not truthy.
12
+ */
13
+ export function assert(condition, message = "Assertion failed.") {
14
+ if (!condition) {
15
+ throw new Error(message);
16
+ }
17
+ }
node_modules/eslint-scope/lib/definition.js ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright
10
+ notice, this list of conditions and the following disclaimer in the
11
+ documentation and/or other materials provided with the distribution.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
+ ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
17
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+ */
24
+
25
+ import Variable from "./variable.js";
26
+
27
+ /** @import * as types from "eslint-scope" */
28
+
29
+ // Cannot implement `types.Definition` directly because it contains a union.
30
+ /**
31
+ * @constructor Definition
32
+ * @implements {Omit<types.Definition, never>}
33
+ */
34
+ class Definition {
35
+ constructor(type, name, node, parent, index, kind) {
36
+ /**
37
+ * @member {string} Definition#type - type of the occurrence (e.g. "Parameter", "Variable", ...).
38
+ */
39
+ this.type = type;
40
+
41
+ /**
42
+ * @member {espree.Identifier} Definition#name - the identifier AST node of the occurrence.
43
+ */
44
+ this.name = name;
45
+
46
+ /**
47
+ * @member {espree.Node} Definition#node - the enclosing node of the identifier.
48
+ */
49
+ this.node = node;
50
+
51
+ /**
52
+ * @member {espree.Node?} Definition#parent - the enclosing statement node of the identifier.
53
+ */
54
+ this.parent = parent;
55
+
56
+ /**
57
+ * @member {number?} Definition#index - the index in the declaration statement.
58
+ */
59
+ this.index = index;
60
+
61
+ /**
62
+ * @member {string?} Definition#kind - the kind of the declaration statement.
63
+ */
64
+ this.kind = kind;
65
+ }
66
+ }
67
+
68
+ /**
69
+ * @constructor ParameterDefinition
70
+ */
71
+ class ParameterDefinition extends Definition {
72
+ constructor(name, node, index, rest) {
73
+ super(Variable.Parameter, name, node, null, index, null);
74
+
75
+ /**
76
+ * Whether the parameter definition is a part of a rest parameter.
77
+ * @member {boolean} ParameterDefinition#rest
78
+ */
79
+ this.rest = rest;
80
+ }
81
+ }
82
+
83
+ export { ParameterDefinition, Definition };
84
+
85
+ /* vim: set sw=4 ts=4 et tw=80 : */
node_modules/eslint-scope/lib/index.d.cts ADDED
@@ -0,0 +1,1152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview This file contains the types for ESLint Scope.
3
+ * It was initially extracted from the DefinitelyTyped repository.
4
+ */
5
+
6
+ /*
7
+ * MIT License
8
+ * Copyright (c) Microsoft Corporation.
9
+ *
10
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ * of this software and associated documentation files (the "Software"), to deal
12
+ * in the Software without restriction, including without limitation the rights
13
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ * copies of the Software, and to permit persons to whom the Software is
15
+ * furnished to do so, subject to the following conditions:
16
+ * The above copyright notice and this permission notice shall be included in all
17
+ * copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ * SOFTWARE
26
+ */
27
+
28
+ //------------------------------------------------------------------------------
29
+ // Imports
30
+ //------------------------------------------------------------------------------
31
+
32
+ import type { Visitor, VisitorOptions } from "esrecurse";
33
+ import type * as ESTree from "estree";
34
+
35
+ //------------------------------------------------------------------------------
36
+ // Helpers
37
+ //------------------------------------------------------------------------------
38
+
39
+ interface JSXIdentifier extends ESTree.BaseNode {
40
+ type: "JSXIdentifier";
41
+ name: string;
42
+ }
43
+
44
+ //------------------------------------------------------------------------------
45
+ // Exports
46
+ //------------------------------------------------------------------------------
47
+
48
+ /**
49
+ * Options for scope analysis.
50
+ */
51
+ export interface AnalyzeOptions {
52
+ /**
53
+ * Whether to ignore `eval()` calls, which normally create scopes.
54
+ * @default false
55
+ */
56
+ ignoreEval?: boolean;
57
+
58
+ /**
59
+ * Whether to create a top-level function scope for CommonJS evaluation.
60
+ * @default false
61
+ */
62
+ nodejsScope?: boolean;
63
+
64
+ /**
65
+ * Whether to evaluate code in strict mode even outside modules or without `"use strict"`.
66
+ * @default false
67
+ */
68
+ impliedStrict?: boolean;
69
+
70
+ /**
71
+ * The ECMAScript version to use for evaluation (e.g., `5`, `2015`, `2022`).
72
+ * @default 5
73
+ */
74
+ ecmaVersion?: number;
75
+
76
+ /**
77
+ * The type of JavaScript file to evaluate.
78
+ * @default "script"
79
+ */
80
+ sourceType?: "script" | "module" | "commonjs";
81
+
82
+ /**
83
+ * Visitor key information for performance enhancement.
84
+ * @default null
85
+ */
86
+ childVisitorKeys?: {
87
+ readonly [type: string]: ReadonlyArray<string>;
88
+ } | null;
89
+
90
+ /**
91
+ * Strategy to use when `childVisitorKeys` is not specified.
92
+ * @default "iteration"
93
+ */
94
+ fallback?: "iteration" | ((node: ESTree.Node) => string[]);
95
+
96
+ /**
97
+ * Whether to enable optimistic scope analysis.
98
+ * @default false
99
+ */
100
+ optimistic?: boolean;
101
+
102
+ /**
103
+ * Enables the tracking of JSX components as variable references.
104
+ * @default false
105
+ */
106
+ jsx?: boolean;
107
+ }
108
+
109
+ /**
110
+ * Callback function for pattern visitors.
111
+ */
112
+ export type PatternVisitorCallback = (
113
+ pattern: ESTree.Identifier,
114
+ misc: {
115
+ topLevel: boolean;
116
+ rest: boolean;
117
+ assignments: ESTree.AssignmentPattern[];
118
+ },
119
+ ) => void;
120
+
121
+ /**
122
+ * Manages the scope hierarchy of an AST.
123
+ */
124
+ export class ScopeManager {
125
+ /**
126
+ * Creates a new `ScopeManager` instance.
127
+ * @param options Options for scope analysis.
128
+ */
129
+ constructor(options: AnalyzeOptions);
130
+
131
+ /**
132
+ * The global scope, initially set to `null`.
133
+ */
134
+ globalScope: GlobalScope | null;
135
+
136
+ /**
137
+ * All scopes in the analyzed program.
138
+ */
139
+ scopes: Scope[];
140
+
141
+ /**
142
+ * Adds variables to the global scope and resolves references to them.
143
+ * @param names An array of strings, the names of variables to add to the global scope.
144
+ * @returns void
145
+ */
146
+ addGlobals(names: ReadonlyArray<string>): void;
147
+
148
+ /**
149
+ * Acquires the scope for a given node.
150
+ * @param node The AST node to get the scope for.
151
+ * @param inner Whether to get the innermost scope. (default: `false`)
152
+ * @returns The scope or null if not found.
153
+ */
154
+ acquire(node: ESTree.Node, inner?: boolean): Scope | null;
155
+
156
+ /**
157
+ * acquire all scopes from node.
158
+ * @param node node for the acquired scope.
159
+ * @returns Scope array
160
+ * @deprecated
161
+ */
162
+ acquireAll(node: ESTree.Node): Scope[] | null;
163
+
164
+ /**
165
+ * Releases a scope, moving to its parent.
166
+ * @param node The AST node to release the scope for.
167
+ * @param inner Whether to release the innermost scope. (default: `false`)
168
+ * @returns The parent scope or null if not found.
169
+ */
170
+ release(node: ESTree.Node, inner?: boolean): Scope | null;
171
+
172
+ /**
173
+ * Gets all scopes for a given node, including parents.
174
+ * @param node The AST node to get scopes for.
175
+ * @param inner Whether to start from the innermost scope.
176
+ * @returns Array of scopes or empty array if none found.
177
+ */
178
+ getDeclaredVariables(node: ESTree.Node): Variable[];
179
+
180
+ /**
181
+ * Determines if the global return statement should be allowed.
182
+ * @returns `true` if the global return is enabled.
183
+ */
184
+ isGlobalReturn(): boolean;
185
+
186
+ /** @deprecated */
187
+ isModule(): boolean;
188
+
189
+ /** @deprecated */
190
+ isImpliedStrict(): boolean;
191
+
192
+ /** @deprecated */
193
+ isStrictModeSupported(): boolean;
194
+
195
+ /** @deprecated */
196
+ attach(): void;
197
+
198
+ /** @deprecated */
199
+ detach(): void;
200
+ }
201
+
202
+ /**
203
+ * Base export class for all scopes.
204
+ */
205
+ export class Scope<
206
+ TVariable extends Variable = Variable,
207
+ TReference extends Reference = Reference,
208
+ > {
209
+ /**
210
+ * Creates a new `Scope` instance.
211
+ * @param scopeManager The scope manager this scope belongs to.
212
+ * @param type The type of the scope.
213
+ * @param upperScope The parent scope, or null for the global scope.
214
+ * @param block The AST node that created this scope.
215
+ * @param isMethodDefinition Whether this scope is for a method definition.
216
+ */
217
+ constructor(
218
+ scopeManager: ScopeManager,
219
+ type: typeof this.type,
220
+ upperScope: Scope | null,
221
+ block: ESTree.Node,
222
+ isMethodDefinition: boolean,
223
+ );
224
+
225
+ /**
226
+ * The type of the scope (e.g., 'global', 'function').
227
+ */
228
+ type:
229
+ | "block"
230
+ | "catch"
231
+ | "class"
232
+ | "class-field-initializer"
233
+ | "class-static-block"
234
+ | "for"
235
+ | "function"
236
+ | "function-expression-name"
237
+ | "global"
238
+ | "module"
239
+ | "switch"
240
+ | "with";
241
+
242
+ /**
243
+ * Whether the scope is in strict mode.
244
+ */
245
+ isStrict: boolean;
246
+
247
+ /**
248
+ * The parent scope, or null for the global scope.
249
+ */
250
+ upper: Scope | null;
251
+
252
+ /**
253
+ * The scope where variables are declared (same as this for most scopes).
254
+ */
255
+ variableScope: Scope;
256
+
257
+ /**
258
+ * Variables defined in this scope.
259
+ */
260
+ variables: TVariable[];
261
+
262
+ /**
263
+ * References to variables in this scope.
264
+ */
265
+ references: TReference[];
266
+
267
+ /**
268
+ * Child scopes.
269
+ */
270
+ childScopes: Scope[];
271
+
272
+ /**
273
+ * The AST node that created this scope.
274
+ */
275
+ block: ESTree.Node;
276
+
277
+ /**
278
+ * Whether this is a function expression scope.
279
+ */
280
+ functionExpressionScope: boolean;
281
+
282
+ /**
283
+ * Map of variable names to variables.
284
+ */
285
+ set: Map<string, TVariable>;
286
+
287
+ /**
288
+ * The tainted variables of this scope.
289
+ * @deprecated
290
+ */
291
+ taints: Map<string, TVariable>;
292
+
293
+ /**
294
+ * References that pass through this scope to outer scopes.
295
+ */
296
+ through: TReference[];
297
+
298
+ /**
299
+ * Dynamic flag for certain scope types.
300
+ * @deprecated
301
+ */
302
+ dynamic: boolean;
303
+
304
+ /**
305
+ * Direct call to eval() flag.
306
+ * @deprecated
307
+ */
308
+ directCallToEvalScope: boolean;
309
+
310
+ /**
311
+ * This scope flag.
312
+ * @deprecated
313
+ */
314
+ thisFound: boolean;
315
+
316
+ /**
317
+ * Resolves a reference in this scope.
318
+ * @param ident An AST node to get their reference object.
319
+ * @deprecated
320
+ */
321
+ resolve(ident: ESTree.Identifier): TReference | null;
322
+
323
+ /**
324
+ * Whether the reference is static.
325
+ * @deprecated
326
+ */
327
+ isStatic(): boolean;
328
+
329
+ /**
330
+ * Returns whether this scope has materialized arguments.
331
+ * @deprecated
332
+ */
333
+ isArgumentsMaterialized(): boolean;
334
+
335
+ /**
336
+ * Returns whether this scope has materialized `this` reference.
337
+ * @deprecated
338
+ */
339
+ isThisMaterialized(): boolean;
340
+
341
+ /** @deprecated */
342
+ isUsedName(name: string): boolean;
343
+ }
344
+
345
+ /**
346
+ * Global scope.
347
+ */
348
+ export class GlobalScope extends Scope {
349
+ /**
350
+ * Creates a new GlobalScope instance.
351
+ * @param scopeManager The scope manager this scope belongs to.
352
+ * @param block The AST node that created this scope.
353
+ */
354
+ constructor(scopeManager: ScopeManager, block: ESTree.Node);
355
+
356
+ type: "global";
357
+
358
+ functionExpressionScope: false;
359
+
360
+ isArgumentsMaterialized(): true;
361
+
362
+ isThisMaterialized(): true;
363
+
364
+ /**
365
+ * Implicit references (e.g., 'arguments' in functions).
366
+ */
367
+ implicit: {
368
+ left: Reference[];
369
+ set: Map<string, Variable>;
370
+ variables: Variable[];
371
+ };
372
+ }
373
+
374
+ /**
375
+ * Module scope.
376
+ */
377
+ export class ModuleScope extends Scope {
378
+ /**
379
+ * Creates a new ModuleScope instance.
380
+ * @param scopeManager The scope manager this scope belongs to.
381
+ * @param upperScope The parent scope.
382
+ * @param block The AST node that created this scope.
383
+ */
384
+ constructor(
385
+ scopeManager: ScopeManager,
386
+ upperScope: Scope,
387
+ block: ESTree.Node,
388
+ );
389
+
390
+ type: "module";
391
+
392
+ functionExpressionScope: false;
393
+
394
+ isArgumentsMaterialized(): true;
395
+
396
+ isThisMaterialized(): true;
397
+ }
398
+
399
+ /**
400
+ * Function expression name scope.
401
+ */
402
+ export class FunctionExpressionNameScope extends Scope {
403
+ /**
404
+ * Creates a new FunctionExpressionNameScope instance.
405
+ * @param scopeManager The scope manager this scope belongs to.
406
+ * @param upperScope The parent scope.
407
+ * @param block The AST node that created this scope.
408
+ */
409
+ constructor(
410
+ scopeManager: ScopeManager,
411
+ upperScope: Scope,
412
+ block: ESTree.Node,
413
+ );
414
+
415
+ type: "function-expression-name";
416
+
417
+ functionExpressionScope: true;
418
+
419
+ isArgumentsMaterialized(): true;
420
+
421
+ isThisMaterialized(): true;
422
+ }
423
+
424
+ /**
425
+ * Catch scope.
426
+ */
427
+ export class CatchScope extends Scope {
428
+ /**
429
+ * Creates a new CatchScope instance.
430
+ * @param scopeManager The scope manager this scope belongs to.
431
+ * @param upperScope The parent scope.
432
+ * @param block The AST node that created this scope.
433
+ */
434
+ constructor(
435
+ scopeManager: ScopeManager,
436
+ upperScope: Scope,
437
+ block: ESTree.Node,
438
+ );
439
+
440
+ type: "catch";
441
+
442
+ functionExpressionScope: false;
443
+
444
+ isArgumentsMaterialized(): true;
445
+
446
+ isThisMaterialized(): true;
447
+ }
448
+
449
+ /**
450
+ * With scope.
451
+ */
452
+ export class WithScope extends Scope {
453
+ /**
454
+ * Creates a new WithScope instance.
455
+ * @param scopeManager The scope manager this scope belongs to.
456
+ * @param upperScope The parent scope.
457
+ * @param block The AST node that created this scope.
458
+ */
459
+ constructor(
460
+ scopeManager: ScopeManager,
461
+ upperScope: Scope,
462
+ block: ESTree.Node,
463
+ );
464
+
465
+ type: "with";
466
+
467
+ functionExpressionScope: false;
468
+
469
+ isArgumentsMaterialized(): true;
470
+
471
+ isThisMaterialized(): true;
472
+ }
473
+
474
+ /**
475
+ * Block scope.
476
+ */
477
+ export class BlockScope extends Scope {
478
+ /**
479
+ * Creates a new BlockScope instance.
480
+ * @param scopeManager The scope manager this scope belongs to.
481
+ * @param upperScope The parent scope.
482
+ * @param block The AST node that created this scope.
483
+ */
484
+ constructor(
485
+ scopeManager: ScopeManager,
486
+ upperScope: Scope,
487
+ block: ESTree.Node,
488
+ );
489
+
490
+ type: "block";
491
+
492
+ functionExpressionScope: false;
493
+
494
+ isArgumentsMaterialized(): true;
495
+
496
+ isThisMaterialized(): true;
497
+ }
498
+
499
+ /**
500
+ * Switch scope.
501
+ */
502
+ export class SwitchScope extends Scope {
503
+ /**
504
+ * Creates a new SwitchScope instance.
505
+ * @param scopeManager The scope manager this scope belongs to.
506
+ * @param upperScope The parent scope.
507
+ * @param block The AST node that created this scope.
508
+ */
509
+ constructor(
510
+ scopeManager: ScopeManager,
511
+ upperScope: Scope,
512
+ block: ESTree.Node,
513
+ );
514
+
515
+ type: "switch";
516
+
517
+ functionExpressionScope: false;
518
+
519
+ isArgumentsMaterialized(): true;
520
+
521
+ isThisMaterialized(): true;
522
+ }
523
+
524
+ /**
525
+ * Function scope.
526
+ */
527
+ export class FunctionScope extends Scope {
528
+ /**
529
+ * Creates a new FunctionScope instance.
530
+ * @param scopeManager The scope manager this scope belongs to.
531
+ * @param upperScope The parent scope.
532
+ * @param block The AST node that created this scope.
533
+ * @param isMethodDefinition Whether this scope is for a method definition.
534
+ */
535
+ constructor(
536
+ scopeManager: ScopeManager,
537
+ upperScope: Scope,
538
+ block: ESTree.Node,
539
+ isMethodDefinition: boolean,
540
+ );
541
+
542
+ type: "function";
543
+
544
+ functionExpressionScope: false;
545
+ }
546
+
547
+ /**
548
+ * Scope of for, for-in, and for-of statements.
549
+ */
550
+ export class ForScope extends Scope {
551
+ /**
552
+ * Creates a new ForScope instance.
553
+ * @param scopeManager The scope manager this scope belongs to.
554
+ * @param upperScope The parent scope.
555
+ * @param block The AST node that created this scope.
556
+ */
557
+ constructor(
558
+ scopeManager: ScopeManager,
559
+ upperScope: Scope,
560
+ block: ESTree.Node,
561
+ );
562
+
563
+ type: "for";
564
+
565
+ functionExpressionScope: false;
566
+
567
+ isArgumentsMaterialized(): true;
568
+
569
+ isThisMaterialized(): true;
570
+ }
571
+
572
+ /**
573
+ * Class scope.
574
+ */
575
+ export class ClassScope extends Scope {
576
+ /**
577
+ * Creates a new ClassScope instance.
578
+ * @param scopeManager The scope manager this scope belongs to.
579
+ * @param upperScope The parent scope.
580
+ * @param block The AST node that created this scope.
581
+ */
582
+ constructor(
583
+ scopeManager: ScopeManager,
584
+ upperScope: Scope,
585
+ block: ESTree.Node,
586
+ );
587
+
588
+ type: "class";
589
+
590
+ functionExpressionScope: false;
591
+
592
+ isArgumentsMaterialized(): true;
593
+
594
+ isThisMaterialized(): true;
595
+ }
596
+
597
+ /**
598
+ * Class field initializer scope.
599
+ */
600
+ export class ClassFieldInitializerScope extends Scope {
601
+ /**
602
+ * Creates a new ClassFieldInitializerScope instance.
603
+ * @param scopeManager The scope manager this scope belongs to.
604
+ * @param upperScope The parent scope.
605
+ * @param block The AST node that created this scope.
606
+ */
607
+ constructor(
608
+ scopeManager: ScopeManager,
609
+ upperScope: Scope,
610
+ block: ESTree.Node,
611
+ );
612
+
613
+ type: "class-field-initializer";
614
+
615
+ functionExpressionScope: false;
616
+
617
+ isArgumentsMaterialized(): true;
618
+
619
+ isThisMaterialized(): true;
620
+ }
621
+
622
+ /**
623
+ * Class static block scope.
624
+ */
625
+ export class ClassStaticBlockScope extends Scope {
626
+ /**
627
+ * Creates a new ClassStaticBlockScope instance.
628
+ * @param scopeManager The scope manager this scope belongs to.
629
+ * @param upperScope The parent scope.
630
+ * @param block The AST node that created this scope.
631
+ */
632
+ constructor(
633
+ scopeManager: ScopeManager,
634
+ upperScope: Scope,
635
+ block: ESTree.Node,
636
+ );
637
+
638
+ type: "class-static-block";
639
+
640
+ functionExpressionScope: false;
641
+
642
+ isArgumentsMaterialized(): true;
643
+
644
+ isThisMaterialized(): true;
645
+ }
646
+
647
+ /**
648
+ * Represents a variable in a scope.
649
+ */
650
+ export class Variable<TReference extends Reference = Reference> {
651
+ static readonly CatchClause: "CatchClause";
652
+ static readonly Parameter: "Parameter";
653
+ static readonly FunctionName: "FunctionName";
654
+ static readonly ClassName: "ClassName";
655
+ static readonly Variable: "Variable";
656
+ static readonly ImportBinding: "ImportBinding";
657
+ static readonly ImplicitGlobalVariable: "ImplicitGlobalVariable";
658
+
659
+ /**
660
+ * Creates a new Variable instance.
661
+ * @param name The name of the variable.
662
+ * @param scope The scope where the variable is defined.
663
+ */
664
+ constructor(name: string, scope: Scope);
665
+
666
+ /**
667
+ * The name of the variable.
668
+ */
669
+ name: string;
670
+
671
+ /**
672
+ * The scope where the variable is defined.
673
+ */
674
+ scope: Scope;
675
+
676
+ /**
677
+ * Identifiers that declare this variable.
678
+ */
679
+ identifiers: ESTree.Identifier[];
680
+
681
+ /**
682
+ * References to this variable.
683
+ */
684
+ references: TReference[];
685
+
686
+ /**
687
+ * Definitions of this variable.
688
+ */
689
+ defs: Definition[];
690
+
691
+ /**
692
+ * Whether the variable is tainted (e.g., potentially modified externally).
693
+ * @deprecated
694
+ */
695
+ tainted: boolean;
696
+
697
+ /**
698
+ * Stack flag for certain variable types.
699
+ * @deprecated
700
+ */
701
+ stack: boolean;
702
+ }
703
+
704
+ /**
705
+ * Represents a reference to a variable.
706
+ */
707
+ export class Reference {
708
+ static readonly READ: 1;
709
+ static readonly WRITE: 2;
710
+ static readonly RW: 3;
711
+
712
+ /**
713
+ * Creates a new Reference instance.
714
+ * @param ident The identifier node of the reference.
715
+ * @param scope The scope where the reference occurs.
716
+ * @param flag The reference flag (read, write, or read-write).
717
+ * @param writeExpr The expression being written, if applicable.
718
+ * @param maybeImplicitGlobal Information about a possible global variable, if applicable.
719
+ * @param partial Whether this is a partial reference.
720
+ * @param init Whether this is an initialization reference.
721
+ */
722
+ constructor(
723
+ ident: ESTree.Identifier | JSXIdentifier,
724
+ scope: Scope,
725
+ flag: number,
726
+ writeExpr: ESTree.Expression | null,
727
+ maybeImplicitGlobal: {
728
+ pattern: ESTree.Pattern;
729
+ node: ESTree.Node;
730
+ } | null,
731
+ partial: boolean,
732
+ init: boolean,
733
+ );
734
+
735
+ /**
736
+ * The identifier node of the reference.
737
+ */
738
+ identifier: ESTree.Identifier | JSXIdentifier;
739
+
740
+ /**
741
+ * The variable being referenced, or null if unresolved.
742
+ */
743
+ resolved: Variable | null;
744
+
745
+ /**
746
+ * Whether the reference is static.
747
+ * @deprecated
748
+ */
749
+ isStatic(): boolean;
750
+
751
+ /**
752
+ * Whether this is a write operation.
753
+ */
754
+ isWrite(): boolean;
755
+
756
+ /**
757
+ * Whether this is a read operation.
758
+ */
759
+ isRead(): boolean;
760
+
761
+ /**
762
+ * The scope where the reference occurs.
763
+ */
764
+ from: Scope;
765
+
766
+ /**
767
+ * Whether the reference comes from a dynamic scope (such as 'eval',
768
+ * 'with', etc.), and may be trapped by dynamic scopes.
769
+ * @deprecated
770
+ */
771
+ tainted: boolean;
772
+
773
+ /**
774
+ * The expression being written, if applicable.
775
+ */
776
+ writeExpr?: ESTree.Expression | null;
777
+
778
+ /**
779
+ * Whether this is a partial reference.
780
+ * @deprecated
781
+ */
782
+ partial?: boolean;
783
+
784
+ /**
785
+ * Whether this is an initialization reference.
786
+ */
787
+ init?: boolean;
788
+
789
+ /**
790
+ * Whether this reference is only read.
791
+ * @returns True if the reference is read-only.
792
+ */
793
+ isReadOnly(): boolean;
794
+
795
+ /**
796
+ * Whether this reference is only written.
797
+ * @returns True if the reference is write-only.
798
+ */
799
+ isWriteOnly(): boolean;
800
+
801
+ /**
802
+ * Whether this reference is read-write.
803
+ * @returns True if the reference is read-write.
804
+ */
805
+ isReadWrite(): boolean;
806
+
807
+ /** @deprecated */
808
+ flag: number;
809
+ }
810
+
811
+ /**
812
+ * Represents a variable definition.
813
+ */
814
+ export const Definition: {
815
+ /**
816
+ * Creates a new Definition instance.
817
+ * @param type The type of definition (e.g., 'Variable', 'Parameter').
818
+ * @param name The identifier node of the definition.
819
+ * @param node The AST node where the definition occurs.
820
+ * @param parent The parent node, if applicable.
821
+ * @param index The index of the definition in a pattern, if applicable.
822
+ * @param kind The kind of variable (e.g., 'var', 'let', 'const'), if applicable.
823
+ */
824
+ new (
825
+ type: Definition["type"],
826
+ name: ESTree.Identifier,
827
+ node: Definition["node"],
828
+ parent: Definition["parent"],
829
+ index: number | null,
830
+ kind: string | null,
831
+ ): Definition;
832
+ };
833
+
834
+ export type Definition = (
835
+ | { type: "CatchClause"; node: ESTree.CatchClause; parent: null }
836
+ | {
837
+ type: "ClassName";
838
+ node: ESTree.ClassDeclaration | ESTree.ClassExpression;
839
+ parent: null;
840
+ }
841
+ | {
842
+ type: "FunctionName";
843
+ node: ESTree.FunctionDeclaration | ESTree.FunctionExpression;
844
+ parent: null;
845
+ }
846
+ | {
847
+ type: "ImplicitGlobalVariable";
848
+ node:
849
+ | ESTree.AssignmentExpression
850
+ | ESTree.ForInStatement
851
+ | ESTree.ForOfStatement;
852
+ parent: null;
853
+ }
854
+ | {
855
+ type: "ImportBinding";
856
+ node:
857
+ | ESTree.ImportSpecifier
858
+ | ESTree.ImportDefaultSpecifier
859
+ | ESTree.ImportNamespaceSpecifier;
860
+ parent: ESTree.ImportDeclaration;
861
+ }
862
+ | {
863
+ type: "Parameter";
864
+ node:
865
+ | ESTree.FunctionDeclaration
866
+ | ESTree.FunctionExpression
867
+ | ESTree.ArrowFunctionExpression;
868
+ parent: null;
869
+ }
870
+ | {
871
+ type: "Variable";
872
+ node: ESTree.VariableDeclarator;
873
+ parent: ESTree.VariableDeclaration;
874
+ }
875
+ ) & {
876
+ /**
877
+ * The identifier node of the definition.
878
+ */
879
+ name: ESTree.Identifier;
880
+
881
+ /**
882
+ * The index of the definition in a pattern, if applicable.
883
+ * @deprecated
884
+ */
885
+ index: number | null;
886
+
887
+ /**
888
+ * The kind of variable (e.g., 'var', 'let', 'const'), if applicable.
889
+ * @deprecated
890
+ */
891
+ kind: string | null;
892
+ };
893
+
894
+ /**
895
+ * Visitor for destructuring patterns.
896
+ */
897
+ export class PatternVisitor extends Visitor {
898
+ static isPattern(
899
+ node: ESTree.Node,
900
+ ): node is
901
+ | ESTree.Identifier
902
+ | ESTree.ObjectPattern
903
+ | ESTree.ArrayPattern
904
+ | ESTree.SpreadElement
905
+ | ESTree.RestElement
906
+ | ESTree.AssignmentPattern;
907
+
908
+ constructor(
909
+ options: VisitorOptions | null | undefined,
910
+ rootPattern: ESTree.Pattern,
911
+ callback: PatternVisitorCallback,
912
+ );
913
+
914
+ rootPattern: ESTree.Pattern;
915
+
916
+ callback: PatternVisitorCallback;
917
+
918
+ assignments: Array<ESTree.AssignmentExpression | ESTree.AssignmentPattern>;
919
+
920
+ rightHandNodes: ESTree.Node[];
921
+
922
+ restElements: ESTree.RestElement[];
923
+
924
+ Identifier(pattern: ESTree.Identifier): void;
925
+
926
+ Property(pattern: ESTree.Property): void;
927
+
928
+ ArrayPattern(pattern: ESTree.ArrayPattern): void;
929
+
930
+ AssignmentPattern(pattern: ESTree.AssignmentPattern): void;
931
+
932
+ RestElement(pattern: ESTree.RestElement): void;
933
+
934
+ MemberExpression(pattern: ESTree.MemberExpression): void;
935
+
936
+ SpreadElement(pattern: ESTree.SpreadElement): void;
937
+
938
+ ArrayExpression(pattern: ESTree.ArrayExpression): void;
939
+
940
+ AssignmentExpression(pattern: ESTree.AssignmentExpression): void;
941
+
942
+ CallExpression(pattern: ESTree.CallExpression): void;
943
+ }
944
+
945
+ /**
946
+ * Visitor class for traversing AST nodes and creating variable references and bindings.
947
+ */
948
+ export class Referencer extends Visitor {
949
+ /**
950
+ * Creates a new Referencer instance.
951
+ * @param options Options for scope analysis.
952
+ * @param scopeManager The scope manager to use.
953
+ */
954
+ constructor(
955
+ options: VisitorOptions | null | undefined,
956
+ scopeManager: ScopeManager,
957
+ );
958
+
959
+ /**
960
+ * Options for scope analysis.
961
+ */
962
+ options: VisitorOptions | null | undefined;
963
+
964
+ /**
965
+ * The scope manager being used.
966
+ */
967
+ scopeManager: ScopeManager;
968
+
969
+ /**
970
+ * The parent node.
971
+ */
972
+ parent: ESTree.Node | null;
973
+
974
+ /**
975
+ * Whether currently inside a method definition.
976
+ */
977
+ isInnerMethodDefinition: boolean;
978
+
979
+ /**
980
+ * Gets the current scope.
981
+ * @returns The current scope.
982
+ */
983
+ currentScope(): Scope;
984
+
985
+ /**
986
+ * Closes scopes up to the given node.
987
+ * @param node The AST node.
988
+ */
989
+ close(node: ESTree.Node): void;
990
+
991
+ /**
992
+ * Pushes a new inner method definition state.
993
+ * @param isInnerMethodDefinition Whether inside a method definition.
994
+ * @returns The previous state.
995
+ */
996
+ pushInnerMethodDefinition(isInnerMethodDefinition: boolean): boolean;
997
+
998
+ /**
999
+ * Pops the inner method definition state.
1000
+ * @param isInnerMethodDefinition The state to restore.
1001
+ */
1002
+ popInnerMethodDefinition(isInnerMethodDefinition: boolean): void;
1003
+
1004
+ /**
1005
+ * References default values in patterns.
1006
+ * @param pattern The pattern.
1007
+ * @param assignments The assignments.
1008
+ * @param maybeImplicitGlobal Information about a possible implicit global.
1009
+ * @param init Whether this is an initialization.
1010
+ */
1011
+ referencingDefaultValue(
1012
+ pattern: ESTree.Pattern,
1013
+ assignments: Array<
1014
+ ESTree.AssignmentExpression | ESTree.AssignmentPattern
1015
+ >,
1016
+ maybeImplicitGlobal: {
1017
+ pattern: ESTree.Pattern;
1018
+ node: ESTree.Node;
1019
+ } | null,
1020
+ init: boolean,
1021
+ ): void;
1022
+
1023
+ /**
1024
+ * Visits a pattern node.
1025
+ * @param node The pattern node.
1026
+ * @param options Options or callback.
1027
+ * @param callback The callback function.
1028
+ */
1029
+ visitPattern(
1030
+ node: ESTree.Pattern,
1031
+ options: { processRightHandNodes: boolean } | PatternVisitorCallback,
1032
+ callback?: PatternVisitorCallback,
1033
+ ): void;
1034
+
1035
+ /**
1036
+ * Visits a function node.
1037
+ * @param node The function node.
1038
+ */
1039
+ visitFunction(
1040
+ node:
1041
+ | ESTree.FunctionDeclaration
1042
+ | ESTree.FunctionExpression
1043
+ | ESTree.ArrowFunctionExpression,
1044
+ ): void;
1045
+
1046
+ /**
1047
+ * Visits a class node.
1048
+ * @param node The class node.
1049
+ */
1050
+ visitClass(node: ESTree.ClassDeclaration | ESTree.ClassExpression): void;
1051
+
1052
+ /**
1053
+ * Visits a property node.
1054
+ * @param node The property node.
1055
+ */
1056
+ visitProperty(node: ESTree.Property | ESTree.MethodDefinition): void;
1057
+
1058
+ /**
1059
+ * Visits a for-in or for-of statement.
1060
+ * @param node The for-in or for-of node.
1061
+ */
1062
+ visitForIn(node: ESTree.ForInStatement | ESTree.ForOfStatement): void;
1063
+
1064
+ /**
1065
+ * Visits a variable declaration.
1066
+ * @param variableTargetScope The scope where the variable should be defined.
1067
+ * @param type The variable type.
1068
+ * @param node The variable declaration node.
1069
+ * @param index The index of the declarator.
1070
+ */
1071
+ visitVariableDeclaration(
1072
+ variableTargetScope: Scope,
1073
+ type: typeof Variable.Variable,
1074
+ node: ESTree.VariableDeclaration,
1075
+ index: number,
1076
+ ): void;
1077
+
1078
+ /**
1079
+ * Visits an export declaration.
1080
+ * @param node The export declaration node.
1081
+ */
1082
+ visitExportDeclaration(
1083
+ node:
1084
+ | ESTree.ExportAllDeclaration
1085
+ | ESTree.ExportDefaultDeclaration
1086
+ | ESTree.ExportNamedDeclaration,
1087
+ ): void;
1088
+
1089
+ AssignmentExpression(node: ESTree.AssignmentExpression): void;
1090
+ CatchClause(node: ESTree.CatchClause): void;
1091
+ Program(node: ESTree.Program): void;
1092
+ Identifier(node: ESTree.Identifier): void;
1093
+ PrivateIdentifier(): void;
1094
+ UpdateExpression(node: ESTree.UpdateExpression): void;
1095
+ MemberExpression(node: ESTree.MemberExpression): void;
1096
+ Property(node: ESTree.Property): void;
1097
+ PropertyDefinition(node: ESTree.PropertyDefinition): void;
1098
+ StaticBlock(node: ESTree.StaticBlock): void;
1099
+ MethodDefinition(node: ESTree.MethodDefinition): void;
1100
+ BreakStatement(): void;
1101
+ ContinueStatement(): void;
1102
+ LabeledStatement(node: ESTree.LabeledStatement): void;
1103
+ ForStatement(node: ESTree.ForStatement): void;
1104
+ ClassExpression(node: ESTree.ClassExpression): void;
1105
+ ClassDeclaration(node: ESTree.ClassDeclaration): void;
1106
+ CallExpression(node: ESTree.CallExpression): void;
1107
+ BlockStatement(node: ESTree.BlockStatement): void;
1108
+ ThisExpression(): void;
1109
+ WithStatement(node: ESTree.WithStatement): void;
1110
+ VariableDeclaration(node: ESTree.VariableDeclaration): void;
1111
+ SwitchStatement(node: ESTree.SwitchStatement): void;
1112
+ FunctionDeclaration(node: ESTree.FunctionDeclaration): void;
1113
+ FunctionExpression(node: ESTree.FunctionExpression): void;
1114
+ ForOfStatement(node: ESTree.ForOfStatement): void;
1115
+ ForInStatement(node: ESTree.ForInStatement): void;
1116
+ ArrowFunctionExpression(node: ESTree.ArrowFunctionExpression): void;
1117
+ ImportDeclaration(node: ESTree.ImportDeclaration): void;
1118
+ ExportDeclaration(
1119
+ node:
1120
+ | ESTree.ExportAllDeclaration
1121
+ | ESTree.ExportDefaultDeclaration
1122
+ | ESTree.ExportNamedDeclaration,
1123
+ ): void;
1124
+ ExportAllDeclaration(node: ESTree.ExportAllDeclaration): void;
1125
+ ExportDefaultDeclaration(node: ESTree.ExportDefaultDeclaration): void;
1126
+ ExportNamedDeclaration(node: ESTree.ExportNamedDeclaration): void;
1127
+ ExportSpecifier(node: ESTree.ExportSpecifier): void;
1128
+ MetaProperty(): void;
1129
+ JSXIdentifier(node: JSXIdentifier): void;
1130
+ JSXMemberExpression(node: any): void;
1131
+ JSXElement(node: any): void;
1132
+ JSXOpeningElement(node: any): void;
1133
+ JSXAttribute(node: any): void;
1134
+ JSXExpressionContainer(node: any): void;
1135
+ JSXNamespacedName(node: any): void;
1136
+ }
1137
+
1138
+ /**
1139
+ * Analyzes the scope of an AST.
1140
+ * @param ast The ESTree-compliant AST to analyze.
1141
+ * @param options Options for scope analysis.
1142
+ * @returns The scope manager for the analyzed AST.
1143
+ */
1144
+ export function analyze(
1145
+ ast: ESTree.Program,
1146
+ options?: AnalyzeOptions,
1147
+ ): ScopeManager;
1148
+
1149
+ /**
1150
+ * The version of ESLint Scope.
1151
+ */
1152
+ export const version: string;
node_modules/eslint-scope/lib/index.d.ts ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ /**
2
+ * @fileoverview ESLint Scope types in ESM format.
3
+ * @author Francesco Trotta
4
+ */
5
+
6
+ export * from "./index.cjs";
node_modules/eslint-scope/lib/index.js ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright (C) 2012-2014 Yusuke Suzuki <utatane.tea@gmail.com>
3
+ Copyright (C) 2013 Alex Seville <hi@alexanderseville.com>
4
+ Copyright (C) 2014 Thiago de Arruda <tpadilha84@gmail.com>
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above copyright
10
+ notice, this list of conditions and the following disclaimer.
11
+ * Redistributions in binary form must reproduce the above copyright
12
+ notice, this list of conditions and the following disclaimer in the
13
+ documentation and/or other materials provided with the distribution.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
+ ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
19
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25
+ */
26
+
27
+ /**
28
+ * Escope (<a href="http://github.com/estools/escope">escope</a>) is an <a
29
+ * href="http://www.ecma-international.org/publications/standards/Ecma-262.htm">ECMAScript</a>
30
+ * scope analyzer extracted from the <a
31
+ * href="http://github.com/estools/esmangle">esmangle project</a/>.
32
+ * <p>
33
+ * <em>escope</em> finds lexical scopes in a source program, i.e. areas of that
34
+ * program where different occurrences of the same identifier refer to the same
35
+ * variable. With each scope the contained variables are collected, and each
36
+ * identifier reference in code is linked to its corresponding variable (if
37
+ * possible).
38
+ * <p>
39
+ * <em>escope</em> works on a syntax tree of the parsed source code which has
40
+ * to adhere to the <a
41
+ * href="https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API">
42
+ * Mozilla Parser API</a>. E.g. <a href="https://github.com/eslint/espree">espree</a> is a parser
43
+ * that produces such syntax trees.
44
+ * <p>
45
+ * The main interface is the {@link analyze} function.
46
+ * @module escope
47
+ */
48
+
49
+ import { assert } from "./assert.js";
50
+
51
+ import ScopeManager from "./scope-manager.js";
52
+ import Referencer from "./referencer.js";
53
+ import Reference from "./reference.js";
54
+ import Variable from "./variable.js";
55
+
56
+ /** @import ESTree from "estree" */
57
+
58
+ /**
59
+ * Set the default options
60
+ * @returns {Object} options
61
+ */
62
+ function defaultOptions() {
63
+ return {
64
+ optimistic: false,
65
+ nodejsScope: false,
66
+ impliedStrict: false,
67
+ sourceType: "script", // one of ['script', 'module', 'commonjs']
68
+ ecmaVersion: 5,
69
+ childVisitorKeys: null,
70
+ fallback: "iteration",
71
+ };
72
+ }
73
+
74
+ /**
75
+ * Preform deep update on option object
76
+ * @param {Record<string, unknown>} target Options
77
+ * @param {Record<string, unknown>} override Updates
78
+ * @returns {Record<string, unknown>} Updated options
79
+ */
80
+ function updateDeeply(target, override) {
81
+ /**
82
+ * Is hash object
83
+ * @param {Object} value Test value
84
+ * @returns {value is Record<string, unknown>} Result
85
+ */
86
+ function isHashObject(value) {
87
+ return (
88
+ typeof value === "object" &&
89
+ value instanceof Object &&
90
+ !(value instanceof Array) &&
91
+ !(value instanceof RegExp)
92
+ );
93
+ }
94
+
95
+ for (const key in override) {
96
+ if (Object.hasOwn(override, key)) {
97
+ const val = override[key];
98
+
99
+ if (isHashObject(val)) {
100
+ if (isHashObject(target[key])) {
101
+ updateDeeply(target[key], val);
102
+ } else {
103
+ target[key] = updateDeeply({}, val);
104
+ }
105
+ } else {
106
+ target[key] = val;
107
+ }
108
+ }
109
+ }
110
+ return target;
111
+ }
112
+
113
+ /**
114
+ * Main interface function. Takes an Espree syntax tree and returns the
115
+ * analyzed scopes.
116
+ * @function analyze
117
+ * @param {ESTree.Program} tree Abstract Syntax Tree
118
+ * @param {Object} providedOptions Options that tailor the scope analysis
119
+ * @param {boolean} [providedOptions.optimistic=false] the optimistic flag
120
+ * @param {boolean} [providedOptions.ignoreEval=false] whether to check 'eval()' calls
121
+ * @param {boolean} [providedOptions.nodejsScope=false] whether the whole
122
+ * script is executed under node.js environment. When enabled, escope adds
123
+ * a function scope immediately following the global scope.
124
+ * @param {boolean} [providedOptions.impliedStrict=false] implied strict mode
125
+ * (if ecmaVersion >= 5).
126
+ * @param {string} [providedOptions.sourceType='script'] the source type of the script. one of 'script', 'module', and 'commonjs'
127
+ * @param {number} [providedOptions.ecmaVersion=5] which ECMAScript version is considered
128
+ * @param {boolean} [providedOptions.jsx=false] support JSX references
129
+ * @param {Object} [providedOptions.childVisitorKeys=null] Additional known visitor keys. See [esrecurse](https://github.com/estools/esrecurse)'s the `childVisitorKeys` option.
130
+ * @param {string} [providedOptions.fallback='iteration'] A kind of the fallback in order to encounter with unknown node. See [esrecurse](https://github.com/estools/esrecurse)'s the `fallback` option.
131
+ * @returns {ScopeManager} ScopeManager
132
+ */
133
+ function analyze(tree, providedOptions) {
134
+ const options = updateDeeply(defaultOptions(), providedOptions);
135
+ const scopeManager = new ScopeManager(options);
136
+ const referencer = new Referencer(options, scopeManager);
137
+
138
+ referencer.visit(tree);
139
+
140
+ assert(
141
+ scopeManager.__currentScope === null,
142
+ "currentScope should be null.",
143
+ );
144
+
145
+ return scopeManager;
146
+ }
147
+
148
+ /** @name module:escope.version */
149
+ export const version = "9.1.2"; // x-release-please-version
150
+
151
+ export {
152
+ /** @name module:escope.Reference */
153
+ Reference,
154
+
155
+ /** @name module:escope.Variable */
156
+ Variable,
157
+
158
+ /** @name module:escope.ScopeManager */
159
+ ScopeManager,
160
+
161
+ /** @name module:escope.Referencer */
162
+ Referencer,
163
+ analyze,
164
+ };
165
+
166
+ /** @name module:escope.Definition */
167
+ export { Definition } from "./definition.js";
168
+
169
+ /** @name module:escope.PatternVisitor */
170
+ export { default as PatternVisitor } from "./pattern-visitor.js";
171
+
172
+ /** @name module:escope.Scope */
173
+ export { Scope } from "./scope.js";
174
+
175
+ /* vim: set sw=4 ts=4 et tw=80 : */
node_modules/eslint-scope/lib/pattern-visitor.js ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright
10
+ notice, this list of conditions and the following disclaimer in the
11
+ documentation and/or other materials provided with the distribution.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
+ ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
17
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+ */
24
+
25
+ import estraverse from "estraverse";
26
+ import esrecurse from "esrecurse";
27
+
28
+ /** @import * as types from "eslint-scope" */
29
+
30
+ const { Syntax } = estraverse;
31
+
32
+ /**
33
+ * Get last array element
34
+ * @param {Array} xs array
35
+ * @returns {any} Last elment
36
+ */
37
+ function getLast(xs) {
38
+ return xs.at(-1) || null;
39
+ }
40
+
41
+ /**
42
+ * Visitor for destructuring patterns.
43
+ * @implements {types.PatternVisitor}
44
+ */
45
+ class PatternVisitor extends esrecurse.Visitor {
46
+ static isPattern(node) {
47
+ const nodeType = node.type;
48
+
49
+ return (
50
+ nodeType === Syntax.Identifier ||
51
+ nodeType === Syntax.ObjectPattern ||
52
+ nodeType === Syntax.ArrayPattern ||
53
+ nodeType === Syntax.SpreadElement ||
54
+ nodeType === Syntax.RestElement ||
55
+ nodeType === Syntax.AssignmentPattern
56
+ );
57
+ }
58
+
59
+ constructor(options, rootPattern, callback) {
60
+ super(null, options);
61
+ this.rootPattern = rootPattern;
62
+ this.callback = callback;
63
+ this.assignments = [];
64
+ this.rightHandNodes = [];
65
+ this.restElements = [];
66
+ }
67
+
68
+ Identifier(pattern) {
69
+ const lastRestElement = getLast(this.restElements);
70
+
71
+ this.callback(pattern, {
72
+ topLevel: pattern === this.rootPattern,
73
+ rest:
74
+ lastRestElement !== null &&
75
+ lastRestElement !== void 0 &&
76
+ lastRestElement.argument === pattern,
77
+ assignments: this.assignments,
78
+ });
79
+ }
80
+
81
+ Property(property) {
82
+ // Computed property's key is a right hand node.
83
+ if (property.computed) {
84
+ this.rightHandNodes.push(property.key);
85
+ }
86
+
87
+ // If it's shorthand, its key is same as its value.
88
+ // If it's shorthand and has its default value, its key is same as its value.left (the value is AssignmentPattern).
89
+ // If it's not shorthand, the name of new variable is its value's.
90
+ this.visit(property.value);
91
+ }
92
+
93
+ ArrayPattern(pattern) {
94
+ for (let i = 0, iz = pattern.elements.length; i < iz; ++i) {
95
+ const element = pattern.elements[i];
96
+
97
+ this.visit(element);
98
+ }
99
+ }
100
+
101
+ AssignmentPattern(pattern) {
102
+ this.assignments.push(pattern);
103
+ this.visit(pattern.left);
104
+ this.rightHandNodes.push(pattern.right);
105
+ this.assignments.pop();
106
+ }
107
+
108
+ RestElement(pattern) {
109
+ this.restElements.push(pattern);
110
+ this.visit(pattern.argument);
111
+ this.restElements.pop();
112
+ }
113
+
114
+ MemberExpression(node) {
115
+ // Computed property's key is a right hand node.
116
+ if (node.computed) {
117
+ this.rightHandNodes.push(node.property);
118
+ }
119
+
120
+ // the object is only read, write to its property.
121
+ this.rightHandNodes.push(node.object);
122
+ }
123
+
124
+ //
125
+ // ForInStatement.left and AssignmentExpression.left are LeftHandSideExpression.
126
+ // By spec, LeftHandSideExpression is Pattern or MemberExpression.
127
+ // (see also: https://github.com/estree/estree/pull/20#issuecomment-74584758)
128
+ // But espree 2.0 parses to ArrayExpression, ObjectExpression, etc...
129
+ //
130
+
131
+ SpreadElement(node) {
132
+ this.visit(node.argument);
133
+ }
134
+
135
+ ArrayExpression(node) {
136
+ node.elements.forEach(this.visit, this);
137
+ }
138
+
139
+ AssignmentExpression(node) {
140
+ this.assignments.push(node);
141
+ this.visit(node.left);
142
+ this.rightHandNodes.push(node.right);
143
+ this.assignments.pop();
144
+ }
145
+
146
+ CallExpression(node) {
147
+ // arguments are right hand nodes.
148
+ node.arguments.forEach(a => {
149
+ this.rightHandNodes.push(a);
150
+ });
151
+ this.visit(node.callee);
152
+ }
153
+ }
154
+
155
+ export default PatternVisitor;
156
+
157
+ /* vim: set sw=4 ts=4 et tw=80 : */
node_modules/eslint-scope/lib/reference.js ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright
10
+ notice, this list of conditions and the following disclaimer in the
11
+ documentation and/or other materials provided with the distribution.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
+ ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
17
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+ */
24
+
25
+ /** @import * as types from "eslint-scope" */
26
+
27
+ const READ = 0x1;
28
+ const WRITE = 0x2;
29
+ const RW = READ | WRITE;
30
+
31
+ /**
32
+ * A Reference represents a single occurrence of an identifier in code.
33
+ * @constructor Reference
34
+ * @implements {types.Reference}
35
+ */
36
+ class Reference {
37
+ constructor(
38
+ ident,
39
+ scope,
40
+ flag,
41
+ writeExpr,
42
+ maybeImplicitGlobal,
43
+ partial,
44
+ init,
45
+ ) {
46
+ /**
47
+ * Identifier syntax node.
48
+ * @member {espreeIdentifier} Reference#identifier
49
+ */
50
+ this.identifier = ident;
51
+
52
+ /**
53
+ * Reference to the enclosing Scope.
54
+ * @member {Scope} Reference#from
55
+ */
56
+ this.from = scope;
57
+
58
+ /**
59
+ * Whether the reference comes from a dynamic scope (such as 'eval',
60
+ * 'with', etc.), and may be trapped by dynamic scopes.
61
+ * @member {boolean} Reference#tainted
62
+ */
63
+ this.tainted = false;
64
+
65
+ /**
66
+ * The variable this reference is resolved with.
67
+ * @member {Variable} Reference#resolved
68
+ */
69
+ this.resolved = null;
70
+
71
+ /**
72
+ * The read-write mode of the reference. (Value is one of {@link
73
+ * Reference.READ}, {@link Reference.RW}, {@link Reference.WRITE}).
74
+ * @member {number} Reference#flag
75
+ */
76
+ this.flag = flag;
77
+ if (this.isWrite()) {
78
+ /**
79
+ * If reference is writeable, this is the tree being written to it.
80
+ * @member {espreeNode} Reference#writeExpr
81
+ */
82
+ this.writeExpr = writeExpr;
83
+
84
+ /**
85
+ * Whether the Reference might refer to a partial value of writeExpr.
86
+ * @member {boolean} Reference#partial
87
+ */
88
+ this.partial = partial;
89
+
90
+ /**
91
+ * Whether the Reference is to write of initialization.
92
+ * @member {boolean} Reference#init
93
+ */
94
+ this.init = init;
95
+ }
96
+ this.__maybeImplicitGlobal = maybeImplicitGlobal;
97
+ }
98
+
99
+ /**
100
+ * Whether the reference is static.
101
+ * @function Reference#isStatic
102
+ * @returns {boolean} static
103
+ */
104
+ isStatic() {
105
+ return (
106
+ !this.tainted && !!this.resolved && this.resolved.scope.isStatic()
107
+ );
108
+ }
109
+
110
+ /**
111
+ * Whether the reference is writeable.
112
+ * @function Reference#isWrite
113
+ * @returns {boolean} write
114
+ */
115
+ isWrite() {
116
+ return !!(this.flag & Reference.WRITE);
117
+ }
118
+
119
+ /**
120
+ * Whether the reference is readable.
121
+ * @function Reference#isRead
122
+ * @returns {boolean} read
123
+ */
124
+ isRead() {
125
+ return !!(this.flag & Reference.READ);
126
+ }
127
+
128
+ /**
129
+ * Whether the reference is read-only.
130
+ * @function Reference#isReadOnly
131
+ * @returns {boolean} read only
132
+ */
133
+ isReadOnly() {
134
+ return this.flag === Reference.READ;
135
+ }
136
+
137
+ /**
138
+ * Whether the reference is write-only.
139
+ * @function Reference#isWriteOnly
140
+ * @returns {boolean} write only
141
+ */
142
+ isWriteOnly() {
143
+ return this.flag === Reference.WRITE;
144
+ }
145
+
146
+ /**
147
+ * Whether the reference is read-write.
148
+ * @function Reference#isReadWrite
149
+ * @returns {boolean} read write
150
+ */
151
+ isReadWrite() {
152
+ return this.flag === Reference.RW;
153
+ }
154
+ }
155
+
156
+ /**
157
+ * @constant Reference.READ
158
+ */
159
+ Reference.READ = READ;
160
+
161
+ /**
162
+ * @constant Reference.WRITE
163
+ */
164
+ Reference.WRITE = WRITE;
165
+
166
+ /**
167
+ * @constant Reference.RW
168
+ */
169
+ Reference.RW = RW;
170
+
171
+ export default Reference;
172
+
173
+ /* vim: set sw=4 ts=4 et tw=80 : */
node_modules/eslint-scope/lib/referencer.js ADDED
@@ -0,0 +1,817 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright
10
+ notice, this list of conditions and the following disclaimer in the
11
+ documentation and/or other materials provided with the distribution.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
+ ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
17
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+ */
24
+
25
+ import estraverse from "estraverse";
26
+ import esrecurse from "esrecurse";
27
+ import Reference from "./reference.js";
28
+ import Variable from "./variable.js";
29
+ import PatternVisitor from "./pattern-visitor.js";
30
+ import { Definition, ParameterDefinition } from "./definition.js";
31
+ import { assert } from "./assert.js";
32
+
33
+ /** @import * as types from "eslint-scope" */
34
+ /** @import ESTree from "estree" */
35
+
36
+ const { Syntax } = estraverse;
37
+
38
+ /**
39
+ * Traverse identifier in pattern
40
+ * @param {Object} options options
41
+ * @param {ESTree.Pattern} rootPattern root pattern
42
+ * @param {?Referencer} referencer referencer
43
+ * @param {types.PatternVisitorCallback} callback callback
44
+ * @returns {void}
45
+ */
46
+ function traverseIdentifierInPattern(
47
+ options,
48
+ rootPattern,
49
+ referencer,
50
+ callback,
51
+ ) {
52
+ // Call the callback at left hand identifier nodes, and Collect right hand nodes.
53
+ const visitor = new PatternVisitor(options, rootPattern, callback);
54
+
55
+ visitor.visit(rootPattern);
56
+
57
+ // Process the right hand nodes recursively.
58
+ if (referencer !== null && referencer !== void 0) {
59
+ visitor.rightHandNodes.forEach(referencer.visit, referencer);
60
+ }
61
+ }
62
+
63
+ // Importing ImportDeclaration.
64
+ // http://people.mozilla.org/~jorendorff/es6-draft.html#sec-moduledeclarationinstantiation
65
+ // https://github.com/estree/estree/blob/master/es6.md#importdeclaration
66
+ // FIXME: Now, we don't create module environment, because the context is
67
+ // implementation dependent.
68
+
69
+ /**
70
+ * Visitor for import specifiers.
71
+ */
72
+ class Importer extends esrecurse.Visitor {
73
+ constructor(declaration, referencer) {
74
+ super(null, referencer.options);
75
+ this.declaration = declaration;
76
+ this.referencer = referencer;
77
+ }
78
+
79
+ visitImport(id, specifier) {
80
+ this.referencer.visitPattern(id, pattern => {
81
+ this.referencer
82
+ .currentScope()
83
+ .__define(
84
+ pattern,
85
+ new Definition(
86
+ Variable.ImportBinding,
87
+ pattern,
88
+ specifier,
89
+ this.declaration,
90
+ null,
91
+ null,
92
+ ),
93
+ );
94
+ });
95
+ }
96
+
97
+ ImportNamespaceSpecifier(node) {
98
+ const local = node.local || node.id;
99
+
100
+ if (local) {
101
+ this.visitImport(local, node);
102
+ }
103
+ }
104
+
105
+ ImportDefaultSpecifier(node) {
106
+ const local = node.local || node.id;
107
+
108
+ this.visitImport(local, node);
109
+ }
110
+
111
+ ImportSpecifier(node) {
112
+ const local = node.local || node.id;
113
+
114
+ if (node.name) {
115
+ this.visitImport(node.name, node);
116
+ } else {
117
+ this.visitImport(local, node);
118
+ }
119
+ }
120
+ }
121
+
122
+ /**
123
+ * Referencing variables and creating bindings.
124
+ * @implements {types.Referencer}
125
+ */
126
+ class Referencer extends esrecurse.Visitor {
127
+ constructor(options, scopeManager) {
128
+ super(null, options);
129
+ this.options = options;
130
+ this.scopeManager = scopeManager;
131
+ this.parent = null;
132
+ this.isInnerMethodDefinition = false;
133
+ }
134
+
135
+ currentScope() {
136
+ return this.scopeManager.__currentScope;
137
+ }
138
+
139
+ close(node) {
140
+ while (this.currentScope() && node === this.currentScope().block) {
141
+ this.scopeManager.__currentScope = this.currentScope().__close(
142
+ this.scopeManager,
143
+ );
144
+ }
145
+ }
146
+
147
+ pushInnerMethodDefinition(isInnerMethodDefinition) {
148
+ const previous = this.isInnerMethodDefinition;
149
+
150
+ this.isInnerMethodDefinition = isInnerMethodDefinition;
151
+ return previous;
152
+ }
153
+
154
+ popInnerMethodDefinition(isInnerMethodDefinition) {
155
+ this.isInnerMethodDefinition = isInnerMethodDefinition;
156
+ }
157
+
158
+ referencingDefaultValue(pattern, assignments, maybeImplicitGlobal, init) {
159
+ const scope = this.currentScope();
160
+
161
+ assignments.forEach(assignment => {
162
+ scope.__referencing(
163
+ pattern,
164
+ Reference.WRITE,
165
+ assignment.right,
166
+ maybeImplicitGlobal,
167
+ pattern !== assignment.left,
168
+ init,
169
+ );
170
+ });
171
+ }
172
+
173
+ visitPattern(node, options, callback) {
174
+ let visitPatternOptions = options;
175
+ let visitPatternCallback = callback;
176
+
177
+ if (typeof options === "function") {
178
+ visitPatternCallback = options;
179
+ visitPatternOptions = { processRightHandNodes: false };
180
+ }
181
+
182
+ traverseIdentifierInPattern(
183
+ this.options,
184
+ node,
185
+ visitPatternOptions.processRightHandNodes ? this : null,
186
+ visitPatternCallback,
187
+ );
188
+ }
189
+
190
+ visitFunction(node) {
191
+ let i, iz;
192
+
193
+ // FunctionDeclaration name is defined in upper scope
194
+ // NOTE: Not referring variableScope. It is intended.
195
+ // Since
196
+ // in ES5, FunctionDeclaration should be in FunctionBody.
197
+ // in ES6, FunctionDeclaration should be block scoped.
198
+
199
+ if (node.type === Syntax.FunctionDeclaration) {
200
+ // id is defined in upper scope
201
+ this.currentScope().__define(
202
+ node.id,
203
+ new Definition(
204
+ Variable.FunctionName,
205
+ node.id,
206
+ node,
207
+ null,
208
+ null,
209
+ null,
210
+ ),
211
+ );
212
+ }
213
+
214
+ // FunctionExpression with name creates its special scope;
215
+ // FunctionExpressionNameScope.
216
+ if (node.type === Syntax.FunctionExpression && node.id) {
217
+ this.scopeManager.__nestFunctionExpressionNameScope(node);
218
+ }
219
+
220
+ // Consider this function is in the MethodDefinition.
221
+ this.scopeManager.__nestFunctionScope(
222
+ node,
223
+ this.isInnerMethodDefinition,
224
+ );
225
+
226
+ const that = this;
227
+
228
+ /**
229
+ * Visit pattern callback
230
+ * @param {ESTree.Pattern} pattern pattern
231
+ * @param {Object} info info
232
+ * @returns {void}
233
+ */
234
+ function visitPatternCallback(pattern, info) {
235
+ that.currentScope().__define(
236
+ pattern,
237
+ new ParameterDefinition(pattern, node, i, info.rest),
238
+ );
239
+
240
+ that.referencingDefaultValue(pattern, info.assignments, null, true);
241
+ }
242
+
243
+ // Process parameter declarations.
244
+ for (i = 0, iz = node.params.length; i < iz; ++i) {
245
+ this.visitPattern(
246
+ node.params[i],
247
+ { processRightHandNodes: true },
248
+ visitPatternCallback,
249
+ );
250
+ }
251
+
252
+ // if there's a rest argument, add that
253
+ if (node.rest) {
254
+ this.visitPattern(
255
+ {
256
+ type: "RestElement",
257
+ argument: node.rest,
258
+ },
259
+ pattern => {
260
+ this.currentScope().__define(
261
+ pattern,
262
+ new ParameterDefinition(
263
+ pattern,
264
+ node,
265
+ node.params.length,
266
+ true,
267
+ ),
268
+ );
269
+ },
270
+ );
271
+ }
272
+
273
+ // In TypeScript there are a number of function-like constructs which have no body,
274
+ // so check it exists before traversing
275
+ if (node.body) {
276
+ // Skip BlockStatement to prevent creating BlockStatement scope.
277
+ if (node.body.type === Syntax.BlockStatement) {
278
+ this.visitChildren(node.body);
279
+ } else {
280
+ this.visit(node.body);
281
+ }
282
+ }
283
+
284
+ this.close(node);
285
+ }
286
+
287
+ visitClass(node) {
288
+ if (node.type === Syntax.ClassDeclaration) {
289
+ this.currentScope().__define(
290
+ node.id,
291
+ new Definition(
292
+ Variable.ClassName,
293
+ node.id,
294
+ node,
295
+ null,
296
+ null,
297
+ null,
298
+ ),
299
+ );
300
+ }
301
+
302
+ this.scopeManager.__nestClassScope(node);
303
+
304
+ if (node.id) {
305
+ this.currentScope().__define(
306
+ node.id,
307
+ new Definition(Variable.ClassName, node.id, node),
308
+ );
309
+ }
310
+
311
+ this.visit(node.superClass);
312
+ this.visit(node.body);
313
+
314
+ this.close(node);
315
+ }
316
+
317
+ visitProperty(node) {
318
+ let previous;
319
+
320
+ if (node.computed) {
321
+ this.visit(node.key);
322
+ }
323
+
324
+ const isMethodDefinition = node.type === Syntax.MethodDefinition;
325
+
326
+ if (isMethodDefinition) {
327
+ previous = this.pushInnerMethodDefinition(true);
328
+ }
329
+ this.visit(node.value);
330
+ if (isMethodDefinition) {
331
+ this.popInnerMethodDefinition(previous);
332
+ }
333
+ }
334
+
335
+ visitForIn(node) {
336
+ if (
337
+ node.left.type === Syntax.VariableDeclaration &&
338
+ node.left.kind !== "var"
339
+ ) {
340
+ this.scopeManager.__nestForScope(node);
341
+ }
342
+
343
+ if (node.left.type === Syntax.VariableDeclaration) {
344
+ this.visit(node.left);
345
+ this.visitPattern(node.left.declarations[0].id, pattern => {
346
+ this.currentScope().__referencing(
347
+ pattern,
348
+ Reference.WRITE,
349
+ node.right,
350
+ null,
351
+ true,
352
+ true,
353
+ );
354
+ });
355
+ } else {
356
+ this.visitPattern(
357
+ node.left,
358
+ { processRightHandNodes: true },
359
+ (pattern, info) => {
360
+ let maybeImplicitGlobal = null;
361
+
362
+ if (!this.currentScope().isStrict) {
363
+ maybeImplicitGlobal = {
364
+ pattern,
365
+ node,
366
+ };
367
+ }
368
+ this.referencingDefaultValue(
369
+ pattern,
370
+ info.assignments,
371
+ maybeImplicitGlobal,
372
+ false,
373
+ );
374
+ this.currentScope().__referencing(
375
+ pattern,
376
+ Reference.WRITE,
377
+ node.right,
378
+ maybeImplicitGlobal,
379
+ true,
380
+ false,
381
+ );
382
+ },
383
+ );
384
+ }
385
+ this.visit(node.right);
386
+ this.visit(node.body);
387
+
388
+ this.close(node);
389
+ }
390
+
391
+ visitVariableDeclaration(variableTargetScope, type, node, index) {
392
+ const decl = node.declarations[index];
393
+ const init = decl.init;
394
+
395
+ this.visitPattern(
396
+ decl.id,
397
+ { processRightHandNodes: true },
398
+ (pattern, info) => {
399
+ variableTargetScope.__define(
400
+ pattern,
401
+ new Definition(type, pattern, decl, node, index, node.kind),
402
+ );
403
+
404
+ this.referencingDefaultValue(
405
+ pattern,
406
+ info.assignments,
407
+ null,
408
+ true,
409
+ );
410
+ if (init) {
411
+ this.currentScope().__referencing(
412
+ pattern,
413
+ Reference.WRITE,
414
+ init,
415
+ null,
416
+ !info.topLevel,
417
+ true,
418
+ );
419
+ }
420
+ },
421
+ );
422
+ }
423
+
424
+ AssignmentExpression(node) {
425
+ if (PatternVisitor.isPattern(node.left)) {
426
+ if (node.operator === "=") {
427
+ this.visitPattern(
428
+ node.left,
429
+ { processRightHandNodes: true },
430
+ (pattern, info) => {
431
+ let maybeImplicitGlobal = null;
432
+
433
+ if (!this.currentScope().isStrict) {
434
+ maybeImplicitGlobal = {
435
+ pattern,
436
+ node,
437
+ };
438
+ }
439
+ this.referencingDefaultValue(
440
+ pattern,
441
+ info.assignments,
442
+ maybeImplicitGlobal,
443
+ false,
444
+ );
445
+ this.currentScope().__referencing(
446
+ pattern,
447
+ Reference.WRITE,
448
+ node.right,
449
+ maybeImplicitGlobal,
450
+ !info.topLevel,
451
+ false,
452
+ );
453
+ },
454
+ );
455
+ } else {
456
+ this.currentScope().__referencing(
457
+ node.left,
458
+ Reference.RW,
459
+ node.right,
460
+ );
461
+ }
462
+ } else {
463
+ this.visit(node.left);
464
+ }
465
+ this.visit(node.right);
466
+ }
467
+
468
+ CatchClause(node) {
469
+ this.scopeManager.__nestCatchScope(node);
470
+
471
+ this.visitPattern(
472
+ node.param,
473
+ { processRightHandNodes: true },
474
+ (pattern, info) => {
475
+ this.currentScope().__define(
476
+ pattern,
477
+ new Definition(
478
+ Variable.CatchClause,
479
+ pattern,
480
+ node,
481
+ null,
482
+ null,
483
+ null,
484
+ ),
485
+ );
486
+ this.referencingDefaultValue(
487
+ pattern,
488
+ info.assignments,
489
+ null,
490
+ true,
491
+ );
492
+ },
493
+ );
494
+ this.visit(node.body);
495
+
496
+ this.close(node);
497
+ }
498
+
499
+ Program(node) {
500
+ this.scopeManager.__nestGlobalScope(node);
501
+
502
+ if (this.scopeManager.isGlobalReturn()) {
503
+ // Force strictness of GlobalScope to false when using node.js scope.
504
+ this.currentScope().isStrict = false;
505
+ this.scopeManager.__nestFunctionScope(node, false);
506
+ }
507
+
508
+ if (this.scopeManager.__isES6() && this.scopeManager.isModule()) {
509
+ this.scopeManager.__nestModuleScope(node);
510
+ }
511
+
512
+ if (
513
+ this.scopeManager.isStrictModeSupported() &&
514
+ this.scopeManager.isImpliedStrict()
515
+ ) {
516
+ this.currentScope().isStrict = true;
517
+ }
518
+
519
+ this.visitChildren(node);
520
+ this.close(node);
521
+ }
522
+
523
+ Identifier(node) {
524
+ this.currentScope().__referencing(node);
525
+ }
526
+
527
+ // eslint-disable-next-line class-methods-use-this -- Desired as instance method
528
+ PrivateIdentifier() {
529
+ // Do nothing.
530
+ }
531
+
532
+ UpdateExpression(node) {
533
+ if (PatternVisitor.isPattern(node.argument)) {
534
+ this.currentScope().__referencing(
535
+ node.argument,
536
+ Reference.RW,
537
+ null,
538
+ );
539
+ } else {
540
+ this.visitChildren(node);
541
+ }
542
+ }
543
+
544
+ MemberExpression(node) {
545
+ this.visit(node.object);
546
+ if (node.computed) {
547
+ this.visit(node.property);
548
+ }
549
+ }
550
+
551
+ Property(node) {
552
+ this.visitProperty(node);
553
+ }
554
+
555
+ PropertyDefinition(node) {
556
+ const { computed, key, value } = node;
557
+
558
+ if (computed) {
559
+ this.visit(key);
560
+ }
561
+ if (value) {
562
+ this.scopeManager.__nestClassFieldInitializerScope(value);
563
+ this.visit(value);
564
+ this.close(value);
565
+ }
566
+ }
567
+
568
+ StaticBlock(node) {
569
+ this.scopeManager.__nestClassStaticBlockScope(node);
570
+
571
+ this.visitChildren(node);
572
+
573
+ this.close(node);
574
+ }
575
+
576
+ MethodDefinition(node) {
577
+ this.visitProperty(node);
578
+ }
579
+
580
+ BreakStatement() {} // eslint-disable-line class-methods-use-this -- Desired as instance method
581
+
582
+ ContinueStatement() {} // eslint-disable-line class-methods-use-this -- Desired as instance method
583
+
584
+ LabeledStatement(node) {
585
+ this.visit(node.body);
586
+ }
587
+
588
+ ForStatement(node) {
589
+ // Create ForStatement declaration.
590
+ // NOTE: In ES6, ForStatement dynamically generates
591
+ // per iteration environment. However, escope is
592
+ // a static analyzer, we only generate one scope for ForStatement.
593
+ if (
594
+ node.init &&
595
+ node.init.type === Syntax.VariableDeclaration &&
596
+ node.init.kind !== "var"
597
+ ) {
598
+ this.scopeManager.__nestForScope(node);
599
+ }
600
+
601
+ this.visitChildren(node);
602
+
603
+ this.close(node);
604
+ }
605
+
606
+ ClassExpression(node) {
607
+ this.visitClass(node);
608
+ }
609
+
610
+ ClassDeclaration(node) {
611
+ this.visitClass(node);
612
+ }
613
+
614
+ CallExpression(node) {
615
+ // Check this is direct call to eval
616
+ if (
617
+ !this.scopeManager.__ignoreEval() &&
618
+ node.callee.type === Syntax.Identifier &&
619
+ node.callee.name === "eval"
620
+ ) {
621
+ // NOTE: This should be `variableScope`. Since direct eval call always creates Lexical environment and
622
+ // let / const should be enclosed into it. Only VariableDeclaration affects on the caller's environment.
623
+ this.currentScope().variableScope.__detectEval();
624
+ }
625
+ this.visitChildren(node);
626
+ }
627
+
628
+ BlockStatement(node) {
629
+ if (this.scopeManager.__isES6()) {
630
+ this.scopeManager.__nestBlockScope(node);
631
+ }
632
+
633
+ this.visitChildren(node);
634
+
635
+ this.close(node);
636
+ }
637
+
638
+ ThisExpression() {
639
+ this.currentScope().variableScope.__detectThis();
640
+ }
641
+
642
+ WithStatement(node) {
643
+ this.visit(node.object);
644
+
645
+ // Then nest scope for WithStatement.
646
+ this.scopeManager.__nestWithScope(node);
647
+
648
+ this.visit(node.body);
649
+
650
+ this.close(node);
651
+ }
652
+
653
+ VariableDeclaration(node) {
654
+ const variableTargetScope =
655
+ node.kind === "var"
656
+ ? this.currentScope().variableScope
657
+ : this.currentScope();
658
+
659
+ for (let i = 0, iz = node.declarations.length; i < iz; ++i) {
660
+ const decl = node.declarations[i];
661
+
662
+ this.visitVariableDeclaration(
663
+ variableTargetScope,
664
+ Variable.Variable,
665
+ node,
666
+ i,
667
+ );
668
+ if (decl.init) {
669
+ this.visit(decl.init);
670
+ }
671
+ }
672
+ }
673
+
674
+ // sec 13.11.8
675
+ SwitchStatement(node) {
676
+ this.visit(node.discriminant);
677
+
678
+ if (this.scopeManager.__isES6()) {
679
+ this.scopeManager.__nestSwitchScope(node);
680
+ }
681
+
682
+ for (let i = 0, iz = node.cases.length; i < iz; ++i) {
683
+ this.visit(node.cases[i]);
684
+ }
685
+
686
+ this.close(node);
687
+ }
688
+
689
+ FunctionDeclaration(node) {
690
+ this.visitFunction(node);
691
+ }
692
+
693
+ FunctionExpression(node) {
694
+ this.visitFunction(node);
695
+ }
696
+
697
+ ForOfStatement(node) {
698
+ this.visitForIn(node);
699
+ }
700
+
701
+ ForInStatement(node) {
702
+ this.visitForIn(node);
703
+ }
704
+
705
+ ArrowFunctionExpression(node) {
706
+ this.visitFunction(node);
707
+ }
708
+
709
+ ImportDeclaration(node) {
710
+ assert(
711
+ this.scopeManager.__isES6() && this.scopeManager.isModule(),
712
+ "ImportDeclaration should appear when the mode is ES6 and in the module context.",
713
+ );
714
+
715
+ const importer = new Importer(node, this);
716
+
717
+ importer.visit(node);
718
+ }
719
+
720
+ visitExportDeclaration(node) {
721
+ if (node.source) {
722
+ return;
723
+ }
724
+ if (node.declaration) {
725
+ this.visit(node.declaration);
726
+ return;
727
+ }
728
+
729
+ this.visitChildren(node);
730
+ }
731
+
732
+ // TODO: ExportDeclaration doesn't exist. for bc?
733
+ ExportDeclaration(node) {
734
+ this.visitExportDeclaration(node);
735
+ }
736
+
737
+ ExportAllDeclaration(node) {
738
+ this.visitExportDeclaration(node);
739
+ }
740
+
741
+ ExportDefaultDeclaration(node) {
742
+ this.visitExportDeclaration(node);
743
+ }
744
+
745
+ ExportNamedDeclaration(node) {
746
+ this.visitExportDeclaration(node);
747
+ }
748
+
749
+ ExportSpecifier(node) {
750
+ // TODO: `node.id` doesn't exist. for bc?
751
+ const local = node.id || node.local;
752
+
753
+ this.visit(local);
754
+ }
755
+
756
+ // eslint-disable-next-line class-methods-use-this -- Desired as instance method
757
+ MetaProperty() {
758
+ // do nothing.
759
+ }
760
+
761
+ JSXIdentifier(node) {
762
+ // Special case: "this" should not count as a reference
763
+ if (this.scopeManager.__isJSXEnabled() && node.name !== "this") {
764
+ this.currentScope().__referencing(node);
765
+ }
766
+ }
767
+
768
+ JSXMemberExpression(node) {
769
+ this.visit(node.object);
770
+ }
771
+
772
+ JSXElement(node) {
773
+ if (this.scopeManager.__isJSXEnabled()) {
774
+ this.visit(node.openingElement);
775
+ node.children.forEach(this.visit, this);
776
+ } else {
777
+ this.visitChildren(node);
778
+ }
779
+ }
780
+
781
+ JSXOpeningElement(node) {
782
+ if (this.scopeManager.__isJSXEnabled()) {
783
+ const nameNode = node.name;
784
+ const isComponentName =
785
+ nameNode.type === "JSXIdentifier" &&
786
+ nameNode.name[0].toUpperCase() === nameNode.name[0];
787
+ const isComponent =
788
+ isComponentName || nameNode.type === "JSXMemberExpression";
789
+
790
+ // we only want to visit JSXIdentifier nodes if they are capitalized
791
+ if (isComponent) {
792
+ this.visit(nameNode);
793
+ }
794
+ }
795
+
796
+ node.attributes.forEach(this.visit, this);
797
+ }
798
+
799
+ JSXAttribute(node) {
800
+ if (node.value) {
801
+ this.visit(node.value);
802
+ }
803
+ }
804
+
805
+ JSXExpressionContainer(node) {
806
+ this.visit(node.expression);
807
+ }
808
+
809
+ JSXNamespacedName(node) {
810
+ this.visit(node.namespace);
811
+ this.visit(node.name);
812
+ }
813
+ }
814
+
815
+ export default Referencer;
816
+
817
+ /* vim: set sw=4 ts=4 et tw=80 : */
node_modules/eslint-scope/lib/scope-manager.js ADDED
@@ -0,0 +1,298 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright
10
+ notice, this list of conditions and the following disclaimer in the
11
+ documentation and/or other materials provided with the distribution.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
+ ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
17
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+ */
24
+
25
+ import {
26
+ BlockScope,
27
+ CatchScope,
28
+ ClassFieldInitializerScope,
29
+ ClassStaticBlockScope,
30
+ ClassScope,
31
+ ForScope,
32
+ FunctionExpressionNameScope,
33
+ FunctionScope,
34
+ GlobalScope,
35
+ ModuleScope,
36
+ SwitchScope,
37
+ WithScope,
38
+ } from "./scope.js";
39
+ import { assert } from "./assert.js";
40
+
41
+ /** @import * as types from "eslint-scope" */
42
+ /** @import ESTree from "estree" */
43
+ /** @import { Scope } from "./scope.js" */
44
+ /** @import Variable from "./variable.js" */
45
+
46
+ /**
47
+ * @constructor ScopeManager
48
+ * @implements {types.ScopeManager}
49
+ */
50
+ class ScopeManager {
51
+ constructor(options) {
52
+ this.scopes = [];
53
+ this.globalScope = null;
54
+ this.__nodeToScope = new WeakMap();
55
+ this.__currentScope = null;
56
+ this.__options = options;
57
+ this.__declaredVariables = new WeakMap();
58
+ }
59
+
60
+ __isOptimistic() {
61
+ return this.__options.optimistic;
62
+ }
63
+
64
+ __ignoreEval() {
65
+ return this.__options.ignoreEval;
66
+ }
67
+
68
+ __isJSXEnabled() {
69
+ return this.__options.jsx === true;
70
+ }
71
+
72
+ isGlobalReturn() {
73
+ return (
74
+ this.__options.nodejsScope ||
75
+ this.__options.sourceType === "commonjs"
76
+ );
77
+ }
78
+
79
+ isModule() {
80
+ return this.__options.sourceType === "module";
81
+ }
82
+
83
+ isImpliedStrict() {
84
+ return !!this.__options.impliedStrict;
85
+ }
86
+
87
+ isStrictModeSupported() {
88
+ return this.__options.ecmaVersion >= 5;
89
+ }
90
+
91
+ // Returns appropriate scope for this node.
92
+ __get(node) {
93
+ return this.__nodeToScope.get(node);
94
+ }
95
+
96
+ /**
97
+ * Get variables that are declared by the node.
98
+ *
99
+ * "are declared by the node" means the node is same as `Variable.defs[].node` or `Variable.defs[].parent`.
100
+ * If the node declares nothing, this method returns an empty array.
101
+ * CAUTION: This API is experimental. See https://github.com/estools/escope/pull/69 for more details.
102
+ * @param {ESTree.Node} node a node to get.
103
+ * @returns {Variable[]} variables that declared by the node.
104
+ */
105
+ getDeclaredVariables(node) {
106
+ return this.__declaredVariables.get(node) || [];
107
+ }
108
+
109
+ /**
110
+ * acquire scope from node.
111
+ * @function ScopeManager#acquire
112
+ * @param {ESTree.Node} node node for the acquired scope.
113
+ * @param {?boolean} [inner=false] look up the most inner scope, default value is false.
114
+ * @returns {Scope?} Scope from node
115
+ */
116
+ acquire(node, inner) {
117
+ /**
118
+ * predicate
119
+ * @param {Scope} testScope scope to test
120
+ * @returns {boolean} predicate
121
+ */
122
+ function predicate(testScope) {
123
+ if (
124
+ testScope.type === "function" &&
125
+ testScope.functionExpressionScope
126
+ ) {
127
+ return false;
128
+ }
129
+ return true;
130
+ }
131
+
132
+ const scopes = this.__get(node);
133
+
134
+ if (!scopes || scopes.length === 0) {
135
+ return null;
136
+ }
137
+
138
+ // Heuristic selection from all scopes.
139
+ // If you would like to get all scopes, please use ScopeManager#acquireAll.
140
+ if (scopes.length === 1) {
141
+ return scopes[0];
142
+ }
143
+
144
+ if (inner) {
145
+ for (let i = scopes.length - 1; i >= 0; --i) {
146
+ const scope = scopes[i];
147
+
148
+ if (predicate(scope)) {
149
+ return scope;
150
+ }
151
+ }
152
+ } else {
153
+ for (let i = 0, iz = scopes.length; i < iz; ++i) {
154
+ const scope = scopes[i];
155
+
156
+ if (predicate(scope)) {
157
+ return scope;
158
+ }
159
+ }
160
+ }
161
+
162
+ return null;
163
+ }
164
+
165
+ /**
166
+ * acquire all scopes from node.
167
+ * @function ScopeManager#acquireAll
168
+ * @param {ESTree.Node} node node for the acquired scope.
169
+ * @returns {Scope[]?} Scope array
170
+ */
171
+ acquireAll(node) {
172
+ return this.__get(node);
173
+ }
174
+
175
+ /**
176
+ * release the node.
177
+ * @function ScopeManager#release
178
+ * @param {ESTree.Node} node releasing node.
179
+ * @param {?boolean} [inner=false] look up the most inner scope, default value is false.
180
+ * @returns {Scope?} upper scope for the node.
181
+ */
182
+ release(node, inner) {
183
+ const scopes = this.__get(node);
184
+
185
+ if (scopes && scopes.length) {
186
+ const scope = scopes[0].upper;
187
+
188
+ if (!scope) {
189
+ return null;
190
+ }
191
+ return this.acquire(scope.block, inner);
192
+ }
193
+ return null;
194
+ }
195
+
196
+ /**
197
+ * Add global variables and resolve their references.
198
+ * @function ScopeManager#addGlobals
199
+ * @param {string[]} names Names of global variables to add.
200
+ * @returns {void}
201
+ */
202
+ addGlobals(names) {
203
+ // @ts-ignore -- globalScope must be set before this method is called.
204
+ this.globalScope.__addVariables(names);
205
+ }
206
+
207
+ attach() {} // eslint-disable-line class-methods-use-this -- Desired as instance method
208
+
209
+ detach() {} // eslint-disable-line class-methods-use-this -- Desired as instance method
210
+
211
+ __nestScope(scope) {
212
+ if (scope instanceof GlobalScope) {
213
+ assert(this.__currentScope === null);
214
+ this.globalScope = scope;
215
+ }
216
+ this.__currentScope = scope;
217
+ return scope;
218
+ }
219
+
220
+ __nestGlobalScope(node) {
221
+ return this.__nestScope(new GlobalScope(this, node));
222
+ }
223
+
224
+ __nestBlockScope(node) {
225
+ return this.__nestScope(
226
+ new BlockScope(this, this.__currentScope, node),
227
+ );
228
+ }
229
+
230
+ __nestFunctionScope(node, isMethodDefinition) {
231
+ return this.__nestScope(
232
+ new FunctionScope(
233
+ this,
234
+ this.__currentScope,
235
+ node,
236
+ isMethodDefinition,
237
+ ),
238
+ );
239
+ }
240
+
241
+ __nestForScope(node) {
242
+ return this.__nestScope(new ForScope(this, this.__currentScope, node));
243
+ }
244
+
245
+ __nestCatchScope(node) {
246
+ return this.__nestScope(
247
+ new CatchScope(this, this.__currentScope, node),
248
+ );
249
+ }
250
+
251
+ __nestWithScope(node) {
252
+ return this.__nestScope(new WithScope(this, this.__currentScope, node));
253
+ }
254
+
255
+ __nestClassScope(node) {
256
+ return this.__nestScope(
257
+ new ClassScope(this, this.__currentScope, node),
258
+ );
259
+ }
260
+
261
+ __nestClassFieldInitializerScope(node) {
262
+ return this.__nestScope(
263
+ new ClassFieldInitializerScope(this, this.__currentScope, node),
264
+ );
265
+ }
266
+
267
+ __nestClassStaticBlockScope(node) {
268
+ return this.__nestScope(
269
+ new ClassStaticBlockScope(this, this.__currentScope, node),
270
+ );
271
+ }
272
+
273
+ __nestSwitchScope(node) {
274
+ return this.__nestScope(
275
+ new SwitchScope(this, this.__currentScope, node),
276
+ );
277
+ }
278
+
279
+ __nestModuleScope(node) {
280
+ return this.__nestScope(
281
+ new ModuleScope(this, this.__currentScope, node),
282
+ );
283
+ }
284
+
285
+ __nestFunctionExpressionNameScope(node) {
286
+ return this.__nestScope(
287
+ new FunctionExpressionNameScope(this, this.__currentScope, node),
288
+ );
289
+ }
290
+
291
+ __isES6() {
292
+ return this.__options.ecmaVersion >= 6;
293
+ }
294
+ }
295
+
296
+ export default ScopeManager;
297
+
298
+ /* vim: set sw=4 ts=4 et tw=80 : */
node_modules/eslint-scope/lib/scope.js ADDED
@@ -0,0 +1,852 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright
10
+ notice, this list of conditions and the following disclaimer in the
11
+ documentation and/or other materials provided with the distribution.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
+ ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
17
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+ */
24
+
25
+ import estraverse from "estraverse";
26
+
27
+ import Reference from "./reference.js";
28
+ import Variable from "./variable.js";
29
+ import { Definition } from "./definition.js";
30
+ import { assert } from "./assert.js";
31
+
32
+ /** @import * as types from "eslint-scope" */
33
+ /** @import ESTree from "estree" */
34
+ /** @import ScopeManager from "./scope-manager.js" */
35
+ /** @typedef {ESTree.Function | ESTree.Program | ESTree.StaticBlock} Block */
36
+ /** @typedef {{pattern: unknown, node: unknown}} MaybeImplicitGlobal */
37
+
38
+ const { Syntax } = estraverse;
39
+
40
+ /**
41
+ * Test if scope is struct
42
+ * @param {Scope} scope scope
43
+ * @param {Block} block block
44
+ * @param {boolean} isMethodDefinition is method definition
45
+ * @returns {boolean} is strict scope
46
+ */
47
+ function isStrictScope(scope, block, isMethodDefinition) {
48
+ let body;
49
+
50
+ // When upper scope is exists and strict, inner scope is also strict.
51
+ if (scope.upper && scope.upper.isStrict) {
52
+ return true;
53
+ }
54
+
55
+ if (isMethodDefinition) {
56
+ return true;
57
+ }
58
+
59
+ if (scope.type === "class" || scope.type === "module") {
60
+ return true;
61
+ }
62
+
63
+ if (scope.type === "block" || scope.type === "switch") {
64
+ return false;
65
+ }
66
+
67
+ if (scope.type === "function") {
68
+ if (
69
+ block.type === Syntax.ArrowFunctionExpression &&
70
+ // @ts-ignore -- when block is ArrowFunctionExpression
71
+ block.body.type !== Syntax.BlockStatement
72
+ ) {
73
+ return false;
74
+ }
75
+
76
+ if (block.type === Syntax.Program) {
77
+ body = block;
78
+ } else {
79
+ body = block.body;
80
+ }
81
+
82
+ if (!body) {
83
+ return false;
84
+ }
85
+ } else if (scope.type === "global") {
86
+ body = block;
87
+ } else {
88
+ return false;
89
+ }
90
+
91
+ // Search for a 'use strict' directive.
92
+ // @ts-ignore -- body is a function body
93
+ for (let i = 0, iz = body.body.length; i < iz; ++i) {
94
+ // @ts-ignore -- body is a function body
95
+ const stmt = body.body[i];
96
+
97
+ /*
98
+ * Check if the current statement is a directive.
99
+ * If it isn't, then we're past the directive prologue
100
+ * so stop the search because directives cannot
101
+ * appear after this point.
102
+ *
103
+ * Some parsers set `directive:null` on non-directive
104
+ * statements, so the `typeof` check is safer than
105
+ * checking for property existence.
106
+ */
107
+ if (typeof stmt.directive !== "string") {
108
+ break;
109
+ }
110
+
111
+ if (stmt.directive === "use strict") {
112
+ return true;
113
+ }
114
+ }
115
+
116
+ return false;
117
+ }
118
+
119
+ /**
120
+ * Register scope
121
+ * @param {ScopeManager} scopeManager scope manager
122
+ * @param {Scope} scope scope
123
+ * @returns {void}
124
+ */
125
+ function registerScope(scopeManager, scope) {
126
+ scopeManager.scopes.push(scope);
127
+
128
+ const scopes = scopeManager.__nodeToScope.get(scope.block);
129
+
130
+ if (scopes) {
131
+ scopes.push(scope);
132
+ } else {
133
+ scopeManager.__nodeToScope.set(scope.block, [scope]);
134
+ }
135
+ }
136
+
137
+ /**
138
+ * @constructor Scope
139
+ * @implements {types.Scope}
140
+ */
141
+ class Scope {
142
+ constructor(scopeManager, type, upperScope, block, isMethodDefinition) {
143
+ /**
144
+ * One of "global", "module", "function", "function-expression-name", "block", "switch", "catch", "with", "for",
145
+ * "class", "class-field-initializer", "class-static-block".
146
+ * @member {string} Scope#type
147
+ */
148
+ this.type = type;
149
+
150
+ /**
151
+ * The scoped {@link Variable}s of this scope, as <code>{ Variable.name
152
+ * : Variable }</code>.
153
+ * @member {Map} Scope#set
154
+ */
155
+ this.set = new Map();
156
+
157
+ /**
158
+ * The tainted variables of this scope, as <code>{ Variable.name :
159
+ * boolean }</code>.
160
+ * @member {Map} Scope#taints
161
+ */
162
+ this.taints = new Map();
163
+
164
+ /**
165
+ * Generally, through the lexical scoping of JS you can always know
166
+ * which variable an identifier in the source code refers to. There are
167
+ * a few exceptions to this rule. With 'global' and 'with' scopes you
168
+ * can only decide at runtime which variable a reference refers to.
169
+ * Moreover, if 'eval()' is used in a scope, it might introduce new
170
+ * bindings in this or its parent scopes.
171
+ * All those scopes are considered 'dynamic'.
172
+ * @member {boolean} Scope#dynamic
173
+ */
174
+ this.dynamic = this.type === "global" || this.type === "with";
175
+
176
+ /**
177
+ * A reference to the scope-defining syntax node.
178
+ * @member {espree.Node} Scope#block
179
+ */
180
+ this.block = block;
181
+
182
+ /**
183
+ * The {@link Reference|references} that are not resolved with this scope.
184
+ * @member {Reference[]} Scope#through
185
+ */
186
+ this.through = [];
187
+
188
+ /**
189
+ * The scoped {@link Variable}s of this scope. In the case of a
190
+ * 'function' scope this includes the automatic argument <em>arguments</em> as
191
+ * its first element, as well as all further formal arguments.
192
+ * @member {Variable[]} Scope#variables
193
+ */
194
+ this.variables = [];
195
+
196
+ /**
197
+ * Any variable {@link Reference|reference} found in this scope. This
198
+ * includes occurrences of local variables as well as variables from
199
+ * parent scopes (including the global scope). For local variables
200
+ * this also includes defining occurrences (like in a 'var' statement).
201
+ * In a 'function' scope this does not include the occurrences of the
202
+ * formal parameter in the parameter list.
203
+ * @member {Reference[]} Scope#references
204
+ */
205
+ this.references = [];
206
+
207
+ /**
208
+ * For 'global' and 'function' scopes, this is a self-reference. For
209
+ * other scope types this is the <em>variableScope</em> value of the
210
+ * parent scope.
211
+ * @member {Scope} Scope#variableScope
212
+ */
213
+ this.variableScope =
214
+ this.type === "global" ||
215
+ this.type === "module" ||
216
+ this.type === "function" ||
217
+ this.type === "class-field-initializer" ||
218
+ this.type === "class-static-block"
219
+ ? this
220
+ : upperScope.variableScope;
221
+
222
+ /**
223
+ * Whether this scope is created by a FunctionExpression.
224
+ * @member {boolean} Scope#functionExpressionScope
225
+ */
226
+ this.functionExpressionScope = /** @type {any} */ (false);
227
+
228
+ /**
229
+ * Whether this is a scope that contains an 'eval()' invocation.
230
+ * @member {boolean} Scope#directCallToEvalScope
231
+ */
232
+ this.directCallToEvalScope = false;
233
+
234
+ /**
235
+ * @member {boolean} Scope#thisFound
236
+ */
237
+ this.thisFound = false;
238
+
239
+ /** @type {?Reference[]} */
240
+ this.__left = [];
241
+
242
+ /**
243
+ * Reference to the parent {@link Scope|scope}.
244
+ * @member {Scope} Scope#upper
245
+ */
246
+ this.upper = upperScope;
247
+
248
+ /**
249
+ * Whether 'use strict' is in effect in this scope.
250
+ * @member {boolean} Scope#isStrict
251
+ */
252
+ this.isStrict = scopeManager.isStrictModeSupported()
253
+ ? isStrictScope(this, block, isMethodDefinition)
254
+ : false;
255
+
256
+ /**
257
+ * List of nested {@link Scope}s.
258
+ * @member {Scope[]} Scope#childScopes
259
+ */
260
+ this.childScopes = [];
261
+ if (this.upper) {
262
+ this.upper.childScopes.push(this);
263
+ }
264
+
265
+ this.__declaredVariables = scopeManager.__declaredVariables;
266
+
267
+ registerScope(scopeManager, this);
268
+ }
269
+
270
+ __shouldStaticallyClose(scopeManager) {
271
+ return (
272
+ !this.dynamic ||
273
+ scopeManager.__isOptimistic() ||
274
+ this.type === "global"
275
+ );
276
+ }
277
+
278
+ __staticCloseRef(ref) {
279
+ if (!this.__resolve(ref)) {
280
+ this.__delegateToUpperScope(ref);
281
+ }
282
+ }
283
+
284
+ __dynamicCloseRef(ref) {
285
+ // notify all names are through to global
286
+ let current = this;
287
+
288
+ do {
289
+ current.through.push(ref);
290
+ current = current.upper;
291
+ } while (current);
292
+ }
293
+
294
+ __close(scopeManager) {
295
+ let closeRef;
296
+
297
+ if (this.__shouldStaticallyClose(scopeManager)) {
298
+ closeRef = this.__staticCloseRef;
299
+ } else {
300
+ closeRef = this.__dynamicCloseRef;
301
+ }
302
+
303
+ // Try Resolving all references in this scope.
304
+ // @ts-ignore -- __left should be an array here
305
+ for (let i = 0, iz = this.__left.length; i < iz; ++i) {
306
+ // @ts-ignore -- __left should be an array here
307
+ const ref = this.__left[i];
308
+
309
+ closeRef.call(this, ref);
310
+ }
311
+ this.__left = null;
312
+
313
+ return this.upper;
314
+ }
315
+
316
+ // To override by function scopes.
317
+ // References in default parameters isn't resolved to variables which are in their function body.
318
+ // eslint-disable-next-line class-methods-use-this, no-unused-vars -- Desired as instance method with signature
319
+ __isValidResolution(ref, variable) {
320
+ return true;
321
+ }
322
+
323
+ __resolve(ref) {
324
+ const name = ref.identifier.name;
325
+
326
+ if (!this.set.has(name)) {
327
+ return false;
328
+ }
329
+ const variable = this.set.get(name);
330
+
331
+ if (!this.__isValidResolution(ref, variable)) {
332
+ return false;
333
+ }
334
+ variable.references.push(ref);
335
+ variable.stack =
336
+ variable.stack && ref.from.variableScope === this.variableScope;
337
+ if (ref.tainted) {
338
+ variable.tainted = true;
339
+ this.taints.set(variable.name, true);
340
+ }
341
+ ref.resolved = variable;
342
+
343
+ return true;
344
+ }
345
+
346
+ __delegateToUpperScope(ref) {
347
+ if (this.upper) {
348
+ this.upper.__left.push(ref);
349
+ }
350
+ this.through.push(ref);
351
+ }
352
+
353
+ __addDeclaredVariablesOfNode(variable, node) {
354
+ if (node === null || node === void 0) {
355
+ return;
356
+ }
357
+
358
+ let variables = this.__declaredVariables.get(node);
359
+
360
+ if (variables === null || variables === void 0) {
361
+ variables = [];
362
+ this.__declaredVariables.set(node, variables);
363
+ }
364
+ if (!variables.includes(variable)) {
365
+ variables.push(variable);
366
+ }
367
+ }
368
+
369
+ __defineGeneric(name, set, variables, node, def) {
370
+ let variable;
371
+
372
+ variable = set.get(name);
373
+ if (!variable) {
374
+ variable = new Variable(name, this);
375
+ set.set(name, variable);
376
+ variables.push(variable);
377
+ }
378
+
379
+ if (def) {
380
+ variable.defs.push(def);
381
+ this.__addDeclaredVariablesOfNode(variable, def.node);
382
+ this.__addDeclaredVariablesOfNode(variable, def.parent);
383
+ }
384
+ if (node) {
385
+ variable.identifiers.push(node);
386
+ }
387
+ }
388
+
389
+ __define(node, def) {
390
+ if (node && node.type === Syntax.Identifier) {
391
+ this.__defineGeneric(
392
+ node.name,
393
+ this.set,
394
+ this.variables,
395
+ node,
396
+ def,
397
+ );
398
+ }
399
+ }
400
+
401
+ __referencing(node, assign, writeExpr, maybeImplicitGlobal, partial, init) {
402
+ // because Array element may be null
403
+ if (
404
+ !node ||
405
+ (node.type !== Syntax.Identifier && node.type !== "JSXIdentifier")
406
+ ) {
407
+ return;
408
+ }
409
+
410
+ // Specially handle like `this`.
411
+ if (node.name === "super") {
412
+ return;
413
+ }
414
+
415
+ const ref = new Reference(
416
+ node,
417
+ this,
418
+ assign || Reference.READ,
419
+ writeExpr,
420
+ maybeImplicitGlobal,
421
+ !!partial,
422
+ !!init,
423
+ );
424
+
425
+ this.references.push(ref);
426
+
427
+ // @ts-ignore -- __left should be an array here
428
+ this.__left.push(ref);
429
+ }
430
+
431
+ __detectEval() {
432
+ let current = this;
433
+
434
+ this.directCallToEvalScope = true;
435
+ do {
436
+ current.dynamic = true;
437
+ current = current.upper;
438
+ } while (current);
439
+ }
440
+
441
+ __detectThis() {
442
+ this.thisFound = true;
443
+ }
444
+
445
+ __isClosed() {
446
+ return this.__left === null;
447
+ }
448
+
449
+ /**
450
+ * returns resolved {Reference}
451
+ * @function Scope#resolve
452
+ * @param {ESTree.Identifier} ident identifier to be resolved.
453
+ * @returns {?Reference} reference
454
+ */
455
+ resolve(ident) {
456
+ let ref, i, iz;
457
+
458
+ assert(this.__isClosed(), "Scope should be closed.");
459
+ assert(
460
+ ident.type === Syntax.Identifier,
461
+ "Target should be identifier.",
462
+ );
463
+ for (i = 0, iz = this.references.length; i < iz; ++i) {
464
+ ref = this.references[i];
465
+ if (ref.identifier === ident) {
466
+ return ref;
467
+ }
468
+ }
469
+ return null;
470
+ }
471
+
472
+ /**
473
+ * returns this scope is static
474
+ * @function Scope#isStatic
475
+ * @returns {boolean} static
476
+ */
477
+ isStatic() {
478
+ return !this.dynamic;
479
+ }
480
+
481
+ /**
482
+ * returns this scope has materialized arguments
483
+ * @function Scope#isArgumentsMaterialized
484
+ * @returns {any} arguments materialized
485
+ */ // eslint-disable-next-line class-methods-use-this -- Desired as instance method
486
+ isArgumentsMaterialized() {
487
+ return true;
488
+ }
489
+
490
+ /**
491
+ * returns this scope has materialized `this` reference
492
+ * @function Scope#isThisMaterialized
493
+ * @returns {any} this materialized
494
+ */ // eslint-disable-next-line class-methods-use-this -- Desired as instance method
495
+ isThisMaterialized() {
496
+ return true;
497
+ }
498
+
499
+ isUsedName(name) {
500
+ if (this.set.has(name)) {
501
+ return true;
502
+ }
503
+ for (let i = 0, iz = this.through.length; i < iz; ++i) {
504
+ if (this.through[i].identifier.name === name) {
505
+ return true;
506
+ }
507
+ }
508
+ return false;
509
+ }
510
+ }
511
+
512
+ /**
513
+ * Global scope.
514
+ * @implements {types.GlobalScope}
515
+ */
516
+ class GlobalScope extends Scope {
517
+ constructor(scopeManager, block) {
518
+ super(scopeManager, "global", null, block, false);
519
+ this.implicit = {
520
+ set: new Map(),
521
+
522
+ /** @type {Variable[]} */
523
+ variables: [],
524
+
525
+ /**
526
+ * List of {@link Reference}s that are left to be resolved (i.e. which
527
+ * need to be linked to the variable they refer to).
528
+ * @member {Reference[]} Scope#implicit#left
529
+ * @type {Reference[]}
530
+ */
531
+ left: [],
532
+ };
533
+ }
534
+
535
+ __close(scopeManager) {
536
+ const implicit = [];
537
+
538
+ // @ts-ignore -- __left should be an array here
539
+ for (let i = 0, iz = this.__left.length; i < iz; ++i) {
540
+ // @ts-ignore -- __left should be an array here
541
+ const ref = this.__left[i];
542
+
543
+ if (
544
+ ref.__maybeImplicitGlobal &&
545
+ !this.set.has(ref.identifier.name)
546
+ ) {
547
+ implicit.push(ref.__maybeImplicitGlobal);
548
+ }
549
+ }
550
+
551
+ // create an implicit global variable from assignment expression
552
+ for (let i = 0, iz = implicit.length; i < iz; ++i) {
553
+ const info = implicit[i];
554
+
555
+ this.__defineImplicit(
556
+ info.pattern,
557
+ new Definition(
558
+ Variable.ImplicitGlobalVariable,
559
+ info.pattern,
560
+ info.node,
561
+ null,
562
+ null,
563
+ null,
564
+ ),
565
+ );
566
+ }
567
+
568
+ super.__close(scopeManager);
569
+
570
+ this.implicit.left = [...this.through];
571
+
572
+ return null;
573
+ }
574
+
575
+ __defineImplicit(node, def) {
576
+ if (node && node.type === Syntax.Identifier) {
577
+ this.__defineGeneric(
578
+ node.name,
579
+ this.implicit.set,
580
+ this.implicit.variables,
581
+ node,
582
+ def,
583
+ );
584
+ }
585
+ }
586
+
587
+ __addVariables(names) {
588
+ for (const name of names) {
589
+ this.__defineGeneric(name, this.set, this.variables, null, null);
590
+ }
591
+
592
+ const namesSet = new Set(names);
593
+
594
+ this.through = this.through.filter(reference => {
595
+ const name = reference.identifier.name;
596
+
597
+ if (namesSet.has(name)) {
598
+ const variable = this.set.get(name);
599
+
600
+ reference.resolved = variable;
601
+ variable.references.push(reference);
602
+
603
+ return false;
604
+ }
605
+
606
+ return true;
607
+ });
608
+
609
+ this.implicit.variables = this.implicit.variables.filter(variable => {
610
+ const name = variable.name;
611
+
612
+ if (namesSet.has(name)) {
613
+ this.implicit.set.delete(name);
614
+
615
+ return false;
616
+ }
617
+
618
+ return true;
619
+ });
620
+
621
+ this.implicit.left = this.implicit.left.filter(
622
+ reference => !namesSet.has(reference.identifier.name),
623
+ );
624
+ }
625
+ }
626
+
627
+ /**
628
+ * Module scope.
629
+ * @implements {types.ModuleScope}
630
+ */
631
+ class ModuleScope extends Scope {
632
+ constructor(scopeManager, upperScope, block) {
633
+ super(scopeManager, "module", upperScope, block, false);
634
+ }
635
+ }
636
+
637
+ /**
638
+ * Function expression name scope.
639
+ * @implements {types.FunctionExpressionNameScope}
640
+ */
641
+ class FunctionExpressionNameScope extends Scope {
642
+ constructor(scopeManager, upperScope, block) {
643
+ super(
644
+ scopeManager,
645
+ "function-expression-name",
646
+ upperScope,
647
+ block,
648
+ false,
649
+ );
650
+ this.__define(
651
+ block.id,
652
+ new Definition(
653
+ Variable.FunctionName,
654
+ block.id,
655
+ block,
656
+ null,
657
+ null,
658
+ null,
659
+ ),
660
+ );
661
+ this.functionExpressionScope = /** @type {const} */ (true);
662
+ }
663
+ }
664
+
665
+ /**
666
+ * Catch scope.
667
+ * @implements {types.CatchScope}
668
+ */
669
+ class CatchScope extends Scope {
670
+ constructor(scopeManager, upperScope, block) {
671
+ super(scopeManager, "catch", upperScope, block, false);
672
+ }
673
+ }
674
+
675
+ /**
676
+ * With statement scope.
677
+ * @implements {types.WithScope}
678
+ */
679
+ class WithScope extends Scope {
680
+ constructor(scopeManager, upperScope, block) {
681
+ super(scopeManager, "with", upperScope, block, false);
682
+ }
683
+
684
+ __close(scopeManager) {
685
+ if (this.__shouldStaticallyClose(scopeManager)) {
686
+ return super.__close(scopeManager);
687
+ }
688
+
689
+ // @ts-ignore -- __left should be an array here
690
+ for (let i = 0, iz = this.__left.length; i < iz; ++i) {
691
+ // @ts-ignore -- __left should be an array here
692
+ const ref = this.__left[i];
693
+
694
+ ref.tainted = true;
695
+ this.__delegateToUpperScope(ref);
696
+ }
697
+ this.__left = null;
698
+
699
+ return this.upper;
700
+ }
701
+ }
702
+
703
+ /**
704
+ * Block scope.
705
+ * @implements {types.BlockScope}
706
+ */
707
+ class BlockScope extends Scope {
708
+ constructor(scopeManager, upperScope, block) {
709
+ super(scopeManager, "block", upperScope, block, false);
710
+ }
711
+ }
712
+
713
+ /**
714
+ * Switch scope.
715
+ * @implements {types.SwitchScope}
716
+ */
717
+ class SwitchScope extends Scope {
718
+ constructor(scopeManager, upperScope, block) {
719
+ super(scopeManager, "switch", upperScope, block, false);
720
+ }
721
+ }
722
+
723
+ /**
724
+ * Function scope.
725
+ * @implements {types.FunctionScope}
726
+ */
727
+ class FunctionScope extends Scope {
728
+ constructor(scopeManager, upperScope, block, isMethodDefinition) {
729
+ super(scopeManager, "function", upperScope, block, isMethodDefinition);
730
+
731
+ // section 9.2.13, FunctionDeclarationInstantiation.
732
+ // NOTE Arrow functions never have an arguments objects.
733
+ if (this.block.type !== Syntax.ArrowFunctionExpression) {
734
+ this.__defineArguments();
735
+ }
736
+ }
737
+
738
+ isArgumentsMaterialized() {
739
+ // TODO(Constellation)
740
+ // We can more aggressive on this condition like this.
741
+ //
742
+ // function t() {
743
+ // // arguments of t is always hidden.
744
+ // function arguments() {
745
+ // }
746
+ // }
747
+ if (this.block.type === Syntax.ArrowFunctionExpression) {
748
+ return false;
749
+ }
750
+
751
+ if (!this.isStatic()) {
752
+ return true;
753
+ }
754
+
755
+ const variable = this.set.get("arguments");
756
+
757
+ assert(variable, "Always have arguments variable.");
758
+ return variable.tainted || variable.references.length !== 0;
759
+ }
760
+
761
+ isThisMaterialized() {
762
+ if (!this.isStatic()) {
763
+ return true;
764
+ }
765
+ return this.thisFound;
766
+ }
767
+
768
+ __defineArguments() {
769
+ this.__defineGeneric("arguments", this.set, this.variables, null, null);
770
+ this.taints.set("arguments", true);
771
+ }
772
+
773
+ // References in default parameters isn't resolved to variables which are in their function body.
774
+ // const x = 1
775
+ // function f(a = x) { // This `x` is resolved to the `x` in the outer scope.
776
+ // const x = 2
777
+ // console.log(a)
778
+ // }
779
+ __isValidResolution(ref, variable) {
780
+ // If `options.nodejsScope` is true, `this.block` becomes a Program node.
781
+ if (this.block.type === "Program") {
782
+ return true;
783
+ }
784
+
785
+ const bodyStart = this.block.body.range[0];
786
+
787
+ // It's invalid resolution in the following case:
788
+ return !(
789
+ variable.scope === this &&
790
+ ref.identifier.range[0] < bodyStart && // the reference is in the parameter part.
791
+ variable.defs.every(d => d.name.range[0] >= bodyStart) // the variable is in the body.
792
+ );
793
+ }
794
+ }
795
+
796
+ /**
797
+ * Scope of for, for-in, and for-of statements.
798
+ * @implements {types.ForScope}
799
+ */
800
+ class ForScope extends Scope {
801
+ constructor(scopeManager, upperScope, block) {
802
+ super(scopeManager, "for", upperScope, block, false);
803
+ }
804
+ }
805
+
806
+ /**
807
+ * Class scope.
808
+ * @implements {types.ClassScope}
809
+ */
810
+ class ClassScope extends Scope {
811
+ constructor(scopeManager, upperScope, block) {
812
+ super(scopeManager, "class", upperScope, block, false);
813
+ }
814
+ }
815
+
816
+ /**
817
+ * Class field initializer scope.
818
+ * @implements {types.ClassFieldInitializerScope}
819
+ */
820
+ class ClassFieldInitializerScope extends Scope {
821
+ constructor(scopeManager, upperScope, block) {
822
+ super(scopeManager, "class-field-initializer", upperScope, block, true);
823
+ }
824
+ }
825
+
826
+ /**
827
+ * Class static block scope.
828
+ * @implements {types.ClassStaticBlockScope}
829
+ */
830
+ class ClassStaticBlockScope extends Scope {
831
+ constructor(scopeManager, upperScope, block) {
832
+ super(scopeManager, "class-static-block", upperScope, block, true);
833
+ }
834
+ }
835
+
836
+ export {
837
+ Scope,
838
+ GlobalScope,
839
+ ModuleScope,
840
+ FunctionExpressionNameScope,
841
+ CatchScope,
842
+ WithScope,
843
+ BlockScope,
844
+ SwitchScope,
845
+ FunctionScope,
846
+ ForScope,
847
+ ClassScope,
848
+ ClassFieldInitializerScope,
849
+ ClassStaticBlockScope,
850
+ };
851
+
852
+ /* vim: set sw=4 ts=4 et tw=80 : */
node_modules/eslint-scope/lib/variable.js ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright (C) 2015 Yusuke Suzuki <utatane.tea@gmail.com>
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright
10
+ notice, this list of conditions and the following disclaimer in the
11
+ documentation and/or other materials provided with the distribution.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
+ ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
17
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22
+ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+ */
24
+
25
+ /** @import * as types from "eslint-scope" */
26
+ /** @import Reference from "./reference.js" */
27
+
28
+ /**
29
+ * A Variable represents a locally scoped identifier. These include arguments to
30
+ * functions.
31
+ * @constructor Variable
32
+ * @implements {types.Variable}
33
+ */
34
+ class Variable {
35
+ constructor(name, scope) {
36
+ /**
37
+ * The variable name, as given in the source code.
38
+ * @member {string} Variable#name
39
+ */
40
+ this.name = name;
41
+
42
+ /**
43
+ * List of defining occurrences of this variable (like in 'var ...'
44
+ * statements or as parameter), as AST nodes.
45
+ * @member {espree.Identifier[]} Variable#identifiers
46
+ */
47
+ this.identifiers = [];
48
+
49
+ /**
50
+ * List of {@link Reference|references} of this variable (excluding parameter entries)
51
+ * in its defining scope and all nested scopes. For defining
52
+ * occurrences only see {@link Variable#defs}.
53
+ * @member {Reference[]} Variable#references
54
+ */
55
+ this.references = [];
56
+
57
+ /**
58
+ * List of defining occurrences of this variable (like in 'var ...'
59
+ * statements or as parameter), as custom objects.
60
+ * @member {Definition[]} Variable#defs
61
+ */
62
+ this.defs = [];
63
+
64
+ this.tainted = false;
65
+
66
+ /**
67
+ * Whether this is a stack variable.
68
+ * @member {boolean} Variable#stack
69
+ */
70
+ this.stack = true;
71
+
72
+ /**
73
+ * Reference to the enclosing Scope.
74
+ * @member {Scope} Variable#scope
75
+ */
76
+ this.scope = scope;
77
+ }
78
+ }
79
+
80
+ Variable.CatchClause = "CatchClause";
81
+ Variable.Parameter = "Parameter";
82
+ Variable.FunctionName = "FunctionName";
83
+ Variable.ClassName = "ClassName";
84
+ Variable.Variable = "Variable";
85
+ Variable.ImportBinding = "ImportBinding";
86
+ Variable.ImplicitGlobalVariable = "ImplicitGlobalVariable";
87
+
88
+ export default Variable;
89
+
90
+ /* vim: set sw=4 ts=4 et tw=80 : */
node_modules/eslint-scope/package.json ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "eslint-scope",
3
+ "description": "ECMAScript scope analyzer for ESLint",
4
+ "homepage": "https://github.com/eslint/js/blob/main/packages/eslint-scope/README.md",
5
+ "main": "./dist/eslint-scope.cjs",
6
+ "types": "./lib/index.d.cts",
7
+ "type": "module",
8
+ "exports": {
9
+ ".": {
10
+ "import": {
11
+ "types": "./lib/index.d.ts",
12
+ "default": "./lib/index.js"
13
+ },
14
+ "require": {
15
+ "types": "./lib/index.d.cts",
16
+ "default": "./dist/eslint-scope.cjs"
17
+ }
18
+ },
19
+ "./package.json": "./package.json"
20
+ },
21
+ "version": "9.1.2",
22
+ "engines": {
23
+ "node": "^20.19.0 || ^22.13.0 || >=24"
24
+ },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "https://github.com/eslint/js.git",
28
+ "directory": "packages/eslint-scope"
29
+ },
30
+ "funding": "https://opencollective.com/eslint",
31
+ "keywords": [
32
+ "eslint"
33
+ ],
34
+ "bugs": {
35
+ "url": "https://github.com/eslint/js/issues"
36
+ },
37
+ "license": "BSD-2-Clause",
38
+ "scripts": {
39
+ "build": "rollup -c",
40
+ "lint:types": "attw --pack",
41
+ "pretest": "npm run build",
42
+ "test": "node Makefile.js test && npm run test:types",
43
+ "test:types": "tsc -p tsconfig.json && tsc -p tests/types/tsconfig.json"
44
+ },
45
+ "files": [
46
+ "LICENSE",
47
+ "README.md",
48
+ "lib",
49
+ "dist/eslint-scope.cjs"
50
+ ],
51
+ "dependencies": {
52
+ "@types/esrecurse": "^4.3.1",
53
+ "@types/estree": "^1.0.8",
54
+ "esrecurse": "^4.3.0",
55
+ "estraverse": "^5.2.0"
56
+ },
57
+ "devDependencies": {
58
+ "@typescript-eslint/parser": "^8.7.0",
59
+ "chai": "^6.0.0",
60
+ "eslint": ">=10.0.0-rc.0 <10.0.0 || ^10.0.0",
61
+ "eslint-visitor-keys": "^5.0.1",
62
+ "espree": "^11.2.0",
63
+ "npm-license": "^0.3.3",
64
+ "shelljs": "^0.8.5"
65
+ }
66
+ }