mirror of
https://github.com/djav1985/v-wordpress-plugin-updater.git
synced 2025-10-03 16:20:58 +08:00
up
This commit is contained in:
parent
6a4a98e61a
commit
fa7c686911
3079 changed files with 69340 additions and 562647 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,3 +1,5 @@
|
|||
# Ignore files and directories that should not be tracked by Git
|
||||
.vscode/
|
||||
*.code-workspace
|
||||
update-api/storage/BLACKLIST.json
|
||||
vendor/
|
||||
node_modules/
|
||||
|
|
34
CHANGELOG.md
Normal file
34
CHANGELOG.md
Normal file
|
@ -0,0 +1,34 @@
|
|||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
## Unreleased
|
||||
- Added `vontmnt_get_api_key` helper in mu-plugins to cache API keys and auto-regenerate via the `/api/key` endpoint.
|
||||
- Introduced `send_auth` flag and `KeyController` so keys are retrievable once per regeneration.
|
||||
- Updated installation to use `VONTMNT_UPDATE_KEYREGEN` instead of `VONTMENT_KEY`.
|
||||
- Consolidated `VONTMENT_PLUGINS` and `VONTMENT_THEMES` into a single `VONTMNT_API_URL` constant.
|
||||
- **Split update loops into single-item tasks**: Refactored plugin and theme updaters to use asynchronous per-item processing. Daily update checks now schedule individual `wp_schedule_single_event()` tasks for each plugin/theme instead of processing all items synchronously. Added `vontmnt_plugin_update_single()` and `vontmnt_theme_update_single()` callback functions.
|
||||
- Added comprehensive test coverage for database manager, router dispatching, plugin model uploads, session manager, updater error handling, and URL encoding.
|
||||
|
||||
## 4.0.0
|
||||
- Added PHP_CodeSniffer with WordPress Coding Standards for linting.
|
||||
- Moved validation helpers to `App\Helpers\Validation` and encryption helpers to `App\Helpers\Encryption`.
|
||||
- Added `App\Models\Blacklist` for IP blacklist management and removed `App\Core\Utility`.
|
||||
- Introduced centralized `SessionManager` and `Csrf` utilities, refactored controllers and routing to use them, and replaced `AuthController` with `LoginController`.
|
||||
- Switched router to instantiate controllers, dropped unused account/user/info routes, and added `/api` endpoint.
|
||||
- Updated `LoginController` to render views through `$this` instead of creating a new instance.
|
||||
- Converted controllers to instance methods using `$this->render` and removed the feeds controller and route.
|
||||
- Refined router dispatch to include HTTP method and validate API requests before enforcing authentication.
|
||||
- Streamlined session validation to check only timeout and user agent, moved IP blacklist enforcement to authentication, and added unit tests for session expiry, user-agent changes, and blacklist handling.
|
||||
- Refactored router into a singleton and documented root URL redirection to `/home`.
|
||||
- Restricted table generation helpers in controllers and `SessionManager::isValid` to internal use and updated tests accordingly.
|
||||
- Fixed PHPStan reported issues by initializing variables, adding explicit type annotations, and excluding vendor code from analysis.
|
||||
- Introduced SQLite persistence using Doctrine DBAL with install and cron scripts, and migrated models and controllers to use the database.
|
||||
- Replaced JSON-based blacklist with SQLite table that automatically resets entries after three days.
|
||||
- Moved blacklist table creation to installer script.
|
||||
- Removed `rawurlencode` from updater request parameters to prevent double encoding.
|
||||
- Added `WP_Error` checks after `wp_remote_get` calls to log network failures and skip processing.
|
||||
- Corrected the header in `v-sys-theme-updater.php` so it loads as a plugin.
|
||||
- Updated `SessionManager::requireAuth` to return a boolean and halt routing for blacklisted IPs.
|
||||
- Logged failed package writes in plugin and theme updaters and skipped installation when writes fail.
|
129
README.md
129
README.md
|
@ -55,7 +55,7 @@ The v-wordpress-plugin-updater project is designed to streamline the management
|
|||
| 🧪 | **Testing** | <ul><li>Limited unit tests present, primarily for core classes</li><li>Uses PHPUnit for testing PHP components</li><li>Test coverage appears minimal, mainly functional tests</li></ul> |
|
||||
| ⚡️ | **Performance** | <ul><li>Optimized file checks with caching mechanisms</li><li>Minimized HTTP requests during update checks</li><li>Uses transient caching in WordPress</li></ul> |
|
||||
| 🛡️ | **Security** | <ul><li>Sanitizes and validates external inputs</li><li>Uses nonces for admin actions</li><li>Reads configuration files with restricted permissions</li></ul> |
|
||||
| 📦 | **Dependencies** | <ul><li>PHP standard library</li><li>WordPress core functions</li><li>Configuration files: robots.txt, blacklist.json, php.ini, etc.</li></ul> |
|
||||
| 📦 | **Dependencies** | <ul><li>PHP standard library</li><li>WordPress core functions</li><li>Configuration files: robots.txt, php.ini, etc.</li><li>SQLite database for persistence (e.g., updater.sqlite with blacklist table)</li></ul> |
|
||||
|
||||
---
|
||||
|
||||
|
@ -75,19 +75,27 @@ The v-wordpress-plugin-updater project is designed to streamline the management
|
|||
│ ├── HOSTS
|
||||
│ ├── app
|
||||
│ │ ├── Controllers
|
||||
│ │ │ ├── AccountsController.php
|
||||
│ │ │ ├── ApiController.php
|
||||
│ │ │ ├── AuthController.php
|
||||
│ │ │ ├── HomeController.php
|
||||
│ │ │ ├── InfoController.php
|
||||
│ │ │ ├── LoginController.php
|
||||
│ │ │ ├── LogsController.php
|
||||
│ │ │ ├── PluginsController.php
|
||||
│ │ │ └── ThemesController.php
|
||||
│ │ │ ├── ThemesController.php
|
||||
│ │ │ └── UsersController.php
|
||||
│ │ ├── Core
|
||||
│ │ │ ├── AuthMiddleware.php
|
||||
│ │ │ ├── Controller.php
|
||||
│ │ │ ├── ErrorMiddleware.php
|
||||
│ │ │ ├── Csrf.php
|
||||
│ │ │ ├── ErrorManager.php
|
||||
│ │ │ ├── Router.php
|
||||
│ │ │ └── Utility.php
|
||||
│ │ │ └── SessionManager.php
|
||||
│ │ ├── Helpers
|
||||
│ │ │ ├── Encryption.php
|
||||
│ │ │ ├── MessageHelper.php
|
||||
│ │ │ └── Validation.php
|
||||
│ │ ├── Models
|
||||
│ │ │ ├── Blacklist.php
|
||||
│ │ │ ├── HostsModel.php
|
||||
│ │ │ ├── LogModel.php
|
||||
│ │ │ ├── PluginModel.php
|
||||
|
@ -101,7 +109,10 @@ The v-wordpress-plugin-updater project is designed to streamline the management
|
|||
│ │ ├── login.php
|
||||
│ │ ├── logs.php
|
||||
│ │ ├── plupdate.php
|
||||
│ │ └── thupdate.php
|
||||
│ │ ├── thupdate.php
|
||||
│ │ ├── accounts.php
|
||||
│ │ ├── info.php
|
||||
│ │ └── users.php
|
||||
│ ├── autoload.php
|
||||
│ ├── config.php
|
||||
│ ├── php.ini
|
||||
|
@ -123,7 +134,7 @@ The v-wordpress-plugin-updater project is designed to streamline the management
|
|||
│ │ ├── index.php
|
||||
│ │ └── robots.txt
|
||||
│ └── storage
|
||||
│ ├── BLACKLIST.json
|
||||
│ ├── updater.sqlite
|
||||
│ └── logs
|
||||
│ ├── php_app.log
|
||||
│ ├── plugin.log
|
||||
|
@ -142,7 +153,7 @@ The v-wordpress-plugin-updater project is designed to streamline the management
|
|||
<div class='directory-path' style='padding: 8px 0; color: #666;'>
|
||||
<code><b>⦿ __root__</b></code>
|
||||
<table style='width: 100%; border-collapse: collapse;'>
|
||||
<thead>
|
||||
<thead>
|
||||
<tr style='background-color: #f8f9fa;'>
|
||||
<th style='width: 30%; text-align: left; padding: 8px;'>File Name</th>
|
||||
<th style='text-align: left; padding: 8px;'>Summary</th>
|
||||
|
@ -231,11 +242,15 @@ The v-wordpress-plugin-updater project is designed to streamline the management
|
|||
<th style='width: 30%; text-align: left; padding: 8px;'>File Name</th>
|
||||
<th style='text-align: left; padding: 8px;'>Summary</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr style='border-bottom: 1px solid #eee;'>
|
||||
<td style='padding: 8px;'><b><a href='https://github.com/djav1985/v-wordpress-plugin-updater/blob/master/update-api/app/Models/ThemeModel.php'>ThemeModel.php</a></b></td>
|
||||
<td style='padding: 8px;'>- Manages theme files within the WordPress Update API, enabling retrieval, deletion, and uploading of theme ZIP packages<br>- Facilitates theme lifecycle operations, ensuring proper file handling, validation, and size restrictions to support seamless theme management in the broader update infrastructure.</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr style='border-bottom: 1px solid #eee;'>
|
||||
<td style='padding: 8px;'><b><a href='https://github.com/djav1985/v-wordpress-plugin-updater/blob/master/update-api/app/Models/Blacklist.php'>Blacklist.php</a></b></td>
|
||||
<td style='padding: 8px;'>- Tracks failed login attempts and manages IP blacklisting for the Update API, automatically expiring bans after a defined period to maintain security.</td>
|
||||
</tr>
|
||||
<tr style='border-bottom: 1px solid #eee;'>
|
||||
<td style='padding: 8px;'><b><a href='https://github.com/djav1985/v-wordpress-plugin-updater/blob/master/update-api/app/Models/ThemeModel.php'>ThemeModel.php</a></b></td>
|
||||
<td style='padding: 8px;'>- Manages theme files within the WordPress Update API, enabling retrieval, deletion, and uploading of theme ZIP packages<br>- Facilitates theme lifecycle operations, ensuring proper file handling, validation, and size restrictions to support seamless theme management in the broader update infrastructure.</td>
|
||||
</tr>
|
||||
<tr style='border-bottom: 1px solid #eee;'>
|
||||
<td style='padding: 8px;'><b><a href='https://github.com/djav1985/v-wordpress-plugin-updater/blob/master/update-api/app/Models/HostsModel.php'>HostsModel.php</a></b></td>
|
||||
<td style='padding: 8px;'>- Manages host entries within the WordPress Update API by providing functionalities to retrieve, add, update, and delete host records<br>- Ensures consistent handling of host data, maintains log integrity, and supports dynamic configuration of host access controls, integral to the overall architecture for secure and flexible update management.</td>
|
||||
|
@ -264,10 +279,6 @@ The v-wordpress-plugin-updater project is designed to streamline the management
|
|||
<th style='text-align: left; padding: 8px;'>Summary</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr style='border-bottom: 1px solid #eee;'>
|
||||
<td style='padding: 8px;'><b><a href='https://github.com/djav1985/v-wordpress-plugin-updater/blob/master/update-api/app/Core/Utility.php'>Utility.php</a></b></td>
|
||||
<td style='padding: 8px;'>- Provides utility functions for validating domain names, API keys, slugs, filenames, versions, usernames, and passwords within the WordPress Update API<br>- Manages IP-based security by tracking failed login attempts and maintaining a blacklist, ensuring enhanced security and integrity across the update process<br>- Integral to maintaining data validation standards and safeguarding the API against unauthorized access.</td>
|
||||
</tr>
|
||||
<tr style='border-bottom: 1px solid #eee;'>
|
||||
<td style='padding: 8px;'><b><a href='https://github.com/djav1985/v-wordpress-plugin-updater/blob/master/update-api/app/Core/Router.php'>Router.php</a></b></td>
|
||||
<td style='padding: 8px;'>- Defines the core routing mechanism for the WordPress Update API, directing incoming requests to appropriate controllers based on URL paths<br>- Ensures authentication for protected routes and handles URL redirection and error responses, facilitating seamless request handling within the applications architecture.</td>
|
||||
|
@ -277,16 +288,16 @@ The v-wordpress-plugin-updater project is designed to streamline the management
|
|||
<td style='padding: 8px;'>- Provides a foundational class for rendering view templates within the WordPress Update API, facilitating separation of concerns by managing presentation logic<br>- It supports the overall architecture by enabling consistent and streamlined output generation, ensuring that different parts of the application can display data effectively while maintaining a clean code structure.</td>
|
||||
</tr>
|
||||
<tr style='border-bottom: 1px solid #eee;'>
|
||||
<td style='padding: 8px;'><b><a href='https://github.com/djav1985/v-wordpress-plugin-updater/blob/master/update-api/app/Core/ErrorMiddleware.php'>ErrorMiddleware.php</a></b></td>
|
||||
<td style='padding: 8px;'>- Provides centralized error handling and logging for the WordPress Update API, ensuring robust management of runtime errors, exceptions, and shutdown events<br>- Facilitates graceful error responses, maintains application stability, and logs critical issues, thereby supporting reliable API operations and easier troubleshooting within the overall system architecture.</td>
|
||||
<td style='padding: 8px;'><b><a href='https://github.com/djav1985/v-wordpress-plugin-updater/blob/master/update-api/app/Core/ErrorManager.php'>ErrorManager.php</a></b></td>
|
||||
<td style='padding: 8px;'>- Provides centralized error handling and logging for the WordPress Update API through a singleton manager that registers handlers for runtime errors, exceptions, and shutdown events<br>- Facilitates graceful error responses, maintains application stability, and logs critical issues, thereby supporting reliable API operations and easier troubleshooting within the overall system architecture.</td>
|
||||
</tr>
|
||||
<tr style='border-bottom: 1px solid #eee;'>
|
||||
<td style='padding: 8px;'><b><a href='https://github.com/djav1985/v-wordpress-plugin-updater/blob/master/update-api/app/Core/AuthMiddleware.php'>AuthMiddleware.php</a></b></td>
|
||||
<td style='padding: 8px;'>- Implements authentication and security checks within the WordPress Update API, ensuring only authorized users and trusted IPs access update functionalities<br>- It enforces session validation, handles timeout and user agent consistency, and blocks blacklisted IPs, thereby maintaining secure and controlled API interactions as part of the overall application security architecture.</td>
|
||||
</tr>
|
||||
</table>
|
||||
</blockquote>
|
||||
</details>
|
||||
<td style='padding: 8px;'><b><a href='https://github.com/djav1985/v-wordpress-plugin-updater/blob/master/update-api/app/Core/SessionManager.php'>SessionManager.php</a></b></td>
|
||||
<td style='padding: 8px;'>- Implements authentication and security checks within the WordPress Update API, ensuring only authorized users access update functionalities<br>- It enforces session validation by checking timeout and user agent consistency, while IP blacklist enforcement occurs during authentication to block banned addresses, maintaining secure and controlled API interactions as part of the overall application security architecture.</td>
|
||||
</tr>
|
||||
</table>
|
||||
</blockquote>
|
||||
</details>
|
||||
<!-- Views Submodule -->
|
||||
<details>
|
||||
<summary><b>Views</b></summary>
|
||||
|
@ -320,11 +331,23 @@ The v-wordpress-plugin-updater project is designed to streamline the management
|
|||
<td style='padding: 8px;'><b><a href='https://github.com/djav1985/v-wordpress-plugin-updater/blob/master/update-api/app/Views/plupdate.php'>plupdate.php</a></b></td>
|
||||
<td style='padding: 8px;'>- Provides a user interface for managing WordPress plugin updates within the UpdateAPI platform<br>- Facilitates viewing installed plugins, uploading new plugin ZIP files via drag-and-drop, and displaying real-time upload status messages<br>- Integrates with backend processes to streamline plugin management, ensuring seamless updates and installations in a structured, user-friendly manner.</td>
|
||||
</tr>
|
||||
<tr style='border-bottom: 1px solid #eee;'>
|
||||
<td style='padding: 8px;'><b><a href='https://github.com/djav1985/v-wordpress-plugin-updater/blob/master/update-api/app/Views/home.php'>home.php</a></b></td>
|
||||
<td style='padding: 8px;'>- Provides a user interface for managing allowed hosts within the WordPress Update API, enabling viewing and adding domain entries<br>- Facilitates administrative control over host configurations, ensuring secure and organized management of permitted domains for update operations<br>- Integrates form handling and display logic to support dynamic updates in the APIs host list.</td>
|
||||
</tr>
|
||||
</table>
|
||||
<tr style='border-bottom: 1px solid #eee;'>
|
||||
<td style='padding: 8px;'><b><a href='https://github.com/djav1985/v-wordpress-plugin-updater/blob/master/update-api/app/Views/home.php'>home.php</a></b></td>
|
||||
<td style='padding: 8px;'>- Provides a user interface for managing allowed hosts within the WordPress Update API, enabling viewing and adding domain entries<br>- Facilitates administrative control over host configurations, ensuring secure and organized management of permitted domains for update operations<br>- Integrates form handling and display logic to support dynamic updates in the APIs host list.</td>
|
||||
</tr>
|
||||
<tr style='border-bottom: 1px solid #eee;'>
|
||||
<td style='padding: 8px;'><b><a href='https://github.com/djav1985/v-wordpress-plugin-updater/blob/master/update-api/app/Views/accounts.php'>accounts.php</a></b></td>
|
||||
<td style='padding: 8px;'>- Placeholder view for managing accounts.</td>
|
||||
</tr>
|
||||
<tr style='border-bottom: 1px solid #eee;'>
|
||||
<td style='padding: 8px;'><b><a href='https://github.com/djav1985/v-wordpress-plugin-updater/blob/master/update-api/app/Views/info.php'>info.php</a></b></td>
|
||||
<td style='padding: 8px;'>- Placeholder view for displaying info.</td>
|
||||
</tr>
|
||||
<tr style='border-bottom: 1px solid #eee;'>
|
||||
<td style='padding: 8px;'><b><a href='https://github.com/djav1985/v-wordpress-plugin-updater/blob/master/update-api/app/Views/users.php'>users.php</a></b></td>
|
||||
<td style='padding: 8px;'>- Placeholder view for managing users.</td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- layouts Submodule -->
|
||||
<details>
|
||||
<summary><b>layouts</b></summary>
|
||||
|
@ -385,7 +408,7 @@ The v-wordpress-plugin-updater project is designed to streamline the management
|
|||
<td style='padding: 8px;'>- Manages theme-related operations within the WordPress Update API, including uploading, deleting, and displaying themes<br>- Facilitates secure handling of theme files through validation and CSRF protection, while generating dynamic HTML interfaces for theme management<br>- Integrates with core models and middleware to ensure smooth, secure interactions across the applications architecture.</td>
|
||||
</tr>
|
||||
<tr style='border-bottom: 1px solid #eee;'>
|
||||
<td style='padding: 8px;'><b><a href='https://github.com/djav1985/v-wordpress-plugin-updater/blob/master/update-api/app/Controllers/AuthController.php'>AuthController.php</a></b></td>
|
||||
<td style='padding: 8px;'><b><a href='https://github.com/djav1985/v-wordpress-plugin-updater/blob/master/update-api/app/Controllers/LoginController.php'>LoginController.php</a></b></td>
|
||||
<td style='padding: 8px;'>- Handles user authentication within the WordPress Update API, managing login sessions, validating credentials, and redirecting users appropriately<br>- Ensures secure session management, tracks failed login attempts, and integrates blacklisting for security<br>- Facilitates user access control, enabling authenticated interactions with the API while safeguarding against unauthorized access.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -407,8 +430,8 @@ The v-wordpress-plugin-updater project is designed to streamline the management
|
|||
</tr>
|
||||
</thead>
|
||||
<tr style='border-bottom: 1px solid #eee;'>
|
||||
<td style='padding: 8px;'><b><a href='https://github.com/djav1985/v-wordpress-plugin-updater/blob/master/update-api/storage/BLACKLIST.json'>BLACKLIST.json</a></b></td>
|
||||
<td style='padding: 8px;'>- Maintains a list of blacklisted entries to enforce security and access control within the update API<br>- Serves as a centralized reference for filtering or blocking specific data, ensuring compliance with security policies across the system<br>- Integrates seamlessly into the overall architecture to support consistent and efficient management of restricted entities.</td>
|
||||
<td style='padding: 8px;'><b>updater.sqlite</b></td>
|
||||
<td style='padding: 8px;'>- SQLite database storing plugin and theme metadata and tracking failed logins in the blacklist table.</td>
|
||||
</tr>
|
||||
</table>
|
||||
</blockquote>
|
||||
|
@ -465,34 +488,44 @@ The v-wordpress-plugin-updater project is designed to streamline the management
|
|||
mkdir -p /storage/logs
|
||||
```
|
||||
3. Edit `/config.php` and set the login credentials and directory constants. Adjust `VALID_USERNAME`, `VALID_PASSWORD`, and paths under `BASE_DIR` if the defaults do not match your setup.
|
||||
4. Define the API constants used by the mu-plugins in your WordPress `wp-config.php`:
|
||||
4. Set an `ENCRYPTION_KEY` environment variable used to secure host keys:
|
||||
|
||||
```sh
|
||||
export ENCRYPTION_KEY="your-32-byte-secret"
|
||||
```
|
||||
5. Define the API constants used by the mu-plugins in your WordPress `wp-config.php`:
|
||||
|
||||
```php
|
||||
define('VONTMENT_KEY', 'your-api-key');
|
||||
define('VONTMENT_PLUGINS', 'https://example.com/api');
|
||||
define('VONTMENT_THEMES', 'https://example.com/api');
|
||||
define('VONTMNT_API_URL', 'https://example.com/api');
|
||||
define('VONTMNT_UPDATE_KEYREGEN', true); // set to true to fetch/regenerate the key
|
||||
```
|
||||
5. Ensure the web server user owns the `/storage` directory so uploads and logs can be written.
|
||||
The updater will fetch the API key from `/api/key` when this constant is true or when no key is stored. The key is saved as the `vontmnt_api_key` option and `wp-config.php` is rewritten to disable regeneration after the first retrieval.
|
||||
6. Ensure the web server user owns the `/storage` directory so uploads and logs can be written.
|
||||
|
||||
NOTE: Make sure to set /public/ as doc root.
|
||||
7. From the `update-api/` directory run `php install.php` to create the SQLite database and required tables, including the blacklist. Ensure `storage/updater.sqlite` is writable by the web server.
|
||||
|
||||
8. Configure a system cron to run `php cron.php` regularly so the database stays in sync with the plugin and theme directories.
|
||||
|
||||
NOTE: Make sure to set /public/ as doc root.
|
||||
|
||||
When a host entry is created or its key regenerated, the server marks it to send the key once. The `/api/key` endpoint returns the key only while this flag is set, then disables it after the first retrieval.
|
||||
|
||||
### Usage
|
||||
|
||||
1. Copy the files from the repository's `mu-plugin/` folder into your WordPress installation's `wp-content/mu-plugins/` directory. Create the directory if it doesn't exist. WordPress automatically loads any PHP files placed here.
|
||||
2. Log in to the Update API by visiting the `/login` route (handled by `index.php`) using the credentials configured in `config.php` to manage hosts, plugins and themes.
|
||||
2. Run install.php to update from v3 to v4 imports and handles conversion to db.
|
||||
3. Log in to the Update API by visiting the `/login` route (handled by `index.php`) using the credentials configured in `config.php` to manage hosts, plugins and themes.
|
||||
|
||||
---
|
||||
|
||||
## Roadmap
|
||||
|
||||
- [X] **`Task 1`**: <strike>Convert to MVC framework</strike>
|
||||
- [ ] **`Task 2`**: Implement more advanced authorization for site connections
|
||||
- [ ] **`Task 3`**: Implement ability to remove ips from blacklist
|
||||
- [ ] **`Task 4`**: Implement plug-in verification on upload
|
||||
- [ ] **`Task 4`**: Implement docker version
|
||||
- [ ] **`Task 5`**: Databasebackend instead of file system
|
||||
- [ ] **`Task 6`**: Admin api, sotre files outside of server, etc
|
||||
- [ ] **`Task 7`**: More efficent update flow
|
||||
- [X] **`Task 2`**: <strike>Implement more advanced authorization for site connections</strike>
|
||||
- [X] **`Task 3`**: <strike>Implement Database instead of useing filesystem</strike>
|
||||
- [ ] **`Task 4`**: Implement ability to remove ips from blacklist
|
||||
- [ ] **`Task 5`**: Implement plug-in verification on upload
|
||||
- [ ] **`Task 6`**: Implement docker version
|
||||
|
||||
---
|
||||
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
"php-stubs/wp-cli-stubs": "^2",
|
||||
"szepeviktor/phpstan-wordpress": "^1",
|
||||
"php-stubs/wordpress-stubs": "^6",
|
||||
"phpstan/extension-installer": "1.3"
|
||||
"phpstan/extension-installer": "1.3",
|
||||
"phpunit/phpunit": "^11.5"
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
|
|
1758
composer.lock
generated
1758
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
// phpcs:ignoreFile
|
||||
/**
|
||||
* Project: UpdateAPI
|
||||
* Author: Vontainment <services@vontainment.com>
|
||||
* License: https://opensource.org/licenses/MIT MIT License
|
||||
* Link: https://vontainment.com
|
||||
* Version: 3.0.0
|
||||
* Version: 4.0.0
|
||||
*
|
||||
* File: v-sys-plugin-updater-mu.php
|
||||
* Description: WordPress Update API
|
||||
|
@ -18,98 +19,366 @@
|
|||
* @package VontainmentPluginUpdaterMU
|
||||
*/
|
||||
|
||||
if (! defined('ABSPATH')) {
|
||||
exit;
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the API key, requesting from the server when needed.
|
||||
*/
|
||||
if ( ! function_exists( 'vontmnt_get_api_key' ) ) {
|
||||
function vontmnt_get_api_key(): string {
|
||||
$key = get_option( 'vontmnt_api_key' );
|
||||
if ( ! $key || ( defined( 'VONTMNT_UPDATE_KEYREGEN' ) && VONTMNT_UPDATE_KEYREGEN ) ) {
|
||||
$base = defined( 'VONTMNT_API_URL' ) ? VONTMNT_API_URL : '';
|
||||
$api_url = add_query_arg(
|
||||
array(
|
||||
'type' => 'auth',
|
||||
'domain' => wp_parse_url( site_url(), PHP_URL_HOST ),
|
||||
),
|
||||
rtrim( $base, '/' ) . '/key'
|
||||
);
|
||||
$response = wp_remote_get( $api_url );
|
||||
if ( ! is_wp_error( $response ) && 200 === wp_remote_retrieve_response_code( $response ) ) {
|
||||
$key = wp_remote_retrieve_body( $response );
|
||||
update_option( 'vontmnt_api_key', $key, false );
|
||||
$wp_config = ABSPATH . 'wp-config.php';
|
||||
if ( file_exists( $wp_config ) && is_writable( $wp_config ) ) {
|
||||
$config = file_get_contents( $wp_config );
|
||||
if ( false !== $config ) {
|
||||
$config = preg_replace( "/define\(\s*'VONTMNT_UPDATE_KEYREGEN'\s*,\s*true\s*\);/i", "define('VONTMNT_UPDATE_KEYREGEN', false);", $config );
|
||||
file_put_contents( $wp_config, $config );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return is_string( $key ) ? $key : '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate ZIP package by checking header and optionally testing extraction.
|
||||
*
|
||||
* @param string $file_path Path to ZIP file.
|
||||
* @return bool True if valid ZIP package.
|
||||
*/
|
||||
if ( ! function_exists( 'vontmnt_validate_zip_package' ) ) {
|
||||
function vontmnt_validate_zip_package( string $file_path ): bool {
|
||||
if ( ! file_exists( $file_path ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check ZIP file header (magic bytes: PK\x03\x04)
|
||||
$handle = fopen( $file_path, 'rb' );
|
||||
if ( false === $handle ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$header = fread( $handle, 4 );
|
||||
fclose( $handle );
|
||||
|
||||
if ( 4 !== strlen( $header ) || "\x50\x4b\x03\x04" !== $header ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Test ZIP extraction using ZipArchive if available
|
||||
if ( class_exists( 'ZipArchive' ) ) {
|
||||
$zip = new ZipArchive();
|
||||
$result = $zip->open( $file_path );
|
||||
if ( true !== $result ) {
|
||||
return false;
|
||||
}
|
||||
$zip->close();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Redact the API key from a URL for logging purposes.
|
||||
*
|
||||
* @param string $url The URL that may contain an API key.
|
||||
* @return string The URL with the key parameter redacted.
|
||||
*/
|
||||
if ( ! function_exists( 'vontmnt_redact_key' ) ) {
|
||||
function vontmnt_redact_key( string $url ): string {
|
||||
return preg_replace( '/([?&]key=)[^&]*/', '$1[REDACTED]', $url );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log update context with detailed information.
|
||||
*
|
||||
* @param string $type Update type (plugin/theme).
|
||||
* @param string $slug Item slug.
|
||||
* @param string $version Item version.
|
||||
* @param string $url API URL called.
|
||||
* @param int $response_code HTTP response code.
|
||||
* @param int $response_size Response body size in bytes.
|
||||
* @param string $status Update status (success/failed/skipped).
|
||||
* @param string $message Optional message.
|
||||
*/
|
||||
if ( ! function_exists( 'vontmnt_log_update_context' ) ) {
|
||||
function vontmnt_log_update_context( string $type, string $slug, string $version, string $url, int $response_code, int $response_size, string $status, string $message = '' ): void {
|
||||
$context = sprintf(
|
||||
'[%s] %s:%s | URL: %s | HTTP: %d | Size: %d bytes | Status: %s',
|
||||
strtoupper( $type ),
|
||||
$slug,
|
||||
$version,
|
||||
vontmnt_redact_key( $url ),
|
||||
$response_code,
|
||||
$response_size,
|
||||
$status
|
||||
);
|
||||
|
||||
if ( ! empty( $message ) ) {
|
||||
$context .= ' | ' . $message;
|
||||
}
|
||||
|
||||
error_log( $context );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule a single event only if an identical one (hook+args) isn't already queued.
|
||||
*
|
||||
* @param int $timestamp The timestamp when the event should run.
|
||||
* @param string $hook The action hook name.
|
||||
* @param array $args Arguments to pass to the hook.
|
||||
*/
|
||||
if ( ! function_exists( 'vontmnt_schedule_unique_single_event' ) ) {
|
||||
function vontmnt_schedule_unique_single_event( int $timestamp, string $hook, array $args ): void {
|
||||
if ( ! wp_next_scheduled( $hook, $args ) ) {
|
||||
wp_schedule_single_event( $timestamp, $hook, $args );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Schedule the update check to run every day.
|
||||
add_action('wp', 'vontmnt_plugin_updater_schedule_updates');
|
||||
add_action( 'admin_init', 'vontmnt_plugin_updater_schedule_updates' );
|
||||
|
||||
|
||||
/**
|
||||
|
||||
/**
|
||||
* @package UpdateAPI
|
||||
* @author Vontainment <services@vontainment.com>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://vontainment.com
|
||||
*
|
||||
* Schedule daily plugin update checks for multisite. */
|
||||
function vontmnt_plugin_updater_schedule_updates(): void
|
||||
{
|
||||
if (! is_main_site()) {
|
||||
return;
|
||||
}
|
||||
if (! wp_next_scheduled('vontmnt_plugin_updater_check_updates')) {
|
||||
wp_schedule_event(time(), 'daily', 'vontmnt_plugin_updater_check_updates');
|
||||
}
|
||||
if ( ! function_exists( 'vontmnt_plugin_updater_schedule_updates' ) ) {
|
||||
function vontmnt_plugin_updater_schedule_updates(): void {
|
||||
if ( ! is_main_site() ) {
|
||||
return;
|
||||
}
|
||||
if ( ! wp_next_scheduled( 'vontmnt_plugin_updater_check_updates' ) ) {
|
||||
wp_schedule_event( time(), 'daily', 'vontmnt_plugin_updater_check_updates' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
add_action('vontmnt_plugin_updater_check_updates', 'vontmnt_plugin_updater_run_updates');
|
||||
add_action( 'vontmnt_plugin_updater_check_updates', 'vontmnt_plugin_updater_run_updates' );
|
||||
add_action( 'vontmnt_plugin_update_single', 'vontmnt_plugin_update_single', 10, 2 );
|
||||
|
||||
/**
|
||||
/**
|
||||
* @package UpdateAPI
|
||||
* @author Vontainment <services@vontainment.com>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://vontainment.com
|
||||
*
|
||||
* Run plugin updates for all installed plugins on the main site. */
|
||||
function vontmnt_plugin_updater_run_updates(): void
|
||||
{
|
||||
// Check if it's the main site.
|
||||
if (! is_main_site()) {
|
||||
return;
|
||||
}
|
||||
if (! function_exists('get_plugins')) {
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||
}
|
||||
$plugins = get_plugins();
|
||||
foreach ($plugins as $plugin_path => $plugin) {
|
||||
$plugin_slug = dirname($plugin_path);
|
||||
$installed_version = $plugin['Version'];
|
||||
$api_url = add_query_arg(
|
||||
array(
|
||||
'type' => 'plugin',
|
||||
'domain' => rawurlencode(wp_parse_url(site_url(), PHP_URL_HOST)),
|
||||
'slug' => rawurlencode($plugin_slug),
|
||||
'version' => rawurlencode($installed_version),
|
||||
'key' => VONTMENT_KEY,
|
||||
),
|
||||
VONTMENT_PLUGINS
|
||||
);
|
||||
* Schedule plugin update checks for all installed plugins on the main site. */
|
||||
if ( ! function_exists( 'vontmnt_plugin_updater_run_updates' ) ) {
|
||||
function vontmnt_plugin_updater_run_updates(): void {
|
||||
// Check if it's the main site.
|
||||
if ( ! is_main_site() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Use wp_remote_get instead of cURL.
|
||||
$response = wp_remote_get($api_url);
|
||||
$http_code = wp_remote_retrieve_response_code($response);
|
||||
$response_body = wp_remote_retrieve_body($response);
|
||||
// Atomic locking using add_option pattern with TTL support
|
||||
$lock_key = 'vontmnt_updates_scheduling';
|
||||
$lock_ttl = 60; // 1 minute TTL for scheduling lock
|
||||
|
||||
if ( ! add_option( $lock_key, time(), '', false ) ) {
|
||||
// Lock exists, check if it's expired
|
||||
$lock_time = get_option( $lock_key );
|
||||
if ( $lock_time && ( time() - $lock_time ) > $lock_ttl ) {
|
||||
// Lock expired, remove it and try again
|
||||
delete_option( $lock_key );
|
||||
if ( ! add_option( $lock_key, time(), '', false ) ) {
|
||||
// Still can't acquire lock, another process may have just acquired it
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Lock is still valid, another scheduling run is in progress
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (200 === $http_code && ! empty($response_body)) {
|
||||
require_once ABSPATH . 'wp-admin/includes/file.php';
|
||||
$upload_dir = wp_upload_dir();
|
||||
$plugin_zip_file = $upload_dir['path'] . '/' . basename($plugin_path) . '.zip';
|
||||
file_put_contents($plugin_zip_file, $response_body);
|
||||
if ( ! function_exists( 'get_plugins' ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||
}
|
||||
$plugins = get_plugins();
|
||||
|
||||
global $wp_filesystem;
|
||||
if (empty($wp_filesystem)) {
|
||||
require_once ABSPATH . '/wp-admin/includes/file.php';
|
||||
WP_Filesystem();
|
||||
}
|
||||
$when = time() + 5; // tiny jitter to reduce "same-second" collisions
|
||||
|
||||
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
|
||||
$upgrader = new Plugin_Upgrader();
|
||||
$callback = function ($options) use ($plugin_zip_file) {
|
||||
$options['package'] = $plugin_zip_file;
|
||||
$options['clear_destination'] = true;
|
||||
return $options;
|
||||
};
|
||||
add_filter('upgrader_package_options', $callback);
|
||||
$upgrader->install($plugin_zip_file);
|
||||
remove_filter('upgrader_package_options', $callback);
|
||||
|
||||
// Delete the plugin zip file using wp_delete_file.
|
||||
wp_delete_file($plugin_zip_file);
|
||||
} elseif (204 === $http_code) {
|
||||
continue;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
foreach ( $plugins as $plugin_path => $plugin ) {
|
||||
$args = array( $plugin_path, $plugin['Version'] );
|
||||
vontmnt_schedule_unique_single_event( $when, 'vontmnt_plugin_update_single', $args );
|
||||
$when += rand( 0, 2 ); // Add small jitter per plugin to further reduce collisions
|
||||
}
|
||||
|
||||
// Release the lock
|
||||
delete_option( $lock_key );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @package UpdateAPI
|
||||
* @author Vontainment <services@vontainment.com>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://vontainment.com
|
||||
*
|
||||
* Update a single plugin. */
|
||||
if ( ! function_exists( 'vontmnt_plugin_update_single' ) ) {
|
||||
function vontmnt_plugin_update_single( $plugin_path, $installed_version ): void {
|
||||
// Check if it's the main site.
|
||||
if ( ! is_main_site() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Atomic locking using add_option pattern with TTL support
|
||||
$lock_key = 'vontmnt_updating_' . md5( $plugin_path );
|
||||
$lock_ttl = 300; // 5 minutes TTL to handle crashes
|
||||
|
||||
if ( ! add_option( $lock_key, time(), '', false ) ) {
|
||||
// Lock exists, check if it's expired
|
||||
$lock_time = get_option( $lock_key );
|
||||
if ( $lock_time && ( time() - $lock_time ) > $lock_ttl ) {
|
||||
// Lock expired, remove it and try again
|
||||
delete_option( $lock_key );
|
||||
if ( ! add_option( $lock_key, time(), '', false ) ) {
|
||||
// Still can't acquire lock, another process may have just acquired it
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Lock is still valid, another update is in progress
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Handle single-file plugins where dirname returns "."
|
||||
$plugin_slug = dirname( $plugin_path );
|
||||
if ( '.' === $plugin_slug ) {
|
||||
$plugin_slug = pathinfo( $plugin_path, PATHINFO_FILENAME );
|
||||
}
|
||||
|
||||
$api_url = add_query_arg(
|
||||
array(
|
||||
'type' => 'plugin',
|
||||
'domain' => wp_parse_url( site_url(), PHP_URL_HOST ),
|
||||
'slug' => $plugin_slug,
|
||||
'version' => $installed_version,
|
||||
'key' => vontmnt_get_api_key(),
|
||||
),
|
||||
VONTMNT_API_URL
|
||||
);
|
||||
|
||||
// Use wp_remote_get instead of cURL.
|
||||
$response = wp_remote_get( $api_url );
|
||||
if ( is_wp_error( $response ) ) {
|
||||
vontmnt_log_update_context( 'plugin', $plugin_slug, $installed_version, $api_url, 0, 0, 'failed', 'HTTP error: ' . $response->get_error_message() );
|
||||
delete_option( $lock_key );
|
||||
return;
|
||||
}
|
||||
|
||||
$http_code = wp_remote_retrieve_response_code( $response );
|
||||
$response_body = wp_remote_retrieve_body( $response );
|
||||
|
||||
if ( 200 === $http_code && ! empty( $response_body ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/file.php';
|
||||
|
||||
// Initialize WP_Filesystem before any file operations
|
||||
global $wp_filesystem;
|
||||
if ( empty( $wp_filesystem ) ) {
|
||||
WP_Filesystem();
|
||||
}
|
||||
|
||||
$upload_dir = wp_upload_dir();
|
||||
|
||||
// Ensure the upload directory exists
|
||||
if ( ! wp_mkdir_p( $upload_dir['path'] ) ) {
|
||||
vontmnt_log_update_context( 'plugin', $plugin_slug, $installed_version, $api_url, $http_code, 0, 'failed', 'Failed to create upload directory' );
|
||||
delete_option( $lock_key );
|
||||
return;
|
||||
}
|
||||
|
||||
$plugin_zip_file = $upload_dir['path'] . '/' . $plugin_slug . '.zip';
|
||||
|
||||
// Stream large files to disk instead of loading into memory
|
||||
$temp_file = wp_tempnam( $plugin_zip_file );
|
||||
$stream_response = wp_remote_get( $api_url, array( 'stream' => true, 'filename' => $temp_file ) );
|
||||
|
||||
if ( is_wp_error( $stream_response ) ) {
|
||||
vontmnt_log_update_context( 'plugin', $plugin_slug, $installed_version, $api_url, $http_code, 0, 'failed', 'Failed to stream update package' );
|
||||
delete_option( $lock_key );
|
||||
return;
|
||||
}
|
||||
|
||||
// Move temp file to final location (allow overwrite)
|
||||
if ( file_exists( $plugin_zip_file ) ) {
|
||||
wp_delete_file( $plugin_zip_file );
|
||||
}
|
||||
if ( ! $wp_filesystem->move( $temp_file, $plugin_zip_file ) ) {
|
||||
vontmnt_log_update_context( 'plugin', $plugin_slug, $installed_version, $api_url, $http_code, 0, 'failed', 'Failed to move update package' );
|
||||
wp_delete_file( $temp_file );
|
||||
delete_option( $lock_key );
|
||||
return;
|
||||
}
|
||||
|
||||
$response_size = filesize( $plugin_zip_file );
|
||||
|
||||
// Validate ZIP package before installation
|
||||
if ( ! vontmnt_validate_zip_package( $plugin_zip_file ) ) {
|
||||
vontmnt_log_update_context( 'plugin', $plugin_slug, $installed_version, $api_url, $http_code, $response_size, 'failed', 'Invalid ZIP package' );
|
||||
wp_delete_file( $plugin_zip_file );
|
||||
delete_option( $lock_key );
|
||||
return;
|
||||
}
|
||||
|
||||
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
|
||||
$upgrader = new Plugin_Upgrader();
|
||||
$callback = function ( $options ) use ( $plugin_zip_file ) {
|
||||
$options['package'] = $plugin_zip_file;
|
||||
$options['clear_destination'] = true;
|
||||
return $options;
|
||||
};
|
||||
add_filter( 'upgrader_package_options', $callback );
|
||||
$result = $upgrader->install( $plugin_zip_file );
|
||||
remove_filter( 'upgrader_package_options', $callback );
|
||||
|
||||
// Delete the plugin zip file using wp_delete_file.
|
||||
wp_delete_file( $plugin_zip_file );
|
||||
|
||||
// Post-install housekeeping: refresh plugin update data
|
||||
if ( function_exists( 'wp_clean_plugins_cache' ) ) {
|
||||
wp_clean_plugins_cache( true );
|
||||
}
|
||||
|
||||
// Log success or failure
|
||||
if ( ! is_wp_error( $result ) && $result ) {
|
||||
vontmnt_log_update_context( 'plugin', $plugin_slug, $installed_version, $api_url, $http_code, $response_size, 'success', 'Plugin updated successfully' );
|
||||
} else {
|
||||
$error_msg = is_wp_error( $result ) ? $result->get_error_message() : 'Installation failed';
|
||||
vontmnt_log_update_context( 'plugin', $plugin_slug, $installed_version, $api_url, $http_code, $response_size, 'failed', $error_msg );
|
||||
}
|
||||
} elseif ( 204 === $http_code ) {
|
||||
vontmnt_log_update_context( 'plugin', $plugin_slug, $installed_version, $api_url, $http_code, 0, 'skipped', 'No update available' );
|
||||
} else {
|
||||
vontmnt_log_update_context( 'plugin', $plugin_slug, $installed_version, $api_url, $http_code, 0, 'failed', 'Unexpected HTTP response' );
|
||||
}
|
||||
|
||||
// Release the lock
|
||||
delete_option( $lock_key );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
// phpcs:ignoreFile
|
||||
/**
|
||||
* Project: UpdateAPI
|
||||
* Author: Vontainment <services@vontainment.com>
|
||||
* License: https://opensource.org/licenses/MIT MIT License
|
||||
* Link: https://vontainment.com
|
||||
* Version: 3.0.0
|
||||
* Version: 4.0.0
|
||||
*
|
||||
* File: v-sys-plugin-updater.php
|
||||
* Description: WordPress Update API
|
||||
|
@ -18,91 +19,350 @@
|
|||
* @package VontainmentPluginUpdater
|
||||
*/
|
||||
|
||||
if (! defined('ABSPATH')) {
|
||||
exit;
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Retrieve the API key, requesting from the server when needed.
|
||||
*/
|
||||
if ( ! function_exists( 'vontmnt_get_api_key' ) ) {
|
||||
function vontmnt_get_api_key(): string {
|
||||
$key = get_option( 'vontmnt_api_key' );
|
||||
if ( ! $key || ( defined( 'VONTMNT_UPDATE_KEYREGEN' ) && VONTMNT_UPDATE_KEYREGEN ) ) {
|
||||
$base = defined( 'VONTMNT_API_URL' ) ? VONTMNT_API_URL : '';
|
||||
$api_url = add_query_arg(
|
||||
array(
|
||||
'type' => 'auth',
|
||||
'domain' => wp_parse_url( site_url(), PHP_URL_HOST ),
|
||||
),
|
||||
rtrim( $base, '/' ) . '/key'
|
||||
);
|
||||
$response = wp_remote_get( $api_url );
|
||||
if ( ! is_wp_error( $response ) && 200 === wp_remote_retrieve_response_code( $response ) ) {
|
||||
$key = wp_remote_retrieve_body( $response );
|
||||
update_option( 'vontmnt_api_key', $key );
|
||||
$wp_config = ABSPATH . 'wp-config.php';
|
||||
if ( file_exists( $wp_config ) && is_writable( $wp_config ) ) {
|
||||
$config = file_get_contents( $wp_config );
|
||||
if ( false !== $config ) {
|
||||
$config = preg_replace( "/define\(\s*'VONTMNT_UPDATE_KEYREGEN'\s*,\s*true\s*\);/i", "define('VONTMNT_UPDATE_KEYREGEN', false);", $config );
|
||||
file_put_contents( $wp_config, $config );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return is_string( $key ) ? $key : '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate ZIP package by checking header and optionally testing extraction.
|
||||
*
|
||||
* @param string $file_path Path to ZIP file.
|
||||
* @return bool True if valid ZIP package.
|
||||
*/
|
||||
if ( ! function_exists( 'vontmnt_validate_zip_package' ) ) {
|
||||
function vontmnt_validate_zip_package( string $file_path ): bool {
|
||||
if ( ! file_exists( $file_path ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check ZIP file header (magic bytes: PK\x03\x04)
|
||||
$handle = fopen( $file_path, 'rb' );
|
||||
if ( false === $handle ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$header = fread( $handle, 4 );
|
||||
fclose( $handle );
|
||||
|
||||
if ( 4 !== strlen( $header ) || "\x50\x4b\x03\x04" !== $header ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Test ZIP extraction using ZipArchive if available
|
||||
if ( class_exists( 'ZipArchive' ) ) {
|
||||
$zip = new ZipArchive();
|
||||
$result = $zip->open( $file_path );
|
||||
if ( true !== $result ) {
|
||||
return false;
|
||||
}
|
||||
$zip->close();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Redact the API key from a URL for logging purposes.
|
||||
*
|
||||
* @param string $url The URL that may contain an API key.
|
||||
* @return string The URL with the key parameter redacted.
|
||||
*/
|
||||
if ( ! function_exists( 'vontmnt_redact_key' ) ) {
|
||||
function vontmnt_redact_key( string $url ): string {
|
||||
return preg_replace( '/([?&]key=)[^&]*/', '$1[REDACTED]', $url );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log update context with detailed information.
|
||||
*
|
||||
* @param string $type Update type (plugin/theme).
|
||||
* @param string $slug Item slug.
|
||||
* @param string $version Item version.
|
||||
* @param string $url API URL called.
|
||||
* @param int $response_code HTTP response code.
|
||||
* @param int $response_size Response body size in bytes.
|
||||
* @param string $status Update status (success/failed/skipped).
|
||||
* @param string $message Optional message.
|
||||
*/
|
||||
if ( ! function_exists( 'vontmnt_log_update_context' ) ) {
|
||||
function vontmnt_log_update_context( string $type, string $slug, string $version, string $url, int $response_code, int $response_size, string $status, string $message = '' ): void {
|
||||
$context = sprintf(
|
||||
'[%s] %s:%s | URL: %s | HTTP: %d | Size: %d bytes | Status: %s',
|
||||
strtoupper( $type ),
|
||||
$slug,
|
||||
$version,
|
||||
vontmnt_redact_key( $url ),
|
||||
$response_code,
|
||||
$response_size,
|
||||
$status
|
||||
);
|
||||
|
||||
if ( ! empty( $message ) ) {
|
||||
$context .= ' | ' . $message;
|
||||
}
|
||||
|
||||
error_log( $context );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule a single event only if an identical one (hook+args) isn't already queued.
|
||||
*
|
||||
* @param int $timestamp The timestamp when the event should run.
|
||||
* @param string $hook The action hook name.
|
||||
* @param array $args Arguments to pass to the hook.
|
||||
*/
|
||||
if ( ! function_exists( 'vontmnt_schedule_unique_single_event' ) ) {
|
||||
function vontmnt_schedule_unique_single_event( int $timestamp, string $hook, array $args ): void {
|
||||
if ( ! wp_next_scheduled( $hook, $args ) ) {
|
||||
wp_schedule_single_event( $timestamp, $hook, $args );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @package UpdateAPI
|
||||
* @author Vontainment <services@vontainment.com>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://vontainment.com
|
||||
*
|
||||
* Schedule daily plugin update checks. */
|
||||
function vontmnt_plugin_updater_schedule_updates(): void
|
||||
{
|
||||
if (! wp_next_scheduled('vontmnt_plugin_updater_check_updates')) {
|
||||
wp_schedule_event(time(), 'daily', 'vontmnt_plugin_updater_check_updates');
|
||||
}
|
||||
if ( ! function_exists( 'vontmnt_plugin_updater_schedule_updates' ) ) {
|
||||
function vontmnt_plugin_updater_schedule_updates(): void {
|
||||
if ( ! wp_next_scheduled( 'vontmnt_plugin_updater_check_updates' ) ) {
|
||||
wp_schedule_event( time(), 'daily', 'vontmnt_plugin_updater_check_updates' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
add_action('wp', 'vontmnt_plugin_updater_schedule_updates');
|
||||
add_action( 'admin_init', 'vontmnt_plugin_updater_schedule_updates' );
|
||||
|
||||
add_action('vontmnt_plugin_updater_check_updates', 'vontmnt_plugin_updater_run_updates');
|
||||
add_action( 'vontmnt_plugin_updater_check_updates', 'vontmnt_plugin_updater_run_updates' );
|
||||
add_action( 'vontmnt_plugin_update_single', 'vontmnt_plugin_update_single', 10, 2 );
|
||||
|
||||
/**
|
||||
/**
|
||||
* @package UpdateAPI
|
||||
* @author Vontainment <services@vontainment.com>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://vontainment.com
|
||||
*
|
||||
* Run plugin updates for all installed plugins. */
|
||||
function vontmnt_plugin_updater_run_updates(): void
|
||||
{
|
||||
if (! function_exists('get_plugins')) {
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||
}
|
||||
$plugins = get_plugins();
|
||||
foreach ($plugins as $plugin_path => $plugin) {
|
||||
$plugin_slug = dirname($plugin_path);
|
||||
$installed_version = $plugin['Version'];
|
||||
$api_url = add_query_arg(
|
||||
array(
|
||||
'type' => 'plugin',
|
||||
'domain' => rawurlencode(wp_parse_url(site_url(), PHP_URL_HOST)),
|
||||
'slug' => rawurlencode($plugin_slug),
|
||||
'version' => rawurlencode($installed_version),
|
||||
'key' => VONTMENT_KEY,
|
||||
),
|
||||
VONTMENT_PLUGINS
|
||||
);
|
||||
* Schedule plugin update checks for all installed plugins. */
|
||||
if ( ! function_exists( 'vontmnt_plugin_updater_run_updates' ) ) {
|
||||
function vontmnt_plugin_updater_run_updates(): void {
|
||||
// Atomic locking using add_option pattern with TTL support
|
||||
$lock_key = 'vontmnt_updates_scheduling';
|
||||
$lock_ttl = 60; // 1 minute TTL for scheduling lock
|
||||
|
||||
if ( ! add_option( $lock_key, time(), '', false ) ) {
|
||||
// Lock exists, check if it's expired
|
||||
$lock_time = get_option( $lock_key );
|
||||
if ( $lock_time && ( time() - $lock_time ) > $lock_ttl ) {
|
||||
// Lock expired, remove it and try again
|
||||
delete_option( $lock_key );
|
||||
if ( ! add_option( $lock_key, time(), '', false ) ) {
|
||||
// Still can't acquire lock, another process may have just acquired it
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Lock is still valid, another scheduling run is in progress
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Use wp_remote_get instead of cURL.
|
||||
$response = wp_remote_get($api_url);
|
||||
$http_code = wp_remote_retrieve_response_code($response);
|
||||
$response_body = wp_remote_retrieve_body($response);
|
||||
if ( ! function_exists( 'get_plugins' ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||
}
|
||||
$plugins = get_plugins();
|
||||
|
||||
if ($http_code === 200 && ! empty($response_body)) {
|
||||
require_once ABSPATH . 'wp-admin/includes/file.php';
|
||||
$upload_dir = wp_upload_dir();
|
||||
$plugin_zip_file = $upload_dir['path'] . '/' . basename($plugin_path) . '.zip';
|
||||
file_put_contents($plugin_zip_file, $response_body);
|
||||
$when = time() + 5; // tiny jitter to reduce "same-second" collisions
|
||||
|
||||
global $wp_filesystem;
|
||||
if (empty($wp_filesystem)) {
|
||||
require_once ABSPATH . '/wp-admin/includes/file.php';
|
||||
WP_Filesystem();
|
||||
}
|
||||
|
||||
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
|
||||
$upgrader = new Plugin_Upgrader();
|
||||
$callback = function ($options) use ($plugin_zip_file) {
|
||||
$options['package'] = $plugin_zip_file;
|
||||
$options['clear_destination'] = true;
|
||||
return $options;
|
||||
};
|
||||
add_filter('upgrader_package_options', $callback);
|
||||
$upgrader->install($plugin_zip_file);
|
||||
remove_filter('upgrader_package_options', $callback);
|
||||
|
||||
// Delete the plugin zip file using wp_delete_file.
|
||||
wp_delete_file($plugin_zip_file);
|
||||
} elseif ($http_code === 204) {
|
||||
// No updates, check next plugin.
|
||||
continue;
|
||||
} else {
|
||||
// For 400, 403, or any other unexpected code, stop further processing.
|
||||
break;
|
||||
}
|
||||
}
|
||||
foreach ( $plugins as $plugin_path => $plugin ) {
|
||||
$args = array( $plugin_path, $plugin['Version'] );
|
||||
vontmnt_schedule_unique_single_event( $when, 'vontmnt_plugin_update_single', $args );
|
||||
$when += rand( 0, 2 ); // Add small jitter per plugin to further reduce collisions
|
||||
}
|
||||
|
||||
// Release the lock
|
||||
delete_option( $lock_key );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @package UpdateAPI
|
||||
* @author Vontainment <services@vontainment.com>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://vontainment.com
|
||||
*
|
||||
* Update a single plugin. */
|
||||
if ( ! function_exists( 'vontmnt_plugin_update_single' ) ) {
|
||||
function vontmnt_plugin_update_single( $plugin_path, $installed_version ): void {
|
||||
// Atomic locking using add_option pattern with TTL support
|
||||
$lock_key = 'vontmnt_updating_' . md5( $plugin_path );
|
||||
$lock_ttl = 300; // 5 minutes TTL to handle crashes
|
||||
|
||||
if ( ! add_option( $lock_key, time(), '', false ) ) {
|
||||
// Lock exists, check if it's expired
|
||||
$lock_time = get_option( $lock_key );
|
||||
if ( $lock_time && ( time() - $lock_time ) > $lock_ttl ) {
|
||||
// Lock expired, remove it and try again
|
||||
delete_option( $lock_key );
|
||||
if ( ! add_option( $lock_key, time(), '', false ) ) {
|
||||
// Still can't acquire lock, another process may have just acquired it
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Lock is still valid, another update is in progress
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Handle single-file plugins where dirname returns "."
|
||||
$plugin_slug = dirname( $plugin_path );
|
||||
if ( '.' === $plugin_slug ) {
|
||||
$plugin_slug = pathinfo( $plugin_path, PATHINFO_FILENAME );
|
||||
}
|
||||
|
||||
$api_url = add_query_arg(
|
||||
array(
|
||||
'type' => 'plugin',
|
||||
'domain' => wp_parse_url( site_url(), PHP_URL_HOST ),
|
||||
'slug' => $plugin_slug,
|
||||
'version' => $installed_version,
|
||||
'key' => vontmnt_get_api_key(),
|
||||
),
|
||||
VONTMNT_API_URL
|
||||
);
|
||||
|
||||
// Use wp_remote_get instead of cURL.
|
||||
$response = wp_remote_get( $api_url );
|
||||
if ( is_wp_error( $response ) ) {
|
||||
vontmnt_log_update_context( 'plugin', $plugin_slug, $installed_version, $api_url, 0, 0, 'failed', 'HTTP error: ' . $response->get_error_message() );
|
||||
delete_option( $lock_key );
|
||||
return;
|
||||
}
|
||||
|
||||
$http_code = wp_remote_retrieve_response_code( $response );
|
||||
$response_body = wp_remote_retrieve_body( $response );
|
||||
|
||||
if ( $http_code === 200 && ! empty( $response_body ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/file.php';
|
||||
|
||||
// Initialize WP_Filesystem before any file operations
|
||||
global $wp_filesystem;
|
||||
if ( empty( $wp_filesystem ) ) {
|
||||
WP_Filesystem();
|
||||
}
|
||||
|
||||
$upload_dir = wp_upload_dir();
|
||||
|
||||
// Ensure the upload directory exists
|
||||
if ( ! wp_mkdir_p( $upload_dir['path'] ) ) {
|
||||
vontmnt_log_update_context( 'plugin', $plugin_slug, $installed_version, $api_url, $http_code, 0, 'failed', 'Failed to create upload directory' );
|
||||
delete_option( $lock_key );
|
||||
return;
|
||||
}
|
||||
|
||||
$plugin_zip_file = $upload_dir['path'] . '/' . $plugin_slug . '.zip';
|
||||
|
||||
// Stream large files to disk instead of loading into memory
|
||||
$temp_file = wp_tempnam( $plugin_zip_file );
|
||||
$stream_response = wp_remote_get( $api_url, array( 'stream' => true, 'filename' => $temp_file ) );
|
||||
|
||||
if ( is_wp_error( $stream_response ) ) {
|
||||
vontmnt_log_update_context( 'plugin', $plugin_slug, $installed_version, $api_url, $http_code, 0, 'failed', 'Failed to stream update package' );
|
||||
delete_option( $lock_key );
|
||||
return;
|
||||
}
|
||||
|
||||
// Move temp file to final location (allow overwrite)
|
||||
if ( file_exists( $plugin_zip_file ) ) {
|
||||
wp_delete_file( $plugin_zip_file );
|
||||
}
|
||||
if ( ! $wp_filesystem->move( $temp_file, $plugin_zip_file ) ) {
|
||||
vontmnt_log_update_context( 'plugin', $plugin_slug, $installed_version, $api_url, $http_code, 0, 'failed', 'Failed to move update package' );
|
||||
wp_delete_file( $temp_file );
|
||||
delete_option( $lock_key );
|
||||
return;
|
||||
}
|
||||
|
||||
$response_size = filesize( $plugin_zip_file );
|
||||
|
||||
// Validate ZIP package before installation
|
||||
if ( ! vontmnt_validate_zip_package( $plugin_zip_file ) ) {
|
||||
vontmnt_log_update_context( 'plugin', $plugin_slug, $installed_version, $api_url, $http_code, $response_size, 'failed', 'Invalid ZIP package' );
|
||||
wp_delete_file( $plugin_zip_file );
|
||||
delete_option( $lock_key );
|
||||
return;
|
||||
}
|
||||
|
||||
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
|
||||
$upgrader = new Plugin_Upgrader();
|
||||
$callback = function ( $options ) use ( $plugin_zip_file ) {
|
||||
$options['package'] = $plugin_zip_file;
|
||||
$options['clear_destination'] = true;
|
||||
return $options;
|
||||
};
|
||||
add_filter( 'upgrader_package_options', $callback );
|
||||
$result = $upgrader->install( $plugin_zip_file );
|
||||
remove_filter( 'upgrader_package_options', $callback );
|
||||
|
||||
// Delete the plugin zip file using wp_delete_file.
|
||||
wp_delete_file( $plugin_zip_file );
|
||||
|
||||
// Post-install housekeeping: refresh plugin update data
|
||||
if ( function_exists( 'wp_clean_plugins_cache' ) ) {
|
||||
wp_clean_plugins_cache( true );
|
||||
}
|
||||
|
||||
// Log success or failure
|
||||
if ( ! is_wp_error( $result ) && $result ) {
|
||||
vontmnt_log_update_context( 'plugin', $plugin_slug, $installed_version, $api_url, $http_code, $response_size, 'success', 'Plugin updated successfully' );
|
||||
} else {
|
||||
$error_msg = is_wp_error( $result ) ? $result->get_error_message() : 'Installation failed';
|
||||
vontmnt_log_update_context( 'plugin', $plugin_slug, $installed_version, $api_url, $http_code, $response_size, 'failed', $error_msg );
|
||||
}
|
||||
} elseif ( 204 === $http_code ) {
|
||||
vontmnt_log_update_context( 'plugin', $plugin_slug, $installed_version, $api_url, $http_code, 0, 'skipped', 'No update available' );
|
||||
} else {
|
||||
vontmnt_log_update_context( 'plugin', $plugin_slug, $installed_version, $api_url, $http_code, 0, 'failed', 'Unexpected HTTP response' );
|
||||
}
|
||||
|
||||
// Release the lock
|
||||
delete_option( $lock_key );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
<?php
|
||||
// phpcs:ignoreFile
|
||||
/**
|
||||
* Project: UpdateAPI
|
||||
* Author: Vontainment <services@vontainment.com>
|
||||
* License: https://opensource.org/licenses/MIT MIT License
|
||||
* Link: https://vontainment.com
|
||||
* Version: 3.0.0
|
||||
* Version: 4.0.0
|
||||
*
|
||||
* File: v-sys-theme-updater-mu.php
|
||||
* Description: WordPress Update API
|
||||
|
@ -18,12 +19,129 @@
|
|||
* @package VontainmentThemeUpdaterMU
|
||||
*/
|
||||
|
||||
if (! defined('ABSPATH')) {
|
||||
exit;
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the API key, requesting from the server when needed.
|
||||
*/
|
||||
if ( ! function_exists( 'vontmnt_get_api_key' ) ) {
|
||||
function vontmnt_get_api_key(): string {
|
||||
$key = get_option( 'vontmnt_api_key' );
|
||||
if ( ! $key || ( defined( 'VONTMNT_UPDATE_KEYREGEN' ) && VONTMNT_UPDATE_KEYREGEN ) ) {
|
||||
$base = defined( 'VONTMNT_API_URL' ) ? VONTMNT_API_URL : '';
|
||||
$api_url = add_query_arg(
|
||||
array(
|
||||
'type' => 'auth',
|
||||
'domain' => wp_parse_url( site_url(), PHP_URL_HOST ),
|
||||
),
|
||||
rtrim( $base, '/' ) . '/key'
|
||||
);
|
||||
$response = wp_remote_get( $api_url );
|
||||
if ( ! is_wp_error( $response ) && 200 === wp_remote_retrieve_response_code( $response ) ) {
|
||||
$key = wp_remote_retrieve_body( $response );
|
||||
update_option( 'vontmnt_api_key', $key );
|
||||
$wp_config = ABSPATH . 'wp-config.php';
|
||||
if ( file_exists( $wp_config ) && is_writable( $wp_config ) ) {
|
||||
$config = file_get_contents( $wp_config );
|
||||
if ( false !== $config ) {
|
||||
$config = preg_replace( "/define\(\s*'VONTMNT_UPDATE_KEYREGEN'\s*,\s*true\s*\);/i", "define('VONTMNT_UPDATE_KEYREGEN', false);", $config );
|
||||
file_put_contents( $wp_config, $config );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return is_string( $key ) ? $key : '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate ZIP package by checking header and optionally testing extraction.
|
||||
*
|
||||
* @param string $file_path Path to ZIP file.
|
||||
* @return bool True if valid ZIP package.
|
||||
*/
|
||||
if ( ! function_exists( 'vontmnt_validate_zip_package' ) ) {
|
||||
function vontmnt_validate_zip_package( string $file_path ): bool {
|
||||
if ( ! file_exists( $file_path ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check ZIP file header (magic bytes: PK\x03\x04)
|
||||
$handle = fopen( $file_path, 'rb' );
|
||||
if ( false === $handle ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$header = fread( $handle, 4 );
|
||||
fclose( $handle );
|
||||
|
||||
if ( 4 !== strlen( $header ) || "\x50\x4b\x03\x04" !== $header ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Test ZIP extraction using ZipArchive if available
|
||||
if ( class_exists( 'ZipArchive' ) ) {
|
||||
$zip = new ZipArchive();
|
||||
$result = $zip->open( $file_path );
|
||||
if ( true !== $result ) {
|
||||
return false;
|
||||
}
|
||||
$zip->close();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Redact the API key from a URL for logging purposes.
|
||||
*
|
||||
* @param string $url The URL that may contain an API key.
|
||||
* @return string The URL with the key parameter redacted.
|
||||
*/
|
||||
if ( ! function_exists( 'vontmnt_redact_key' ) ) {
|
||||
function vontmnt_redact_key( string $url ): string {
|
||||
return preg_replace( '/([?&]key=)[^&]*/', '$1[REDACTED]', $url );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log update context with detailed information.
|
||||
*
|
||||
* @param string $type Update type (plugin/theme).
|
||||
* @param string $slug Item slug.
|
||||
* @param string $version Item version.
|
||||
* @param string $url API URL called.
|
||||
* @param int $response_code HTTP response code.
|
||||
* @param int $response_size Response body size in bytes.
|
||||
* @param string $status Update status (success/failed/skipped).
|
||||
* @param string $message Optional message.
|
||||
*/
|
||||
if ( ! function_exists( 'vontmnt_log_update_context' ) ) {
|
||||
function vontmnt_log_update_context( string $type, string $slug, string $version, string $url, int $response_code, int $response_size, string $status, string $message = '' ): void {
|
||||
$context = sprintf(
|
||||
'[%s] %s:%s | URL: %s | HTTP: %d | Size: %d bytes | Status: %s',
|
||||
strtoupper( $type ),
|
||||
$slug,
|
||||
$version,
|
||||
vontmnt_redact_key( $url ),
|
||||
$response_code,
|
||||
$response_size,
|
||||
$status
|
||||
);
|
||||
|
||||
if ( ! empty( $message ) ) {
|
||||
$context .= ' | ' . $message;
|
||||
}
|
||||
|
||||
error_log( $context );
|
||||
}
|
||||
}
|
||||
|
||||
// Schedule the update check to run every day on the main site.
|
||||
add_action('wp', 'vontmnt_theme_updater_schedule_updates');
|
||||
add_action( 'admin_init', 'vontmnt_theme_updater_schedule_updates' );
|
||||
|
||||
/**
|
||||
* Schedule daily theme update checks for multisite.
|
||||
|
@ -33,82 +151,170 @@ add_action('wp', 'vontmnt_theme_updater_schedule_updates');
|
|||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://vontainment.com
|
||||
*/
|
||||
function vontmnt_theme_updater_schedule_updates(): void
|
||||
{
|
||||
if (! is_main_site()) {
|
||||
return;
|
||||
}
|
||||
if (! wp_next_scheduled('vontmnt_theme_updater_check_updates')) {
|
||||
wp_schedule_event(time(), 'daily', 'vontmnt_theme_updater_check_updates');
|
||||
}
|
||||
function vontmnt_theme_updater_schedule_updates(): void {
|
||||
if ( ! is_main_site() ) {
|
||||
return;
|
||||
}
|
||||
if ( ! wp_next_scheduled( 'vontmnt_theme_updater_check_updates' ) ) {
|
||||
wp_schedule_event( time(), 'daily', 'vontmnt_theme_updater_check_updates' );
|
||||
}
|
||||
}
|
||||
|
||||
add_action('vontmnt_theme_updater_check_updates', 'vontmnt_theme_updater_run_updates');
|
||||
add_action( 'vontmnt_theme_updater_check_updates', 'vontmnt_theme_updater_run_updates' );
|
||||
add_action( 'vontmnt_theme_update_single', 'vontmnt_theme_update_single', 10, 2 );
|
||||
|
||||
/**
|
||||
* Run theme updates for all installed themes on the main site.
|
||||
* Schedule theme update checks for all installed themes on the main site.
|
||||
*
|
||||
* @package UpdateAPI
|
||||
* @author Vontainment <services@vontainment.com>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://vontainment.com
|
||||
*/
|
||||
function vontmnt_theme_updater_run_updates(): void
|
||||
{
|
||||
if (! is_main_site()) {
|
||||
return;
|
||||
}
|
||||
if (! function_exists('wp_get_themes')) {
|
||||
require_once ABSPATH . 'wp-includes/theme.php';
|
||||
}
|
||||
$themes = wp_get_themes();
|
||||
foreach ($themes as $theme) {
|
||||
$theme_slug = $theme->get_stylesheet();
|
||||
$installed_version = $theme->get('Version');
|
||||
$api_url = add_query_arg(
|
||||
array(
|
||||
'type' => 'theme',
|
||||
'domain' => rawurlencode(wp_parse_url(site_url(), PHP_URL_HOST)),
|
||||
'slug' => rawurlencode($theme_slug),
|
||||
'version' => rawurlencode($installed_version),
|
||||
'key' => VONTMENT_KEY,
|
||||
),
|
||||
VONTMENT_THEMES
|
||||
);
|
||||
|
||||
$response = wp_remote_get($api_url);
|
||||
$http_code = wp_remote_retrieve_response_code($response);
|
||||
$response_body = wp_remote_retrieve_body($response);
|
||||
|
||||
if ($http_code === 200 && ! empty($response_body)) {
|
||||
require_once ABSPATH . 'wp-admin/includes/file.php';
|
||||
$upload_dir = wp_upload_dir();
|
||||
$theme_zip_file = $upload_dir['path'] . '/' . basename($theme_slug) . '.zip';
|
||||
file_put_contents($theme_zip_file, $response_body);
|
||||
|
||||
global $wp_filesystem;
|
||||
if (empty($wp_filesystem)) {
|
||||
require_once ABSPATH . '/wp-admin/includes/file.php';
|
||||
WP_Filesystem();
|
||||
}
|
||||
|
||||
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
|
||||
$upgrader = new Theme_Upgrader();
|
||||
$callback = function ($options) use ($theme_zip_file) {
|
||||
$options['package'] = $theme_zip_file;
|
||||
$options['clear_destination'] = true;
|
||||
return $options;
|
||||
};
|
||||
add_filter('upgrader_package_options', $callback);
|
||||
$upgrader->install($theme_zip_file);
|
||||
remove_filter('upgrader_package_options', $callback);
|
||||
|
||||
// Delete the theme zip file using wp_delete_file.
|
||||
wp_delete_file($theme_zip_file);
|
||||
} elseif ($http_code === 204) {
|
||||
continue;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
function vontmnt_theme_updater_run_updates(): void {
|
||||
if ( ! is_main_site() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Atomic locking using add_option pattern
|
||||
$lock_key = 'vontmnt_theme_updates_scheduling';
|
||||
if ( ! add_option( $lock_key, time(), '', false ) ) {
|
||||
// Lock exists, another scheduling run is in progress
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'wp_get_themes' ) ) {
|
||||
require_once ABSPATH . 'wp-includes/theme.php';
|
||||
}
|
||||
$themes = wp_get_themes();
|
||||
|
||||
$when = time() + 5; // tiny jitter to reduce "same-second" collisions
|
||||
|
||||
foreach ( $themes as $theme ) {
|
||||
$theme_slug = $theme->get_stylesheet();
|
||||
$installed_version = $theme->get( 'Version' );
|
||||
// Schedule individual theme update check
|
||||
wp_schedule_single_event( $when, 'vontmnt_theme_update_single', array( $theme_slug, $installed_version ) );
|
||||
$when += rand( 0, 2 ); // Add small jitter per theme to further reduce collisions
|
||||
}
|
||||
|
||||
// Release the lock
|
||||
delete_option( $lock_key );
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a single theme.
|
||||
*
|
||||
* @package UpdateAPI
|
||||
* @author Vontainment <services@vontainment.com>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://vontainment.com
|
||||
*/
|
||||
function vontmnt_theme_update_single( $theme_slug, $installed_version ): void {
|
||||
if ( ! is_main_site() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Atomic locking using add_option pattern
|
||||
$lock_key = 'vontmnt_updating_theme_' . md5( $theme_slug );
|
||||
if ( ! add_option( $lock_key, time(), '', false ) ) {
|
||||
// Lock exists, another update is in progress
|
||||
return;
|
||||
}
|
||||
|
||||
$api_url = add_query_arg(
|
||||
array(
|
||||
'type' => 'theme',
|
||||
'domain' => wp_parse_url( site_url(), PHP_URL_HOST ),
|
||||
'slug' => $theme_slug,
|
||||
'version' => $installed_version,
|
||||
'key' => vontmnt_get_api_key(),
|
||||
),
|
||||
VONTMNT_API_URL
|
||||
);
|
||||
|
||||
$response = wp_remote_get( $api_url );
|
||||
if ( is_wp_error( $response ) ) {
|
||||
vontmnt_log_update_context( 'theme', $theme_slug, $installed_version, $api_url, 0, 0, 'failed', 'HTTP error: ' . $response->get_error_message() );
|
||||
delete_option( $lock_key );
|
||||
return;
|
||||
}
|
||||
|
||||
$http_code = wp_remote_retrieve_response_code( $response );
|
||||
$response_body = wp_remote_retrieve_body( $response );
|
||||
|
||||
if ( $http_code === 200 && ! empty( $response_body ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/file.php';
|
||||
|
||||
// Initialize WP_Filesystem before any file operations
|
||||
global $wp_filesystem;
|
||||
if ( empty( $wp_filesystem ) ) {
|
||||
WP_Filesystem();
|
||||
}
|
||||
|
||||
$upload_dir = wp_upload_dir();
|
||||
$theme_zip_file = $upload_dir['path'] . '/' . $theme_slug . '.zip';
|
||||
|
||||
// Stream large files to disk instead of loading into memory
|
||||
$temp_file = wp_tempnam( $theme_zip_file );
|
||||
$stream_response = wp_remote_get( $api_url, array( 'stream' => true, 'filename' => $temp_file ) );
|
||||
|
||||
if ( is_wp_error( $stream_response ) ) {
|
||||
vontmnt_log_update_context( 'theme', $theme_slug, $installed_version, $api_url, $http_code, 0, 'failed', 'Failed to stream update package' );
|
||||
delete_option( $lock_key );
|
||||
return;
|
||||
}
|
||||
|
||||
// Move temp file to final location
|
||||
if ( ! $wp_filesystem->move( $temp_file, $theme_zip_file ) ) {
|
||||
vontmnt_log_update_context( 'theme', $theme_slug, $installed_version, $api_url, $http_code, 0, 'failed', 'Failed to move update package' );
|
||||
wp_delete_file( $temp_file );
|
||||
delete_option( $lock_key );
|
||||
return;
|
||||
}
|
||||
|
||||
$response_size = filesize( $theme_zip_file );
|
||||
|
||||
// Validate ZIP package before installation
|
||||
if ( ! vontmnt_validate_zip_package( $theme_zip_file ) ) {
|
||||
vontmnt_log_update_context( 'theme', $theme_slug, $installed_version, $api_url, $http_code, $response_size, 'failed', 'Invalid ZIP package' );
|
||||
wp_delete_file( $theme_zip_file );
|
||||
delete_option( $lock_key );
|
||||
return;
|
||||
}
|
||||
|
||||
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
|
||||
$upgrader = new Theme_Upgrader();
|
||||
$callback = function ( $options ) use ( $theme_zip_file ) {
|
||||
$options['package'] = $theme_zip_file;
|
||||
$options['clear_destination'] = true;
|
||||
return $options;
|
||||
};
|
||||
add_filter( 'upgrader_package_options', $callback );
|
||||
$result = $upgrader->install( $theme_zip_file );
|
||||
remove_filter( 'upgrader_package_options', $callback );
|
||||
|
||||
// Delete the theme zip file using wp_delete_file.
|
||||
wp_delete_file( $theme_zip_file );
|
||||
|
||||
// Post-install housekeeping: refresh theme update data
|
||||
if ( function_exists( 'wp_clean_themes_cache' ) ) {
|
||||
wp_clean_themes_cache();
|
||||
}
|
||||
|
||||
// Log success or failure
|
||||
if ( ! is_wp_error( $result ) && $result ) {
|
||||
vontmnt_log_update_context( 'theme', $theme_slug, $installed_version, $api_url, $http_code, $response_size, 'success', 'Theme updated successfully' );
|
||||
} else {
|
||||
$error_msg = is_wp_error( $result ) ? $result->get_error_message() : 'Installation failed';
|
||||
vontmnt_log_update_context( 'theme', $theme_slug, $installed_version, $api_url, $http_code, $response_size, 'failed', $error_msg );
|
||||
}
|
||||
} elseif ( 204 === $http_code ) {
|
||||
vontmnt_log_update_context( 'theme', $theme_slug, $installed_version, $api_url, $http_code, 0, 'skipped', 'No update available' );
|
||||
} else {
|
||||
vontmnt_log_update_context( 'theme', $theme_slug, $installed_version, $api_url, $http_code, 0, 'failed', 'Unexpected HTTP response' );
|
||||
}
|
||||
|
||||
// Release the lock
|
||||
delete_option( $lock_key );
|
||||
}
|
||||
|
|
|
@ -1,108 +1,307 @@
|
|||
<?php
|
||||
// phpcs:ignoreFile
|
||||
/**
|
||||
* Project: UpdateAPI
|
||||
* Author: Vontainment <services@vontainment.com>
|
||||
* License: https://opensource.org/licenses/MIT MIT License
|
||||
* Link: https://vontainment.com
|
||||
* Version: 3.0.0
|
||||
* Version: 4.0.0
|
||||
*
|
||||
* File: v-sys-theme-updater.php
|
||||
* Description: WordPress Update API
|
||||
*
|
||||
* Theme Name: WP Theme Updater
|
||||
* Theme URI: https://vontainment.com
|
||||
* Description: This theme updates your WordPress themes.
|
||||
* Plugin Name: WP Theme Updater
|
||||
* Plugin URI: https://vontainment.com
|
||||
* Description: This plugin updates your WordPress themes.
|
||||
* Version: 1.2.0
|
||||
* Author: Vontainment
|
||||
* Author URI: https://vontainment.com
|
||||
* @package VontainmentThemeUpdater
|
||||
*/
|
||||
|
||||
if (! defined('ABSPATH')) {
|
||||
exit;
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the API key, requesting from the server when needed.
|
||||
*/
|
||||
if ( ! function_exists( 'vontmnt_get_api_key' ) ) {
|
||||
function vontmnt_get_api_key(): string {
|
||||
$key = get_option( 'vontmnt_api_key' );
|
||||
if ( ! $key || ( defined( 'VONTMNT_UPDATE_KEYREGEN' ) && VONTMNT_UPDATE_KEYREGEN ) ) {
|
||||
$base = defined( 'VONTMNT_API_URL' ) ? VONTMNT_API_URL : '';
|
||||
$api_url = add_query_arg(
|
||||
array(
|
||||
'type' => 'auth',
|
||||
'domain' => wp_parse_url( site_url(), PHP_URL_HOST ),
|
||||
),
|
||||
rtrim( $base, '/' ) . '/key'
|
||||
);
|
||||
$response = wp_remote_get( $api_url );
|
||||
if ( ! is_wp_error( $response ) && 200 === wp_remote_retrieve_response_code( $response ) ) {
|
||||
$key = wp_remote_retrieve_body( $response );
|
||||
update_option( 'vontmnt_api_key', $key );
|
||||
$wp_config = ABSPATH . 'wp-config.php';
|
||||
if ( file_exists( $wp_config ) && is_writable( $wp_config ) ) {
|
||||
$config = file_get_contents( $wp_config );
|
||||
if ( false !== $config ) {
|
||||
$config = preg_replace( "/define\(\s*'VONTMNT_UPDATE_KEYREGEN'\s*,\s*true\s*\);/i", "define('VONTMNT_UPDATE_KEYREGEN', false);", $config );
|
||||
file_put_contents( $wp_config, $config );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return is_string( $key ) ? $key : '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* Validate ZIP package by checking header and optionally testing extraction.
|
||||
*
|
||||
* @param string $file_path Path to ZIP file.
|
||||
* @return bool True if valid ZIP package.
|
||||
*/
|
||||
if ( ! function_exists( 'vontmnt_validate_zip_package' ) ) {
|
||||
function vontmnt_validate_zip_package( string $file_path ): bool {
|
||||
if ( ! file_exists( $file_path ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check ZIP file header (magic bytes: PK\x03\x04)
|
||||
$handle = fopen( $file_path, 'rb' );
|
||||
if ( false === $handle ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$header = fread( $handle, 4 );
|
||||
fclose( $handle );
|
||||
|
||||
if ( 4 !== strlen( $header ) || "\x50\x4b\x03\x04" !== $header ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Test ZIP extraction using ZipArchive if available
|
||||
if ( class_exists( 'ZipArchive' ) ) {
|
||||
$zip = new ZipArchive();
|
||||
$result = $zip->open( $file_path );
|
||||
if ( true !== $result ) {
|
||||
return false;
|
||||
}
|
||||
$zip->close();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Redact the API key from a URL for logging purposes.
|
||||
*
|
||||
* @param string $url The URL that may contain an API key.
|
||||
* @return string The URL with the key parameter redacted.
|
||||
*/
|
||||
if ( ! function_exists( 'vontmnt_redact_key' ) ) {
|
||||
function vontmnt_redact_key( string $url ): string {
|
||||
return preg_replace( '/([?&]key=)[^&]*/', '$1[REDACTED]', $url );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log update context with detailed information.
|
||||
*
|
||||
* @param string $type Update type (plugin/theme).
|
||||
* @param string $slug Item slug.
|
||||
* @param string $version Item version.
|
||||
* @param string $url API URL called.
|
||||
* @param int $response_code HTTP response code.
|
||||
* @param int $response_size Response body size in bytes.
|
||||
* @param string $status Update status (success/failed/skipped).
|
||||
* @param string $message Optional message.
|
||||
*/
|
||||
if ( ! function_exists( 'vontmnt_log_update_context' ) ) {
|
||||
function vontmnt_log_update_context( string $type, string $slug, string $version, string $url, int $response_code, int $response_size, string $status, string $message = '' ): void {
|
||||
$context = sprintf(
|
||||
'[%s] %s:%s | URL: %s | HTTP: %d | Size: %d bytes | Status: %s',
|
||||
strtoupper( $type ),
|
||||
$slug,
|
||||
$version,
|
||||
vontmnt_redact_key( $url ),
|
||||
$response_code,
|
||||
$response_size,
|
||||
$status
|
||||
);
|
||||
|
||||
if ( ! empty( $message ) ) {
|
||||
$context .= ' | ' . $message;
|
||||
}
|
||||
|
||||
error_log( $context );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @package UpdateAPI
|
||||
* @author Vontainment <services@vontainment.com>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://vontainment.com
|
||||
*
|
||||
* Schedule daily theme update checks. */
|
||||
function vontmnt_theme_updater_schedule_updates(): void
|
||||
{
|
||||
if (! wp_next_scheduled('vontmnt_theme_updater_check_updates')) {
|
||||
wp_schedule_event(time(), 'daily', 'vontmnt_theme_updater_check_updates');
|
||||
}
|
||||
function vontmnt_theme_updater_schedule_updates(): void {
|
||||
if ( ! wp_next_scheduled( 'vontmnt_theme_updater_check_updates' ) ) {
|
||||
wp_schedule_event( time(), 'daily', 'vontmnt_theme_updater_check_updates' );
|
||||
}
|
||||
}
|
||||
|
||||
add_action('wp', 'vontmnt_theme_updater_schedule_updates');
|
||||
add_action( 'admin_init', 'vontmnt_theme_updater_schedule_updates' );
|
||||
|
||||
add_action('vontmnt_theme_updater_check_updates', 'vontmnt_theme_updater_run_updates');
|
||||
add_action( 'vontmnt_theme_updater_check_updates', 'vontmnt_theme_updater_run_updates' );
|
||||
add_action( 'vontmnt_theme_update_single', 'vontmnt_theme_update_single', 10, 2 );
|
||||
|
||||
/**
|
||||
/**
|
||||
* @package UpdateAPI
|
||||
* @author Vontainment <services@vontainment.com>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://vontainment.com
|
||||
*
|
||||
* Run theme updates for all installed themes. */
|
||||
function vontmnt_theme_updater_run_updates(): void
|
||||
{
|
||||
if (! function_exists('wp_get_themes')) {
|
||||
require_once ABSPATH . 'wp-includes/theme.php';
|
||||
}
|
||||
$themes = wp_get_themes();
|
||||
foreach ($themes as $theme) {
|
||||
$theme_slug = $theme->get_stylesheet();
|
||||
$installed_version = $theme->get('Version');
|
||||
$api_url = add_query_arg(
|
||||
array(
|
||||
'type' => 'theme',
|
||||
'domain' => rawurlencode(wp_parse_url(site_url(), PHP_URL_HOST)),
|
||||
'slug' => rawurlencode($theme_slug),
|
||||
'version' => rawurlencode($installed_version),
|
||||
'key' => VONTMENT_KEY,
|
||||
),
|
||||
VONTMENT_THEMES
|
||||
);
|
||||
|
||||
$response = wp_remote_get($api_url);
|
||||
$http_code = wp_remote_retrieve_response_code($response);
|
||||
$response_body = wp_remote_retrieve_body($response);
|
||||
|
||||
if ($http_code === 200 && ! empty($response_body)) {
|
||||
require_once ABSPATH . 'wp-admin/includes/file.php';
|
||||
$upload_dir = wp_upload_dir();
|
||||
$theme_zip_file = $upload_dir['path'] . '/' . basename($theme_slug) . '.zip';
|
||||
file_put_contents($theme_zip_file, $response_body);
|
||||
|
||||
global $wp_filesystem;
|
||||
if (empty($wp_filesystem)) {
|
||||
require_once ABSPATH . '/wp-admin/includes/file.php';
|
||||
WP_Filesystem();
|
||||
}
|
||||
|
||||
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
|
||||
$upgrader = new Theme_Upgrader();
|
||||
$callback = function ($options) use ($theme_zip_file) {
|
||||
$options['package'] = $theme_zip_file;
|
||||
$options['clear_destination'] = true;
|
||||
return $options;
|
||||
};
|
||||
add_filter('upgrader_package_options', $callback);
|
||||
$upgrader->install($theme_zip_file);
|
||||
remove_filter('upgrader_package_options', $callback);
|
||||
|
||||
// Delete the theme zip file using wp_delete_file.
|
||||
wp_delete_file($theme_zip_file);
|
||||
} elseif ($http_code === 204) {
|
||||
// No updates, check next theme.
|
||||
continue;
|
||||
} else {
|
||||
// For 400, 403, or any other unexpected code, stop further processing.
|
||||
break;
|
||||
}
|
||||
}
|
||||
* Schedule theme update checks for all installed themes. */
|
||||
function vontmnt_theme_updater_run_updates(): void {
|
||||
// Atomic locking using add_option pattern
|
||||
$lock_key = 'vontmnt_theme_updates_scheduling';
|
||||
if ( ! add_option( $lock_key, time(), '', false ) ) {
|
||||
// Lock exists, another scheduling run is in progress
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'wp_get_themes' ) ) {
|
||||
require_once ABSPATH . 'wp-includes/theme.php';
|
||||
}
|
||||
$themes = wp_get_themes();
|
||||
|
||||
$when = time() + 5; // tiny jitter to reduce "same-second" collisions
|
||||
|
||||
foreach ( $themes as $theme ) {
|
||||
$theme_slug = $theme->get_stylesheet();
|
||||
$installed_version = $theme->get( 'Version' );
|
||||
// Schedule individual theme update check
|
||||
wp_schedule_single_event( $when, 'vontmnt_theme_update_single', array( $theme_slug, $installed_version ) );
|
||||
$when += rand( 0, 2 ); // Add small jitter per theme to further reduce collisions
|
||||
}
|
||||
|
||||
// Release the lock
|
||||
delete_option( $lock_key );
|
||||
}
|
||||
|
||||
/**
|
||||
* @package UpdateAPI
|
||||
* @author Vontainment <services@vontainment.com>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://vontainment.com
|
||||
*
|
||||
* Update a single theme. */
|
||||
function vontmnt_theme_update_single( $theme_slug, $installed_version ): void {
|
||||
// Atomic locking using add_option pattern
|
||||
$lock_key = 'vontmnt_updating_theme_' . md5( $theme_slug );
|
||||
if ( ! add_option( $lock_key, time(), '', false ) ) {
|
||||
// Lock exists, another update is in progress
|
||||
return;
|
||||
}
|
||||
|
||||
$api_url = add_query_arg(
|
||||
array(
|
||||
'type' => 'theme',
|
||||
'domain' => wp_parse_url( site_url(), PHP_URL_HOST ),
|
||||
'slug' => $theme_slug,
|
||||
'version' => $installed_version,
|
||||
'key' => vontmnt_get_api_key(),
|
||||
),
|
||||
VONTMNT_API_URL
|
||||
);
|
||||
|
||||
$response = wp_remote_get( $api_url );
|
||||
if ( is_wp_error( $response ) ) {
|
||||
vontmnt_log_update_context( 'theme', $theme_slug, $installed_version, $api_url, 0, 0, 'failed', 'HTTP error: ' . $response->get_error_message() );
|
||||
delete_option( $lock_key );
|
||||
return;
|
||||
}
|
||||
|
||||
$http_code = wp_remote_retrieve_response_code( $response );
|
||||
$response_body = wp_remote_retrieve_body( $response );
|
||||
|
||||
if ( $http_code === 200 && ! empty( $response_body ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/file.php';
|
||||
|
||||
// Initialize WP_Filesystem before any file operations
|
||||
global $wp_filesystem;
|
||||
if ( empty( $wp_filesystem ) ) {
|
||||
WP_Filesystem();
|
||||
}
|
||||
|
||||
$upload_dir = wp_upload_dir();
|
||||
$theme_zip_file = $upload_dir['path'] . '/' . $theme_slug . '.zip';
|
||||
|
||||
// Stream large files to disk instead of loading into memory
|
||||
$temp_file = wp_tempnam( $theme_zip_file );
|
||||
$stream_response = wp_remote_get( $api_url, array( 'stream' => true, 'filename' => $temp_file ) );
|
||||
|
||||
if ( is_wp_error( $stream_response ) ) {
|
||||
vontmnt_log_update_context( 'theme', $theme_slug, $installed_version, $api_url, $http_code, 0, 'failed', 'Failed to stream update package' );
|
||||
delete_option( $lock_key );
|
||||
return;
|
||||
}
|
||||
|
||||
// Move temp file to final location
|
||||
if ( ! $wp_filesystem->move( $temp_file, $theme_zip_file ) ) {
|
||||
vontmnt_log_update_context( 'theme', $theme_slug, $installed_version, $api_url, $http_code, 0, 'failed', 'Failed to move update package' );
|
||||
wp_delete_file( $temp_file );
|
||||
delete_option( $lock_key );
|
||||
return;
|
||||
}
|
||||
|
||||
$response_size = filesize( $theme_zip_file );
|
||||
|
||||
// Validate ZIP package before installation
|
||||
if ( ! vontmnt_validate_zip_package( $theme_zip_file ) ) {
|
||||
vontmnt_log_update_context( 'theme', $theme_slug, $installed_version, $api_url, $http_code, $response_size, 'failed', 'Invalid ZIP package' );
|
||||
wp_delete_file( $theme_zip_file );
|
||||
delete_option( $lock_key );
|
||||
return;
|
||||
}
|
||||
|
||||
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
|
||||
$upgrader = new Theme_Upgrader();
|
||||
$callback = function ( $options ) use ( $theme_zip_file ) {
|
||||
$options['package'] = $theme_zip_file;
|
||||
$options['clear_destination'] = true;
|
||||
return $options;
|
||||
};
|
||||
add_filter( 'upgrader_package_options', $callback );
|
||||
$result = $upgrader->install( $theme_zip_file );
|
||||
remove_filter( 'upgrader_package_options', $callback );
|
||||
|
||||
// Delete the theme zip file using wp_delete_file.
|
||||
wp_delete_file( $theme_zip_file );
|
||||
|
||||
// Post-install housekeeping: refresh theme update data
|
||||
if ( function_exists( 'wp_clean_themes_cache' ) ) {
|
||||
wp_clean_themes_cache();
|
||||
}
|
||||
|
||||
// Log success or failure
|
||||
if ( ! is_wp_error( $result ) && $result ) {
|
||||
vontmnt_log_update_context( 'theme', $theme_slug, $installed_version, $api_url, $http_code, $response_size, 'success', 'Theme updated successfully' );
|
||||
} else {
|
||||
$error_msg = is_wp_error( $result ) ? $result->get_error_message() : 'Installation failed';
|
||||
vontmnt_log_update_context( 'theme', $theme_slug, $installed_version, $api_url, $http_code, $response_size, 'failed', $error_msg );
|
||||
}
|
||||
} elseif ( 204 === $http_code ) {
|
||||
vontmnt_log_update_context( 'theme', $theme_slug, $installed_version, $api_url, $http_code, 0, 'skipped', 'No update available' );
|
||||
} else {
|
||||
vontmnt_log_update_context( 'theme', $theme_slug, $installed_version, $api_url, $http_code, 0, 'failed', 'Unexpected HTTP response' );
|
||||
}
|
||||
|
||||
// Release the lock
|
||||
delete_option( $lock_key );
|
||||
}
|
||||
|
|
436
node_modules/.package-lock.json
generated
vendored
436
node_modules/.package-lock.json
generated
vendored
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"name": "v-wordpress-plugin-updater",
|
||||
"name": "v-wordpress-plugin-updater-root",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
|
@ -148,19 +149,6 @@
|
|||
"eslint": "^6.0.0 || ^7.0.0 || >=8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys": {
|
||||
"version": "3.4.3",
|
||||
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz",
|
||||
"integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/@eslint-community/regexpp": {
|
||||
"version": "4.12.1",
|
||||
"resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.1.tgz",
|
||||
|
@ -171,55 +159,17 @@
|
|||
"node": "^12.0.0 || ^14.0.0 || >=16.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@eslint/config-array": {
|
||||
"version": "0.21.0",
|
||||
"resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.21.0.tgz",
|
||||
"integrity": "sha512-ENIdc4iLu0d93HeYirvKmrzshzofPw6VkZRKQGe9Nv46ZnWUzcF1xV01dcvEg/1wXUR61OmmlSfyeyO7EvjLxQ==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@eslint/object-schema": "^2.1.6",
|
||||
"debug": "^4.3.1",
|
||||
"minimatch": "^3.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@eslint/config-helpers": {
|
||||
"version": "0.3.1",
|
||||
"resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.3.1.tgz",
|
||||
"integrity": "sha512-xR93k9WhrDYpXHORXpxVL5oHj3Era7wo6k/Wd8/IsQNnZUTzkGS29lyn3nAT05v6ltUuTFVCCYDEGfy2Or/sPA==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@eslint/core": {
|
||||
"version": "0.15.2",
|
||||
"resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.15.2.tgz",
|
||||
"integrity": "sha512-78Md3/Rrxh83gCxoUc0EiciuOHsIITzLy53m3d9UyiW8y9Dj2D29FeETqyKA+BRK76tnTp6RXWb3pCay8Oyomg==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@types/json-schema": "^7.0.15"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@eslint/eslintrc": {
|
||||
"version": "3.3.1",
|
||||
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.3.1.tgz",
|
||||
"integrity": "sha512-gtF186CXhIl1p4pJNGZw8Yc6RlshoePRvE0X91oPGb3vZ8pM3qOS9W9NGPat9LziaBV7XrJWGylNQXkGcnM3IQ==",
|
||||
"version": "2.1.4",
|
||||
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz",
|
||||
"integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ajv": "^6.12.4",
|
||||
"debug": "^4.3.2",
|
||||
"espree": "^10.0.1",
|
||||
"globals": "^14.0.0",
|
||||
"espree": "^9.6.0",
|
||||
"globals": "^13.19.0",
|
||||
"ignore": "^5.2.0",
|
||||
"import-fresh": "^3.2.1",
|
||||
"js-yaml": "^4.1.0",
|
||||
|
@ -227,85 +177,36 @@
|
|||
"strip-json-comments": "^3.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/@eslint/js": {
|
||||
"version": "9.33.0",
|
||||
"resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.33.0.tgz",
|
||||
"integrity": "sha512-5K1/mKhWaMfreBGJTwval43JJmkip0RmM+3+IuqupeSKNC/Th2Kc7ucaq5ovTSra/OOKB9c58CGSz3QMVbWt0A==",
|
||||
"version": "8.57.1",
|
||||
"resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.1.tgz",
|
||||
"integrity": "sha512-d9zaMRSTIKDLhctzH12MtXvJKSSUhaHcjV+2Z+GK+EEY7XKpP5yR4x+N3TAcHTcu963nIr+TMcCb4DBCYX1z6Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://eslint.org/donate"
|
||||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@eslint/object-schema": {
|
||||
"version": "2.1.6",
|
||||
"resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.6.tgz",
|
||||
"integrity": "sha512-RBMg5FRL0I0gs51M/guSAj5/e14VQ4tpZnQNWwuDT66P14I43ItmPfIZRhO9fUVIPOAQXU47atlywZ/czoqFPA==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@eslint/plugin-kit": {
|
||||
"version": "0.3.5",
|
||||
"resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.3.5.tgz",
|
||||
"integrity": "sha512-Z5kJ+wU3oA7MMIqVR9tyZRtjYPr4OC004Q4Rw7pgOKUOKkJfZ3O24nz3WYfGRpMDNmcOi3TwQOmgm7B7Tpii0w==",
|
||||
"node_modules/@humanwhocodes/config-array": {
|
||||
"version": "0.13.0",
|
||||
"resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.13.0.tgz",
|
||||
"integrity": "sha512-DZLEEqFWQFiyK6h5YIeynKx7JlvCYWL0cImfSRXZ9l4Sg2efkFGTuFf6vzXjK1cq6IYkU+Eg/JizXw+TD2vRNw==",
|
||||
"deprecated": "Use @eslint/config-array instead",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@eslint/core": "^0.15.2",
|
||||
"levn": "^0.4.1"
|
||||
"@humanwhocodes/object-schema": "^2.0.3",
|
||||
"debug": "^4.3.1",
|
||||
"minimatch": "^3.0.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@humanfs/core": {
|
||||
"version": "0.19.1",
|
||||
"resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.1.tgz",
|
||||
"integrity": "sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
"node": ">=18.18.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@humanfs/node": {
|
||||
"version": "0.16.6",
|
||||
"resolved": "https://registry.npmjs.org/@humanfs/node/-/node-0.16.6.tgz",
|
||||
"integrity": "sha512-YuI2ZHQL78Q5HbhDiBA1X4LmYdXCKCMQIfw0pw7piHJwyREFebJUvrQN4cMssyES6x+vfUbx1CIpaQUKYdQZOw==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@humanfs/core": "^0.19.1",
|
||||
"@humanwhocodes/retry": "^0.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18.18.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@humanfs/node/node_modules/@humanwhocodes/retry": {
|
||||
"version": "0.3.1",
|
||||
"resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.3.1.tgz",
|
||||
"integrity": "sha512-JBxkERygn7Bv/GbN5Rv8Ul6LVknS+5Bp6RgDC/O8gEBU/yeH5Ui5C/OlWrTb6qct7LjjfT6Re2NxB0ln0yYybA==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
"node": ">=18.18"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/nzakas"
|
||||
"node": ">=10.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@humanwhocodes/module-importer": {
|
||||
|
@ -322,19 +223,13 @@
|
|||
"url": "https://github.com/sponsors/nzakas"
|
||||
}
|
||||
},
|
||||
"node_modules/@humanwhocodes/retry": {
|
||||
"version": "0.4.3",
|
||||
"resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.4.3.tgz",
|
||||
"integrity": "sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==",
|
||||
"node_modules/@humanwhocodes/object-schema": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz",
|
||||
"integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==",
|
||||
"deprecated": "Use @eslint/object-schema instead",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
"node": ">=18.18"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/nzakas"
|
||||
}
|
||||
"license": "BSD-3-Clause"
|
||||
},
|
||||
"node_modules/@keyv/serialize": {
|
||||
"version": "1.1.0",
|
||||
|
@ -381,19 +276,12 @@
|
|||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/estree": {
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz",
|
||||
"integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==",
|
||||
"node_modules/@ungap/structured-clone": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.3.0.tgz",
|
||||
"integrity": "sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/json-schema": {
|
||||
"version": "7.0.15",
|
||||
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz",
|
||||
"integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/acorn": {
|
||||
"version": "8.15.0",
|
||||
|
@ -718,6 +606,19 @@
|
|||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/doctrine": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz",
|
||||
"integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"esutils": "^2.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/emoji-regex": {
|
||||
"version": "8.0.0",
|
||||
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
|
||||
|
@ -759,70 +660,66 @@
|
|||
}
|
||||
},
|
||||
"node_modules/eslint": {
|
||||
"version": "9.33.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint/-/eslint-9.33.0.tgz",
|
||||
"integrity": "sha512-TS9bTNIryDzStCpJN93aC5VRSW3uTx9sClUn4B87pwiCaJh220otoI0X8mJKr+VcPtniMdN8GKjlwgWGUv5ZKA==",
|
||||
"version": "8.57.1",
|
||||
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.1.tgz",
|
||||
"integrity": "sha512-ypowyDxpVSYpkXr9WPv2PAZCtNip1Mv5KTW0SCurXv/9iOpcrH9PaqUElksqEB6pChqHGDRCFTyrZlGhnLNGiA==",
|
||||
"deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@eslint-community/eslint-utils": "^4.2.0",
|
||||
"@eslint-community/regexpp": "^4.12.1",
|
||||
"@eslint/config-array": "^0.21.0",
|
||||
"@eslint/config-helpers": "^0.3.1",
|
||||
"@eslint/core": "^0.15.2",
|
||||
"@eslint/eslintrc": "^3.3.1",
|
||||
"@eslint/js": "9.33.0",
|
||||
"@eslint/plugin-kit": "^0.3.5",
|
||||
"@humanfs/node": "^0.16.6",
|
||||
"@eslint-community/regexpp": "^4.6.1",
|
||||
"@eslint/eslintrc": "^2.1.4",
|
||||
"@eslint/js": "8.57.1",
|
||||
"@humanwhocodes/config-array": "^0.13.0",
|
||||
"@humanwhocodes/module-importer": "^1.0.1",
|
||||
"@humanwhocodes/retry": "^0.4.2",
|
||||
"@types/estree": "^1.0.6",
|
||||
"@types/json-schema": "^7.0.15",
|
||||
"@nodelib/fs.walk": "^1.2.8",
|
||||
"@ungap/structured-clone": "^1.2.0",
|
||||
"ajv": "^6.12.4",
|
||||
"chalk": "^4.0.0",
|
||||
"cross-spawn": "^7.0.6",
|
||||
"cross-spawn": "^7.0.2",
|
||||
"debug": "^4.3.2",
|
||||
"doctrine": "^3.0.0",
|
||||
"escape-string-regexp": "^4.0.0",
|
||||
"eslint-scope": "^8.4.0",
|
||||
"eslint-visitor-keys": "^4.2.1",
|
||||
"espree": "^10.4.0",
|
||||
"esquery": "^1.5.0",
|
||||
"eslint-scope": "^7.2.2",
|
||||
"eslint-visitor-keys": "^3.4.3",
|
||||
"espree": "^9.6.1",
|
||||
"esquery": "^1.4.2",
|
||||
"esutils": "^2.0.2",
|
||||
"fast-deep-equal": "^3.1.3",
|
||||
"file-entry-cache": "^8.0.0",
|
||||
"file-entry-cache": "^6.0.1",
|
||||
"find-up": "^5.0.0",
|
||||
"glob-parent": "^6.0.2",
|
||||
"globals": "^13.19.0",
|
||||
"graphemer": "^1.4.0",
|
||||
"ignore": "^5.2.0",
|
||||
"imurmurhash": "^0.1.4",
|
||||
"is-glob": "^4.0.0",
|
||||
"is-path-inside": "^3.0.3",
|
||||
"js-yaml": "^4.1.0",
|
||||
"json-stable-stringify-without-jsonify": "^1.0.1",
|
||||
"levn": "^0.4.1",
|
||||
"lodash.merge": "^4.6.2",
|
||||
"minimatch": "^3.1.2",
|
||||
"natural-compare": "^1.4.0",
|
||||
"optionator": "^0.9.3"
|
||||
"optionator": "^0.9.3",
|
||||
"strip-ansi": "^6.0.1",
|
||||
"text-table": "^0.2.0"
|
||||
},
|
||||
"bin": {
|
||||
"eslint": "bin/eslint.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://eslint.org/donate"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"jiti": "*"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"jiti": {
|
||||
"optional": true
|
||||
}
|
||||
"url": "https://opencollective.com/eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-scope": {
|
||||
"version": "8.4.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.4.0.tgz",
|
||||
"integrity": "sha512-sNXOfKCn74rt8RICKMvJS7XKV/Xk9kA7DyJr8mJik3S7Cwgy3qlkkmyS2uQB3jiJg6VNdZd/pDBJu0nvG2NlTg==",
|
||||
"version": "7.2.2",
|
||||
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz",
|
||||
"integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==",
|
||||
"dev": true,
|
||||
"license": "BSD-2-Clause",
|
||||
"dependencies": {
|
||||
|
@ -830,38 +727,38 @@
|
|||
"estraverse": "^5.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-visitor-keys": {
|
||||
"version": "4.2.1",
|
||||
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz",
|
||||
"integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==",
|
||||
"version": "3.4.3",
|
||||
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz",
|
||||
"integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/espree": {
|
||||
"version": "10.4.0",
|
||||
"resolved": "https://registry.npmjs.org/espree/-/espree-10.4.0.tgz",
|
||||
"integrity": "sha512-j6PAQ2uUr79PZhBjP5C5fhl8e39FmRnOjsD5lGnWrFU8i2G776tBK7+nP8KuQUTTyAZUwfQqXAgrVH5MbH9CYQ==",
|
||||
"version": "9.6.1",
|
||||
"resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz",
|
||||
"integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==",
|
||||
"dev": true,
|
||||
"license": "BSD-2-Clause",
|
||||
"dependencies": {
|
||||
"acorn": "^8.15.0",
|
||||
"acorn": "^8.9.0",
|
||||
"acorn-jsx": "^5.3.2",
|
||||
"eslint-visitor-keys": "^4.2.1"
|
||||
"eslint-visitor-keys": "^3.4.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/eslint"
|
||||
|
@ -1002,16 +899,16 @@
|
|||
}
|
||||
},
|
||||
"node_modules/file-entry-cache": {
|
||||
"version": "8.0.0",
|
||||
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz",
|
||||
"integrity": "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==",
|
||||
"version": "6.0.1",
|
||||
"resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz",
|
||||
"integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"flat-cache": "^4.0.0"
|
||||
"flat-cache": "^3.0.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.0.0"
|
||||
"node": "^10.12.0 || >=12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/fill-range": {
|
||||
|
@ -1045,17 +942,18 @@
|
|||
}
|
||||
},
|
||||
"node_modules/flat-cache": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-4.0.1.tgz",
|
||||
"integrity": "sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==",
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.2.0.tgz",
|
||||
"integrity": "sha512-CYcENa+FtcUKLmhhqyctpclsq7QF38pKjZHsGNiSQF5r4FtoKDWabFDl3hzaEQMvT1LHEysw5twgLvpYYb4vbw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"flatted": "^3.2.9",
|
||||
"keyv": "^4.5.4"
|
||||
"keyv": "^4.5.3",
|
||||
"rimraf": "^3.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
"node": "^10.12.0 || >=12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/flatted": {
|
||||
|
@ -1065,6 +963,35 @@
|
|||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/fs.realpath": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||
"integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==",
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/glob": {
|
||||
"version": "7.2.3",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
|
||||
"integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==",
|
||||
"deprecated": "Glob versions prior to v9 are no longer supported",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"fs.realpath": "^1.0.0",
|
||||
"inflight": "^1.0.4",
|
||||
"inherits": "2",
|
||||
"minimatch": "^3.1.1",
|
||||
"once": "^1.3.0",
|
||||
"path-is-absolute": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/glob-parent": {
|
||||
"version": "6.0.2",
|
||||
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz",
|
||||
|
@ -1120,13 +1047,16 @@
|
|||
}
|
||||
},
|
||||
"node_modules/globals": {
|
||||
"version": "14.0.0",
|
||||
"resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz",
|
||||
"integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==",
|
||||
"version": "13.24.0",
|
||||
"resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz",
|
||||
"integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"type-fest": "^0.20.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
"node": ">=8"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
|
@ -1160,6 +1090,13 @@
|
|||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/graphemer": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz",
|
||||
"integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/has-flag": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
|
||||
|
@ -1227,6 +1164,25 @@
|
|||
"node": ">=0.8.19"
|
||||
}
|
||||
},
|
||||
"node_modules/inflight": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
|
||||
"integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==",
|
||||
"deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"once": "^1.3.0",
|
||||
"wrappy": "1"
|
||||
}
|
||||
},
|
||||
"node_modules/inherits": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
|
||||
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/ini": {
|
||||
"version": "1.3.8",
|
||||
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz",
|
||||
|
@ -1284,6 +1240,16 @@
|
|||
"node": ">=0.12.0"
|
||||
}
|
||||
},
|
||||
"node_modules/is-path-inside": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz",
|
||||
"integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/is-plain-object": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz",
|
||||
|
@ -1538,6 +1504,16 @@
|
|||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/once": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||
"integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
},
|
||||
"node_modules/optionator": {
|
||||
"version": "0.9.4",
|
||||
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz",
|
||||
|
@ -1630,6 +1606,16 @@
|
|||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/path-is-absolute": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
|
||||
"integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/path-key": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
|
||||
|
@ -1826,6 +1812,23 @@
|
|||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/rimraf": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz",
|
||||
"integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==",
|
||||
"deprecated": "Rimraf versions prior to v4 are no longer supported",
|
||||
"dev": true,
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"glob": "^7.1.3"
|
||||
},
|
||||
"bin": {
|
||||
"rimraf": "bin.js"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/run-parallel": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz",
|
||||
|
@ -2154,6 +2157,13 @@
|
|||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/text-table": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz",
|
||||
"integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/to-regex-range": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
|
||||
|
@ -2180,6 +2190,19 @@
|
|||
"node": ">= 0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/type-fest": {
|
||||
"version": "0.20.2",
|
||||
"resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz",
|
||||
"integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==",
|
||||
"dev": true,
|
||||
"license": "(MIT OR CC0-1.0)",
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/uri-js": {
|
||||
"version": "4.4.1",
|
||||
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
|
||||
|
@ -2223,6 +2246,13 @@
|
|||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/wrappy": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/write-file-atomic": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-5.0.1.tgz",
|
||||
|
|
201
node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/LICENSE
generated
vendored
201
node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/LICENSE
generated
vendored
|
@ -1,201 +0,0 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright contributors
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
105
node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/README.md
generated
vendored
105
node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/README.md
generated
vendored
|
@ -1,105 +0,0 @@
|
|||
# eslint-visitor-keys
|
||||
|
||||
[](https://www.npmjs.com/package/eslint-visitor-keys)
|
||||
[](http://www.npmtrends.com/eslint-visitor-keys)
|
||||
[](https://github.com/eslint/eslint-visitor-keys/actions)
|
||||
|
||||
Constants and utilities about visitor keys to traverse AST.
|
||||
|
||||
## 💿 Installation
|
||||
|
||||
Use [npm] to install.
|
||||
|
||||
```bash
|
||||
$ npm install eslint-visitor-keys
|
||||
```
|
||||
|
||||
### Requirements
|
||||
|
||||
- [Node.js] `^12.22.0`, `^14.17.0`, or `>=16.0.0`
|
||||
|
||||
|
||||
## 📖 Usage
|
||||
|
||||
To use in an ESM file:
|
||||
|
||||
```js
|
||||
import * as evk from "eslint-visitor-keys"
|
||||
```
|
||||
|
||||
To use in a CommonJS file:
|
||||
|
||||
```js
|
||||
const evk = require("eslint-visitor-keys")
|
||||
```
|
||||
|
||||
### evk.KEYS
|
||||
|
||||
> type: `{ [type: string]: string[] | undefined }`
|
||||
|
||||
Visitor keys. This keys are frozen.
|
||||
|
||||
This is an object. Keys are the type of [ESTree] nodes. Their values are an array of property names which have child nodes.
|
||||
|
||||
For example:
|
||||
|
||||
```
|
||||
console.log(evk.KEYS.AssignmentExpression) // → ["left", "right"]
|
||||
```
|
||||
|
||||
### evk.getKeys(node)
|
||||
|
||||
> type: `(node: object) => string[]`
|
||||
|
||||
Get the visitor keys of a given AST node.
|
||||
|
||||
This is similar to `Object.keys(node)` of ES Standard, but some keys are excluded: `parent`, `leadingComments`, `trailingComments`, and names which start with `_`.
|
||||
|
||||
This will be used to traverse unknown nodes.
|
||||
|
||||
For example:
|
||||
|
||||
```js
|
||||
const node = {
|
||||
type: "AssignmentExpression",
|
||||
left: { type: "Identifier", name: "foo" },
|
||||
right: { type: "Literal", value: 0 }
|
||||
}
|
||||
console.log(evk.getKeys(node)) // → ["type", "left", "right"]
|
||||
```
|
||||
|
||||
### evk.unionWith(additionalKeys)
|
||||
|
||||
> type: `(additionalKeys: object) => { [type: string]: string[] | undefined }`
|
||||
|
||||
Make the union set with `evk.KEYS` and the given keys.
|
||||
|
||||
- The order of keys is, `additionalKeys` is at first, then `evk.KEYS` is concatenated after that.
|
||||
- It removes duplicated keys as keeping the first one.
|
||||
|
||||
For example:
|
||||
|
||||
```js
|
||||
console.log(evk.unionWith({
|
||||
MethodDefinition: ["decorators"]
|
||||
})) // → { ..., MethodDefinition: ["decorators", "key", "value"], ... }
|
||||
```
|
||||
|
||||
## 📰 Change log
|
||||
|
||||
See [GitHub releases](https://github.com/eslint/eslint-visitor-keys/releases).
|
||||
|
||||
## 🍻 Contributing
|
||||
|
||||
Welcome. See [ESLint contribution guidelines](https://eslint.org/docs/developer-guide/contributing/).
|
||||
|
||||
### Development commands
|
||||
|
||||
- `npm test` runs tests and measures code coverage.
|
||||
- `npm run lint` checks source codes with ESLint.
|
||||
- `npm run test:open-coverage` opens the code coverage report of the previous test with your default browser.
|
||||
|
||||
|
||||
[npm]: https://www.npmjs.com/
|
||||
[Node.js]: https://nodejs.org/
|
||||
[ESTree]: https://github.com/estree/estree
|
|
@ -1,384 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
/**
|
||||
* @typedef {{ readonly [type: string]: ReadonlyArray<string> }} VisitorKeys
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {VisitorKeys}
|
||||
*/
|
||||
const KEYS = {
|
||||
ArrayExpression: [
|
||||
"elements"
|
||||
],
|
||||
ArrayPattern: [
|
||||
"elements"
|
||||
],
|
||||
ArrowFunctionExpression: [
|
||||
"params",
|
||||
"body"
|
||||
],
|
||||
AssignmentExpression: [
|
||||
"left",
|
||||
"right"
|
||||
],
|
||||
AssignmentPattern: [
|
||||
"left",
|
||||
"right"
|
||||
],
|
||||
AwaitExpression: [
|
||||
"argument"
|
||||
],
|
||||
BinaryExpression: [
|
||||
"left",
|
||||
"right"
|
||||
],
|
||||
BlockStatement: [
|
||||
"body"
|
||||
],
|
||||
BreakStatement: [
|
||||
"label"
|
||||
],
|
||||
CallExpression: [
|
||||
"callee",
|
||||
"arguments"
|
||||
],
|
||||
CatchClause: [
|
||||
"param",
|
||||
"body"
|
||||
],
|
||||
ChainExpression: [
|
||||
"expression"
|
||||
],
|
||||
ClassBody: [
|
||||
"body"
|
||||
],
|
||||
ClassDeclaration: [
|
||||
"id",
|
||||
"superClass",
|
||||
"body"
|
||||
],
|
||||
ClassExpression: [
|
||||
"id",
|
||||
"superClass",
|
||||
"body"
|
||||
],
|
||||
ConditionalExpression: [
|
||||
"test",
|
||||
"consequent",
|
||||
"alternate"
|
||||
],
|
||||
ContinueStatement: [
|
||||
"label"
|
||||
],
|
||||
DebuggerStatement: [],
|
||||
DoWhileStatement: [
|
||||
"body",
|
||||
"test"
|
||||
],
|
||||
EmptyStatement: [],
|
||||
ExperimentalRestProperty: [
|
||||
"argument"
|
||||
],
|
||||
ExperimentalSpreadProperty: [
|
||||
"argument"
|
||||
],
|
||||
ExportAllDeclaration: [
|
||||
"exported",
|
||||
"source"
|
||||
],
|
||||
ExportDefaultDeclaration: [
|
||||
"declaration"
|
||||
],
|
||||
ExportNamedDeclaration: [
|
||||
"declaration",
|
||||
"specifiers",
|
||||
"source"
|
||||
],
|
||||
ExportSpecifier: [
|
||||
"exported",
|
||||
"local"
|
||||
],
|
||||
ExpressionStatement: [
|
||||
"expression"
|
||||
],
|
||||
ForInStatement: [
|
||||
"left",
|
||||
"right",
|
||||
"body"
|
||||
],
|
||||
ForOfStatement: [
|
||||
"left",
|
||||
"right",
|
||||
"body"
|
||||
],
|
||||
ForStatement: [
|
||||
"init",
|
||||
"test",
|
||||
"update",
|
||||
"body"
|
||||
],
|
||||
FunctionDeclaration: [
|
||||
"id",
|
||||
"params",
|
||||
"body"
|
||||
],
|
||||
FunctionExpression: [
|
||||
"id",
|
||||
"params",
|
||||
"body"
|
||||
],
|
||||
Identifier: [],
|
||||
IfStatement: [
|
||||
"test",
|
||||
"consequent",
|
||||
"alternate"
|
||||
],
|
||||
ImportDeclaration: [
|
||||
"specifiers",
|
||||
"source"
|
||||
],
|
||||
ImportDefaultSpecifier: [
|
||||
"local"
|
||||
],
|
||||
ImportExpression: [
|
||||
"source"
|
||||
],
|
||||
ImportNamespaceSpecifier: [
|
||||
"local"
|
||||
],
|
||||
ImportSpecifier: [
|
||||
"imported",
|
||||
"local"
|
||||
],
|
||||
JSXAttribute: [
|
||||
"name",
|
||||
"value"
|
||||
],
|
||||
JSXClosingElement: [
|
||||
"name"
|
||||
],
|
||||
JSXClosingFragment: [],
|
||||
JSXElement: [
|
||||
"openingElement",
|
||||
"children",
|
||||
"closingElement"
|
||||
],
|
||||
JSXEmptyExpression: [],
|
||||
JSXExpressionContainer: [
|
||||
"expression"
|
||||
],
|
||||
JSXFragment: [
|
||||
"openingFragment",
|
||||
"children",
|
||||
"closingFragment"
|
||||
],
|
||||
JSXIdentifier: [],
|
||||
JSXMemberExpression: [
|
||||
"object",
|
||||
"property"
|
||||
],
|
||||
JSXNamespacedName: [
|
||||
"namespace",
|
||||
"name"
|
||||
],
|
||||
JSXOpeningElement: [
|
||||
"name",
|
||||
"attributes"
|
||||
],
|
||||
JSXOpeningFragment: [],
|
||||
JSXSpreadAttribute: [
|
||||
"argument"
|
||||
],
|
||||
JSXSpreadChild: [
|
||||
"expression"
|
||||
],
|
||||
JSXText: [],
|
||||
LabeledStatement: [
|
||||
"label",
|
||||
"body"
|
||||
],
|
||||
Literal: [],
|
||||
LogicalExpression: [
|
||||
"left",
|
||||
"right"
|
||||
],
|
||||
MemberExpression: [
|
||||
"object",
|
||||
"property"
|
||||
],
|
||||
MetaProperty: [
|
||||
"meta",
|
||||
"property"
|
||||
],
|
||||
MethodDefinition: [
|
||||
"key",
|
||||
"value"
|
||||
],
|
||||
NewExpression: [
|
||||
"callee",
|
||||
"arguments"
|
||||
],
|
||||
ObjectExpression: [
|
||||
"properties"
|
||||
],
|
||||
ObjectPattern: [
|
||||
"properties"
|
||||
],
|
||||
PrivateIdentifier: [],
|
||||
Program: [
|
||||
"body"
|
||||
],
|
||||
Property: [
|
||||
"key",
|
||||
"value"
|
||||
],
|
||||
PropertyDefinition: [
|
||||
"key",
|
||||
"value"
|
||||
],
|
||||
RestElement: [
|
||||
"argument"
|
||||
],
|
||||
ReturnStatement: [
|
||||
"argument"
|
||||
],
|
||||
SequenceExpression: [
|
||||
"expressions"
|
||||
],
|
||||
SpreadElement: [
|
||||
"argument"
|
||||
],
|
||||
StaticBlock: [
|
||||
"body"
|
||||
],
|
||||
Super: [],
|
||||
SwitchCase: [
|
||||
"test",
|
||||
"consequent"
|
||||
],
|
||||
SwitchStatement: [
|
||||
"discriminant",
|
||||
"cases"
|
||||
],
|
||||
TaggedTemplateExpression: [
|
||||
"tag",
|
||||
"quasi"
|
||||
],
|
||||
TemplateElement: [],
|
||||
TemplateLiteral: [
|
||||
"quasis",
|
||||
"expressions"
|
||||
],
|
||||
ThisExpression: [],
|
||||
ThrowStatement: [
|
||||
"argument"
|
||||
],
|
||||
TryStatement: [
|
||||
"block",
|
||||
"handler",
|
||||
"finalizer"
|
||||
],
|
||||
UnaryExpression: [
|
||||
"argument"
|
||||
],
|
||||
UpdateExpression: [
|
||||
"argument"
|
||||
],
|
||||
VariableDeclaration: [
|
||||
"declarations"
|
||||
],
|
||||
VariableDeclarator: [
|
||||
"id",
|
||||
"init"
|
||||
],
|
||||
WhileStatement: [
|
||||
"test",
|
||||
"body"
|
||||
],
|
||||
WithStatement: [
|
||||
"object",
|
||||
"body"
|
||||
],
|
||||
YieldExpression: [
|
||||
"argument"
|
||||
]
|
||||
};
|
||||
|
||||
// Types.
|
||||
const NODE_TYPES = Object.keys(KEYS);
|
||||
|
||||
// Freeze the keys.
|
||||
for (const type of NODE_TYPES) {
|
||||
Object.freeze(KEYS[type]);
|
||||
}
|
||||
Object.freeze(KEYS);
|
||||
|
||||
/**
|
||||
* @author Toru Nagashima <https://github.com/mysticatea>
|
||||
* See LICENSE file in root directory for full license.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {import('./visitor-keys.js').VisitorKeys} VisitorKeys
|
||||
*/
|
||||
|
||||
// List to ignore keys.
|
||||
const KEY_BLACKLIST = new Set([
|
||||
"parent",
|
||||
"leadingComments",
|
||||
"trailingComments"
|
||||
]);
|
||||
|
||||
/**
|
||||
* Check whether a given key should be used or not.
|
||||
* @param {string} key The key to check.
|
||||
* @returns {boolean} `true` if the key should be used.
|
||||
*/
|
||||
function filterKey(key) {
|
||||
return !KEY_BLACKLIST.has(key) && key[0] !== "_";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get visitor keys of a given node.
|
||||
* @param {object} node The AST node to get keys.
|
||||
* @returns {readonly string[]} Visitor keys of the node.
|
||||
*/
|
||||
function getKeys(node) {
|
||||
return Object.keys(node).filter(filterKey);
|
||||
}
|
||||
|
||||
// Disable valid-jsdoc rule because it reports syntax error on the type of @returns.
|
||||
// eslint-disable-next-line valid-jsdoc
|
||||
/**
|
||||
* Make the union set with `KEYS` and given keys.
|
||||
* @param {VisitorKeys} additionalKeys The additional keys.
|
||||
* @returns {VisitorKeys} The union set.
|
||||
*/
|
||||
function unionWith(additionalKeys) {
|
||||
const retv = /** @type {{
|
||||
[type: string]: ReadonlyArray<string>
|
||||
}} */ (Object.assign({}, KEYS));
|
||||
|
||||
for (const type of Object.keys(additionalKeys)) {
|
||||
if (Object.prototype.hasOwnProperty.call(retv, type)) {
|
||||
const keys = new Set(additionalKeys[type]);
|
||||
|
||||
for (const key of retv[type]) {
|
||||
keys.add(key);
|
||||
}
|
||||
|
||||
retv[type] = Object.freeze(Array.from(keys));
|
||||
} else {
|
||||
retv[type] = Object.freeze(Array.from(additionalKeys[type]));
|
||||
}
|
||||
}
|
||||
|
||||
return Object.freeze(retv);
|
||||
}
|
||||
|
||||
exports.KEYS = KEYS;
|
||||
exports.getKeys = getKeys;
|
||||
exports.unionWith = unionWith;
|
|
@ -1,27 +0,0 @@
|
|||
type VisitorKeys$1 = {
|
||||
readonly [type: string]: readonly string[];
|
||||
};
|
||||
/**
|
||||
* @typedef {{ readonly [type: string]: ReadonlyArray<string> }} VisitorKeys
|
||||
*/
|
||||
/**
|
||||
* @type {VisitorKeys}
|
||||
*/
|
||||
declare const KEYS: VisitorKeys$1;
|
||||
|
||||
/**
|
||||
* Get visitor keys of a given node.
|
||||
* @param {object} node The AST node to get keys.
|
||||
* @returns {readonly string[]} Visitor keys of the node.
|
||||
*/
|
||||
declare function getKeys(node: object): readonly string[];
|
||||
/**
|
||||
* Make the union set with `KEYS` and given keys.
|
||||
* @param {VisitorKeys} additionalKeys The additional keys.
|
||||
* @returns {VisitorKeys} The union set.
|
||||
*/
|
||||
declare function unionWith(additionalKeys: VisitorKeys): VisitorKeys;
|
||||
|
||||
type VisitorKeys = VisitorKeys$1;
|
||||
|
||||
export { KEYS, VisitorKeys, getKeys, unionWith };
|
|
@ -1,16 +0,0 @@
|
|||
/**
|
||||
* Get visitor keys of a given node.
|
||||
* @param {object} node The AST node to get keys.
|
||||
* @returns {readonly string[]} Visitor keys of the node.
|
||||
*/
|
||||
export function getKeys(node: object): readonly string[];
|
||||
/**
|
||||
* Make the union set with `KEYS` and given keys.
|
||||
* @param {VisitorKeys} additionalKeys The additional keys.
|
||||
* @returns {VisitorKeys} The union set.
|
||||
*/
|
||||
export function unionWith(additionalKeys: VisitorKeys): VisitorKeys;
|
||||
export { KEYS };
|
||||
export type VisitorKeys = import('./visitor-keys.js').VisitorKeys;
|
||||
import KEYS from "./visitor-keys.js";
|
||||
//# sourceMappingURL=index.d.ts.map
|
|
@ -1,12 +0,0 @@
|
|||
export default KEYS;
|
||||
export type VisitorKeys = {
|
||||
readonly [type: string]: readonly string[];
|
||||
};
|
||||
/**
|
||||
* @typedef {{ readonly [type: string]: ReadonlyArray<string> }} VisitorKeys
|
||||
*/
|
||||
/**
|
||||
* @type {VisitorKeys}
|
||||
*/
|
||||
declare const KEYS: VisitorKeys;
|
||||
//# sourceMappingURL=visitor-keys.d.ts.map
|
|
@ -1,65 +0,0 @@
|
|||
/**
|
||||
* @author Toru Nagashima <https://github.com/mysticatea>
|
||||
* See LICENSE file in root directory for full license.
|
||||
*/
|
||||
import KEYS from "./visitor-keys.js";
|
||||
|
||||
/**
|
||||
* @typedef {import('./visitor-keys.js').VisitorKeys} VisitorKeys
|
||||
*/
|
||||
|
||||
// List to ignore keys.
|
||||
const KEY_BLACKLIST = new Set([
|
||||
"parent",
|
||||
"leadingComments",
|
||||
"trailingComments"
|
||||
]);
|
||||
|
||||
/**
|
||||
* Check whether a given key should be used or not.
|
||||
* @param {string} key The key to check.
|
||||
* @returns {boolean} `true` if the key should be used.
|
||||
*/
|
||||
function filterKey(key) {
|
||||
return !KEY_BLACKLIST.has(key) && key[0] !== "_";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get visitor keys of a given node.
|
||||
* @param {object} node The AST node to get keys.
|
||||
* @returns {readonly string[]} Visitor keys of the node.
|
||||
*/
|
||||
export function getKeys(node) {
|
||||
return Object.keys(node).filter(filterKey);
|
||||
}
|
||||
|
||||
// Disable valid-jsdoc rule because it reports syntax error on the type of @returns.
|
||||
// eslint-disable-next-line valid-jsdoc
|
||||
/**
|
||||
* Make the union set with `KEYS` and given keys.
|
||||
* @param {VisitorKeys} additionalKeys The additional keys.
|
||||
* @returns {VisitorKeys} The union set.
|
||||
*/
|
||||
export function unionWith(additionalKeys) {
|
||||
const retv = /** @type {{
|
||||
[type: string]: ReadonlyArray<string>
|
||||
}} */ (Object.assign({}, KEYS));
|
||||
|
||||
for (const type of Object.keys(additionalKeys)) {
|
||||
if (Object.prototype.hasOwnProperty.call(retv, type)) {
|
||||
const keys = new Set(additionalKeys[type]);
|
||||
|
||||
for (const key of retv[type]) {
|
||||
keys.add(key);
|
||||
}
|
||||
|
||||
retv[type] = Object.freeze(Array.from(keys));
|
||||
} else {
|
||||
retv[type] = Object.freeze(Array.from(additionalKeys[type]));
|
||||
}
|
||||
}
|
||||
|
||||
return Object.freeze(retv);
|
||||
}
|
||||
|
||||
export { KEYS };
|
|
@ -1,315 +0,0 @@
|
|||
/**
|
||||
* @typedef {{ readonly [type: string]: ReadonlyArray<string> }} VisitorKeys
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type {VisitorKeys}
|
||||
*/
|
||||
const KEYS = {
|
||||
ArrayExpression: [
|
||||
"elements"
|
||||
],
|
||||
ArrayPattern: [
|
||||
"elements"
|
||||
],
|
||||
ArrowFunctionExpression: [
|
||||
"params",
|
||||
"body"
|
||||
],
|
||||
AssignmentExpression: [
|
||||
"left",
|
||||
"right"
|
||||
],
|
||||
AssignmentPattern: [
|
||||
"left",
|
||||
"right"
|
||||
],
|
||||
AwaitExpression: [
|
||||
"argument"
|
||||
],
|
||||
BinaryExpression: [
|
||||
"left",
|
||||
"right"
|
||||
],
|
||||
BlockStatement: [
|
||||
"body"
|
||||
],
|
||||
BreakStatement: [
|
||||
"label"
|
||||
],
|
||||
CallExpression: [
|
||||
"callee",
|
||||
"arguments"
|
||||
],
|
||||
CatchClause: [
|
||||
"param",
|
||||
"body"
|
||||
],
|
||||
ChainExpression: [
|
||||
"expression"
|
||||
],
|
||||
ClassBody: [
|
||||
"body"
|
||||
],
|
||||
ClassDeclaration: [
|
||||
"id",
|
||||
"superClass",
|
||||
"body"
|
||||
],
|
||||
ClassExpression: [
|
||||
"id",
|
||||
"superClass",
|
||||
"body"
|
||||
],
|
||||
ConditionalExpression: [
|
||||
"test",
|
||||
"consequent",
|
||||
"alternate"
|
||||
],
|
||||
ContinueStatement: [
|
||||
"label"
|
||||
],
|
||||
DebuggerStatement: [],
|
||||
DoWhileStatement: [
|
||||
"body",
|
||||
"test"
|
||||
],
|
||||
EmptyStatement: [],
|
||||
ExperimentalRestProperty: [
|
||||
"argument"
|
||||
],
|
||||
ExperimentalSpreadProperty: [
|
||||
"argument"
|
||||
],
|
||||
ExportAllDeclaration: [
|
||||
"exported",
|
||||
"source"
|
||||
],
|
||||
ExportDefaultDeclaration: [
|
||||
"declaration"
|
||||
],
|
||||
ExportNamedDeclaration: [
|
||||
"declaration",
|
||||
"specifiers",
|
||||
"source"
|
||||
],
|
||||
ExportSpecifier: [
|
||||
"exported",
|
||||
"local"
|
||||
],
|
||||
ExpressionStatement: [
|
||||
"expression"
|
||||
],
|
||||
ForInStatement: [
|
||||
"left",
|
||||
"right",
|
||||
"body"
|
||||
],
|
||||
ForOfStatement: [
|
||||
"left",
|
||||
"right",
|
||||
"body"
|
||||
],
|
||||
ForStatement: [
|
||||
"init",
|
||||
"test",
|
||||
"update",
|
||||
"body"
|
||||
],
|
||||
FunctionDeclaration: [
|
||||
"id",
|
||||
"params",
|
||||
"body"
|
||||
],
|
||||
FunctionExpression: [
|
||||
"id",
|
||||
"params",
|
||||
"body"
|
||||
],
|
||||
Identifier: [],
|
||||
IfStatement: [
|
||||
"test",
|
||||
"consequent",
|
||||
"alternate"
|
||||
],
|
||||
ImportDeclaration: [
|
||||
"specifiers",
|
||||
"source"
|
||||
],
|
||||
ImportDefaultSpecifier: [
|
||||
"local"
|
||||
],
|
||||
ImportExpression: [
|
||||
"source"
|
||||
],
|
||||
ImportNamespaceSpecifier: [
|
||||
"local"
|
||||
],
|
||||
ImportSpecifier: [
|
||||
"imported",
|
||||
"local"
|
||||
],
|
||||
JSXAttribute: [
|
||||
"name",
|
||||
"value"
|
||||
],
|
||||
JSXClosingElement: [
|
||||
"name"
|
||||
],
|
||||
JSXClosingFragment: [],
|
||||
JSXElement: [
|
||||
"openingElement",
|
||||
"children",
|
||||
"closingElement"
|
||||
],
|
||||
JSXEmptyExpression: [],
|
||||
JSXExpressionContainer: [
|
||||
"expression"
|
||||
],
|
||||
JSXFragment: [
|
||||
"openingFragment",
|
||||
"children",
|
||||
"closingFragment"
|
||||
],
|
||||
JSXIdentifier: [],
|
||||
JSXMemberExpression: [
|
||||
"object",
|
||||
"property"
|
||||
],
|
||||
JSXNamespacedName: [
|
||||
"namespace",
|
||||
"name"
|
||||
],
|
||||
JSXOpeningElement: [
|
||||
"name",
|
||||
"attributes"
|
||||
],
|
||||
JSXOpeningFragment: [],
|
||||
JSXSpreadAttribute: [
|
||||
"argument"
|
||||
],
|
||||
JSXSpreadChild: [
|
||||
"expression"
|
||||
],
|
||||
JSXText: [],
|
||||
LabeledStatement: [
|
||||
"label",
|
||||
"body"
|
||||
],
|
||||
Literal: [],
|
||||
LogicalExpression: [
|
||||
"left",
|
||||
"right"
|
||||
],
|
||||
MemberExpression: [
|
||||
"object",
|
||||
"property"
|
||||
],
|
||||
MetaProperty: [
|
||||
"meta",
|
||||
"property"
|
||||
],
|
||||
MethodDefinition: [
|
||||
"key",
|
||||
"value"
|
||||
],
|
||||
NewExpression: [
|
||||
"callee",
|
||||
"arguments"
|
||||
],
|
||||
ObjectExpression: [
|
||||
"properties"
|
||||
],
|
||||
ObjectPattern: [
|
||||
"properties"
|
||||
],
|
||||
PrivateIdentifier: [],
|
||||
Program: [
|
||||
"body"
|
||||
],
|
||||
Property: [
|
||||
"key",
|
||||
"value"
|
||||
],
|
||||
PropertyDefinition: [
|
||||
"key",
|
||||
"value"
|
||||
],
|
||||
RestElement: [
|
||||
"argument"
|
||||
],
|
||||
ReturnStatement: [
|
||||
"argument"
|
||||
],
|
||||
SequenceExpression: [
|
||||
"expressions"
|
||||
],
|
||||
SpreadElement: [
|
||||
"argument"
|
||||
],
|
||||
StaticBlock: [
|
||||
"body"
|
||||
],
|
||||
Super: [],
|
||||
SwitchCase: [
|
||||
"test",
|
||||
"consequent"
|
||||
],
|
||||
SwitchStatement: [
|
||||
"discriminant",
|
||||
"cases"
|
||||
],
|
||||
TaggedTemplateExpression: [
|
||||
"tag",
|
||||
"quasi"
|
||||
],
|
||||
TemplateElement: [],
|
||||
TemplateLiteral: [
|
||||
"quasis",
|
||||
"expressions"
|
||||
],
|
||||
ThisExpression: [],
|
||||
ThrowStatement: [
|
||||
"argument"
|
||||
],
|
||||
TryStatement: [
|
||||
"block",
|
||||
"handler",
|
||||
"finalizer"
|
||||
],
|
||||
UnaryExpression: [
|
||||
"argument"
|
||||
],
|
||||
UpdateExpression: [
|
||||
"argument"
|
||||
],
|
||||
VariableDeclaration: [
|
||||
"declarations"
|
||||
],
|
||||
VariableDeclarator: [
|
||||
"id",
|
||||
"init"
|
||||
],
|
||||
WhileStatement: [
|
||||
"test",
|
||||
"body"
|
||||
],
|
||||
WithStatement: [
|
||||
"object",
|
||||
"body"
|
||||
],
|
||||
YieldExpression: [
|
||||
"argument"
|
||||
]
|
||||
};
|
||||
|
||||
// Types.
|
||||
const NODE_TYPES = Object.keys(KEYS);
|
||||
|
||||
// Freeze the keys.
|
||||
for (const type of NODE_TYPES) {
|
||||
Object.freeze(KEYS[type]);
|
||||
}
|
||||
Object.freeze(KEYS);
|
||||
|
||||
export default KEYS;
|
|
@ -1,74 +0,0 @@
|
|||
{
|
||||
"name": "eslint-visitor-keys",
|
||||
"version": "3.4.3",
|
||||
"description": "Constants and utilities about visitor keys to traverse AST.",
|
||||
"type": "module",
|
||||
"main": "dist/eslint-visitor-keys.cjs",
|
||||
"types": "./dist/index.d.ts",
|
||||
"exports": {
|
||||
".": [
|
||||
{
|
||||
"import": "./lib/index.js",
|
||||
"require": "./dist/eslint-visitor-keys.cjs"
|
||||
},
|
||||
"./dist/eslint-visitor-keys.cjs"
|
||||
],
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"files": [
|
||||
"dist/index.d.ts",
|
||||
"dist/visitor-keys.d.ts",
|
||||
"dist/eslint-visitor-keys.cjs",
|
||||
"dist/eslint-visitor-keys.d.cts",
|
||||
"lib"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/estree": "^0.0.51",
|
||||
"@types/estree-jsx": "^0.0.1",
|
||||
"@typescript-eslint/parser": "^5.14.0",
|
||||
"c8": "^7.11.0",
|
||||
"chai": "^4.3.6",
|
||||
"eslint": "^7.29.0",
|
||||
"eslint-config-eslint": "^7.0.0",
|
||||
"eslint-plugin-jsdoc": "^35.4.0",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-release": "^3.2.0",
|
||||
"esquery": "^1.4.0",
|
||||
"json-diff": "^0.7.3",
|
||||
"mocha": "^9.2.1",
|
||||
"opener": "^1.5.2",
|
||||
"rollup": "^2.70.0",
|
||||
"rollup-plugin-dts": "^4.2.3",
|
||||
"tsd": "^0.19.1",
|
||||
"typescript": "^4.6.2"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "npm run build:cjs && npm run build:types",
|
||||
"build:cjs": "rollup -c",
|
||||
"build:debug": "npm run build:cjs -- -m && npm run build:types",
|
||||
"build:keys": "node tools/build-keys-from-ts",
|
||||
"build:types": "tsc",
|
||||
"lint": "eslint .",
|
||||
"prepare": "npm run build",
|
||||
"release:generate:latest": "eslint-generate-release",
|
||||
"release:generate:alpha": "eslint-generate-prerelease alpha",
|
||||
"release:generate:beta": "eslint-generate-prerelease beta",
|
||||
"release:generate:rc": "eslint-generate-prerelease rc",
|
||||
"release:publish": "eslint-publish-release",
|
||||
"test": "mocha tests/lib/**/*.cjs && c8 mocha tests/lib/**/*.js && npm run test:types",
|
||||
"test:open-coverage": "c8 report --reporter lcov && opener coverage/lcov-report/index.html",
|
||||
"test:types": "tsd"
|
||||
},
|
||||
"repository": "eslint/eslint-visitor-keys",
|
||||
"funding": "https://opencollective.com/eslint",
|
||||
"keywords": [],
|
||||
"author": "Toru Nagashima (https://github.com/mysticatea)",
|
||||
"license": "Apache-2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/eslint/eslint-visitor-keys/issues"
|
||||
},
|
||||
"homepage": "https://github.com/eslint/eslint-visitor-keys#readme"
|
||||
}
|
201
node_modules/@eslint/config-array/LICENSE
generated
vendored
201
node_modules/@eslint/config-array/LICENSE
generated
vendored
|
@ -1,201 +0,0 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
369
node_modules/@eslint/config-array/README.md
generated
vendored
369
node_modules/@eslint/config-array/README.md
generated
vendored
|
@ -1,369 +0,0 @@
|
|||
# Config Array
|
||||
|
||||
## Description
|
||||
|
||||
A config array is a way of managing configurations that are based on glob pattern matching of filenames. Each config array contains the information needed to determine the correct configuration for any file based on the filename.
|
||||
|
||||
**Note:** This is a generic package that can be used outside of ESLint. It contains no ESLint-specific functionality.
|
||||
|
||||
## Installation
|
||||
|
||||
For Node.js and compatible runtimes:
|
||||
|
||||
```shell
|
||||
npm install @eslint/config-array
|
||||
# or
|
||||
yarn add @eslint/config-array
|
||||
# or
|
||||
pnpm install @eslint/config-array
|
||||
# or
|
||||
bun add @eslint/config-array
|
||||
```
|
||||
|
||||
For Deno:
|
||||
|
||||
```shell
|
||||
deno add @eslint/config-array
|
||||
```
|
||||
|
||||
## Background
|
||||
|
||||
The basic idea is that all configuration, including overrides, can be represented by a single array where each item in the array is a config object. Config objects appearing later in the array override config objects appearing earlier in the array. You can calculate a config for a given file by traversing all config objects in the array to find the ones that match the filename. Matching is done by specifying glob patterns in `files` and `ignores` properties on each config object. Here's an example:
|
||||
|
||||
```js
|
||||
export default [
|
||||
// match all JSON files
|
||||
{
|
||||
name: "JSON Handler",
|
||||
files: ["**/*.json"],
|
||||
handler: jsonHandler,
|
||||
},
|
||||
|
||||
// match only package.json
|
||||
{
|
||||
name: "package.json Handler",
|
||||
files: ["package.json"],
|
||||
handler: packageJsonHandler,
|
||||
},
|
||||
];
|
||||
```
|
||||
|
||||
In this example, there are two config objects: the first matches all JSON files in all directories and the second matches just `package.json` in the base path directory (all the globs are evaluated as relative to a base path that can be specified). When you retrieve a configuration for `foo.json`, only the first config object matches so `handler` is equal to `jsonHandler`; when you retrieve a configuration for `package.json`, `handler` is equal to `packageJsonHandler` (because both config objects match, the second one wins).
|
||||
|
||||
## Usage
|
||||
|
||||
First, import the `ConfigArray` constructor:
|
||||
|
||||
```js
|
||||
import { ConfigArray } from "@eslint/config-array";
|
||||
|
||||
// or using CommonJS
|
||||
|
||||
const { ConfigArray } = require("@eslint/config-array");
|
||||
```
|
||||
|
||||
When you create a new instance of `ConfigArray`, you must pass in two arguments: an array of configs and an options object. The array of configs is most likely read in from a configuration file, so here's a typical example:
|
||||
|
||||
```js
|
||||
const configFilename = path.resolve(process.cwd(), "my.config.js");
|
||||
const { default: rawConfigs } = await import(configFilename);
|
||||
const configs = new ConfigArray(rawConfigs, {
|
||||
// the path to match filenames from
|
||||
basePath: process.cwd(),
|
||||
|
||||
// additional items in each config
|
||||
schema: mySchema,
|
||||
});
|
||||
```
|
||||
|
||||
This example reads in an object or array from `my.config.js` and passes it into the `ConfigArray` constructor as the first argument. The second argument is an object specifying the `basePath` (the directory in which `my.config.js` is found) and a `schema` to define the additional properties of a config object beyond `files`, `ignores`, `basePath`, and `name`.
|
||||
|
||||
### Specifying a Schema
|
||||
|
||||
The `schema` option is required for you to use additional properties in config objects. The schema is an object that follows the format of an [`ObjectSchema`](https://npmjs.com/package/@eslint/object-schema). The schema specifies both validation and merge rules that the `ConfigArray` instance needs to combine configs when there are multiple matches. Here's an example:
|
||||
|
||||
```js
|
||||
const configFilename = path.resolve(process.cwd(), "my.config.js");
|
||||
const { default: rawConfigs } = await import(configFilename);
|
||||
|
||||
const mySchema = {
|
||||
|
||||
// define the handler key in configs
|
||||
handler: {
|
||||
required: true,
|
||||
merge(a, b) {
|
||||
if (!b) return a;
|
||||
if (!a) return b;
|
||||
},
|
||||
validate(value) {
|
||||
if (typeof value !== "function") {
|
||||
throw new TypeError("Function expected.");
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const configs = new ConfigArray(rawConfigs, {
|
||||
|
||||
// the path to match filenames from
|
||||
basePath: process.cwd(),
|
||||
|
||||
// additional item schemas in each config
|
||||
schema: mySchema,
|
||||
|
||||
// additional config types supported (default: [])
|
||||
extraConfigTypes: ["array", "function"];
|
||||
});
|
||||
```
|
||||
|
||||
### Config Arrays
|
||||
|
||||
Config arrays can be multidimensional, so it's possible for a config array to contain another config array when `extraConfigTypes` contains `"array"`, such as:
|
||||
|
||||
```js
|
||||
export default [
|
||||
// JS config
|
||||
{
|
||||
files: ["**/*.js"],
|
||||
handler: jsHandler,
|
||||
},
|
||||
|
||||
// JSON configs
|
||||
[
|
||||
// match all JSON files
|
||||
{
|
||||
name: "JSON Handler",
|
||||
files: ["**/*.json"],
|
||||
handler: jsonHandler,
|
||||
},
|
||||
|
||||
// match only package.json
|
||||
{
|
||||
name: "package.json Handler",
|
||||
files: ["package.json"],
|
||||
handler: packageJsonHandler,
|
||||
},
|
||||
],
|
||||
|
||||
// filename must match function
|
||||
{
|
||||
files: [filePath => filePath.endsWith(".md")],
|
||||
handler: markdownHandler,
|
||||
},
|
||||
|
||||
// filename must match all patterns in subarray
|
||||
{
|
||||
files: [["*.test.*", "*.js"]],
|
||||
handler: jsTestHandler,
|
||||
},
|
||||
|
||||
// filename must not match patterns beginning with !
|
||||
{
|
||||
name: "Non-JS files",
|
||||
files: ["!*.js"],
|
||||
settings: {
|
||||
js: false,
|
||||
},
|
||||
},
|
||||
|
||||
// specific settings for files inside `src` directory
|
||||
{
|
||||
name: "Source files",
|
||||
basePath: "src",
|
||||
files: ["**/*"],
|
||||
settings: {
|
||||
source: true,
|
||||
},
|
||||
},
|
||||
];
|
||||
```
|
||||
|
||||
In this example, the array contains both config objects and a config array. When a config array is normalized (see details below), it is flattened so only config objects remain. However, the order of evaluation remains the same.
|
||||
|
||||
If the `files` array contains a function, then that function is called with the path of the file as it was passed in. The function is expected to return `true` if there is a match and `false` if not. (The `ignores` array can also contain functions.)
|
||||
|
||||
If the `files` array contains an item that is an array of strings and functions, then all patterns must match in order for the config to match. In the preceding examples, both `*.test.*` and `*.js` must match in order for the config object to be used.
|
||||
|
||||
If a pattern in the files array begins with `!` then it excludes that pattern. In the preceding example, any filename that doesn't end with `.js` will automatically get a `settings.js` property set to `false`.
|
||||
|
||||
You can also specify an `ignores` key that will force files matching those patterns to not be included. If the `ignores` key is in a config object without any other keys, then those ignores will always be applied; otherwise those ignores act as exclusions. Here's an example:
|
||||
|
||||
```js
|
||||
export default [
|
||||
|
||||
// Always ignored
|
||||
{
|
||||
ignores: ["**/.git/**", "**/node_modules/**"]
|
||||
},
|
||||
|
||||
// .eslintrc.js file is ignored only when .js file matches
|
||||
{
|
||||
files: ["**/*.js"],
|
||||
ignores: [".eslintrc.js"]
|
||||
handler: jsHandler
|
||||
}
|
||||
];
|
||||
```
|
||||
|
||||
You can use negated patterns in `ignores` to exclude a file that was already ignored, such as:
|
||||
|
||||
```js
|
||||
export default [
|
||||
// Ignore all JSON files except tsconfig.json
|
||||
{
|
||||
files: ["**/*"],
|
||||
ignores: ["**/*.json", "!tsconfig.json"],
|
||||
},
|
||||
];
|
||||
```
|
||||
|
||||
### Config Functions
|
||||
|
||||
Config arrays can also include config functions when `extraConfigTypes` contains `"function"`. A config function accepts a single parameter, `context` (defined by you), and must return either a config object or a config array (it cannot return another function). Config functions allow end users to execute code in the creation of appropriate config objects. Here's an example:
|
||||
|
||||
```js
|
||||
export default [
|
||||
// JS config
|
||||
{
|
||||
files: ["**/*.js"],
|
||||
handler: jsHandler,
|
||||
},
|
||||
|
||||
// JSON configs
|
||||
function (context) {
|
||||
return [
|
||||
// match all JSON files
|
||||
{
|
||||
name: context.name + " JSON Handler",
|
||||
files: ["**/*.json"],
|
||||
handler: jsonHandler,
|
||||
},
|
||||
|
||||
// match only package.json
|
||||
{
|
||||
name: context.name + " package.json Handler",
|
||||
files: ["package.json"],
|
||||
handler: packageJsonHandler,
|
||||
},
|
||||
];
|
||||
},
|
||||
];
|
||||
```
|
||||
|
||||
When a config array is normalized, each function is executed and replaced in the config array with the return value.
|
||||
|
||||
**Note:** Config functions can also be async.
|
||||
|
||||
### Normalizing Config Arrays
|
||||
|
||||
Once a config array has been created and loaded with all of the raw config data, it must be normalized before it can be used. The normalization process goes through and flattens the config array as well as executing all config functions to get their final values.
|
||||
|
||||
To normalize a config array, call the `normalize()` method and pass in a context object:
|
||||
|
||||
```js
|
||||
await configs.normalize({
|
||||
name: "MyApp",
|
||||
});
|
||||
```
|
||||
|
||||
The `normalize()` method returns a promise, so be sure to use the `await` operator. The config array instance is normalized in-place, so you don't need to create a new variable.
|
||||
|
||||
If you want to disallow async config functions, you can call `normalizeSync()` instead. This method is completely synchronous and does not require using the `await` operator as it does not return a promise:
|
||||
|
||||
```js
|
||||
await configs.normalizeSync({
|
||||
name: "MyApp",
|
||||
});
|
||||
```
|
||||
|
||||
**Important:** Once a `ConfigArray` is normalized, it cannot be changed further. You can, however, create a new `ConfigArray` and pass in the normalized instance to create an unnormalized copy.
|
||||
|
||||
### Getting Config for a File
|
||||
|
||||
To get the config for a file, use the `getConfig()` method on a normalized config array and pass in the filename to get a config for:
|
||||
|
||||
```js
|
||||
// pass in filename
|
||||
const fileConfig = configs.getConfig(
|
||||
path.resolve(process.cwd(), "package.json"),
|
||||
);
|
||||
```
|
||||
|
||||
The config array always returns an object, even if there are no configs matching the given filename. You can then inspect the returned config object to determine how to proceed.
|
||||
|
||||
A few things to keep in mind:
|
||||
|
||||
- If a filename is not an absolute path, it will be resolved relative to the base path directory.
|
||||
- The returned config object never has `files`, `ignores`, `basePath`, or `name` properties; the only properties on the object will be the other configuration options specified.
|
||||
- The config array caches configs, so subsequent calls to `getConfig()` with the same filename will return in a fast lookup rather than another calculation.
|
||||
- A config will only be generated if the filename matches an entry in a `files` key. A config will not be generated without matching a `files` key (configs without a `files` key are only applied when another config with a `files` key is applied; configs without `files` are never applied on their own). Any config with a `files` key entry that is `*` or ends with `/**` or `/*` will only be applied if another entry in the same `files` key matches or another config matches.
|
||||
|
||||
## Determining Ignored Paths
|
||||
|
||||
You can determine if a file is ignored by using the `isFileIgnored()` method and passing in the path of any file, as in this example:
|
||||
|
||||
```js
|
||||
const ignored = configs.isFileIgnored("/foo/bar/baz.txt");
|
||||
```
|
||||
|
||||
A file is considered ignored if any of the following is true:
|
||||
|
||||
- **It's parent directory is ignored.** For example, if `foo` is in `ignores`, then `foo/a.js` is considered ignored.
|
||||
- **It has an ancestor directory that is ignored.** For example, if `foo` is in `ignores`, then `foo/baz/a.js` is considered ignored.
|
||||
- **It matches an ignored file pattern.** For example, if `**/a.js` is in `ignores`, then `foo/a.js` and `foo/baz/a.js` are considered ignored.
|
||||
- **If it matches an entry in `files` and also in `ignores`.** For example, if `**/*.js` is in `files` and `**/a.js` is in `ignores`, then `foo/a.js` and `foo/baz/a.js` are considered ignored.
|
||||
- **The file is outside the `basePath`.** If the `basePath` is `/usr/me`, then `/foo/a.js` is considered ignored.
|
||||
|
||||
For directories, use the `isDirectoryIgnored()` method and pass in the path of any directory, as in this example:
|
||||
|
||||
```js
|
||||
const ignored = configs.isDirectoryIgnored("/foo/bar/");
|
||||
```
|
||||
|
||||
A directory is considered ignored if any of the following is true:
|
||||
|
||||
- **It's parent directory is ignored.** For example, if `foo` is in `ignores`, then `foo/baz` is considered ignored.
|
||||
- **It has an ancestor directory that is ignored.** For example, if `foo` is in `ignores`, then `foo/bar/baz/a.js` is considered ignored.
|
||||
- **It matches and ignored file pattern.** For example, if `**/a.js` is in `ignores`, then `foo/a.js` and `foo/baz/a.js` are considered ignored.
|
||||
- **If it matches an entry in `files` and also in `ignores`.** For example, if `**/*.js` is in `files` and `**/a.js` is in `ignores`, then `foo/a.js` and `foo/baz/a.js` are considered ignored.
|
||||
- **The file is outside the `basePath`.** If the `basePath` is `/usr/me`, then `/foo/a.js` is considered ignored.
|
||||
|
||||
**Important:** A pattern such as `foo/**` means that `foo` and `foo/` are _not_ ignored whereas `foo/bar` is ignored. If you want to ignore `foo` and all of its subdirectories, use the pattern `foo` or `foo/` in `ignores`.
|
||||
|
||||
## Caching Mechanisms
|
||||
|
||||
Each `ConfigArray` aggressively caches configuration objects to avoid unnecessary work. This caching occurs in two ways:
|
||||
|
||||
1. **File-based Caching.** For each filename that is passed into a method, the resulting config is cached against that filename so you're always guaranteed to get the same object returned from `getConfig()` whenever you pass the same filename in.
|
||||
2. **Index-based Caching.** Whenever a config is calculated, the config elements that were used to create the config are also cached. So if a given filename matches elements 1, 5, and 7, the resulting config is cached with a key of `1,5,7`. That way, if another file is passed that matches the same config elements, the result is already known and doesn't have to be recalculated. That means two files that match all the same elements will return the same config from `getConfig()`.
|
||||
|
||||
## Acknowledgements
|
||||
|
||||
The design of this project was influenced by feedback on the ESLint RFC, and incorporates ideas from:
|
||||
|
||||
- Teddy Katz (@not-an-aardvark)
|
||||
- Toru Nagashima (@mysticatea)
|
||||
- Kai Cataldo (@kaicataldo)
|
||||
|
||||
## License
|
||||
|
||||
Apache 2.0
|
||||
|
||||
<!-- NOTE: This section is autogenerated. Do not manually edit.-->
|
||||
<!--sponsorsstart-->
|
||||
|
||||
## Sponsors
|
||||
|
||||
The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://eslint.org/donate)
|
||||
to get your logo on our READMEs and [website](https://eslint.org/sponsors).
|
||||
|
||||
<h3>Diamond Sponsors</h3>
|
||||
<p><a href="https://www.ag-grid.com/"><img src="https://images.opencollective.com/ag-grid/bec0580/logo.png" alt="AG Grid" height="128"></a></p><h3>Platinum Sponsors</h3>
|
||||
<p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="128"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="128"></a></p><h3>Gold Sponsors</h3>
|
||||
<p><a href="https://qlty.sh/"><img src="https://images.opencollective.com/qltysh/33d157d/logo.png" alt="Qlty Software" height="96"></a> <a href="https://trunk.io/"><img src="https://images.opencollective.com/trunkio/fb92d60/avatar.png" alt="trunk.io" height="96"></a> <a href="https://shopify.engineering/"><img src="https://avatars.githubusercontent.com/u/8085" alt="Shopify" height="96"></a></p><h3>Silver Sponsors</h3>
|
||||
<p><a href="https://vite.dev/"><img src="https://images.opencollective.com/vite/e6d15e1/logo.png" alt="Vite" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a> <a href="https://americanexpress.io"><img src="https://avatars.githubusercontent.com/u/3853301" alt="American Express" 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>
|
||||
<p><a href="https://sentry.io"><img src="https://github.com/getsentry.png" alt="Sentry" height="32"></a> <a href="https://syntax.fm"><img src="https://github.com/syntaxfm.png" alt="Syntax" height="32"></a> <a href="https://cybozu.co.jp/"><img src="https://images.opencollective.com/cybozu/933e46d/logo.png" alt="Cybozu" height="32"></a> <a href="https://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" 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://nolebase.ayaka.io"><img src="https://avatars.githubusercontent.com/u/11081491" alt="Neko" height="32"></a> <a href="https://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104" alt="Nx" height="32"></a> <a href="https://opensource.mercedes-benz.com/"><img src="https://avatars.githubusercontent.com/u/34240465" alt="Mercedes-Benz Group" 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="LambdaTest" height="32"></a></p>
|
||||
<h3>Technology Sponsors</h3>
|
||||
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.
|
||||
<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>
|
||||
<!--sponsorsend-->
|
1534
node_modules/@eslint/config-array/dist/cjs/index.cjs
generated
vendored
1534
node_modules/@eslint/config-array/dist/cjs/index.cjs
generated
vendored
File diff suppressed because it is too large
Load diff
143
node_modules/@eslint/config-array/dist/cjs/index.d.cts
generated
vendored
143
node_modules/@eslint/config-array/dist/cjs/index.d.cts
generated
vendored
|
@ -1,143 +0,0 @@
|
|||
export { ObjectSchema } from "@eslint/object-schema";
|
||||
export type PropertyDefinition = import("@eslint/object-schema").PropertyDefinition;
|
||||
export type ObjectDefinition = import("@eslint/object-schema").ObjectDefinition;
|
||||
export type ConfigObject = import("./types.cts").ConfigObject;
|
||||
export type IMinimatchStatic = import("minimatch").IMinimatchStatic;
|
||||
export type IMinimatch = import("minimatch").IMinimatch;
|
||||
export type PathImpl = typeof import("@jsr/std__path");
|
||||
export type ObjectSchemaInstance = import("@eslint/object-schema").ObjectSchema;
|
||||
/**
|
||||
* Represents an array of config objects and provides method for working with
|
||||
* those config objects.
|
||||
*/
|
||||
export class ConfigArray extends Array<any> {
|
||||
[x: symbol]: (config: any) => any;
|
||||
/**
|
||||
* Creates a new instance of ConfigArray.
|
||||
* @param {Iterable|Function|Object} configs An iterable yielding config
|
||||
* objects, or a config function, or a config object.
|
||||
* @param {Object} options The options for the ConfigArray.
|
||||
* @param {string} [options.basePath="/"] The absolute path of the config file directory.
|
||||
* Defaults to `"/"`.
|
||||
* @param {boolean} [options.normalized=false] Flag indicating if the
|
||||
* configs have already been normalized.
|
||||
* @param {Object} [options.schema] The additional schema
|
||||
* definitions to use for the ConfigArray schema.
|
||||
* @param {Array<string>} [options.extraConfigTypes] List of config types supported.
|
||||
* @throws {TypeError} When the `basePath` is not a non-empty string,
|
||||
*/
|
||||
constructor(configs: Iterable<any> | Function | any, { basePath, normalized, schema: customSchema, extraConfigTypes, }?: {
|
||||
basePath?: string;
|
||||
normalized?: boolean;
|
||||
schema?: any;
|
||||
extraConfigTypes?: Array<string>;
|
||||
});
|
||||
/**
|
||||
* The path of the config file that this array was loaded from.
|
||||
* This is used to calculate filename matches.
|
||||
* @property basePath
|
||||
* @type {string}
|
||||
*/
|
||||
basePath: string;
|
||||
/**
|
||||
* The supported config types.
|
||||
* @type {Array<string>}
|
||||
*/
|
||||
extraConfigTypes: Array<string>;
|
||||
/**
|
||||
* Returns the `files` globs from every config object in the array.
|
||||
* This can be used to determine which files will be matched by a
|
||||
* config array or to use as a glob pattern when no patterns are provided
|
||||
* for a command line interface.
|
||||
* @returns {Array<string|Function>} An array of matchers.
|
||||
*/
|
||||
get files(): Array<string | Function>;
|
||||
/**
|
||||
* Returns ignore matchers that should always be ignored regardless of
|
||||
* the matching `files` fields in any configs. This is necessary to mimic
|
||||
* the behavior of things like .gitignore and .eslintignore, allowing a
|
||||
* globbing operation to be faster.
|
||||
* @returns {Object[]} An array of config objects representing global ignores.
|
||||
*/
|
||||
get ignores(): any[];
|
||||
/**
|
||||
* Indicates if the config array has been normalized.
|
||||
* @returns {boolean} True if the config array is normalized, false if not.
|
||||
*/
|
||||
isNormalized(): boolean;
|
||||
/**
|
||||
* Normalizes a config array by flattening embedded arrays and executing
|
||||
* config functions.
|
||||
* @param {Object} [context] The context object for config functions.
|
||||
* @returns {Promise<ConfigArray>} The current ConfigArray instance.
|
||||
*/
|
||||
normalize(context?: any): Promise<ConfigArray>;
|
||||
/**
|
||||
* Normalizes a config array by flattening embedded arrays and executing
|
||||
* config functions.
|
||||
* @param {Object} [context] The context object for config functions.
|
||||
* @returns {ConfigArray} The current ConfigArray instance.
|
||||
*/
|
||||
normalizeSync(context?: any): ConfigArray;
|
||||
/**
|
||||
* Returns the config object for a given file path and a status that can be used to determine why a file has no config.
|
||||
* @param {string} filePath The path of a file to get a config for.
|
||||
* @returns {{ config?: Object, status: "ignored"|"external"|"unconfigured"|"matched" }}
|
||||
* An object with an optional property `config` and property `status`.
|
||||
* `config` is the config object for the specified file as returned by {@linkcode ConfigArray.getConfig},
|
||||
* `status` a is one of the constants returned by {@linkcode ConfigArray.getConfigStatus}.
|
||||
*/
|
||||
getConfigWithStatus(filePath: string): {
|
||||
config?: any;
|
||||
status: "ignored" | "external" | "unconfigured" | "matched";
|
||||
};
|
||||
/**
|
||||
* Returns the config object for a given file path.
|
||||
* @param {string} filePath The path of a file to get a config for.
|
||||
* @returns {Object|undefined} The config object for this file or `undefined`.
|
||||
*/
|
||||
getConfig(filePath: string): any | undefined;
|
||||
/**
|
||||
* Determines whether a file has a config or why it doesn't.
|
||||
* @param {string} filePath The path of the file to check.
|
||||
* @returns {"ignored"|"external"|"unconfigured"|"matched"} One of the following values:
|
||||
* * `"ignored"`: the file is ignored
|
||||
* * `"external"`: the file is outside the base path
|
||||
* * `"unconfigured"`: the file is not matched by any config
|
||||
* * `"matched"`: the file has a matching config
|
||||
*/
|
||||
getConfigStatus(filePath: string): "ignored" | "external" | "unconfigured" | "matched";
|
||||
/**
|
||||
* Determines if the given filepath is ignored based on the configs.
|
||||
* @param {string} filePath The path of a file to check.
|
||||
* @returns {boolean} True if the path is ignored, false if not.
|
||||
* @deprecated Use `isFileIgnored` instead.
|
||||
*/
|
||||
isIgnored(filePath: string): boolean;
|
||||
/**
|
||||
* Determines if the given filepath is ignored based on the configs.
|
||||
* @param {string} filePath The path of a file to check.
|
||||
* @returns {boolean} True if the path is ignored, false if not.
|
||||
*/
|
||||
isFileIgnored(filePath: string): boolean;
|
||||
/**
|
||||
* Determines if the given directory is ignored based on the configs.
|
||||
* This checks only default `ignores` that don't have `files` in the
|
||||
* same config. A pattern such as `/foo` be considered to ignore the directory
|
||||
* while a pattern such as `/foo/**` is not considered to ignore the
|
||||
* directory because it is matching files.
|
||||
* @param {string} directoryPath The path of a directory to check.
|
||||
* @returns {boolean} True if the directory is ignored, false if not. Will
|
||||
* return true for any directory that is not inside of `basePath`.
|
||||
* @throws {Error} When the `ConfigArray` is not normalized.
|
||||
*/
|
||||
isDirectoryIgnored(directoryPath: string): boolean;
|
||||
#private;
|
||||
}
|
||||
export namespace ConfigArraySymbol {
|
||||
let isNormalized: symbol;
|
||||
let configCache: symbol;
|
||||
let schema: symbol;
|
||||
let finalizeConfig: symbol;
|
||||
let preprocessConfig: symbol;
|
||||
}
|
1335
node_modules/@eslint/config-array/dist/cjs/std__path/posix.cjs
generated
vendored
1335
node_modules/@eslint/config-array/dist/cjs/std__path/posix.cjs
generated
vendored
File diff suppressed because it is too large
Load diff
1677
node_modules/@eslint/config-array/dist/cjs/std__path/windows.cjs
generated
vendored
1677
node_modules/@eslint/config-array/dist/cjs/std__path/windows.cjs
generated
vendored
File diff suppressed because it is too large
Load diff
29
node_modules/@eslint/config-array/dist/cjs/types.ts
generated
vendored
29
node_modules/@eslint/config-array/dist/cjs/types.ts
generated
vendored
|
@ -1,29 +0,0 @@
|
|||
/**
|
||||
* @fileoverview Types for the config-array package.
|
||||
* @author Nicholas C. Zakas
|
||||
*/
|
||||
|
||||
export interface ConfigObject {
|
||||
/**
|
||||
* The base path for files and ignores.
|
||||
*/
|
||||
basePath?: string;
|
||||
|
||||
/**
|
||||
* The files to include.
|
||||
*/
|
||||
files?: string[];
|
||||
|
||||
/**
|
||||
* The files to exclude.
|
||||
*/
|
||||
ignores?: string[];
|
||||
|
||||
/**
|
||||
* The name of the config object.
|
||||
*/
|
||||
name?: string;
|
||||
|
||||
// may also have any number of other properties
|
||||
[key: string]: unknown;
|
||||
}
|
143
node_modules/@eslint/config-array/dist/esm/index.d.ts
generated
vendored
143
node_modules/@eslint/config-array/dist/esm/index.d.ts
generated
vendored
|
@ -1,143 +0,0 @@
|
|||
export { ObjectSchema } from "@eslint/object-schema";
|
||||
export type PropertyDefinition = import("@eslint/object-schema").PropertyDefinition;
|
||||
export type ObjectDefinition = import("@eslint/object-schema").ObjectDefinition;
|
||||
export type ConfigObject = import("./types.ts").ConfigObject;
|
||||
export type IMinimatchStatic = import("minimatch").IMinimatchStatic;
|
||||
export type IMinimatch = import("minimatch").IMinimatch;
|
||||
export type PathImpl = typeof import("@jsr/std__path");
|
||||
export type ObjectSchemaInstance = import("@eslint/object-schema").ObjectSchema;
|
||||
/**
|
||||
* Represents an array of config objects and provides method for working with
|
||||
* those config objects.
|
||||
*/
|
||||
export class ConfigArray extends Array<any> {
|
||||
[x: symbol]: (config: any) => any;
|
||||
/**
|
||||
* Creates a new instance of ConfigArray.
|
||||
* @param {Iterable|Function|Object} configs An iterable yielding config
|
||||
* objects, or a config function, or a config object.
|
||||
* @param {Object} options The options for the ConfigArray.
|
||||
* @param {string} [options.basePath="/"] The absolute path of the config file directory.
|
||||
* Defaults to `"/"`.
|
||||
* @param {boolean} [options.normalized=false] Flag indicating if the
|
||||
* configs have already been normalized.
|
||||
* @param {Object} [options.schema] The additional schema
|
||||
* definitions to use for the ConfigArray schema.
|
||||
* @param {Array<string>} [options.extraConfigTypes] List of config types supported.
|
||||
* @throws {TypeError} When the `basePath` is not a non-empty string,
|
||||
*/
|
||||
constructor(configs: Iterable<any> | Function | any, { basePath, normalized, schema: customSchema, extraConfigTypes, }?: {
|
||||
basePath?: string;
|
||||
normalized?: boolean;
|
||||
schema?: any;
|
||||
extraConfigTypes?: Array<string>;
|
||||
});
|
||||
/**
|
||||
* The path of the config file that this array was loaded from.
|
||||
* This is used to calculate filename matches.
|
||||
* @property basePath
|
||||
* @type {string}
|
||||
*/
|
||||
basePath: string;
|
||||
/**
|
||||
* The supported config types.
|
||||
* @type {Array<string>}
|
||||
*/
|
||||
extraConfigTypes: Array<string>;
|
||||
/**
|
||||
* Returns the `files` globs from every config object in the array.
|
||||
* This can be used to determine which files will be matched by a
|
||||
* config array or to use as a glob pattern when no patterns are provided
|
||||
* for a command line interface.
|
||||
* @returns {Array<string|Function>} An array of matchers.
|
||||
*/
|
||||
get files(): Array<string | Function>;
|
||||
/**
|
||||
* Returns ignore matchers that should always be ignored regardless of
|
||||
* the matching `files` fields in any configs. This is necessary to mimic
|
||||
* the behavior of things like .gitignore and .eslintignore, allowing a
|
||||
* globbing operation to be faster.
|
||||
* @returns {Object[]} An array of config objects representing global ignores.
|
||||
*/
|
||||
get ignores(): any[];
|
||||
/**
|
||||
* Indicates if the config array has been normalized.
|
||||
* @returns {boolean} True if the config array is normalized, false if not.
|
||||
*/
|
||||
isNormalized(): boolean;
|
||||
/**
|
||||
* Normalizes a config array by flattening embedded arrays and executing
|
||||
* config functions.
|
||||
* @param {Object} [context] The context object for config functions.
|
||||
* @returns {Promise<ConfigArray>} The current ConfigArray instance.
|
||||
*/
|
||||
normalize(context?: any): Promise<ConfigArray>;
|
||||
/**
|
||||
* Normalizes a config array by flattening embedded arrays and executing
|
||||
* config functions.
|
||||
* @param {Object} [context] The context object for config functions.
|
||||
* @returns {ConfigArray} The current ConfigArray instance.
|
||||
*/
|
||||
normalizeSync(context?: any): ConfigArray;
|
||||
/**
|
||||
* Returns the config object for a given file path and a status that can be used to determine why a file has no config.
|
||||
* @param {string} filePath The path of a file to get a config for.
|
||||
* @returns {{ config?: Object, status: "ignored"|"external"|"unconfigured"|"matched" }}
|
||||
* An object with an optional property `config` and property `status`.
|
||||
* `config` is the config object for the specified file as returned by {@linkcode ConfigArray.getConfig},
|
||||
* `status` a is one of the constants returned by {@linkcode ConfigArray.getConfigStatus}.
|
||||
*/
|
||||
getConfigWithStatus(filePath: string): {
|
||||
config?: any;
|
||||
status: "ignored" | "external" | "unconfigured" | "matched";
|
||||
};
|
||||
/**
|
||||
* Returns the config object for a given file path.
|
||||
* @param {string} filePath The path of a file to get a config for.
|
||||
* @returns {Object|undefined} The config object for this file or `undefined`.
|
||||
*/
|
||||
getConfig(filePath: string): any | undefined;
|
||||
/**
|
||||
* Determines whether a file has a config or why it doesn't.
|
||||
* @param {string} filePath The path of the file to check.
|
||||
* @returns {"ignored"|"external"|"unconfigured"|"matched"} One of the following values:
|
||||
* * `"ignored"`: the file is ignored
|
||||
* * `"external"`: the file is outside the base path
|
||||
* * `"unconfigured"`: the file is not matched by any config
|
||||
* * `"matched"`: the file has a matching config
|
||||
*/
|
||||
getConfigStatus(filePath: string): "ignored" | "external" | "unconfigured" | "matched";
|
||||
/**
|
||||
* Determines if the given filepath is ignored based on the configs.
|
||||
* @param {string} filePath The path of a file to check.
|
||||
* @returns {boolean} True if the path is ignored, false if not.
|
||||
* @deprecated Use `isFileIgnored` instead.
|
||||
*/
|
||||
isIgnored(filePath: string): boolean;
|
||||
/**
|
||||
* Determines if the given filepath is ignored based on the configs.
|
||||
* @param {string} filePath The path of a file to check.
|
||||
* @returns {boolean} True if the path is ignored, false if not.
|
||||
*/
|
||||
isFileIgnored(filePath: string): boolean;
|
||||
/**
|
||||
* Determines if the given directory is ignored based on the configs.
|
||||
* This checks only default `ignores` that don't have `files` in the
|
||||
* same config. A pattern such as `/foo` be considered to ignore the directory
|
||||
* while a pattern such as `/foo/**` is not considered to ignore the
|
||||
* directory because it is matching files.
|
||||
* @param {string} directoryPath The path of a directory to check.
|
||||
* @returns {boolean} True if the directory is ignored, false if not. Will
|
||||
* return true for any directory that is not inside of `basePath`.
|
||||
* @throws {Error} When the `ConfigArray` is not normalized.
|
||||
*/
|
||||
isDirectoryIgnored(directoryPath: string): boolean;
|
||||
#private;
|
||||
}
|
||||
export namespace ConfigArraySymbol {
|
||||
let isNormalized: symbol;
|
||||
let configCache: symbol;
|
||||
let schema: symbol;
|
||||
let finalizeConfig: symbol;
|
||||
let preprocessConfig: symbol;
|
||||
}
|
1509
node_modules/@eslint/config-array/dist/esm/index.js
generated
vendored
1509
node_modules/@eslint/config-array/dist/esm/index.js
generated
vendored
File diff suppressed because it is too large
Load diff
1313
node_modules/@eslint/config-array/dist/esm/std__path/posix.js
generated
vendored
1313
node_modules/@eslint/config-array/dist/esm/std__path/posix.js
generated
vendored
File diff suppressed because it is too large
Load diff
1655
node_modules/@eslint/config-array/dist/esm/std__path/windows.js
generated
vendored
1655
node_modules/@eslint/config-array/dist/esm/std__path/windows.js
generated
vendored
File diff suppressed because it is too large
Load diff
23
node_modules/@eslint/config-array/dist/esm/types.d.ts
generated
vendored
23
node_modules/@eslint/config-array/dist/esm/types.d.ts
generated
vendored
|
@ -1,23 +0,0 @@
|
|||
/**
|
||||
* @fileoverview Types for the config-array package.
|
||||
* @author Nicholas C. Zakas
|
||||
*/
|
||||
export interface ConfigObject {
|
||||
/**
|
||||
* The base path for files and ignores.
|
||||
*/
|
||||
basePath?: string;
|
||||
/**
|
||||
* The files to include.
|
||||
*/
|
||||
files?: string[];
|
||||
/**
|
||||
* The files to exclude.
|
||||
*/
|
||||
ignores?: string[];
|
||||
/**
|
||||
* The name of the config object.
|
||||
*/
|
||||
name?: string;
|
||||
[key: string]: unknown;
|
||||
}
|
29
node_modules/@eslint/config-array/dist/esm/types.ts
generated
vendored
29
node_modules/@eslint/config-array/dist/esm/types.ts
generated
vendored
|
@ -1,29 +0,0 @@
|
|||
/**
|
||||
* @fileoverview Types for the config-array package.
|
||||
* @author Nicholas C. Zakas
|
||||
*/
|
||||
|
||||
export interface ConfigObject {
|
||||
/**
|
||||
* The base path for files and ignores.
|
||||
*/
|
||||
basePath?: string;
|
||||
|
||||
/**
|
||||
* The files to include.
|
||||
*/
|
||||
files?: string[];
|
||||
|
||||
/**
|
||||
* The files to exclude.
|
||||
*/
|
||||
ignores?: string[];
|
||||
|
||||
/**
|
||||
* The name of the config object.
|
||||
*/
|
||||
name?: string;
|
||||
|
||||
// may also have any number of other properties
|
||||
[key: string]: unknown;
|
||||
}
|
63
node_modules/@eslint/config-array/package.json
generated
vendored
63
node_modules/@eslint/config-array/package.json
generated
vendored
|
@ -1,63 +0,0 @@
|
|||
{
|
||||
"name": "@eslint/config-array",
|
||||
"version": "0.21.0",
|
||||
"description": "General purpose glob-based configuration matching.",
|
||||
"author": "Nicholas C. Zakas",
|
||||
"type": "module",
|
||||
"main": "dist/esm/index.js",
|
||||
"types": "dist/esm/index.d.ts",
|
||||
"exports": {
|
||||
"require": {
|
||||
"types": "./dist/cjs/index.d.cts",
|
||||
"default": "./dist/cjs/index.cjs"
|
||||
},
|
||||
"import": {
|
||||
"types": "./dist/esm/index.d.ts",
|
||||
"default": "./dist/esm/index.js"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/eslint/rewrite.git",
|
||||
"directory": "packages/config-array"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/eslint/rewrite/issues"
|
||||
},
|
||||
"homepage": "https://github.com/eslint/rewrite/tree/main/packages/config-array#readme",
|
||||
"scripts": {
|
||||
"build:dedupe-types": "node ../../tools/dedupe-types.js dist/cjs/index.cjs dist/esm/index.js",
|
||||
"build:cts": "node ../../tools/build-cts.js dist/esm/index.d.ts dist/cjs/index.d.cts",
|
||||
"build:std__path": "rollup -c rollup.std__path-config.js && node fix-std__path-imports",
|
||||
"build": "rollup -c && npm run build:dedupe-types && tsc -p tsconfig.esm.json && npm run build:cts && npm run build:std__path",
|
||||
"test:jsr": "npx jsr@latest publish --dry-run",
|
||||
"pretest": "npm run build",
|
||||
"test": "mocha tests/",
|
||||
"test:coverage": "c8 npm test"
|
||||
},
|
||||
"keywords": [
|
||||
"configuration",
|
||||
"configarray",
|
||||
"config file"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@eslint/object-schema": "^2.1.6",
|
||||
"debug": "^4.3.1",
|
||||
"minimatch": "^3.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@jsr/std__path": "^1.0.4",
|
||||
"@types/minimatch": "^3.0.5",
|
||||
"rollup-plugin-copy": "^3.5.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
}
|
||||
}
|
201
node_modules/@eslint/config-helpers/LICENSE
generated
vendored
201
node_modules/@eslint/config-helpers/LICENSE
generated
vendored
|
@ -1,201 +0,0 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
97
node_modules/@eslint/config-helpers/README.md
generated
vendored
97
node_modules/@eslint/config-helpers/README.md
generated
vendored
|
@ -1,97 +0,0 @@
|
|||
# @eslint/config-helpers
|
||||
|
||||
## Description
|
||||
|
||||
Helper utilities for creating ESLint configuration.
|
||||
|
||||
## Installation
|
||||
|
||||
For Node.js and compatible runtimes:
|
||||
|
||||
```shell
|
||||
npm install @eslint/config-helpers
|
||||
# or
|
||||
yarn add @eslint/config-helpers
|
||||
# or
|
||||
pnpm install @eslint/config-helpers
|
||||
# or
|
||||
bun add @eslint/config-helpers
|
||||
```
|
||||
|
||||
For Deno:
|
||||
|
||||
```shell
|
||||
deno add @eslint/config-helpers
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### `defineConfig()`
|
||||
|
||||
The `defineConfig()` function allows you to specify an ESLint configuration with full type checking and additional capabilities, such as `extends`. Here's an example:
|
||||
|
||||
```js
|
||||
// eslint.config.js
|
||||
import { defineConfig } from "@eslint/config-helpers";
|
||||
import js from "@eslint/js";
|
||||
|
||||
export default defineConfig([
|
||||
{
|
||||
files: ["src/**/*.js"],
|
||||
plugins: { js },
|
||||
extends: ["js/recommended"],
|
||||
rules: {
|
||||
semi: "error",
|
||||
"prefer-const": "error",
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ["test/**/*.js"],
|
||||
rules: {
|
||||
"no-console": "off",
|
||||
},
|
||||
},
|
||||
]);
|
||||
```
|
||||
|
||||
### `globalIgnores()`
|
||||
|
||||
The `globalIgnores()` function allows you to specify patterns for files and directories that should be globally ignored by ESLint. This is useful for excluding files that you don't want to lint, such as build directories or third-party libraries. Here's an example:
|
||||
|
||||
```js
|
||||
// eslint.config.js
|
||||
import { defineConfig, globalIgnores } from "@eslint/config-helpers";
|
||||
|
||||
export default defineConfig([
|
||||
{
|
||||
files: ["src/**/*.js"],
|
||||
rules: {
|
||||
semi: "error",
|
||||
"prefer-const": "error",
|
||||
},
|
||||
},
|
||||
globalIgnores(["node_modules/", "dist/", "coverage/"]),
|
||||
]);
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
Apache 2.0
|
||||
|
||||
<!-- NOTE: This section is autogenerated. Do not manually edit.-->
|
||||
<!--sponsorsstart-->
|
||||
|
||||
## Sponsors
|
||||
|
||||
The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://eslint.org/donate)
|
||||
to get your logo on our READMEs and [website](https://eslint.org/sponsors).
|
||||
|
||||
<h3>Platinum Sponsors</h3>
|
||||
<p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="128"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="128"></a></p><h3>Gold Sponsors</h3>
|
||||
<p><a href="https://qlty.sh/"><img src="https://images.opencollective.com/qltysh/33d157d/logo.png" alt="Qlty Software" height="96"></a> <a href="https://trunk.io/"><img src="https://images.opencollective.com/trunkio/fb92d60/avatar.png" alt="trunk.io" height="96"></a> <a href="https://shopify.engineering/"><img src="https://avatars.githubusercontent.com/u/8085" alt="Shopify" height="96"></a></p><h3>Silver Sponsors</h3>
|
||||
<p><a href="https://vite.dev/"><img src="https://images.opencollective.com/vite/e6d15e1/logo.png" alt="Vite" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a> <a href="https://americanexpress.io"><img src="https://avatars.githubusercontent.com/u/3853301" alt="American Express" 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>
|
||||
<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://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" 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://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104" alt="Nx" height="32"></a> <a href="https://opensource.mercedes-benz.com/"><img src="https://avatars.githubusercontent.com/u/34240465" alt="Mercedes-Benz Group" 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="LambdaTest" height="32"></a></p>
|
||||
<h3>Technology Sponsors</h3>
|
||||
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.
|
||||
<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>
|
||||
<!--sponsorsend-->
|
581
node_modules/@eslint/config-helpers/dist/cjs/index.cjs
generated
vendored
581
node_modules/@eslint/config-helpers/dist/cjs/index.cjs
generated
vendored
|
@ -1,581 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
/**
|
||||
* @fileoverview defineConfig helper
|
||||
* @author Nicholas C. Zakas
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Type Definitions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/** @typedef {import("eslint").Linter.Config} Config */
|
||||
/** @typedef {import("eslint").Linter.LegacyConfig} LegacyConfig */
|
||||
/** @typedef {import("eslint").ESLint.Plugin} Plugin */
|
||||
/** @typedef {import("eslint").Linter.RuleEntry} RuleEntry */
|
||||
/** @typedef {import("./types.ts").ExtendsElement} ExtendsElement */
|
||||
/** @typedef {import("./types.ts").SimpleExtendsElement} SimpleExtendsElement */
|
||||
/** @typedef {import("./types.ts").ConfigWithExtends} ConfigWithExtends */
|
||||
/** @typedef {import("./types.ts").InfiniteArray<Config>} InfiniteConfigArray */
|
||||
/** @typedef {import("./types.ts").ConfigWithExtendsArray} ConfigWithExtendsArray */
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
const eslintrcKeys = [
|
||||
"env",
|
||||
"extends",
|
||||
"globals",
|
||||
"ignorePatterns",
|
||||
"noInlineConfig",
|
||||
"overrides",
|
||||
"parser",
|
||||
"parserOptions",
|
||||
"reportUnusedDisableDirectives",
|
||||
"root",
|
||||
];
|
||||
|
||||
const allowedGlobalIgnoreKeys = new Set(["basePath", "ignores", "name"]);
|
||||
|
||||
/**
|
||||
* Gets the name of a config object.
|
||||
* @param {Config} config The config object.
|
||||
* @param {string} indexPath The index path of the config object.
|
||||
* @return {string} The name of the config object.
|
||||
*/
|
||||
function getConfigName(config, indexPath) {
|
||||
if (config.name) {
|
||||
return config.name;
|
||||
}
|
||||
|
||||
return `UserConfig${indexPath}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of an extension.
|
||||
* @param {SimpleExtendsElement} extension The extension.
|
||||
* @param {string} indexPath The index of the extension.
|
||||
* @return {string} The name of the extension.
|
||||
*/
|
||||
function getExtensionName(extension, indexPath) {
|
||||
if (typeof extension === "string") {
|
||||
return extension;
|
||||
}
|
||||
|
||||
if (extension.name) {
|
||||
return extension.name;
|
||||
}
|
||||
|
||||
return `ExtendedConfig${indexPath}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if a config object is a legacy config.
|
||||
* @param {Config|LegacyConfig} config The config object to check.
|
||||
* @return {config is LegacyConfig} `true` if the config object is a legacy config.
|
||||
*/
|
||||
function isLegacyConfig(config) {
|
||||
for (const key of eslintrcKeys) {
|
||||
if (key in config) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if a config object is a global ignores config.
|
||||
* @param {Config} config The config object to check.
|
||||
* @return {boolean} `true` if the config object is a global ignores config.
|
||||
*/
|
||||
function isGlobalIgnores(config) {
|
||||
return Object.keys(config).every(key => allowedGlobalIgnoreKeys.has(key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a plugin member ID (rule, processor, etc.) and returns
|
||||
* the namespace and member name.
|
||||
* @param {string} id The ID to parse.
|
||||
* @returns {{namespace:string, name:string}} The namespace and member name.
|
||||
*/
|
||||
function getPluginMember(id) {
|
||||
const firstSlashIndex = id.indexOf("/");
|
||||
|
||||
if (firstSlashIndex === -1) {
|
||||
return { namespace: "", name: id };
|
||||
}
|
||||
|
||||
let namespace = id.slice(0, firstSlashIndex);
|
||||
|
||||
/*
|
||||
* Special cases:
|
||||
* 1. The namespace is `@`, that means it's referring to the
|
||||
* core plugin so `@` is the full namespace.
|
||||
* 2. The namespace starts with `@`, that means it's referring to
|
||||
* an npm scoped package. That means the namespace is the scope
|
||||
* and the package name (i.e., `@eslint/core`).
|
||||
*/
|
||||
if (namespace[0] === "@" && namespace !== "@") {
|
||||
const secondSlashIndex = id.indexOf("/", firstSlashIndex + 1);
|
||||
if (secondSlashIndex !== -1) {
|
||||
namespace = id.slice(0, secondSlashIndex);
|
||||
return { namespace, name: id.slice(secondSlashIndex + 1) };
|
||||
}
|
||||
}
|
||||
|
||||
const name = id.slice(firstSlashIndex + 1);
|
||||
|
||||
return { namespace, name };
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes the plugin config by replacing the namespace with the plugin namespace.
|
||||
* @param {string} userNamespace The namespace of the plugin.
|
||||
* @param {Plugin} plugin The plugin config object.
|
||||
* @param {Config} config The config object to normalize.
|
||||
* @return {Config} The normalized config object.
|
||||
*/
|
||||
function normalizePluginConfig(userNamespace, plugin, config) {
|
||||
const pluginNamespace = plugin.meta?.namespace;
|
||||
|
||||
// don't do anything if the plugin doesn't have a namespace or rules
|
||||
if (
|
||||
!pluginNamespace ||
|
||||
pluginNamespace === userNamespace ||
|
||||
(!config.rules && !config.processor && !config.language)
|
||||
) {
|
||||
return config;
|
||||
}
|
||||
|
||||
const result = { ...config };
|
||||
|
||||
// update the rules
|
||||
if (result.rules) {
|
||||
const ruleIds = Object.keys(result.rules);
|
||||
|
||||
/** @type {Record<string,RuleEntry|undefined>} */
|
||||
const newRules = {};
|
||||
|
||||
for (let i = 0; i < ruleIds.length; i++) {
|
||||
const ruleId = ruleIds[i];
|
||||
const { namespace: ruleNamespace, name: ruleName } =
|
||||
getPluginMember(ruleId);
|
||||
|
||||
if (ruleNamespace === pluginNamespace) {
|
||||
newRules[`${userNamespace}/${ruleName}`] = result.rules[ruleId];
|
||||
} else {
|
||||
newRules[ruleId] = result.rules[ruleId];
|
||||
}
|
||||
}
|
||||
|
||||
result.rules = newRules;
|
||||
}
|
||||
|
||||
// update the processor
|
||||
|
||||
if (typeof result.processor === "string") {
|
||||
const { namespace: processorNamespace, name: processorName } =
|
||||
getPluginMember(result.processor);
|
||||
|
||||
if (processorNamespace) {
|
||||
if (processorNamespace === pluginNamespace) {
|
||||
result.processor = `${userNamespace}/${processorName}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update the language
|
||||
if (typeof result.language === "string") {
|
||||
const { namespace: languageNamespace, name: languageName } =
|
||||
getPluginMember(result.language);
|
||||
|
||||
if (languageNamespace === pluginNamespace) {
|
||||
result.language = `${userNamespace}/${languageName}`;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deeply normalizes a plugin config, traversing recursively into an arrays.
|
||||
* @param {string} userPluginNamespace The namespace of the plugin.
|
||||
* @param {Plugin} plugin The plugin object.
|
||||
* @param {Config|LegacyConfig|(Config|LegacyConfig)[]} pluginConfig The plugin config to normalize.
|
||||
* @param {string} pluginConfigName The name of the plugin config.
|
||||
* @return {InfiniteConfigArray} The normalized plugin config.
|
||||
* @throws {TypeError} If the plugin config is a legacy config.
|
||||
*/
|
||||
function deepNormalizePluginConfig(
|
||||
userPluginNamespace,
|
||||
plugin,
|
||||
pluginConfig,
|
||||
pluginConfigName,
|
||||
) {
|
||||
// if it's an array then it's definitely a new config
|
||||
if (Array.isArray(pluginConfig)) {
|
||||
return pluginConfig.map(pluginSubConfig =>
|
||||
deepNormalizePluginConfig(
|
||||
userPluginNamespace,
|
||||
plugin,
|
||||
pluginSubConfig,
|
||||
pluginConfigName,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// if it's a legacy config, throw an error
|
||||
if (isLegacyConfig(pluginConfig)) {
|
||||
throw new TypeError(
|
||||
`Plugin config "${pluginConfigName}" is an eslintrc config and cannot be used in this context.`,
|
||||
);
|
||||
}
|
||||
|
||||
return normalizePluginConfig(userPluginNamespace, plugin, pluginConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a plugin config by name in the given config.
|
||||
* @param {Config} config The config object.
|
||||
* @param {string} pluginConfigName The name of the plugin config.
|
||||
* @return {InfiniteConfigArray} The plugin config.
|
||||
* @throws {TypeError} If the plugin config is not found or is a legacy config.
|
||||
*/
|
||||
function findPluginConfig(config, pluginConfigName) {
|
||||
const { namespace: userPluginNamespace, name: configName } =
|
||||
getPluginMember(pluginConfigName);
|
||||
const plugin = config.plugins?.[userPluginNamespace];
|
||||
|
||||
if (!plugin) {
|
||||
throw new TypeError(`Plugin "${userPluginNamespace}" not found.`);
|
||||
}
|
||||
|
||||
const directConfig = plugin.configs?.[configName];
|
||||
if (directConfig) {
|
||||
// Arrays are always flat configs, and non-legacy configs can be used directly
|
||||
if (Array.isArray(directConfig) || !isLegacyConfig(directConfig)) {
|
||||
return deepNormalizePluginConfig(
|
||||
userPluginNamespace,
|
||||
plugin,
|
||||
directConfig,
|
||||
pluginConfigName,
|
||||
);
|
||||
}
|
||||
|
||||
// If it's a legacy config, look for the flat version
|
||||
const flatConfig = plugin.configs?.[`flat/${configName}`];
|
||||
|
||||
if (
|
||||
flatConfig &&
|
||||
(Array.isArray(flatConfig) || !isLegacyConfig(flatConfig))
|
||||
) {
|
||||
return deepNormalizePluginConfig(
|
||||
userPluginNamespace,
|
||||
plugin,
|
||||
flatConfig,
|
||||
pluginConfigName,
|
||||
);
|
||||
}
|
||||
|
||||
throw new TypeError(
|
||||
`Plugin config "${configName}" in plugin "${userPluginNamespace}" is an eslintrc config and cannot be used in this context.`,
|
||||
);
|
||||
}
|
||||
|
||||
throw new TypeError(
|
||||
`Plugin config "${configName}" not found in plugin "${userPluginNamespace}".`,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Flattens an array while keeping track of the index path.
|
||||
* @param {any[]} configList The array to traverse.
|
||||
* @param {string} indexPath The index path of the value in a multidimensional array.
|
||||
* @return {IterableIterator<{indexPath:string, value:any}>} The flattened list of values.
|
||||
*/
|
||||
function* flatTraverse(configList, indexPath = "") {
|
||||
for (let i = 0; i < configList.length; i++) {
|
||||
const newIndexPath = indexPath ? `${indexPath}[${i}]` : `[${i}]`;
|
||||
|
||||
// if it's an array then traverse it as well
|
||||
if (Array.isArray(configList[i])) {
|
||||
yield* flatTraverse(configList[i], newIndexPath);
|
||||
continue;
|
||||
}
|
||||
|
||||
yield { indexPath: newIndexPath, value: configList[i] };
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extends a list of config files by creating every combination of base and extension files.
|
||||
* @param {(string|string[])[]} [baseFiles] The base files.
|
||||
* @param {(string|string[])[]} [extensionFiles] The extension files.
|
||||
* @return {(string|string[])[]} The extended files.
|
||||
*/
|
||||
function extendConfigFiles(baseFiles = [], extensionFiles = []) {
|
||||
if (!extensionFiles.length) {
|
||||
return baseFiles.concat();
|
||||
}
|
||||
|
||||
if (!baseFiles.length) {
|
||||
return extensionFiles.concat();
|
||||
}
|
||||
|
||||
/** @type {(string|string[])[]} */
|
||||
const result = [];
|
||||
|
||||
for (const baseFile of baseFiles) {
|
||||
for (const extensionFile of extensionFiles) {
|
||||
/*
|
||||
* Each entry can be a string or array of strings. The end result
|
||||
* needs to be an array of strings, so we need to be sure to include
|
||||
* all of the items when there's an array.
|
||||
*/
|
||||
|
||||
const entry = [];
|
||||
|
||||
if (Array.isArray(baseFile)) {
|
||||
entry.push(...baseFile);
|
||||
} else {
|
||||
entry.push(baseFile);
|
||||
}
|
||||
|
||||
if (Array.isArray(extensionFile)) {
|
||||
entry.push(...extensionFile);
|
||||
} else {
|
||||
entry.push(extensionFile);
|
||||
}
|
||||
|
||||
result.push(entry);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extends a config object with another config object.
|
||||
* @param {Config} baseConfig The base config object.
|
||||
* @param {string} baseConfigName The name of the base config object.
|
||||
* @param {Config} extension The extension config object.
|
||||
* @param {string} extensionName The index of the extension config object.
|
||||
* @return {Config} The extended config object.
|
||||
*/
|
||||
function extendConfig(baseConfig, baseConfigName, extension, extensionName) {
|
||||
const result = { ...extension };
|
||||
|
||||
// for global ignores there is no further work to be done, we just keep everything
|
||||
if (!isGlobalIgnores(extension)) {
|
||||
// for files we need to create every combination of base and extension files
|
||||
if (baseConfig.files) {
|
||||
result.files = extendConfigFiles(baseConfig.files, extension.files);
|
||||
}
|
||||
|
||||
// for ignores we just concatenation the extension ignores onto the base ignores
|
||||
if (baseConfig.ignores) {
|
||||
result.ignores = baseConfig.ignores.concat(extension.ignores ?? []);
|
||||
}
|
||||
}
|
||||
|
||||
result.name = `${baseConfigName} > ${extensionName}`;
|
||||
|
||||
// @ts-ignore -- ESLint types aren't updated yet
|
||||
if (baseConfig.basePath) {
|
||||
// @ts-ignore -- ESLint types aren't updated yet
|
||||
result.basePath = baseConfig.basePath;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes a list of extends elements.
|
||||
* @param {ConfigWithExtends} config The config object.
|
||||
* @param {WeakMap<Config, string>} configNames The map of config objects to their names.
|
||||
* @return {Config[]} The flattened list of config objects.
|
||||
* @throws {TypeError} If the `extends` property is not an array or if nested `extends` is found.
|
||||
*/
|
||||
function processExtends(config, configNames) {
|
||||
if (!config.extends) {
|
||||
return [config];
|
||||
}
|
||||
|
||||
if (!Array.isArray(config.extends)) {
|
||||
throw new TypeError("The `extends` property must be an array.");
|
||||
}
|
||||
|
||||
const {
|
||||
/** @type {Config[]} */
|
||||
extends: extendsList,
|
||||
|
||||
/** @type {Config} */
|
||||
...configObject
|
||||
} = config;
|
||||
|
||||
const extensionNames = new WeakMap();
|
||||
|
||||
// replace strings with the actual configs
|
||||
const objectExtends = extendsList.map(extendsElement => {
|
||||
if (typeof extendsElement === "string") {
|
||||
const pluginConfig = findPluginConfig(config, extendsElement);
|
||||
|
||||
// assign names
|
||||
if (Array.isArray(pluginConfig)) {
|
||||
pluginConfig.forEach((pluginConfigElement, index) => {
|
||||
extensionNames.set(
|
||||
pluginConfigElement,
|
||||
`${extendsElement}[${index}]`,
|
||||
);
|
||||
});
|
||||
} else {
|
||||
extensionNames.set(pluginConfig, extendsElement);
|
||||
}
|
||||
|
||||
return pluginConfig;
|
||||
}
|
||||
|
||||
return /** @type {Config} */ (extendsElement);
|
||||
});
|
||||
|
||||
const result = [];
|
||||
|
||||
for (const { indexPath, value: extendsElement } of flatTraverse(
|
||||
objectExtends,
|
||||
)) {
|
||||
const extension = /** @type {Config} */ (extendsElement);
|
||||
|
||||
if ("basePath" in extension) {
|
||||
throw new TypeError("'basePath' in `extends` is not allowed.");
|
||||
}
|
||||
|
||||
if ("extends" in extension) {
|
||||
throw new TypeError("Nested 'extends' is not allowed.");
|
||||
}
|
||||
|
||||
const baseConfigName = /** @type {string} */ (configNames.get(config));
|
||||
const extensionName =
|
||||
extensionNames.get(extendsElement) ??
|
||||
getExtensionName(extendsElement, indexPath);
|
||||
|
||||
result.push(
|
||||
extendConfig(
|
||||
configObject,
|
||||
baseConfigName,
|
||||
extension,
|
||||
extensionName,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the base config object has only `ignores` and `extends`, then
|
||||
* removing `extends` turns it into a global ignores, which is not what
|
||||
* we want. So we need to check if the base config object is a global ignores
|
||||
* and if so, we don't add it to the array.
|
||||
*
|
||||
* (The other option would be to add a `files` entry, but that would result
|
||||
* in a config that didn't actually do anything because there are no
|
||||
* other keys in the config.)
|
||||
*/
|
||||
if (!isGlobalIgnores(configObject)) {
|
||||
result.push(configObject);
|
||||
}
|
||||
|
||||
return result.flat();
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes a list of config objects and arrays.
|
||||
* @param {ConfigWithExtends[]} configList The list of config objects and arrays.
|
||||
* @param {WeakMap<Config, string>} configNames The map of config objects to their names.
|
||||
* @return {Config[]} The flattened list of config objects.
|
||||
*/
|
||||
function processConfigList(configList, configNames) {
|
||||
return configList.flatMap(config => processExtends(config, configNames));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Exports
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Helper function to define a config array.
|
||||
* @param {ConfigWithExtendsArray} args The arguments to the function.
|
||||
* @returns {Config[]} The config array.
|
||||
* @throws {TypeError} If no arguments are provided or if an argument is not an object.
|
||||
*/
|
||||
function defineConfig(...args) {
|
||||
const configNames = new WeakMap();
|
||||
const configs = [];
|
||||
|
||||
if (args.length === 0) {
|
||||
throw new TypeError("Expected one or more arguments.");
|
||||
}
|
||||
|
||||
// first flatten the list of configs and get the names
|
||||
for (const { indexPath, value } of flatTraverse(args)) {
|
||||
if (typeof value !== "object" || value === null) {
|
||||
throw new TypeError(
|
||||
`Expected an object but received ${String(value)}.`,
|
||||
);
|
||||
}
|
||||
|
||||
const config = /** @type {ConfigWithExtends} */ (value);
|
||||
|
||||
// save config name for easy reference later
|
||||
configNames.set(config, getConfigName(config, indexPath));
|
||||
configs.push(config);
|
||||
}
|
||||
|
||||
return processConfigList(configs, configNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* @fileoverview Global ignores helper function.
|
||||
* @author Nicholas C. Zakas
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Type Definitions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
let globalIgnoreCount = 0;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Exports
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Creates a global ignores config with the given patterns.
|
||||
* @param {string[]} ignorePatterns The ignore patterns.
|
||||
* @param {string} [name] The name of the global ignores config.
|
||||
* @returns {Config} The global ignores config.
|
||||
* @throws {TypeError} If ignorePatterns is not an array or if it is empty.
|
||||
*/
|
||||
function globalIgnores(ignorePatterns, name) {
|
||||
if (!Array.isArray(ignorePatterns)) {
|
||||
throw new TypeError("ignorePatterns must be an array");
|
||||
}
|
||||
|
||||
if (ignorePatterns.length === 0) {
|
||||
throw new TypeError("ignorePatterns must contain at least one pattern");
|
||||
}
|
||||
|
||||
const id = globalIgnoreCount++;
|
||||
|
||||
return {
|
||||
name: name || `globalIgnores ${id}`,
|
||||
ignores: ignorePatterns,
|
||||
};
|
||||
}
|
||||
|
||||
exports.defineConfig = defineConfig;
|
||||
exports.globalIgnores = globalIgnores;
|
24
node_modules/@eslint/config-helpers/dist/cjs/index.d.cts
generated
vendored
24
node_modules/@eslint/config-helpers/dist/cjs/index.d.cts
generated
vendored
|
@ -1,24 +0,0 @@
|
|||
export type Config = import("eslint").Linter.Config;
|
||||
export type LegacyConfig = import("eslint").Linter.LegacyConfig;
|
||||
export type Plugin = import("eslint").ESLint.Plugin;
|
||||
export type RuleEntry = import("eslint").Linter.RuleEntry;
|
||||
export type ExtendsElement = import("./types.cts").ExtendsElement;
|
||||
export type SimpleExtendsElement = import("./types.cts").SimpleExtendsElement;
|
||||
export type ConfigWithExtends = import("./types.cts").ConfigWithExtends;
|
||||
export type InfiniteConfigArray = import("./types.cts").InfiniteArray<Config>;
|
||||
export type ConfigWithExtendsArray = import("./types.cts").ConfigWithExtendsArray;
|
||||
/**
|
||||
* Helper function to define a config array.
|
||||
* @param {ConfigWithExtendsArray} args The arguments to the function.
|
||||
* @returns {Config[]} The config array.
|
||||
* @throws {TypeError} If no arguments are provided or if an argument is not an object.
|
||||
*/
|
||||
export function defineConfig(...args: ConfigWithExtendsArray): Config[];
|
||||
/**
|
||||
* Creates a global ignores config with the given patterns.
|
||||
* @param {string[]} ignorePatterns The ignore patterns.
|
||||
* @param {string} [name] The name of the global ignores config.
|
||||
* @returns {Config} The global ignores config.
|
||||
* @throws {TypeError} If ignorePatterns is not an array or if it is empty.
|
||||
*/
|
||||
export function globalIgnores(ignorePatterns: string[], name?: string): Config;
|
31
node_modules/@eslint/config-helpers/dist/cjs/types.cts
generated
vendored
31
node_modules/@eslint/config-helpers/dist/cjs/types.cts
generated
vendored
|
@ -1,31 +0,0 @@
|
|||
/**
|
||||
* @fileoverview Types for this package.
|
||||
*/
|
||||
|
||||
import type { Linter } from "eslint";
|
||||
|
||||
/**
|
||||
* Infinite array type.
|
||||
*/
|
||||
export type InfiniteArray<T> = T | InfiniteArray<T>[];
|
||||
|
||||
/**
|
||||
* The type of array element in the `extends` property after flattening.
|
||||
*/
|
||||
export type SimpleExtendsElement = string | Linter.Config;
|
||||
|
||||
/**
|
||||
* The type of array element in the `extends` property before flattening.
|
||||
*/
|
||||
export type ExtendsElement =
|
||||
| SimpleExtendsElement
|
||||
| InfiniteArray<Linter.Config>;
|
||||
|
||||
/**
|
||||
* Config with extends. Valid only inside of `defineConfig()`.
|
||||
*/
|
||||
export interface ConfigWithExtends extends Linter.Config {
|
||||
extends?: ExtendsElement[];
|
||||
}
|
||||
|
||||
export type ConfigWithExtendsArray = InfiniteArray<ConfigWithExtends>[];
|
24
node_modules/@eslint/config-helpers/dist/esm/index.d.ts
generated
vendored
24
node_modules/@eslint/config-helpers/dist/esm/index.d.ts
generated
vendored
|
@ -1,24 +0,0 @@
|
|||
export type Config = import("eslint").Linter.Config;
|
||||
export type LegacyConfig = import("eslint").Linter.LegacyConfig;
|
||||
export type Plugin = import("eslint").ESLint.Plugin;
|
||||
export type RuleEntry = import("eslint").Linter.RuleEntry;
|
||||
export type ExtendsElement = import("./types.ts").ExtendsElement;
|
||||
export type SimpleExtendsElement = import("./types.ts").SimpleExtendsElement;
|
||||
export type ConfigWithExtends = import("./types.ts").ConfigWithExtends;
|
||||
export type InfiniteConfigArray = import("./types.ts").InfiniteArray<Config>;
|
||||
export type ConfigWithExtendsArray = import("./types.ts").ConfigWithExtendsArray;
|
||||
/**
|
||||
* Helper function to define a config array.
|
||||
* @param {ConfigWithExtendsArray} args The arguments to the function.
|
||||
* @returns {Config[]} The config array.
|
||||
* @throws {TypeError} If no arguments are provided or if an argument is not an object.
|
||||
*/
|
||||
export function defineConfig(...args: ConfigWithExtendsArray): Config[];
|
||||
/**
|
||||
* Creates a global ignores config with the given patterns.
|
||||
* @param {string[]} ignorePatterns The ignore patterns.
|
||||
* @param {string} [name] The name of the global ignores config.
|
||||
* @returns {Config} The global ignores config.
|
||||
* @throws {TypeError} If ignorePatterns is not an array or if it is empty.
|
||||
*/
|
||||
export function globalIgnores(ignorePatterns: string[], name?: string): Config;
|
579
node_modules/@eslint/config-helpers/dist/esm/index.js
generated
vendored
579
node_modules/@eslint/config-helpers/dist/esm/index.js
generated
vendored
|
@ -1,579 +0,0 @@
|
|||
// @ts-self-types="./index.d.ts"
|
||||
/**
|
||||
* @fileoverview defineConfig helper
|
||||
* @author Nicholas C. Zakas
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Type Definitions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/** @typedef {import("eslint").Linter.Config} Config */
|
||||
/** @typedef {import("eslint").Linter.LegacyConfig} LegacyConfig */
|
||||
/** @typedef {import("eslint").ESLint.Plugin} Plugin */
|
||||
/** @typedef {import("eslint").Linter.RuleEntry} RuleEntry */
|
||||
/** @typedef {import("./types.ts").ExtendsElement} ExtendsElement */
|
||||
/** @typedef {import("./types.ts").SimpleExtendsElement} SimpleExtendsElement */
|
||||
/** @typedef {import("./types.ts").ConfigWithExtends} ConfigWithExtends */
|
||||
/** @typedef {import("./types.ts").InfiniteArray<Config>} InfiniteConfigArray */
|
||||
/** @typedef {import("./types.ts").ConfigWithExtendsArray} ConfigWithExtendsArray */
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
const eslintrcKeys = [
|
||||
"env",
|
||||
"extends",
|
||||
"globals",
|
||||
"ignorePatterns",
|
||||
"noInlineConfig",
|
||||
"overrides",
|
||||
"parser",
|
||||
"parserOptions",
|
||||
"reportUnusedDisableDirectives",
|
||||
"root",
|
||||
];
|
||||
|
||||
const allowedGlobalIgnoreKeys = new Set(["basePath", "ignores", "name"]);
|
||||
|
||||
/**
|
||||
* Gets the name of a config object.
|
||||
* @param {Config} config The config object.
|
||||
* @param {string} indexPath The index path of the config object.
|
||||
* @return {string} The name of the config object.
|
||||
*/
|
||||
function getConfigName(config, indexPath) {
|
||||
if (config.name) {
|
||||
return config.name;
|
||||
}
|
||||
|
||||
return `UserConfig${indexPath}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of an extension.
|
||||
* @param {SimpleExtendsElement} extension The extension.
|
||||
* @param {string} indexPath The index of the extension.
|
||||
* @return {string} The name of the extension.
|
||||
*/
|
||||
function getExtensionName(extension, indexPath) {
|
||||
if (typeof extension === "string") {
|
||||
return extension;
|
||||
}
|
||||
|
||||
if (extension.name) {
|
||||
return extension.name;
|
||||
}
|
||||
|
||||
return `ExtendedConfig${indexPath}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if a config object is a legacy config.
|
||||
* @param {Config|LegacyConfig} config The config object to check.
|
||||
* @return {config is LegacyConfig} `true` if the config object is a legacy config.
|
||||
*/
|
||||
function isLegacyConfig(config) {
|
||||
for (const key of eslintrcKeys) {
|
||||
if (key in config) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if a config object is a global ignores config.
|
||||
* @param {Config} config The config object to check.
|
||||
* @return {boolean} `true` if the config object is a global ignores config.
|
||||
*/
|
||||
function isGlobalIgnores(config) {
|
||||
return Object.keys(config).every(key => allowedGlobalIgnoreKeys.has(key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a plugin member ID (rule, processor, etc.) and returns
|
||||
* the namespace and member name.
|
||||
* @param {string} id The ID to parse.
|
||||
* @returns {{namespace:string, name:string}} The namespace and member name.
|
||||
*/
|
||||
function getPluginMember(id) {
|
||||
const firstSlashIndex = id.indexOf("/");
|
||||
|
||||
if (firstSlashIndex === -1) {
|
||||
return { namespace: "", name: id };
|
||||
}
|
||||
|
||||
let namespace = id.slice(0, firstSlashIndex);
|
||||
|
||||
/*
|
||||
* Special cases:
|
||||
* 1. The namespace is `@`, that means it's referring to the
|
||||
* core plugin so `@` is the full namespace.
|
||||
* 2. The namespace starts with `@`, that means it's referring to
|
||||
* an npm scoped package. That means the namespace is the scope
|
||||
* and the package name (i.e., `@eslint/core`).
|
||||
*/
|
||||
if (namespace[0] === "@" && namespace !== "@") {
|
||||
const secondSlashIndex = id.indexOf("/", firstSlashIndex + 1);
|
||||
if (secondSlashIndex !== -1) {
|
||||
namespace = id.slice(0, secondSlashIndex);
|
||||
return { namespace, name: id.slice(secondSlashIndex + 1) };
|
||||
}
|
||||
}
|
||||
|
||||
const name = id.slice(firstSlashIndex + 1);
|
||||
|
||||
return { namespace, name };
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes the plugin config by replacing the namespace with the plugin namespace.
|
||||
* @param {string} userNamespace The namespace of the plugin.
|
||||
* @param {Plugin} plugin The plugin config object.
|
||||
* @param {Config} config The config object to normalize.
|
||||
* @return {Config} The normalized config object.
|
||||
*/
|
||||
function normalizePluginConfig(userNamespace, plugin, config) {
|
||||
const pluginNamespace = plugin.meta?.namespace;
|
||||
|
||||
// don't do anything if the plugin doesn't have a namespace or rules
|
||||
if (
|
||||
!pluginNamespace ||
|
||||
pluginNamespace === userNamespace ||
|
||||
(!config.rules && !config.processor && !config.language)
|
||||
) {
|
||||
return config;
|
||||
}
|
||||
|
||||
const result = { ...config };
|
||||
|
||||
// update the rules
|
||||
if (result.rules) {
|
||||
const ruleIds = Object.keys(result.rules);
|
||||
|
||||
/** @type {Record<string,RuleEntry|undefined>} */
|
||||
const newRules = {};
|
||||
|
||||
for (let i = 0; i < ruleIds.length; i++) {
|
||||
const ruleId = ruleIds[i];
|
||||
const { namespace: ruleNamespace, name: ruleName } =
|
||||
getPluginMember(ruleId);
|
||||
|
||||
if (ruleNamespace === pluginNamespace) {
|
||||
newRules[`${userNamespace}/${ruleName}`] = result.rules[ruleId];
|
||||
} else {
|
||||
newRules[ruleId] = result.rules[ruleId];
|
||||
}
|
||||
}
|
||||
|
||||
result.rules = newRules;
|
||||
}
|
||||
|
||||
// update the processor
|
||||
|
||||
if (typeof result.processor === "string") {
|
||||
const { namespace: processorNamespace, name: processorName } =
|
||||
getPluginMember(result.processor);
|
||||
|
||||
if (processorNamespace) {
|
||||
if (processorNamespace === pluginNamespace) {
|
||||
result.processor = `${userNamespace}/${processorName}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update the language
|
||||
if (typeof result.language === "string") {
|
||||
const { namespace: languageNamespace, name: languageName } =
|
||||
getPluginMember(result.language);
|
||||
|
||||
if (languageNamespace === pluginNamespace) {
|
||||
result.language = `${userNamespace}/${languageName}`;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deeply normalizes a plugin config, traversing recursively into an arrays.
|
||||
* @param {string} userPluginNamespace The namespace of the plugin.
|
||||
* @param {Plugin} plugin The plugin object.
|
||||
* @param {Config|LegacyConfig|(Config|LegacyConfig)[]} pluginConfig The plugin config to normalize.
|
||||
* @param {string} pluginConfigName The name of the plugin config.
|
||||
* @return {InfiniteConfigArray} The normalized plugin config.
|
||||
* @throws {TypeError} If the plugin config is a legacy config.
|
||||
*/
|
||||
function deepNormalizePluginConfig(
|
||||
userPluginNamespace,
|
||||
plugin,
|
||||
pluginConfig,
|
||||
pluginConfigName,
|
||||
) {
|
||||
// if it's an array then it's definitely a new config
|
||||
if (Array.isArray(pluginConfig)) {
|
||||
return pluginConfig.map(pluginSubConfig =>
|
||||
deepNormalizePluginConfig(
|
||||
userPluginNamespace,
|
||||
plugin,
|
||||
pluginSubConfig,
|
||||
pluginConfigName,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// if it's a legacy config, throw an error
|
||||
if (isLegacyConfig(pluginConfig)) {
|
||||
throw new TypeError(
|
||||
`Plugin config "${pluginConfigName}" is an eslintrc config and cannot be used in this context.`,
|
||||
);
|
||||
}
|
||||
|
||||
return normalizePluginConfig(userPluginNamespace, plugin, pluginConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a plugin config by name in the given config.
|
||||
* @param {Config} config The config object.
|
||||
* @param {string} pluginConfigName The name of the plugin config.
|
||||
* @return {InfiniteConfigArray} The plugin config.
|
||||
* @throws {TypeError} If the plugin config is not found or is a legacy config.
|
||||
*/
|
||||
function findPluginConfig(config, pluginConfigName) {
|
||||
const { namespace: userPluginNamespace, name: configName } =
|
||||
getPluginMember(pluginConfigName);
|
||||
const plugin = config.plugins?.[userPluginNamespace];
|
||||
|
||||
if (!plugin) {
|
||||
throw new TypeError(`Plugin "${userPluginNamespace}" not found.`);
|
||||
}
|
||||
|
||||
const directConfig = plugin.configs?.[configName];
|
||||
if (directConfig) {
|
||||
// Arrays are always flat configs, and non-legacy configs can be used directly
|
||||
if (Array.isArray(directConfig) || !isLegacyConfig(directConfig)) {
|
||||
return deepNormalizePluginConfig(
|
||||
userPluginNamespace,
|
||||
plugin,
|
||||
directConfig,
|
||||
pluginConfigName,
|
||||
);
|
||||
}
|
||||
|
||||
// If it's a legacy config, look for the flat version
|
||||
const flatConfig = plugin.configs?.[`flat/${configName}`];
|
||||
|
||||
if (
|
||||
flatConfig &&
|
||||
(Array.isArray(flatConfig) || !isLegacyConfig(flatConfig))
|
||||
) {
|
||||
return deepNormalizePluginConfig(
|
||||
userPluginNamespace,
|
||||
plugin,
|
||||
flatConfig,
|
||||
pluginConfigName,
|
||||
);
|
||||
}
|
||||
|
||||
throw new TypeError(
|
||||
`Plugin config "${configName}" in plugin "${userPluginNamespace}" is an eslintrc config and cannot be used in this context.`,
|
||||
);
|
||||
}
|
||||
|
||||
throw new TypeError(
|
||||
`Plugin config "${configName}" not found in plugin "${userPluginNamespace}".`,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Flattens an array while keeping track of the index path.
|
||||
* @param {any[]} configList The array to traverse.
|
||||
* @param {string} indexPath The index path of the value in a multidimensional array.
|
||||
* @return {IterableIterator<{indexPath:string, value:any}>} The flattened list of values.
|
||||
*/
|
||||
function* flatTraverse(configList, indexPath = "") {
|
||||
for (let i = 0; i < configList.length; i++) {
|
||||
const newIndexPath = indexPath ? `${indexPath}[${i}]` : `[${i}]`;
|
||||
|
||||
// if it's an array then traverse it as well
|
||||
if (Array.isArray(configList[i])) {
|
||||
yield* flatTraverse(configList[i], newIndexPath);
|
||||
continue;
|
||||
}
|
||||
|
||||
yield { indexPath: newIndexPath, value: configList[i] };
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extends a list of config files by creating every combination of base and extension files.
|
||||
* @param {(string|string[])[]} [baseFiles] The base files.
|
||||
* @param {(string|string[])[]} [extensionFiles] The extension files.
|
||||
* @return {(string|string[])[]} The extended files.
|
||||
*/
|
||||
function extendConfigFiles(baseFiles = [], extensionFiles = []) {
|
||||
if (!extensionFiles.length) {
|
||||
return baseFiles.concat();
|
||||
}
|
||||
|
||||
if (!baseFiles.length) {
|
||||
return extensionFiles.concat();
|
||||
}
|
||||
|
||||
/** @type {(string|string[])[]} */
|
||||
const result = [];
|
||||
|
||||
for (const baseFile of baseFiles) {
|
||||
for (const extensionFile of extensionFiles) {
|
||||
/*
|
||||
* Each entry can be a string or array of strings. The end result
|
||||
* needs to be an array of strings, so we need to be sure to include
|
||||
* all of the items when there's an array.
|
||||
*/
|
||||
|
||||
const entry = [];
|
||||
|
||||
if (Array.isArray(baseFile)) {
|
||||
entry.push(...baseFile);
|
||||
} else {
|
||||
entry.push(baseFile);
|
||||
}
|
||||
|
||||
if (Array.isArray(extensionFile)) {
|
||||
entry.push(...extensionFile);
|
||||
} else {
|
||||
entry.push(extensionFile);
|
||||
}
|
||||
|
||||
result.push(entry);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extends a config object with another config object.
|
||||
* @param {Config} baseConfig The base config object.
|
||||
* @param {string} baseConfigName The name of the base config object.
|
||||
* @param {Config} extension The extension config object.
|
||||
* @param {string} extensionName The index of the extension config object.
|
||||
* @return {Config} The extended config object.
|
||||
*/
|
||||
function extendConfig(baseConfig, baseConfigName, extension, extensionName) {
|
||||
const result = { ...extension };
|
||||
|
||||
// for global ignores there is no further work to be done, we just keep everything
|
||||
if (!isGlobalIgnores(extension)) {
|
||||
// for files we need to create every combination of base and extension files
|
||||
if (baseConfig.files) {
|
||||
result.files = extendConfigFiles(baseConfig.files, extension.files);
|
||||
}
|
||||
|
||||
// for ignores we just concatenation the extension ignores onto the base ignores
|
||||
if (baseConfig.ignores) {
|
||||
result.ignores = baseConfig.ignores.concat(extension.ignores ?? []);
|
||||
}
|
||||
}
|
||||
|
||||
result.name = `${baseConfigName} > ${extensionName}`;
|
||||
|
||||
// @ts-ignore -- ESLint types aren't updated yet
|
||||
if (baseConfig.basePath) {
|
||||
// @ts-ignore -- ESLint types aren't updated yet
|
||||
result.basePath = baseConfig.basePath;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes a list of extends elements.
|
||||
* @param {ConfigWithExtends} config The config object.
|
||||
* @param {WeakMap<Config, string>} configNames The map of config objects to their names.
|
||||
* @return {Config[]} The flattened list of config objects.
|
||||
* @throws {TypeError} If the `extends` property is not an array or if nested `extends` is found.
|
||||
*/
|
||||
function processExtends(config, configNames) {
|
||||
if (!config.extends) {
|
||||
return [config];
|
||||
}
|
||||
|
||||
if (!Array.isArray(config.extends)) {
|
||||
throw new TypeError("The `extends` property must be an array.");
|
||||
}
|
||||
|
||||
const {
|
||||
/** @type {Config[]} */
|
||||
extends: extendsList,
|
||||
|
||||
/** @type {Config} */
|
||||
...configObject
|
||||
} = config;
|
||||
|
||||
const extensionNames = new WeakMap();
|
||||
|
||||
// replace strings with the actual configs
|
||||
const objectExtends = extendsList.map(extendsElement => {
|
||||
if (typeof extendsElement === "string") {
|
||||
const pluginConfig = findPluginConfig(config, extendsElement);
|
||||
|
||||
// assign names
|
||||
if (Array.isArray(pluginConfig)) {
|
||||
pluginConfig.forEach((pluginConfigElement, index) => {
|
||||
extensionNames.set(
|
||||
pluginConfigElement,
|
||||
`${extendsElement}[${index}]`,
|
||||
);
|
||||
});
|
||||
} else {
|
||||
extensionNames.set(pluginConfig, extendsElement);
|
||||
}
|
||||
|
||||
return pluginConfig;
|
||||
}
|
||||
|
||||
return /** @type {Config} */ (extendsElement);
|
||||
});
|
||||
|
||||
const result = [];
|
||||
|
||||
for (const { indexPath, value: extendsElement } of flatTraverse(
|
||||
objectExtends,
|
||||
)) {
|
||||
const extension = /** @type {Config} */ (extendsElement);
|
||||
|
||||
if ("basePath" in extension) {
|
||||
throw new TypeError("'basePath' in `extends` is not allowed.");
|
||||
}
|
||||
|
||||
if ("extends" in extension) {
|
||||
throw new TypeError("Nested 'extends' is not allowed.");
|
||||
}
|
||||
|
||||
const baseConfigName = /** @type {string} */ (configNames.get(config));
|
||||
const extensionName =
|
||||
extensionNames.get(extendsElement) ??
|
||||
getExtensionName(extendsElement, indexPath);
|
||||
|
||||
result.push(
|
||||
extendConfig(
|
||||
configObject,
|
||||
baseConfigName,
|
||||
extension,
|
||||
extensionName,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the base config object has only `ignores` and `extends`, then
|
||||
* removing `extends` turns it into a global ignores, which is not what
|
||||
* we want. So we need to check if the base config object is a global ignores
|
||||
* and if so, we don't add it to the array.
|
||||
*
|
||||
* (The other option would be to add a `files` entry, but that would result
|
||||
* in a config that didn't actually do anything because there are no
|
||||
* other keys in the config.)
|
||||
*/
|
||||
if (!isGlobalIgnores(configObject)) {
|
||||
result.push(configObject);
|
||||
}
|
||||
|
||||
return result.flat();
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes a list of config objects and arrays.
|
||||
* @param {ConfigWithExtends[]} configList The list of config objects and arrays.
|
||||
* @param {WeakMap<Config, string>} configNames The map of config objects to their names.
|
||||
* @return {Config[]} The flattened list of config objects.
|
||||
*/
|
||||
function processConfigList(configList, configNames) {
|
||||
return configList.flatMap(config => processExtends(config, configNames));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Exports
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Helper function to define a config array.
|
||||
* @param {ConfigWithExtendsArray} args The arguments to the function.
|
||||
* @returns {Config[]} The config array.
|
||||
* @throws {TypeError} If no arguments are provided or if an argument is not an object.
|
||||
*/
|
||||
function defineConfig(...args) {
|
||||
const configNames = new WeakMap();
|
||||
const configs = [];
|
||||
|
||||
if (args.length === 0) {
|
||||
throw new TypeError("Expected one or more arguments.");
|
||||
}
|
||||
|
||||
// first flatten the list of configs and get the names
|
||||
for (const { indexPath, value } of flatTraverse(args)) {
|
||||
if (typeof value !== "object" || value === null) {
|
||||
throw new TypeError(
|
||||
`Expected an object but received ${String(value)}.`,
|
||||
);
|
||||
}
|
||||
|
||||
const config = /** @type {ConfigWithExtends} */ (value);
|
||||
|
||||
// save config name for easy reference later
|
||||
configNames.set(config, getConfigName(config, indexPath));
|
||||
configs.push(config);
|
||||
}
|
||||
|
||||
return processConfigList(configs, configNames);
|
||||
}
|
||||
|
||||
/**
|
||||
* @fileoverview Global ignores helper function.
|
||||
* @author Nicholas C. Zakas
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Type Definitions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
let globalIgnoreCount = 0;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Exports
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Creates a global ignores config with the given patterns.
|
||||
* @param {string[]} ignorePatterns The ignore patterns.
|
||||
* @param {string} [name] The name of the global ignores config.
|
||||
* @returns {Config} The global ignores config.
|
||||
* @throws {TypeError} If ignorePatterns is not an array or if it is empty.
|
||||
*/
|
||||
function globalIgnores(ignorePatterns, name) {
|
||||
if (!Array.isArray(ignorePatterns)) {
|
||||
throw new TypeError("ignorePatterns must be an array");
|
||||
}
|
||||
|
||||
if (ignorePatterns.length === 0) {
|
||||
throw new TypeError("ignorePatterns must contain at least one pattern");
|
||||
}
|
||||
|
||||
const id = globalIgnoreCount++;
|
||||
|
||||
return {
|
||||
name: name || `globalIgnores ${id}`,
|
||||
ignores: ignorePatterns,
|
||||
};
|
||||
}
|
||||
|
||||
export { defineConfig, globalIgnores };
|
23
node_modules/@eslint/config-helpers/dist/esm/types.d.ts
generated
vendored
23
node_modules/@eslint/config-helpers/dist/esm/types.d.ts
generated
vendored
|
@ -1,23 +0,0 @@
|
|||
/**
|
||||
* @fileoverview Types for this package.
|
||||
*/
|
||||
import type { Linter } from "eslint";
|
||||
/**
|
||||
* Infinite array type.
|
||||
*/
|
||||
export type InfiniteArray<T> = T | InfiniteArray<T>[];
|
||||
/**
|
||||
* The type of array element in the `extends` property after flattening.
|
||||
*/
|
||||
export type SimpleExtendsElement = string | Linter.Config;
|
||||
/**
|
||||
* The type of array element in the `extends` property before flattening.
|
||||
*/
|
||||
export type ExtendsElement = SimpleExtendsElement | InfiniteArray<Linter.Config>;
|
||||
/**
|
||||
* Config with extends. Valid only inside of `defineConfig()`.
|
||||
*/
|
||||
export interface ConfigWithExtends extends Linter.Config {
|
||||
extends?: ExtendsElement[];
|
||||
}
|
||||
export type ConfigWithExtendsArray = InfiniteArray<ConfigWithExtends>[];
|
31
node_modules/@eslint/config-helpers/dist/esm/types.ts
generated
vendored
31
node_modules/@eslint/config-helpers/dist/esm/types.ts
generated
vendored
|
@ -1,31 +0,0 @@
|
|||
/**
|
||||
* @fileoverview Types for this package.
|
||||
*/
|
||||
|
||||
import type { Linter } from "eslint";
|
||||
|
||||
/**
|
||||
* Infinite array type.
|
||||
*/
|
||||
export type InfiniteArray<T> = T | InfiniteArray<T>[];
|
||||
|
||||
/**
|
||||
* The type of array element in the `extends` property after flattening.
|
||||
*/
|
||||
export type SimpleExtendsElement = string | Linter.Config;
|
||||
|
||||
/**
|
||||
* The type of array element in the `extends` property before flattening.
|
||||
*/
|
||||
export type ExtendsElement =
|
||||
| SimpleExtendsElement
|
||||
| InfiniteArray<Linter.Config>;
|
||||
|
||||
/**
|
||||
* Config with extends. Valid only inside of `defineConfig()`.
|
||||
*/
|
||||
export interface ConfigWithExtends extends Linter.Config {
|
||||
extends?: ExtendsElement[];
|
||||
}
|
||||
|
||||
export type ConfigWithExtendsArray = InfiniteArray<ConfigWithExtends>[];
|
57
node_modules/@eslint/config-helpers/package.json
generated
vendored
57
node_modules/@eslint/config-helpers/package.json
generated
vendored
|
@ -1,57 +0,0 @@
|
|||
{
|
||||
"name": "@eslint/config-helpers",
|
||||
"version": "0.3.1",
|
||||
"description": "Helper utilities for creating ESLint configuration",
|
||||
"type": "module",
|
||||
"main": "dist/esm/index.js",
|
||||
"types": "dist/esm/index.d.ts",
|
||||
"exports": {
|
||||
"require": {
|
||||
"types": "./dist/cjs/index.d.cts",
|
||||
"default": "./dist/cjs/index.cjs"
|
||||
},
|
||||
"import": {
|
||||
"types": "./dist/esm/index.d.ts",
|
||||
"default": "./dist/esm/index.js"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"directories": {
|
||||
"test": "tests"
|
||||
},
|
||||
"scripts": {
|
||||
"build:dedupe-types": "node ../../tools/dedupe-types.js dist/cjs/index.cjs dist/esm/index.js",
|
||||
"build:cts": "node ../../tools/build-cts.js dist/esm/index.d.ts dist/cjs/index.d.cts",
|
||||
"build": "rollup -c && npm run build:dedupe-types && tsc -p tsconfig.esm.json && npm run build:cts",
|
||||
"test:jsr": "npx jsr@latest publish --dry-run",
|
||||
"test": "mocha tests/*.js",
|
||||
"test:coverage": "c8 npm test",
|
||||
"test:types": "tsc -p tests/types/tsconfig.json"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/eslint/rewrite.git",
|
||||
"directory": "packages/config-helpers"
|
||||
},
|
||||
"keywords": [
|
||||
"eslint"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/eslint/rewrite/issues"
|
||||
},
|
||||
"homepage": "https://github.com/eslint/rewrite/tree/main/packages/config-helpers#readme",
|
||||
"devDependencies": {
|
||||
"@eslint/core": "^0.15.2",
|
||||
"eslint": "^9.27.0",
|
||||
"rollup-plugin-copy": "^3.5.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
}
|
||||
}
|
201
node_modules/@eslint/core/LICENSE
generated
vendored
201
node_modules/@eslint/core/LICENSE
generated
vendored
|
@ -1,201 +0,0 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
29
node_modules/@eslint/core/README.md
generated
vendored
29
node_modules/@eslint/core/README.md
generated
vendored
|
@ -1,29 +0,0 @@
|
|||
# ESLint Core
|
||||
|
||||
## Overview
|
||||
|
||||
This package is the future home of the rewritten, runtime-agnostic ESLint core.
|
||||
|
||||
Right now, it exports the core types necessary to implement language plugins.
|
||||
|
||||
## License
|
||||
|
||||
Apache 2.0
|
||||
|
||||
<!-- NOTE: This section is autogenerated. Do not manually edit.-->
|
||||
<!--sponsorsstart-->
|
||||
|
||||
## Sponsors
|
||||
|
||||
The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://eslint.org/donate)
|
||||
to get your logo on our READMEs and [website](https://eslint.org/sponsors).
|
||||
|
||||
<h3>Platinum Sponsors</h3>
|
||||
<p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="128"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="128"></a></p><h3>Gold Sponsors</h3>
|
||||
<p><a href="https://qlty.sh/"><img src="https://images.opencollective.com/qltysh/33d157d/logo.png" alt="Qlty Software" height="96"></a> <a href="https://trunk.io/"><img src="https://images.opencollective.com/trunkio/fb92d60/avatar.png" alt="trunk.io" height="96"></a> <a href="https://shopify.engineering/"><img src="https://avatars.githubusercontent.com/u/8085" alt="Shopify" height="96"></a></p><h3>Silver Sponsors</h3>
|
||||
<p><a href="https://vite.dev/"><img src="https://images.opencollective.com/vite/e6d15e1/logo.png" alt="Vite" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a> <a href="https://americanexpress.io"><img src="https://avatars.githubusercontent.com/u/3853301" alt="American Express" 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>
|
||||
<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://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" 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://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104" alt="Nx" height="32"></a> <a href="https://opensource.mercedes-benz.com/"><img src="https://avatars.githubusercontent.com/u/34240465" alt="Mercedes-Benz Group" 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="LambdaTest" height="32"></a></p>
|
||||
<h3>Technology Sponsors</h3>
|
||||
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.
|
||||
<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>
|
||||
<!--sponsorsend-->
|
849
node_modules/@eslint/core/dist/cjs/types.d.cts
generated
vendored
849
node_modules/@eslint/core/dist/cjs/types.d.cts
generated
vendored
|
@ -1,849 +0,0 @@
|
|||
/**
|
||||
* @fileoverview Shared types for ESLint Core.
|
||||
*/
|
||||
import type { JSONSchema4 } from "json-schema";
|
||||
/**
|
||||
* Represents an error inside of a file.
|
||||
*/
|
||||
export interface FileError {
|
||||
message: string;
|
||||
line: number;
|
||||
column: number;
|
||||
endLine?: number;
|
||||
endColumn?: number;
|
||||
}
|
||||
/**
|
||||
* Represents a problem found in a file.
|
||||
*/
|
||||
export interface FileProblem {
|
||||
ruleId: string | null;
|
||||
message: string;
|
||||
loc: SourceLocation;
|
||||
}
|
||||
/**
|
||||
* Represents the start and end coordinates of a node inside the source.
|
||||
*/
|
||||
export interface SourceLocation {
|
||||
start: Position;
|
||||
end: Position;
|
||||
}
|
||||
/**
|
||||
* Represents the start and end coordinates of a node inside the source with an offset.
|
||||
*/
|
||||
export interface SourceLocationWithOffset {
|
||||
start: PositionWithOffset;
|
||||
end: PositionWithOffset;
|
||||
}
|
||||
/**
|
||||
* Represents a location coordinate inside the source. ESLint-style formats
|
||||
* have just `line` and `column` while others may have `offset` as well.
|
||||
*/
|
||||
export interface Position {
|
||||
line: number;
|
||||
column: number;
|
||||
}
|
||||
/**
|
||||
* Represents a location coordinate inside the source with an offset.
|
||||
*/
|
||||
export interface PositionWithOffset extends Position {
|
||||
offset: number;
|
||||
}
|
||||
/**
|
||||
* Represents a range of characters in the source.
|
||||
*/
|
||||
export type SourceRange = [number, number];
|
||||
/**
|
||||
* What the rule is responsible for finding:
|
||||
* - `problem` means the rule has noticed a potential error.
|
||||
* - `suggestion` means the rule suggests an alternate or better approach.
|
||||
* - `layout` means the rule is looking at spacing, indentation, etc.
|
||||
*/
|
||||
export type RuleType = "problem" | "suggestion" | "layout";
|
||||
/**
|
||||
* The type of fix the rule can provide:
|
||||
* - `code` means the rule can fix syntax.
|
||||
* - `whitespace` means the rule can fix spacing and indentation.
|
||||
*/
|
||||
export type RuleFixType = "code" | "whitespace";
|
||||
/**
|
||||
* An object containing visitor information for a rule. Each method is either the
|
||||
* name of a node type or a selector, or is a method that will be called at specific
|
||||
* times during the traversal.
|
||||
*/
|
||||
export type RuleVisitor = Record<string, ((...args: any[]) => void) | undefined>;
|
||||
/**
|
||||
* Rule meta information used for documentation.
|
||||
*/
|
||||
export interface RulesMetaDocs {
|
||||
/**
|
||||
* A short description of the rule.
|
||||
*/
|
||||
description?: string | undefined;
|
||||
/**
|
||||
* The URL to the documentation for the rule.
|
||||
*/
|
||||
url?: string | undefined;
|
||||
/**
|
||||
* The category the rule falls under.
|
||||
* @deprecated No longer used.
|
||||
*/
|
||||
category?: string | undefined;
|
||||
/**
|
||||
* Indicates if the rule is generally recommended for all users.
|
||||
*
|
||||
* Note - this will always be a boolean for core rules, but may be used in any way by plugins.
|
||||
*/
|
||||
recommended?: unknown;
|
||||
/**
|
||||
* Indicates if the rule is frozen (no longer accepting feature requests).
|
||||
*/
|
||||
frozen?: boolean | undefined;
|
||||
}
|
||||
/**
|
||||
* Meta information about a rule.
|
||||
*/
|
||||
export interface RulesMeta<MessageIds extends string = string, RuleOptions = unknown[], ExtRuleDocs = unknown> {
|
||||
/**
|
||||
* Properties that are used when documenting the rule.
|
||||
*/
|
||||
docs?: (RulesMetaDocs & ExtRuleDocs) | undefined;
|
||||
/**
|
||||
* The type of rule.
|
||||
*/
|
||||
type?: RuleType | undefined;
|
||||
/**
|
||||
* The schema for the rule options. Required if the rule has options.
|
||||
*/
|
||||
schema?: JSONSchema4 | JSONSchema4[] | false | undefined;
|
||||
/**
|
||||
* Any default options to be recursively merged on top of any user-provided options.
|
||||
**/
|
||||
defaultOptions?: RuleOptions;
|
||||
/**
|
||||
* The messages that the rule can report.
|
||||
*/
|
||||
messages?: Record<MessageIds, string>;
|
||||
/**
|
||||
* Indicates whether the rule has been deprecated or provides additional metadata about the deprecation. Omit if not deprecated.
|
||||
*/
|
||||
deprecated?: boolean | DeprecatedInfo | undefined;
|
||||
/**
|
||||
* @deprecated Use deprecated.replacedBy instead.
|
||||
* The name of the rule(s) this rule was replaced by, if it was deprecated.
|
||||
*/
|
||||
replacedBy?: readonly string[] | undefined;
|
||||
/**
|
||||
* Indicates if the rule is fixable, and if so, what type of fix it provides.
|
||||
*/
|
||||
fixable?: RuleFixType | undefined;
|
||||
/**
|
||||
* Indicates if the rule may provide suggestions.
|
||||
*/
|
||||
hasSuggestions?: boolean | undefined;
|
||||
/**
|
||||
* The language the rule is intended to lint.
|
||||
*/
|
||||
language?: string;
|
||||
/**
|
||||
* The dialects of `language` that the rule is intended to lint.
|
||||
*/
|
||||
dialects?: string[];
|
||||
}
|
||||
/**
|
||||
* Provides additional metadata about a deprecation.
|
||||
*/
|
||||
export interface DeprecatedInfo {
|
||||
/**
|
||||
* General message presented to the user, e.g. for the key rule why the rule
|
||||
* is deprecated or for info how to replace the rule.
|
||||
*/
|
||||
message?: string;
|
||||
/**
|
||||
* URL to more information about this deprecation in general.
|
||||
*/
|
||||
url?: string;
|
||||
/**
|
||||
* An empty array explicitly states that there is no replacement.
|
||||
*/
|
||||
replacedBy?: ReplacedByInfo[];
|
||||
/**
|
||||
* The package version since when the rule is deprecated (should use full
|
||||
* semver without a leading "v").
|
||||
*/
|
||||
deprecatedSince?: string;
|
||||
/**
|
||||
* The estimated version when the rule is removed (probably the next major
|
||||
* version). null means the rule is "frozen" (will be available but will not
|
||||
* be changed).
|
||||
*/
|
||||
availableUntil?: string | null;
|
||||
}
|
||||
/**
|
||||
* Provides metadata about a replacement
|
||||
*/
|
||||
export interface ReplacedByInfo {
|
||||
/**
|
||||
* General message presented to the user, e.g. how to replace the rule
|
||||
*/
|
||||
message?: string;
|
||||
/**
|
||||
* URL to more information about this replacement in general
|
||||
*/
|
||||
url?: string;
|
||||
/**
|
||||
* Name should be "eslint" if the replacement is an ESLint core rule. Omit
|
||||
* the property if the replacement is in the same plugin.
|
||||
*/
|
||||
plugin?: ExternalSpecifier;
|
||||
/**
|
||||
* Name and documentation of the replacement rule
|
||||
*/
|
||||
rule?: ExternalSpecifier;
|
||||
}
|
||||
/**
|
||||
* Specifies the name and url of an external resource. At least one property
|
||||
* should be set.
|
||||
*/
|
||||
export interface ExternalSpecifier {
|
||||
/**
|
||||
* Name of the referenced plugin / rule.
|
||||
*/
|
||||
name?: string;
|
||||
/**
|
||||
* URL pointing to documentation for the plugin / rule.
|
||||
*/
|
||||
url?: string;
|
||||
}
|
||||
/**
|
||||
* Generic type for `RuleContext`.
|
||||
*/
|
||||
export interface RuleContextTypeOptions {
|
||||
LangOptions: LanguageOptions;
|
||||
Code: SourceCode;
|
||||
RuleOptions: unknown[];
|
||||
Node: unknown;
|
||||
MessageIds: string;
|
||||
}
|
||||
/**
|
||||
* Represents the context object that is passed to a rule. This object contains
|
||||
* information about the current state of the linting process and is the rule's
|
||||
* view into the outside world.
|
||||
*/
|
||||
export interface RuleContext<Options extends RuleContextTypeOptions = RuleContextTypeOptions> {
|
||||
/**
|
||||
* The current working directory for the session.
|
||||
*/
|
||||
cwd: string;
|
||||
/**
|
||||
* Returns the current working directory for the session.
|
||||
* @deprecated Use `cwd` instead.
|
||||
*/
|
||||
getCwd(): string;
|
||||
/**
|
||||
* The filename of the file being linted.
|
||||
*/
|
||||
filename: string;
|
||||
/**
|
||||
* Returns the filename of the file being linted.
|
||||
* @deprecated Use `filename` instead.
|
||||
*/
|
||||
getFilename(): string;
|
||||
/**
|
||||
* The physical filename of the file being linted.
|
||||
*/
|
||||
physicalFilename: string;
|
||||
/**
|
||||
* Returns the physical filename of the file being linted.
|
||||
* @deprecated Use `physicalFilename` instead.
|
||||
*/
|
||||
getPhysicalFilename(): string;
|
||||
/**
|
||||
* The source code object that the rule is running on.
|
||||
*/
|
||||
sourceCode: Options["Code"];
|
||||
/**
|
||||
* Returns the source code object that the rule is running on.
|
||||
* @deprecated Use `sourceCode` instead.
|
||||
*/
|
||||
getSourceCode(): Options["Code"];
|
||||
/**
|
||||
* Shared settings for the configuration.
|
||||
*/
|
||||
settings: SettingsConfig;
|
||||
/**
|
||||
* Parser-specific options for the configuration.
|
||||
* @deprecated Use `languageOptions.parserOptions` instead.
|
||||
*/
|
||||
parserOptions: Record<string, unknown>;
|
||||
/**
|
||||
* The language options for the configuration.
|
||||
*/
|
||||
languageOptions: Options["LangOptions"];
|
||||
/**
|
||||
* The CommonJS path to the parser used while parsing this file.
|
||||
* @deprecated No longer used.
|
||||
*/
|
||||
parserPath: string | undefined;
|
||||
/**
|
||||
* The rule ID.
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* The rule's configured options.
|
||||
*/
|
||||
options: Options["RuleOptions"];
|
||||
/**
|
||||
* The report function that the rule should use to report problems.
|
||||
* @param violation The violation to report.
|
||||
*/
|
||||
report(violation: ViolationReport<Options["Node"], Options["MessageIds"]>): void;
|
||||
}
|
||||
/**
|
||||
* Manager of text edits for a rule fix.
|
||||
*/
|
||||
export interface RuleTextEditor<EditableSyntaxElement = unknown> {
|
||||
/**
|
||||
* Inserts text after the specified node or token.
|
||||
* @param syntaxElement The node or token to insert after.
|
||||
* @param text The edit to insert after the node or token.
|
||||
*/
|
||||
insertTextAfter(syntaxElement: EditableSyntaxElement, text: string): RuleTextEdit;
|
||||
/**
|
||||
* Inserts text after the specified range.
|
||||
* @param range The range to insert after.
|
||||
* @param text The edit to insert after the range.
|
||||
*/
|
||||
insertTextAfterRange(range: SourceRange, text: string): RuleTextEdit;
|
||||
/**
|
||||
* Inserts text before the specified node or token.
|
||||
* @param syntaxElement A syntax element with location information to insert before.
|
||||
* @param text The edit to insert before the node or token.
|
||||
*/
|
||||
insertTextBefore(syntaxElement: EditableSyntaxElement, text: string): RuleTextEdit;
|
||||
/**
|
||||
* Inserts text before the specified range.
|
||||
* @param range The range to insert before.
|
||||
* @param text The edit to insert before the range.
|
||||
*/
|
||||
insertTextBeforeRange(range: SourceRange, text: string): RuleTextEdit;
|
||||
/**
|
||||
* Removes the specified node or token.
|
||||
* @param syntaxElement A syntax element with location information to remove.
|
||||
* @returns The edit to remove the node or token.
|
||||
*/
|
||||
remove(syntaxElement: EditableSyntaxElement): RuleTextEdit;
|
||||
/**
|
||||
* Removes the specified range.
|
||||
* @param range The range to remove.
|
||||
* @returns The edit to remove the range.
|
||||
*/
|
||||
removeRange(range: SourceRange): RuleTextEdit;
|
||||
/**
|
||||
* Replaces the specified node or token with the given text.
|
||||
* @param syntaxElement A syntax element with location information to replace.
|
||||
* @param text The text to replace the node or token with.
|
||||
* @returns The edit to replace the node or token.
|
||||
*/
|
||||
replaceText(syntaxElement: EditableSyntaxElement, text: string): RuleTextEdit;
|
||||
/**
|
||||
* Replaces the specified range with the given text.
|
||||
* @param range The range to replace.
|
||||
* @param text The text to replace the range with.
|
||||
* @returns The edit to replace the range.
|
||||
*/
|
||||
replaceTextRange(range: SourceRange, text: string): RuleTextEdit;
|
||||
}
|
||||
/**
|
||||
* Represents a fix for a rule violation implemented as a text edit.
|
||||
*/
|
||||
export interface RuleTextEdit {
|
||||
/**
|
||||
* The range to replace.
|
||||
*/
|
||||
range: SourceRange;
|
||||
/**
|
||||
* The text to insert.
|
||||
*/
|
||||
text: string;
|
||||
}
|
||||
/**
|
||||
* Fixes a violation.
|
||||
* @param fixer The text editor to apply the fix.
|
||||
* @returns The fix(es) for the violation.
|
||||
*/
|
||||
type RuleFixer = (fixer: RuleTextEditor) => RuleTextEdit | Iterable<RuleTextEdit> | null;
|
||||
interface ViolationReportBase {
|
||||
/**
|
||||
* The type of node that the violation is for.
|
||||
* @deprecated May be removed in the future.
|
||||
*/
|
||||
nodeType?: string | undefined;
|
||||
/**
|
||||
* The data to insert into the message.
|
||||
*/
|
||||
data?: Record<string, string> | undefined;
|
||||
/**
|
||||
* The fix to be applied for the violation.
|
||||
*/
|
||||
fix?: RuleFixer | null | undefined;
|
||||
/**
|
||||
* An array of suggested fixes for the problem. These fixes may change the
|
||||
* behavior of the code, so they are not applied automatically.
|
||||
*/
|
||||
suggest?: SuggestedEdit[] | null | undefined;
|
||||
}
|
||||
type ViolationMessage<MessageIds = string> = {
|
||||
message: string;
|
||||
} | {
|
||||
messageId: MessageIds;
|
||||
};
|
||||
type ViolationLocation<Node> = {
|
||||
loc: SourceLocation | Position;
|
||||
} | {
|
||||
node: Node;
|
||||
};
|
||||
export type ViolationReport<Node = unknown, MessageIds = string> = ViolationReportBase & ViolationMessage<MessageIds> & ViolationLocation<Node>;
|
||||
interface SuggestedEditBase {
|
||||
/**
|
||||
* The data to insert into the message.
|
||||
*/
|
||||
data?: Record<string, string> | undefined;
|
||||
/**
|
||||
* The fix to be applied for the suggestion.
|
||||
*/
|
||||
fix?: RuleFixer | null | undefined;
|
||||
}
|
||||
type SuggestionMessage = {
|
||||
desc: string;
|
||||
} | {
|
||||
messageId: string;
|
||||
};
|
||||
/**
|
||||
* A suggested edit for a rule violation.
|
||||
*/
|
||||
export type SuggestedEdit = SuggestedEditBase & SuggestionMessage;
|
||||
/**
|
||||
* Generic options for the `RuleDefinition` type.
|
||||
*/
|
||||
export interface RuleDefinitionTypeOptions {
|
||||
LangOptions: LanguageOptions;
|
||||
Code: SourceCode;
|
||||
RuleOptions: unknown[];
|
||||
Visitor: RuleVisitor;
|
||||
Node: unknown;
|
||||
MessageIds: string;
|
||||
ExtRuleDocs: unknown;
|
||||
}
|
||||
/**
|
||||
* The definition of an ESLint rule.
|
||||
*/
|
||||
export interface RuleDefinition<Options extends RuleDefinitionTypeOptions = RuleDefinitionTypeOptions> {
|
||||
/**
|
||||
* The meta information for the rule.
|
||||
*/
|
||||
meta?: RulesMeta<Options["MessageIds"], Options["RuleOptions"], Options["ExtRuleDocs"]>;
|
||||
/**
|
||||
* Creates the visitor that ESLint uses to apply the rule during traversal.
|
||||
* @param context The rule context.
|
||||
* @returns The rule visitor.
|
||||
*/
|
||||
create(context: RuleContext<{
|
||||
LangOptions: Options["LangOptions"];
|
||||
Code: Options["Code"];
|
||||
RuleOptions: Options["RuleOptions"];
|
||||
Node: Options["Node"];
|
||||
MessageIds: Options["MessageIds"];
|
||||
}>): Options["Visitor"];
|
||||
}
|
||||
/**
|
||||
* Defaults for non-language-related `RuleDefinition` options.
|
||||
*/
|
||||
export interface CustomRuleTypeDefinitions {
|
||||
RuleOptions: unknown[];
|
||||
MessageIds: string;
|
||||
ExtRuleDocs: Record<string, unknown>;
|
||||
}
|
||||
/**
|
||||
* A helper type to define language specific specializations of the `RuleDefinition` type.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* type YourRuleDefinition<
|
||||
* Options extends Partial<CustomRuleTypeDefinitions> = {},
|
||||
* > = CustomRuleDefinitionType<
|
||||
* {
|
||||
* LangOptions: YourLanguageOptions;
|
||||
* Code: YourSourceCode;
|
||||
* Visitor: YourRuleVisitor;
|
||||
* Node: YourNode;
|
||||
* },
|
||||
* Options
|
||||
* >;
|
||||
* ```
|
||||
*/
|
||||
export type CustomRuleDefinitionType<LanguageSpecificOptions extends Omit<RuleDefinitionTypeOptions, keyof CustomRuleTypeDefinitions>, Options extends Partial<CustomRuleTypeDefinitions>> = RuleDefinition<LanguageSpecificOptions & Required<Options & Omit<CustomRuleTypeDefinitions, keyof Options>>>;
|
||||
/**
|
||||
* The human readable severity level used in a configuration.
|
||||
*/
|
||||
export type SeverityName = "off" | "warn" | "error";
|
||||
/**
|
||||
* The numeric severity level for a rule.
|
||||
*
|
||||
* - `0` means off.
|
||||
* - `1` means warn.
|
||||
* - `2` means error.
|
||||
*/
|
||||
export type SeverityLevel = 0 | 1 | 2;
|
||||
/**
|
||||
* The severity of a rule in a configuration.
|
||||
*/
|
||||
export type Severity = SeverityName | SeverityLevel;
|
||||
/**
|
||||
* Represents the configuration options for the core linter.
|
||||
*/
|
||||
export interface LinterOptionsConfig {
|
||||
/**
|
||||
* Indicates whether or not inline configuration is evaluated.
|
||||
*/
|
||||
noInlineConfig?: boolean;
|
||||
/**
|
||||
* Indicates what to do when an unused disable directive is found.
|
||||
*/
|
||||
reportUnusedDisableDirectives?: boolean | Severity;
|
||||
/**
|
||||
* A severity value indicating if and how unused inline configs should be
|
||||
* tracked and reported.
|
||||
*/
|
||||
reportUnusedInlineConfigs?: Severity;
|
||||
}
|
||||
/**
|
||||
* The configuration for a rule.
|
||||
*/
|
||||
export type RuleConfig<RuleOptions extends unknown[] = unknown[]> = Severity | [Severity, ...Partial<RuleOptions>];
|
||||
/**
|
||||
* A collection of rules and their configurations.
|
||||
*/
|
||||
export interface RulesConfig {
|
||||
[key: string]: RuleConfig;
|
||||
}
|
||||
/**
|
||||
* A collection of settings.
|
||||
*/
|
||||
export interface SettingsConfig {
|
||||
[key: string]: unknown;
|
||||
}
|
||||
/**
|
||||
* Generic options for the `Language` type.
|
||||
*/
|
||||
export interface LanguageTypeOptions {
|
||||
LangOptions: LanguageOptions;
|
||||
Code: SourceCode;
|
||||
RootNode: unknown;
|
||||
Node: unknown;
|
||||
}
|
||||
/**
|
||||
* Represents a plugin language.
|
||||
*/
|
||||
export interface Language<Options extends LanguageTypeOptions = {
|
||||
LangOptions: LanguageOptions;
|
||||
Code: SourceCode;
|
||||
RootNode: unknown;
|
||||
Node: unknown;
|
||||
}> {
|
||||
/**
|
||||
* Indicates how ESLint should read the file.
|
||||
*/
|
||||
fileType: "text";
|
||||
/**
|
||||
* First line number returned from the parser (text mode only).
|
||||
*/
|
||||
lineStart: 0 | 1;
|
||||
/**
|
||||
* First column number returned from the parser (text mode only).
|
||||
*/
|
||||
columnStart: 0 | 1;
|
||||
/**
|
||||
* The property to read the node type from. Used in selector querying.
|
||||
*/
|
||||
nodeTypeKey: string;
|
||||
/**
|
||||
* The traversal path that tools should take when evaluating the AST
|
||||
*/
|
||||
visitorKeys?: Record<string, string[]>;
|
||||
/**
|
||||
* Default language options. User-defined options are merged with this object.
|
||||
*/
|
||||
defaultLanguageOptions?: LanguageOptions;
|
||||
/**
|
||||
* Validates languageOptions for this language.
|
||||
*/
|
||||
validateLanguageOptions(languageOptions: Options["LangOptions"]): void;
|
||||
/**
|
||||
* Normalizes languageOptions for this language.
|
||||
*/
|
||||
normalizeLanguageOptions?(languageOptions: Options["LangOptions"]): Options["LangOptions"];
|
||||
/**
|
||||
* Helper for esquery that allows languages to match nodes against
|
||||
* class. esquery currently has classes like `function` that will
|
||||
* match all the various function nodes. This method allows languages
|
||||
* to implement similar shorthands.
|
||||
*/
|
||||
matchesSelectorClass?(className: string, node: Options["Node"], ancestry: Options["Node"][]): boolean;
|
||||
/**
|
||||
* Parses the given file input into its component parts. This file should not
|
||||
* throws errors for parsing errors but rather should return any parsing
|
||||
* errors as parse of the ParseResult object.
|
||||
*/
|
||||
parse(file: File, context: LanguageContext<Options["LangOptions"]>): ParseResult<Options["RootNode"]>;
|
||||
/**
|
||||
* Creates SourceCode object that ESLint uses to work with a file.
|
||||
*/
|
||||
createSourceCode(file: File, input: OkParseResult<Options["RootNode"]>, context: LanguageContext<Options["LangOptions"]>): Options["Code"];
|
||||
}
|
||||
/**
|
||||
* Plugin-defined options for the language.
|
||||
*/
|
||||
export type LanguageOptions = Record<string, unknown>;
|
||||
/**
|
||||
* The context object that is passed to the language plugin methods.
|
||||
*/
|
||||
export interface LanguageContext<LangOptions = LanguageOptions> {
|
||||
languageOptions: LangOptions;
|
||||
}
|
||||
/**
|
||||
* Represents a file read by ESLint.
|
||||
*/
|
||||
export interface File {
|
||||
/**
|
||||
* The path that ESLint uses for this file. May be a virtual path
|
||||
* if it was returned by a processor.
|
||||
*/
|
||||
path: string;
|
||||
/**
|
||||
* The path to the file on disk. This always maps directly to a file
|
||||
* regardless of whether it was returned from a processor.
|
||||
*/
|
||||
physicalPath: string;
|
||||
/**
|
||||
* Indicates if the original source contained a byte-order marker.
|
||||
* ESLint strips the BOM from the `body`, but this info is needed
|
||||
* to correctly apply autofixing.
|
||||
*/
|
||||
bom: boolean;
|
||||
/**
|
||||
* The body of the file to parse.
|
||||
*/
|
||||
body: string | Uint8Array;
|
||||
}
|
||||
/**
|
||||
* Represents the successful result of parsing a file.
|
||||
*/
|
||||
export interface OkParseResult<RootNode = unknown> {
|
||||
/**
|
||||
* Indicates if the parse was successful. If true, the parse was successful
|
||||
* and ESLint should continue on to create a SourceCode object and run rules;
|
||||
* if false, ESLint should just report the error(s) without doing anything
|
||||
* else.
|
||||
*/
|
||||
ok: true;
|
||||
/**
|
||||
* The abstract syntax tree created by the parser. (only when ok: true)
|
||||
*/
|
||||
ast: RootNode;
|
||||
/**
|
||||
* Any additional data that the parser wants to provide.
|
||||
*/
|
||||
[key: string]: any;
|
||||
}
|
||||
/**
|
||||
* Represents the unsuccessful result of parsing a file.
|
||||
*/
|
||||
export interface NotOkParseResult {
|
||||
/**
|
||||
* Indicates if the parse was successful. If true, the parse was successful
|
||||
* and ESLint should continue on to create a SourceCode object and run rules;
|
||||
* if false, ESLint should just report the error(s) without doing anything
|
||||
* else.
|
||||
*/
|
||||
ok: false;
|
||||
/**
|
||||
* Any parsing errors, whether fatal or not. (only when ok: false)
|
||||
*/
|
||||
errors: FileError[];
|
||||
/**
|
||||
* Any additional data that the parser wants to provide.
|
||||
*/
|
||||
[key: string]: any;
|
||||
}
|
||||
export type ParseResult<RootNode = unknown> = OkParseResult<RootNode> | NotOkParseResult;
|
||||
/**
|
||||
* Represents inline configuration found in the source code.
|
||||
*/
|
||||
interface InlineConfigElement {
|
||||
/**
|
||||
* The location of the inline config element.
|
||||
*/
|
||||
loc: SourceLocation;
|
||||
/**
|
||||
* The interpreted configuration from the inline config element.
|
||||
*/
|
||||
config: {
|
||||
rules: RulesConfig;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Generic options for the `SourceCodeBase` type.
|
||||
*/
|
||||
export interface SourceCodeBaseTypeOptions {
|
||||
LangOptions: LanguageOptions;
|
||||
RootNode: unknown;
|
||||
SyntaxElementWithLoc: unknown;
|
||||
ConfigNode: unknown;
|
||||
}
|
||||
/**
|
||||
* Represents the basic interface for a source code object.
|
||||
*/
|
||||
interface SourceCodeBase<Options extends SourceCodeBaseTypeOptions = {
|
||||
LangOptions: LanguageOptions;
|
||||
RootNode: unknown;
|
||||
SyntaxElementWithLoc: unknown;
|
||||
ConfigNode: unknown;
|
||||
}> {
|
||||
/**
|
||||
* Root of the AST.
|
||||
*/
|
||||
ast: Options["RootNode"];
|
||||
/**
|
||||
* The traversal path that tools should take when evaluating the AST.
|
||||
* When present, this overrides the `visitorKeys` on the language for
|
||||
* just this source code object.
|
||||
*/
|
||||
visitorKeys?: Record<string, string[]>;
|
||||
/**
|
||||
* Retrieves the equivalent of `loc` for a given node or token.
|
||||
* @param syntaxElement The node or token to get the location for.
|
||||
* @returns The location of the node or token.
|
||||
*/
|
||||
getLoc(syntaxElement: Options["SyntaxElementWithLoc"]): SourceLocation;
|
||||
/**
|
||||
* Retrieves the equivalent of `range` for a given node or token.
|
||||
* @param syntaxElement The node or token to get the range for.
|
||||
* @returns The range of the node or token.
|
||||
*/
|
||||
getRange(syntaxElement: Options["SyntaxElementWithLoc"]): SourceRange;
|
||||
/**
|
||||
* Traversal of AST.
|
||||
*/
|
||||
traverse(): Iterable<TraversalStep>;
|
||||
/**
|
||||
* Applies language options passed in from the ESLint core.
|
||||
*/
|
||||
applyLanguageOptions?(languageOptions: Options["LangOptions"]): void;
|
||||
/**
|
||||
* Return all of the inline areas where ESLint should be disabled/enabled
|
||||
* along with any problems found in evaluating the directives.
|
||||
*/
|
||||
getDisableDirectives?(): {
|
||||
directives: Directive[];
|
||||
problems: FileProblem[];
|
||||
};
|
||||
/**
|
||||
* Returns an array of all inline configuration nodes found in the
|
||||
* source code.
|
||||
*/
|
||||
getInlineConfigNodes?(): Options["ConfigNode"][];
|
||||
/**
|
||||
* Applies configuration found inside of the source code. This method is only
|
||||
* called when ESLint is running with inline configuration allowed.
|
||||
*/
|
||||
applyInlineConfig?(): {
|
||||
configs: InlineConfigElement[];
|
||||
problems: FileProblem[];
|
||||
};
|
||||
/**
|
||||
* Called by ESLint core to indicate that it has finished providing
|
||||
* information. We now add in all the missing variables and ensure that
|
||||
* state-changing methods cannot be called by rules.
|
||||
* @returns {void}
|
||||
*/
|
||||
finalize?(): void;
|
||||
}
|
||||
/**
|
||||
* Represents the source of a text file being linted.
|
||||
*/
|
||||
export interface TextSourceCode<Options extends SourceCodeBaseTypeOptions = {
|
||||
LangOptions: LanguageOptions;
|
||||
RootNode: unknown;
|
||||
SyntaxElementWithLoc: unknown;
|
||||
ConfigNode: unknown;
|
||||
}> extends SourceCodeBase<Options> {
|
||||
/**
|
||||
* The body of the file that you'd like rule developers to access.
|
||||
*/
|
||||
text: string;
|
||||
}
|
||||
/**
|
||||
* Represents the source of a binary file being linted.
|
||||
*/
|
||||
export interface BinarySourceCode<Options extends SourceCodeBaseTypeOptions = {
|
||||
LangOptions: LanguageOptions;
|
||||
RootNode: unknown;
|
||||
SyntaxElementWithLoc: unknown;
|
||||
ConfigNode: unknown;
|
||||
}> extends SourceCodeBase<Options> {
|
||||
/**
|
||||
* The body of the file that you'd like rule developers to access.
|
||||
*/
|
||||
body: Uint8Array;
|
||||
}
|
||||
export type SourceCode<Options extends SourceCodeBaseTypeOptions = {
|
||||
LangOptions: LanguageOptions;
|
||||
RootNode: unknown;
|
||||
SyntaxElementWithLoc: unknown;
|
||||
ConfigNode: unknown;
|
||||
}> = TextSourceCode<Options> | BinarySourceCode<Options>;
|
||||
/**
|
||||
* Represents a traversal step visiting the AST.
|
||||
*/
|
||||
export interface VisitTraversalStep {
|
||||
kind: 1;
|
||||
target: unknown;
|
||||
phase: 1 | 2;
|
||||
args: unknown[];
|
||||
}
|
||||
/**
|
||||
* Represents a traversal step calling a function.
|
||||
*/
|
||||
export interface CallTraversalStep {
|
||||
kind: 2;
|
||||
target: string;
|
||||
phase?: string;
|
||||
args: unknown[];
|
||||
}
|
||||
export type TraversalStep = VisitTraversalStep | CallTraversalStep;
|
||||
/**
|
||||
* The type of disable directive. This determines how ESLint will disable rules.
|
||||
*/
|
||||
export type DirectiveType = "disable" | "enable" | "disable-line" | "disable-next-line";
|
||||
/**
|
||||
* Represents a disable directive.
|
||||
*/
|
||||
export interface Directive {
|
||||
/**
|
||||
* The type of directive.
|
||||
*/
|
||||
type: DirectiveType;
|
||||
/**
|
||||
* The node of the directive. May be in the AST or a comment/token.
|
||||
*/
|
||||
node: unknown;
|
||||
/**
|
||||
* The value of the directive.
|
||||
*/
|
||||
value: string;
|
||||
/**
|
||||
* The justification for the directive.
|
||||
*/
|
||||
justification?: string;
|
||||
}
|
||||
export {};
|
849
node_modules/@eslint/core/dist/esm/types.d.ts
generated
vendored
849
node_modules/@eslint/core/dist/esm/types.d.ts
generated
vendored
|
@ -1,849 +0,0 @@
|
|||
/**
|
||||
* @fileoverview Shared types for ESLint Core.
|
||||
*/
|
||||
import type { JSONSchema4 } from "json-schema";
|
||||
/**
|
||||
* Represents an error inside of a file.
|
||||
*/
|
||||
export interface FileError {
|
||||
message: string;
|
||||
line: number;
|
||||
column: number;
|
||||
endLine?: number;
|
||||
endColumn?: number;
|
||||
}
|
||||
/**
|
||||
* Represents a problem found in a file.
|
||||
*/
|
||||
export interface FileProblem {
|
||||
ruleId: string | null;
|
||||
message: string;
|
||||
loc: SourceLocation;
|
||||
}
|
||||
/**
|
||||
* Represents the start and end coordinates of a node inside the source.
|
||||
*/
|
||||
export interface SourceLocation {
|
||||
start: Position;
|
||||
end: Position;
|
||||
}
|
||||
/**
|
||||
* Represents the start and end coordinates of a node inside the source with an offset.
|
||||
*/
|
||||
export interface SourceLocationWithOffset {
|
||||
start: PositionWithOffset;
|
||||
end: PositionWithOffset;
|
||||
}
|
||||
/**
|
||||
* Represents a location coordinate inside the source. ESLint-style formats
|
||||
* have just `line` and `column` while others may have `offset` as well.
|
||||
*/
|
||||
export interface Position {
|
||||
line: number;
|
||||
column: number;
|
||||
}
|
||||
/**
|
||||
* Represents a location coordinate inside the source with an offset.
|
||||
*/
|
||||
export interface PositionWithOffset extends Position {
|
||||
offset: number;
|
||||
}
|
||||
/**
|
||||
* Represents a range of characters in the source.
|
||||
*/
|
||||
export type SourceRange = [number, number];
|
||||
/**
|
||||
* What the rule is responsible for finding:
|
||||
* - `problem` means the rule has noticed a potential error.
|
||||
* - `suggestion` means the rule suggests an alternate or better approach.
|
||||
* - `layout` means the rule is looking at spacing, indentation, etc.
|
||||
*/
|
||||
export type RuleType = "problem" | "suggestion" | "layout";
|
||||
/**
|
||||
* The type of fix the rule can provide:
|
||||
* - `code` means the rule can fix syntax.
|
||||
* - `whitespace` means the rule can fix spacing and indentation.
|
||||
*/
|
||||
export type RuleFixType = "code" | "whitespace";
|
||||
/**
|
||||
* An object containing visitor information for a rule. Each method is either the
|
||||
* name of a node type or a selector, or is a method that will be called at specific
|
||||
* times during the traversal.
|
||||
*/
|
||||
export type RuleVisitor = Record<string, ((...args: any[]) => void) | undefined>;
|
||||
/**
|
||||
* Rule meta information used for documentation.
|
||||
*/
|
||||
export interface RulesMetaDocs {
|
||||
/**
|
||||
* A short description of the rule.
|
||||
*/
|
||||
description?: string | undefined;
|
||||
/**
|
||||
* The URL to the documentation for the rule.
|
||||
*/
|
||||
url?: string | undefined;
|
||||
/**
|
||||
* The category the rule falls under.
|
||||
* @deprecated No longer used.
|
||||
*/
|
||||
category?: string | undefined;
|
||||
/**
|
||||
* Indicates if the rule is generally recommended for all users.
|
||||
*
|
||||
* Note - this will always be a boolean for core rules, but may be used in any way by plugins.
|
||||
*/
|
||||
recommended?: unknown;
|
||||
/**
|
||||
* Indicates if the rule is frozen (no longer accepting feature requests).
|
||||
*/
|
||||
frozen?: boolean | undefined;
|
||||
}
|
||||
/**
|
||||
* Meta information about a rule.
|
||||
*/
|
||||
export interface RulesMeta<MessageIds extends string = string, RuleOptions = unknown[], ExtRuleDocs = unknown> {
|
||||
/**
|
||||
* Properties that are used when documenting the rule.
|
||||
*/
|
||||
docs?: (RulesMetaDocs & ExtRuleDocs) | undefined;
|
||||
/**
|
||||
* The type of rule.
|
||||
*/
|
||||
type?: RuleType | undefined;
|
||||
/**
|
||||
* The schema for the rule options. Required if the rule has options.
|
||||
*/
|
||||
schema?: JSONSchema4 | JSONSchema4[] | false | undefined;
|
||||
/**
|
||||
* Any default options to be recursively merged on top of any user-provided options.
|
||||
**/
|
||||
defaultOptions?: RuleOptions;
|
||||
/**
|
||||
* The messages that the rule can report.
|
||||
*/
|
||||
messages?: Record<MessageIds, string>;
|
||||
/**
|
||||
* Indicates whether the rule has been deprecated or provides additional metadata about the deprecation. Omit if not deprecated.
|
||||
*/
|
||||
deprecated?: boolean | DeprecatedInfo | undefined;
|
||||
/**
|
||||
* @deprecated Use deprecated.replacedBy instead.
|
||||
* The name of the rule(s) this rule was replaced by, if it was deprecated.
|
||||
*/
|
||||
replacedBy?: readonly string[] | undefined;
|
||||
/**
|
||||
* Indicates if the rule is fixable, and if so, what type of fix it provides.
|
||||
*/
|
||||
fixable?: RuleFixType | undefined;
|
||||
/**
|
||||
* Indicates if the rule may provide suggestions.
|
||||
*/
|
||||
hasSuggestions?: boolean | undefined;
|
||||
/**
|
||||
* The language the rule is intended to lint.
|
||||
*/
|
||||
language?: string;
|
||||
/**
|
||||
* The dialects of `language` that the rule is intended to lint.
|
||||
*/
|
||||
dialects?: string[];
|
||||
}
|
||||
/**
|
||||
* Provides additional metadata about a deprecation.
|
||||
*/
|
||||
export interface DeprecatedInfo {
|
||||
/**
|
||||
* General message presented to the user, e.g. for the key rule why the rule
|
||||
* is deprecated or for info how to replace the rule.
|
||||
*/
|
||||
message?: string;
|
||||
/**
|
||||
* URL to more information about this deprecation in general.
|
||||
*/
|
||||
url?: string;
|
||||
/**
|
||||
* An empty array explicitly states that there is no replacement.
|
||||
*/
|
||||
replacedBy?: ReplacedByInfo[];
|
||||
/**
|
||||
* The package version since when the rule is deprecated (should use full
|
||||
* semver without a leading "v").
|
||||
*/
|
||||
deprecatedSince?: string;
|
||||
/**
|
||||
* The estimated version when the rule is removed (probably the next major
|
||||
* version). null means the rule is "frozen" (will be available but will not
|
||||
* be changed).
|
||||
*/
|
||||
availableUntil?: string | null;
|
||||
}
|
||||
/**
|
||||
* Provides metadata about a replacement
|
||||
*/
|
||||
export interface ReplacedByInfo {
|
||||
/**
|
||||
* General message presented to the user, e.g. how to replace the rule
|
||||
*/
|
||||
message?: string;
|
||||
/**
|
||||
* URL to more information about this replacement in general
|
||||
*/
|
||||
url?: string;
|
||||
/**
|
||||
* Name should be "eslint" if the replacement is an ESLint core rule. Omit
|
||||
* the property if the replacement is in the same plugin.
|
||||
*/
|
||||
plugin?: ExternalSpecifier;
|
||||
/**
|
||||
* Name and documentation of the replacement rule
|
||||
*/
|
||||
rule?: ExternalSpecifier;
|
||||
}
|
||||
/**
|
||||
* Specifies the name and url of an external resource. At least one property
|
||||
* should be set.
|
||||
*/
|
||||
export interface ExternalSpecifier {
|
||||
/**
|
||||
* Name of the referenced plugin / rule.
|
||||
*/
|
||||
name?: string;
|
||||
/**
|
||||
* URL pointing to documentation for the plugin / rule.
|
||||
*/
|
||||
url?: string;
|
||||
}
|
||||
/**
|
||||
* Generic type for `RuleContext`.
|
||||
*/
|
||||
export interface RuleContextTypeOptions {
|
||||
LangOptions: LanguageOptions;
|
||||
Code: SourceCode;
|
||||
RuleOptions: unknown[];
|
||||
Node: unknown;
|
||||
MessageIds: string;
|
||||
}
|
||||
/**
|
||||
* Represents the context object that is passed to a rule. This object contains
|
||||
* information about the current state of the linting process and is the rule's
|
||||
* view into the outside world.
|
||||
*/
|
||||
export interface RuleContext<Options extends RuleContextTypeOptions = RuleContextTypeOptions> {
|
||||
/**
|
||||
* The current working directory for the session.
|
||||
*/
|
||||
cwd: string;
|
||||
/**
|
||||
* Returns the current working directory for the session.
|
||||
* @deprecated Use `cwd` instead.
|
||||
*/
|
||||
getCwd(): string;
|
||||
/**
|
||||
* The filename of the file being linted.
|
||||
*/
|
||||
filename: string;
|
||||
/**
|
||||
* Returns the filename of the file being linted.
|
||||
* @deprecated Use `filename` instead.
|
||||
*/
|
||||
getFilename(): string;
|
||||
/**
|
||||
* The physical filename of the file being linted.
|
||||
*/
|
||||
physicalFilename: string;
|
||||
/**
|
||||
* Returns the physical filename of the file being linted.
|
||||
* @deprecated Use `physicalFilename` instead.
|
||||
*/
|
||||
getPhysicalFilename(): string;
|
||||
/**
|
||||
* The source code object that the rule is running on.
|
||||
*/
|
||||
sourceCode: Options["Code"];
|
||||
/**
|
||||
* Returns the source code object that the rule is running on.
|
||||
* @deprecated Use `sourceCode` instead.
|
||||
*/
|
||||
getSourceCode(): Options["Code"];
|
||||
/**
|
||||
* Shared settings for the configuration.
|
||||
*/
|
||||
settings: SettingsConfig;
|
||||
/**
|
||||
* Parser-specific options for the configuration.
|
||||
* @deprecated Use `languageOptions.parserOptions` instead.
|
||||
*/
|
||||
parserOptions: Record<string, unknown>;
|
||||
/**
|
||||
* The language options for the configuration.
|
||||
*/
|
||||
languageOptions: Options["LangOptions"];
|
||||
/**
|
||||
* The CommonJS path to the parser used while parsing this file.
|
||||
* @deprecated No longer used.
|
||||
*/
|
||||
parserPath: string | undefined;
|
||||
/**
|
||||
* The rule ID.
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* The rule's configured options.
|
||||
*/
|
||||
options: Options["RuleOptions"];
|
||||
/**
|
||||
* The report function that the rule should use to report problems.
|
||||
* @param violation The violation to report.
|
||||
*/
|
||||
report(violation: ViolationReport<Options["Node"], Options["MessageIds"]>): void;
|
||||
}
|
||||
/**
|
||||
* Manager of text edits for a rule fix.
|
||||
*/
|
||||
export interface RuleTextEditor<EditableSyntaxElement = unknown> {
|
||||
/**
|
||||
* Inserts text after the specified node or token.
|
||||
* @param syntaxElement The node or token to insert after.
|
||||
* @param text The edit to insert after the node or token.
|
||||
*/
|
||||
insertTextAfter(syntaxElement: EditableSyntaxElement, text: string): RuleTextEdit;
|
||||
/**
|
||||
* Inserts text after the specified range.
|
||||
* @param range The range to insert after.
|
||||
* @param text The edit to insert after the range.
|
||||
*/
|
||||
insertTextAfterRange(range: SourceRange, text: string): RuleTextEdit;
|
||||
/**
|
||||
* Inserts text before the specified node or token.
|
||||
* @param syntaxElement A syntax element with location information to insert before.
|
||||
* @param text The edit to insert before the node or token.
|
||||
*/
|
||||
insertTextBefore(syntaxElement: EditableSyntaxElement, text: string): RuleTextEdit;
|
||||
/**
|
||||
* Inserts text before the specified range.
|
||||
* @param range The range to insert before.
|
||||
* @param text The edit to insert before the range.
|
||||
*/
|
||||
insertTextBeforeRange(range: SourceRange, text: string): RuleTextEdit;
|
||||
/**
|
||||
* Removes the specified node or token.
|
||||
* @param syntaxElement A syntax element with location information to remove.
|
||||
* @returns The edit to remove the node or token.
|
||||
*/
|
||||
remove(syntaxElement: EditableSyntaxElement): RuleTextEdit;
|
||||
/**
|
||||
* Removes the specified range.
|
||||
* @param range The range to remove.
|
||||
* @returns The edit to remove the range.
|
||||
*/
|
||||
removeRange(range: SourceRange): RuleTextEdit;
|
||||
/**
|
||||
* Replaces the specified node or token with the given text.
|
||||
* @param syntaxElement A syntax element with location information to replace.
|
||||
* @param text The text to replace the node or token with.
|
||||
* @returns The edit to replace the node or token.
|
||||
*/
|
||||
replaceText(syntaxElement: EditableSyntaxElement, text: string): RuleTextEdit;
|
||||
/**
|
||||
* Replaces the specified range with the given text.
|
||||
* @param range The range to replace.
|
||||
* @param text The text to replace the range with.
|
||||
* @returns The edit to replace the range.
|
||||
*/
|
||||
replaceTextRange(range: SourceRange, text: string): RuleTextEdit;
|
||||
}
|
||||
/**
|
||||
* Represents a fix for a rule violation implemented as a text edit.
|
||||
*/
|
||||
export interface RuleTextEdit {
|
||||
/**
|
||||
* The range to replace.
|
||||
*/
|
||||
range: SourceRange;
|
||||
/**
|
||||
* The text to insert.
|
||||
*/
|
||||
text: string;
|
||||
}
|
||||
/**
|
||||
* Fixes a violation.
|
||||
* @param fixer The text editor to apply the fix.
|
||||
* @returns The fix(es) for the violation.
|
||||
*/
|
||||
type RuleFixer = (fixer: RuleTextEditor) => RuleTextEdit | Iterable<RuleTextEdit> | null;
|
||||
interface ViolationReportBase {
|
||||
/**
|
||||
* The type of node that the violation is for.
|
||||
* @deprecated May be removed in the future.
|
||||
*/
|
||||
nodeType?: string | undefined;
|
||||
/**
|
||||
* The data to insert into the message.
|
||||
*/
|
||||
data?: Record<string, string> | undefined;
|
||||
/**
|
||||
* The fix to be applied for the violation.
|
||||
*/
|
||||
fix?: RuleFixer | null | undefined;
|
||||
/**
|
||||
* An array of suggested fixes for the problem. These fixes may change the
|
||||
* behavior of the code, so they are not applied automatically.
|
||||
*/
|
||||
suggest?: SuggestedEdit[] | null | undefined;
|
||||
}
|
||||
type ViolationMessage<MessageIds = string> = {
|
||||
message: string;
|
||||
} | {
|
||||
messageId: MessageIds;
|
||||
};
|
||||
type ViolationLocation<Node> = {
|
||||
loc: SourceLocation | Position;
|
||||
} | {
|
||||
node: Node;
|
||||
};
|
||||
export type ViolationReport<Node = unknown, MessageIds = string> = ViolationReportBase & ViolationMessage<MessageIds> & ViolationLocation<Node>;
|
||||
interface SuggestedEditBase {
|
||||
/**
|
||||
* The data to insert into the message.
|
||||
*/
|
||||
data?: Record<string, string> | undefined;
|
||||
/**
|
||||
* The fix to be applied for the suggestion.
|
||||
*/
|
||||
fix?: RuleFixer | null | undefined;
|
||||
}
|
||||
type SuggestionMessage = {
|
||||
desc: string;
|
||||
} | {
|
||||
messageId: string;
|
||||
};
|
||||
/**
|
||||
* A suggested edit for a rule violation.
|
||||
*/
|
||||
export type SuggestedEdit = SuggestedEditBase & SuggestionMessage;
|
||||
/**
|
||||
* Generic options for the `RuleDefinition` type.
|
||||
*/
|
||||
export interface RuleDefinitionTypeOptions {
|
||||
LangOptions: LanguageOptions;
|
||||
Code: SourceCode;
|
||||
RuleOptions: unknown[];
|
||||
Visitor: RuleVisitor;
|
||||
Node: unknown;
|
||||
MessageIds: string;
|
||||
ExtRuleDocs: unknown;
|
||||
}
|
||||
/**
|
||||
* The definition of an ESLint rule.
|
||||
*/
|
||||
export interface RuleDefinition<Options extends RuleDefinitionTypeOptions = RuleDefinitionTypeOptions> {
|
||||
/**
|
||||
* The meta information for the rule.
|
||||
*/
|
||||
meta?: RulesMeta<Options["MessageIds"], Options["RuleOptions"], Options["ExtRuleDocs"]>;
|
||||
/**
|
||||
* Creates the visitor that ESLint uses to apply the rule during traversal.
|
||||
* @param context The rule context.
|
||||
* @returns The rule visitor.
|
||||
*/
|
||||
create(context: RuleContext<{
|
||||
LangOptions: Options["LangOptions"];
|
||||
Code: Options["Code"];
|
||||
RuleOptions: Options["RuleOptions"];
|
||||
Node: Options["Node"];
|
||||
MessageIds: Options["MessageIds"];
|
||||
}>): Options["Visitor"];
|
||||
}
|
||||
/**
|
||||
* Defaults for non-language-related `RuleDefinition` options.
|
||||
*/
|
||||
export interface CustomRuleTypeDefinitions {
|
||||
RuleOptions: unknown[];
|
||||
MessageIds: string;
|
||||
ExtRuleDocs: Record<string, unknown>;
|
||||
}
|
||||
/**
|
||||
* A helper type to define language specific specializations of the `RuleDefinition` type.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* type YourRuleDefinition<
|
||||
* Options extends Partial<CustomRuleTypeDefinitions> = {},
|
||||
* > = CustomRuleDefinitionType<
|
||||
* {
|
||||
* LangOptions: YourLanguageOptions;
|
||||
* Code: YourSourceCode;
|
||||
* Visitor: YourRuleVisitor;
|
||||
* Node: YourNode;
|
||||
* },
|
||||
* Options
|
||||
* >;
|
||||
* ```
|
||||
*/
|
||||
export type CustomRuleDefinitionType<LanguageSpecificOptions extends Omit<RuleDefinitionTypeOptions, keyof CustomRuleTypeDefinitions>, Options extends Partial<CustomRuleTypeDefinitions>> = RuleDefinition<LanguageSpecificOptions & Required<Options & Omit<CustomRuleTypeDefinitions, keyof Options>>>;
|
||||
/**
|
||||
* The human readable severity level used in a configuration.
|
||||
*/
|
||||
export type SeverityName = "off" | "warn" | "error";
|
||||
/**
|
||||
* The numeric severity level for a rule.
|
||||
*
|
||||
* - `0` means off.
|
||||
* - `1` means warn.
|
||||
* - `2` means error.
|
||||
*/
|
||||
export type SeverityLevel = 0 | 1 | 2;
|
||||
/**
|
||||
* The severity of a rule in a configuration.
|
||||
*/
|
||||
export type Severity = SeverityName | SeverityLevel;
|
||||
/**
|
||||
* Represents the configuration options for the core linter.
|
||||
*/
|
||||
export interface LinterOptionsConfig {
|
||||
/**
|
||||
* Indicates whether or not inline configuration is evaluated.
|
||||
*/
|
||||
noInlineConfig?: boolean;
|
||||
/**
|
||||
* Indicates what to do when an unused disable directive is found.
|
||||
*/
|
||||
reportUnusedDisableDirectives?: boolean | Severity;
|
||||
/**
|
||||
* A severity value indicating if and how unused inline configs should be
|
||||
* tracked and reported.
|
||||
*/
|
||||
reportUnusedInlineConfigs?: Severity;
|
||||
}
|
||||
/**
|
||||
* The configuration for a rule.
|
||||
*/
|
||||
export type RuleConfig<RuleOptions extends unknown[] = unknown[]> = Severity | [Severity, ...Partial<RuleOptions>];
|
||||
/**
|
||||
* A collection of rules and their configurations.
|
||||
*/
|
||||
export interface RulesConfig {
|
||||
[key: string]: RuleConfig;
|
||||
}
|
||||
/**
|
||||
* A collection of settings.
|
||||
*/
|
||||
export interface SettingsConfig {
|
||||
[key: string]: unknown;
|
||||
}
|
||||
/**
|
||||
* Generic options for the `Language` type.
|
||||
*/
|
||||
export interface LanguageTypeOptions {
|
||||
LangOptions: LanguageOptions;
|
||||
Code: SourceCode;
|
||||
RootNode: unknown;
|
||||
Node: unknown;
|
||||
}
|
||||
/**
|
||||
* Represents a plugin language.
|
||||
*/
|
||||
export interface Language<Options extends LanguageTypeOptions = {
|
||||
LangOptions: LanguageOptions;
|
||||
Code: SourceCode;
|
||||
RootNode: unknown;
|
||||
Node: unknown;
|
||||
}> {
|
||||
/**
|
||||
* Indicates how ESLint should read the file.
|
||||
*/
|
||||
fileType: "text";
|
||||
/**
|
||||
* First line number returned from the parser (text mode only).
|
||||
*/
|
||||
lineStart: 0 | 1;
|
||||
/**
|
||||
* First column number returned from the parser (text mode only).
|
||||
*/
|
||||
columnStart: 0 | 1;
|
||||
/**
|
||||
* The property to read the node type from. Used in selector querying.
|
||||
*/
|
||||
nodeTypeKey: string;
|
||||
/**
|
||||
* The traversal path that tools should take when evaluating the AST
|
||||
*/
|
||||
visitorKeys?: Record<string, string[]>;
|
||||
/**
|
||||
* Default language options. User-defined options are merged with this object.
|
||||
*/
|
||||
defaultLanguageOptions?: LanguageOptions;
|
||||
/**
|
||||
* Validates languageOptions for this language.
|
||||
*/
|
||||
validateLanguageOptions(languageOptions: Options["LangOptions"]): void;
|
||||
/**
|
||||
* Normalizes languageOptions for this language.
|
||||
*/
|
||||
normalizeLanguageOptions?(languageOptions: Options["LangOptions"]): Options["LangOptions"];
|
||||
/**
|
||||
* Helper for esquery that allows languages to match nodes against
|
||||
* class. esquery currently has classes like `function` that will
|
||||
* match all the various function nodes. This method allows languages
|
||||
* to implement similar shorthands.
|
||||
*/
|
||||
matchesSelectorClass?(className: string, node: Options["Node"], ancestry: Options["Node"][]): boolean;
|
||||
/**
|
||||
* Parses the given file input into its component parts. This file should not
|
||||
* throws errors for parsing errors but rather should return any parsing
|
||||
* errors as parse of the ParseResult object.
|
||||
*/
|
||||
parse(file: File, context: LanguageContext<Options["LangOptions"]>): ParseResult<Options["RootNode"]>;
|
||||
/**
|
||||
* Creates SourceCode object that ESLint uses to work with a file.
|
||||
*/
|
||||
createSourceCode(file: File, input: OkParseResult<Options["RootNode"]>, context: LanguageContext<Options["LangOptions"]>): Options["Code"];
|
||||
}
|
||||
/**
|
||||
* Plugin-defined options for the language.
|
||||
*/
|
||||
export type LanguageOptions = Record<string, unknown>;
|
||||
/**
|
||||
* The context object that is passed to the language plugin methods.
|
||||
*/
|
||||
export interface LanguageContext<LangOptions = LanguageOptions> {
|
||||
languageOptions: LangOptions;
|
||||
}
|
||||
/**
|
||||
* Represents a file read by ESLint.
|
||||
*/
|
||||
export interface File {
|
||||
/**
|
||||
* The path that ESLint uses for this file. May be a virtual path
|
||||
* if it was returned by a processor.
|
||||
*/
|
||||
path: string;
|
||||
/**
|
||||
* The path to the file on disk. This always maps directly to a file
|
||||
* regardless of whether it was returned from a processor.
|
||||
*/
|
||||
physicalPath: string;
|
||||
/**
|
||||
* Indicates if the original source contained a byte-order marker.
|
||||
* ESLint strips the BOM from the `body`, but this info is needed
|
||||
* to correctly apply autofixing.
|
||||
*/
|
||||
bom: boolean;
|
||||
/**
|
||||
* The body of the file to parse.
|
||||
*/
|
||||
body: string | Uint8Array;
|
||||
}
|
||||
/**
|
||||
* Represents the successful result of parsing a file.
|
||||
*/
|
||||
export interface OkParseResult<RootNode = unknown> {
|
||||
/**
|
||||
* Indicates if the parse was successful. If true, the parse was successful
|
||||
* and ESLint should continue on to create a SourceCode object and run rules;
|
||||
* if false, ESLint should just report the error(s) without doing anything
|
||||
* else.
|
||||
*/
|
||||
ok: true;
|
||||
/**
|
||||
* The abstract syntax tree created by the parser. (only when ok: true)
|
||||
*/
|
||||
ast: RootNode;
|
||||
/**
|
||||
* Any additional data that the parser wants to provide.
|
||||
*/
|
||||
[key: string]: any;
|
||||
}
|
||||
/**
|
||||
* Represents the unsuccessful result of parsing a file.
|
||||
*/
|
||||
export interface NotOkParseResult {
|
||||
/**
|
||||
* Indicates if the parse was successful. If true, the parse was successful
|
||||
* and ESLint should continue on to create a SourceCode object and run rules;
|
||||
* if false, ESLint should just report the error(s) without doing anything
|
||||
* else.
|
||||
*/
|
||||
ok: false;
|
||||
/**
|
||||
* Any parsing errors, whether fatal or not. (only when ok: false)
|
||||
*/
|
||||
errors: FileError[];
|
||||
/**
|
||||
* Any additional data that the parser wants to provide.
|
||||
*/
|
||||
[key: string]: any;
|
||||
}
|
||||
export type ParseResult<RootNode = unknown> = OkParseResult<RootNode> | NotOkParseResult;
|
||||
/**
|
||||
* Represents inline configuration found in the source code.
|
||||
*/
|
||||
interface InlineConfigElement {
|
||||
/**
|
||||
* The location of the inline config element.
|
||||
*/
|
||||
loc: SourceLocation;
|
||||
/**
|
||||
* The interpreted configuration from the inline config element.
|
||||
*/
|
||||
config: {
|
||||
rules: RulesConfig;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Generic options for the `SourceCodeBase` type.
|
||||
*/
|
||||
export interface SourceCodeBaseTypeOptions {
|
||||
LangOptions: LanguageOptions;
|
||||
RootNode: unknown;
|
||||
SyntaxElementWithLoc: unknown;
|
||||
ConfigNode: unknown;
|
||||
}
|
||||
/**
|
||||
* Represents the basic interface for a source code object.
|
||||
*/
|
||||
interface SourceCodeBase<Options extends SourceCodeBaseTypeOptions = {
|
||||
LangOptions: LanguageOptions;
|
||||
RootNode: unknown;
|
||||
SyntaxElementWithLoc: unknown;
|
||||
ConfigNode: unknown;
|
||||
}> {
|
||||
/**
|
||||
* Root of the AST.
|
||||
*/
|
||||
ast: Options["RootNode"];
|
||||
/**
|
||||
* The traversal path that tools should take when evaluating the AST.
|
||||
* When present, this overrides the `visitorKeys` on the language for
|
||||
* just this source code object.
|
||||
*/
|
||||
visitorKeys?: Record<string, string[]>;
|
||||
/**
|
||||
* Retrieves the equivalent of `loc` for a given node or token.
|
||||
* @param syntaxElement The node or token to get the location for.
|
||||
* @returns The location of the node or token.
|
||||
*/
|
||||
getLoc(syntaxElement: Options["SyntaxElementWithLoc"]): SourceLocation;
|
||||
/**
|
||||
* Retrieves the equivalent of `range` for a given node or token.
|
||||
* @param syntaxElement The node or token to get the range for.
|
||||
* @returns The range of the node or token.
|
||||
*/
|
||||
getRange(syntaxElement: Options["SyntaxElementWithLoc"]): SourceRange;
|
||||
/**
|
||||
* Traversal of AST.
|
||||
*/
|
||||
traverse(): Iterable<TraversalStep>;
|
||||
/**
|
||||
* Applies language options passed in from the ESLint core.
|
||||
*/
|
||||
applyLanguageOptions?(languageOptions: Options["LangOptions"]): void;
|
||||
/**
|
||||
* Return all of the inline areas where ESLint should be disabled/enabled
|
||||
* along with any problems found in evaluating the directives.
|
||||
*/
|
||||
getDisableDirectives?(): {
|
||||
directives: Directive[];
|
||||
problems: FileProblem[];
|
||||
};
|
||||
/**
|
||||
* Returns an array of all inline configuration nodes found in the
|
||||
* source code.
|
||||
*/
|
||||
getInlineConfigNodes?(): Options["ConfigNode"][];
|
||||
/**
|
||||
* Applies configuration found inside of the source code. This method is only
|
||||
* called when ESLint is running with inline configuration allowed.
|
||||
*/
|
||||
applyInlineConfig?(): {
|
||||
configs: InlineConfigElement[];
|
||||
problems: FileProblem[];
|
||||
};
|
||||
/**
|
||||
* Called by ESLint core to indicate that it has finished providing
|
||||
* information. We now add in all the missing variables and ensure that
|
||||
* state-changing methods cannot be called by rules.
|
||||
* @returns {void}
|
||||
*/
|
||||
finalize?(): void;
|
||||
}
|
||||
/**
|
||||
* Represents the source of a text file being linted.
|
||||
*/
|
||||
export interface TextSourceCode<Options extends SourceCodeBaseTypeOptions = {
|
||||
LangOptions: LanguageOptions;
|
||||
RootNode: unknown;
|
||||
SyntaxElementWithLoc: unknown;
|
||||
ConfigNode: unknown;
|
||||
}> extends SourceCodeBase<Options> {
|
||||
/**
|
||||
* The body of the file that you'd like rule developers to access.
|
||||
*/
|
||||
text: string;
|
||||
}
|
||||
/**
|
||||
* Represents the source of a binary file being linted.
|
||||
*/
|
||||
export interface BinarySourceCode<Options extends SourceCodeBaseTypeOptions = {
|
||||
LangOptions: LanguageOptions;
|
||||
RootNode: unknown;
|
||||
SyntaxElementWithLoc: unknown;
|
||||
ConfigNode: unknown;
|
||||
}> extends SourceCodeBase<Options> {
|
||||
/**
|
||||
* The body of the file that you'd like rule developers to access.
|
||||
*/
|
||||
body: Uint8Array;
|
||||
}
|
||||
export type SourceCode<Options extends SourceCodeBaseTypeOptions = {
|
||||
LangOptions: LanguageOptions;
|
||||
RootNode: unknown;
|
||||
SyntaxElementWithLoc: unknown;
|
||||
ConfigNode: unknown;
|
||||
}> = TextSourceCode<Options> | BinarySourceCode<Options>;
|
||||
/**
|
||||
* Represents a traversal step visiting the AST.
|
||||
*/
|
||||
export interface VisitTraversalStep {
|
||||
kind: 1;
|
||||
target: unknown;
|
||||
phase: 1 | 2;
|
||||
args: unknown[];
|
||||
}
|
||||
/**
|
||||
* Represents a traversal step calling a function.
|
||||
*/
|
||||
export interface CallTraversalStep {
|
||||
kind: 2;
|
||||
target: string;
|
||||
phase?: string;
|
||||
args: unknown[];
|
||||
}
|
||||
export type TraversalStep = VisitTraversalStep | CallTraversalStep;
|
||||
/**
|
||||
* The type of disable directive. This determines how ESLint will disable rules.
|
||||
*/
|
||||
export type DirectiveType = "disable" | "enable" | "disable-line" | "disable-next-line";
|
||||
/**
|
||||
* Represents a disable directive.
|
||||
*/
|
||||
export interface Directive {
|
||||
/**
|
||||
* The type of directive.
|
||||
*/
|
||||
type: DirectiveType;
|
||||
/**
|
||||
* The node of the directive. May be in the AST or a comment/token.
|
||||
*/
|
||||
node: unknown;
|
||||
/**
|
||||
* The value of the directive.
|
||||
*/
|
||||
value: string;
|
||||
/**
|
||||
* The justification for the directive.
|
||||
*/
|
||||
justification?: string;
|
||||
}
|
||||
export {};
|
49
node_modules/@eslint/core/package.json
generated
vendored
49
node_modules/@eslint/core/package.json
generated
vendored
|
@ -1,49 +0,0 @@
|
|||
{
|
||||
"name": "@eslint/core",
|
||||
"version": "0.15.2",
|
||||
"description": "Runtime-agnostic core of ESLint",
|
||||
"type": "module",
|
||||
"types": "./dist/esm/types.d.ts",
|
||||
"exports": {
|
||||
"types": {
|
||||
"import": "./dist/esm/types.d.ts",
|
||||
"require": "./dist/cjs/types.d.cts"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"scripts": {
|
||||
"build:cts": "node -e \"fs.cpSync('dist/esm/types.d.ts', 'dist/cjs/types.d.cts')\"",
|
||||
"build": "tsc && npm run build:cts",
|
||||
"test:jsr": "npx jsr@latest publish --dry-run",
|
||||
"test:types": "tsc -p tests/types/tsconfig.json"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/eslint/rewrite.git",
|
||||
"directory": "packages/core"
|
||||
},
|
||||
"keywords": [
|
||||
"eslint",
|
||||
"core"
|
||||
],
|
||||
"author": "Nicholas C. Zakas",
|
||||
"license": "Apache-2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/eslint/rewrite/issues"
|
||||
},
|
||||
"homepage": "https://github.com/eslint/rewrite/tree/main/packages/core#readme",
|
||||
"dependencies": {
|
||||
"@types/json-schema": "^7.0.15"
|
||||
},
|
||||
"devDependencies": {
|
||||
"json-schema": "^0.4.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
}
|
||||
}
|
41
node_modules/@eslint/eslintrc/README.md
generated
vendored
41
node_modules/@eslint/eslintrc/README.md
generated
vendored
|
@ -8,14 +8,12 @@ This repository contains the legacy ESLintRC configuration file format for ESLin
|
|||
|
||||
You can install the package as follows:
|
||||
|
||||
```shell
|
||||
npm install @eslint/eslintrc -D
|
||||
```
|
||||
npm install @eslint/eslintrc --save-dev
|
||||
|
||||
# or
|
||||
|
||||
yarn add @eslint/eslintrc -D
|
||||
# or
|
||||
pnpm install @eslint/eslintrc -D
|
||||
# or
|
||||
bun install @eslint/eslintrc -D
|
||||
```
|
||||
|
||||
## Usage (ESM)
|
||||
|
@ -35,14 +33,14 @@ const __dirname = path.dirname(__filename);
|
|||
const compat = new FlatCompat({
|
||||
baseDirectory: __dirname, // optional; default: process.cwd()
|
||||
resolvePluginsRelativeTo: __dirname, // optional
|
||||
recommendedConfig: js.configs.recommended, // optional unless you're using "eslint:recommended"
|
||||
allConfig: js.configs.all, // optional unless you're using "eslint:all"
|
||||
recommendedConfig: js.configs.recommended, // optional
|
||||
allConfig: js.configs.all, // optional
|
||||
});
|
||||
|
||||
export default [
|
||||
|
||||
// mimic ESLintRC-style extends
|
||||
...compat.extends("standard", "example", "plugin:react/recommended"),
|
||||
...compat.extends("standard", "example"),
|
||||
|
||||
// mimic environments
|
||||
...compat.env({
|
||||
|
@ -51,11 +49,11 @@ export default [
|
|||
}),
|
||||
|
||||
// mimic plugins
|
||||
...compat.plugins("jsx-a11y", "react"),
|
||||
...compat.plugins("airbnb", "react"),
|
||||
|
||||
// translate an entire config
|
||||
...compat.config({
|
||||
plugins: ["jsx-a11y", "react"],
|
||||
plugins: ["airbnb", "react"],
|
||||
extends: "standard",
|
||||
env: {
|
||||
es2020: true,
|
||||
|
@ -79,14 +77,14 @@ const js = require("@eslint/js");
|
|||
const compat = new FlatCompat({
|
||||
baseDirectory: __dirname, // optional; default: process.cwd()
|
||||
resolvePluginsRelativeTo: __dirname, // optional
|
||||
recommendedConfig: js.configs.recommended, // optional unless using "eslint:recommended"
|
||||
allConfig: js.configs.all, // optional unless using "eslint:all"
|
||||
recommendedConfig: js.configs.recommended, // optional
|
||||
allConfig: js.configs.all, // optional
|
||||
});
|
||||
|
||||
module.exports = [
|
||||
|
||||
// mimic ESLintRC-style extends
|
||||
...compat.extends("standard", "example", "plugin:react/recommended"),
|
||||
...compat.extends("standard", "example"),
|
||||
|
||||
// mimic environments
|
||||
...compat.env({
|
||||
|
@ -95,11 +93,11 @@ module.exports = [
|
|||
}),
|
||||
|
||||
// mimic plugins
|
||||
...compat.plugins("jsx-a11y", "react"),
|
||||
...compat.plugins("airbnb", "react"),
|
||||
|
||||
// translate an entire config
|
||||
...compat.config({
|
||||
plugins: ["jsx-a11y", "react"],
|
||||
plugins: ["airbnb", "react"],
|
||||
extends: "standard",
|
||||
env: {
|
||||
es2020: true,
|
||||
|
@ -112,17 +110,6 @@ module.exports = [
|
|||
];
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
**TypeError: Missing parameter 'recommendedConfig' in FlatCompat constructor**
|
||||
|
||||
The `recommendedConfig` option is required when any config uses `eslint:recommended`, including any config in an `extends` clause. To fix this, follow the example above using `@eslint/js` to provide the `eslint:recommended` config.
|
||||
|
||||
**TypeError: Missing parameter 'allConfig' in FlatCompat constructor**
|
||||
|
||||
The `allConfig` option is required when any config uses `eslint:all`, including any config in an `extends` clause. To fix this, follow the example above using `@eslint/js` to provide the `eslint:all` config.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT License
|
||||
|
|
2
node_modules/@eslint/eslintrc/conf/environments.js
generated
vendored
2
node_modules/@eslint/eslintrc/conf/environments.js
generated
vendored
|
@ -23,7 +23,7 @@ function getDiff(current, prev) {
|
|||
const retv = {};
|
||||
|
||||
for (const [key, value] of Object.entries(current)) {
|
||||
if (!Object.hasOwn(prev, key)) {
|
||||
if (!Object.hasOwnProperty.call(prev, key)) {
|
||||
retv[key] = value;
|
||||
}
|
||||
}
|
||||
|
|
170
node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs
generated
vendored
170
node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs
generated
vendored
|
@ -2,8 +2,8 @@
|
|||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var util = require('node:util');
|
||||
var path = require('node:path');
|
||||
var util = require('util');
|
||||
var path = require('path');
|
||||
var Ajv = require('ajv');
|
||||
var globals = require('globals');
|
||||
|
||||
|
@ -29,7 +29,7 @@ const RULE_SEVERITY_STRINGS = ["off", "warn", "error"],
|
|||
map[value] = index;
|
||||
return map;
|
||||
}, {}),
|
||||
VALID_SEVERITIES = new Set([0, 1, 2, "off", "warn", "error"]);
|
||||
VALID_SEVERITIES = [0, 1, 2, "off", "warn", "error"];
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Public Interface
|
||||
|
@ -99,7 +99,7 @@ function isValidSeverity(ruleConfig) {
|
|||
if (typeof severity === "string") {
|
||||
severity = severity.toLowerCase();
|
||||
}
|
||||
return VALID_SEVERITIES.has(severity);
|
||||
return VALID_SEVERITIES.indexOf(severity) !== -1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -381,69 +381,12 @@ var ajvOrig = (additionalOptions = {}) => {
|
|||
});
|
||||
|
||||
ajv.addMetaSchema(metaSchema);
|
||||
// eslint-disable-next-line no-underscore-dangle -- part of the API
|
||||
// eslint-disable-next-line no-underscore-dangle
|
||||
ajv._opts.defaultMeta = metaSchema.id;
|
||||
|
||||
return ajv;
|
||||
};
|
||||
|
||||
/**
|
||||
* @fileoverview Applies default rule options
|
||||
* @author JoshuaKGoldberg
|
||||
*/
|
||||
|
||||
/**
|
||||
* Check if the variable contains an object strictly rejecting arrays
|
||||
* @param {unknown} value an object
|
||||
* @returns {boolean} Whether value is an object
|
||||
*/
|
||||
function isObjectNotArray(value) {
|
||||
return typeof value === "object" && value !== null && !Array.isArray(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deeply merges second on top of first, creating a new {} object if needed.
|
||||
* @param {T} first Base, default value.
|
||||
* @param {U} second User-specified value.
|
||||
* @returns {T | U | (T & U)} Merged equivalent of second on top of first.
|
||||
*/
|
||||
function deepMergeObjects(first, second) {
|
||||
if (second === void 0) {
|
||||
return first;
|
||||
}
|
||||
|
||||
if (!isObjectNotArray(first) || !isObjectNotArray(second)) {
|
||||
return second;
|
||||
}
|
||||
|
||||
const result = { ...first, ...second };
|
||||
|
||||
for (const key of Object.keys(second)) {
|
||||
if (Object.prototype.propertyIsEnumerable.call(first, key)) {
|
||||
result[key] = deepMergeObjects(first[key], second[key]);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deeply merges second on top of first, creating a new [] array if needed.
|
||||
* @param {T[] | undefined} first Base, default values.
|
||||
* @param {U[] | undefined} second User-specified values.
|
||||
* @returns {(T | U | (T & U))[]} Merged equivalent of second on top of first.
|
||||
*/
|
||||
function deepMergeArrays(first, second) {
|
||||
if (!first || !second) {
|
||||
return second || first || [];
|
||||
}
|
||||
|
||||
return [
|
||||
...first.map((value, i) => deepMergeObjects(value, second[i])),
|
||||
...second.slice(first.length)
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @fileoverview Defines a schema for configs.
|
||||
* @author Sylvan Mably
|
||||
|
@ -541,7 +484,7 @@ function getDiff(current, prev) {
|
|||
const retv = {};
|
||||
|
||||
for (const [key, value] of Object.entries(current)) {
|
||||
if (!Object.hasOwn(prev, key)) {
|
||||
if (!Object.hasOwnProperty.call(prev, key)) {
|
||||
retv[key] = value;
|
||||
}
|
||||
}
|
||||
|
@ -754,20 +697,10 @@ const severityMap = {
|
|||
|
||||
const validated = new WeakSet();
|
||||
|
||||
// JSON schema that disallows passing any options
|
||||
const noOptionsSchema = Object.freeze({
|
||||
type: "array",
|
||||
minItems: 0,
|
||||
maxItems: 0
|
||||
});
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Exports
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Validator for configuration objects.
|
||||
*/
|
||||
class ConfigValidator {
|
||||
constructor({ builtInRules = new Map() } = {}) {
|
||||
this.builtInRules = builtInRules;
|
||||
|
@ -775,36 +708,17 @@ class ConfigValidator {
|
|||
|
||||
/**
|
||||
* Gets a complete options schema for a rule.
|
||||
* @param {Rule} rule A rule object
|
||||
* @throws {TypeError} If `meta.schema` is specified but is not an array, object or `false`.
|
||||
* @returns {Object|null} JSON Schema for the rule's options.
|
||||
* `null` if rule wasn't passed or its `meta.schema` is `false`.
|
||||
* @param {{create: Function, schema: (Array|null)}} rule A new-style rule object
|
||||
* @returns {Object} JSON Schema for the rule's options.
|
||||
*/
|
||||
getRuleOptionsSchema(rule) {
|
||||
if (!rule) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!rule.meta) {
|
||||
return { ...noOptionsSchema }; // default if `meta.schema` is not specified
|
||||
}
|
||||
const schema = rule.schema || rule.meta && rule.meta.schema;
|
||||
|
||||
const schema = rule.meta.schema;
|
||||
|
||||
if (typeof schema === "undefined") {
|
||||
return { ...noOptionsSchema }; // default if `meta.schema` is not specified
|
||||
}
|
||||
|
||||
// `schema:false` is an allowed explicit opt-out of options validation for the rule
|
||||
if (schema === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (typeof schema !== "object" || schema === null) {
|
||||
throw new TypeError("Rule's `meta.schema` must be an array or object");
|
||||
}
|
||||
|
||||
// ESLint-specific array form needs to be converted into a valid JSON Schema definition
|
||||
// Given a tuple of schemas, insert warning level at the beginning
|
||||
if (Array.isArray(schema)) {
|
||||
if (schema.length) {
|
||||
return {
|
||||
|
@ -814,20 +728,22 @@ class ConfigValidator {
|
|||
maxItems: schema.length
|
||||
};
|
||||
}
|
||||
return {
|
||||
type: "array",
|
||||
minItems: 0,
|
||||
maxItems: 0
|
||||
};
|
||||
|
||||
// `schema:[]` is an explicit way to specify that the rule does not accept any options
|
||||
return { ...noOptionsSchema };
|
||||
}
|
||||
|
||||
// `schema:<object>` is assumed to be a valid JSON Schema definition
|
||||
return schema;
|
||||
// Given a full schema, leave it alone
|
||||
return schema || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a rule's severity and returns the severity value. Throws an error if the severity is invalid.
|
||||
* @param {options} options The given options for the rule.
|
||||
* @returns {number|string} The rule's severity value
|
||||
* @throws {Error} If the severity is invalid.
|
||||
*/
|
||||
validateRuleSeverity(options) {
|
||||
const severity = Array.isArray(options) ? options[0] : options;
|
||||
|
@ -846,32 +762,20 @@ class ConfigValidator {
|
|||
* @param {{create: Function}} rule The rule to validate
|
||||
* @param {Array} localOptions The options for the rule, excluding severity
|
||||
* @returns {void}
|
||||
* @throws {Error} If the options are invalid.
|
||||
*/
|
||||
validateRuleSchema(rule, localOptions) {
|
||||
if (!ruleValidators.has(rule)) {
|
||||
try {
|
||||
const schema = this.getRuleOptionsSchema(rule);
|
||||
const schema = this.getRuleOptionsSchema(rule);
|
||||
|
||||
if (schema) {
|
||||
ruleValidators.set(rule, ajv.compile(schema));
|
||||
}
|
||||
} catch (err) {
|
||||
const errorWithCode = new Error(err.message, { cause: err });
|
||||
|
||||
errorWithCode.code = "ESLINT_INVALID_RULE_OPTIONS_SCHEMA";
|
||||
|
||||
throw errorWithCode;
|
||||
if (schema) {
|
||||
ruleValidators.set(rule, ajv.compile(schema));
|
||||
}
|
||||
}
|
||||
|
||||
const validateRule = ruleValidators.get(rule);
|
||||
|
||||
if (validateRule) {
|
||||
const mergedOptions = deepMergeArrays(rule.meta?.defaultOptions, localOptions);
|
||||
|
||||
validateRule(mergedOptions);
|
||||
|
||||
validateRule(localOptions);
|
||||
if (validateRule.errors) {
|
||||
throw new Error(validateRule.errors.map(
|
||||
error => `\tValue ${JSON.stringify(error.data)} ${error.message}.\n`
|
||||
|
@ -888,7 +792,6 @@ class ConfigValidator {
|
|||
* @param {string|null} source The name of the configuration source to report in any errors. If null or undefined,
|
||||
* no source is prepended to the message.
|
||||
* @returns {void}
|
||||
* @throws {Error} If the options are invalid.
|
||||
*/
|
||||
validateRuleOptions(rule, ruleId, options, source = null) {
|
||||
try {
|
||||
|
@ -898,21 +801,13 @@ class ConfigValidator {
|
|||
this.validateRuleSchema(rule, Array.isArray(options) ? options.slice(1) : []);
|
||||
}
|
||||
} catch (err) {
|
||||
let enhancedMessage = err.code === "ESLINT_INVALID_RULE_OPTIONS_SCHEMA"
|
||||
? `Error while processing options validation schema of rule '${ruleId}': ${err.message}`
|
||||
: `Configuration for rule "${ruleId}" is invalid:\n${err.message}`;
|
||||
const enhancedMessage = `Configuration for rule "${ruleId}" is invalid:\n${err.message}`;
|
||||
|
||||
if (typeof source === "string") {
|
||||
enhancedMessage = `${source}:\n\t${enhancedMessage}`;
|
||||
throw new Error(`${source}:\n\t${enhancedMessage}`);
|
||||
} else {
|
||||
throw new Error(enhancedMessage);
|
||||
}
|
||||
|
||||
const enhancedError = new Error(enhancedMessage, { cause: err });
|
||||
|
||||
if (err.code) {
|
||||
enhancedError.code = err.code;
|
||||
}
|
||||
|
||||
throw enhancedError;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -920,9 +815,8 @@ class ConfigValidator {
|
|||
* Validates an environment object
|
||||
* @param {Object} environment The environment config object to validate.
|
||||
* @param {string} source The name of the configuration source to report in any errors.
|
||||
* @param {(envId:string) => Object} [getAdditionalEnv] A map from strings to loaded environments.
|
||||
* @param {function(envId:string): Object} [getAdditionalEnv] A map from strings to loaded environments.
|
||||
* @returns {void}
|
||||
* @throws {Error} If the environment is invalid.
|
||||
*/
|
||||
validateEnvironment(
|
||||
environment,
|
||||
|
@ -950,7 +844,7 @@ class ConfigValidator {
|
|||
* Validates a rules config object
|
||||
* @param {Object} rulesConfig The rules config object to validate.
|
||||
* @param {string} source The name of the configuration source to report in any errors.
|
||||
* @param {(ruleId:string) => Object} getAdditionalRule A map from strings to loaded rules
|
||||
* @param {function(ruleId:string): Object} getAdditionalRule A map from strings to loaded rules
|
||||
* @returns {void}
|
||||
*/
|
||||
validateRules(
|
||||
|
@ -994,9 +888,8 @@ class ConfigValidator {
|
|||
* Validate `processor` configuration.
|
||||
* @param {string|undefined} processorName The processor name.
|
||||
* @param {string} source The name of config file.
|
||||
* @param {(id:string) => Processor} getProcessor The getter of defined processors.
|
||||
* @param {function(id:string): Processor} getProcessor The getter of defined processors.
|
||||
* @returns {void}
|
||||
* @throws {Error} If the processor is invalid.
|
||||
*/
|
||||
validateProcessor(processorName, source, getProcessor) {
|
||||
if (processorName && !getProcessor(processorName)) {
|
||||
|
@ -1035,7 +928,6 @@ class ConfigValidator {
|
|||
* @param {Object} config The config object to validate.
|
||||
* @param {string} source The name of the configuration source to report in any errors.
|
||||
* @returns {void}
|
||||
* @throws {Error} If the config is invalid.
|
||||
*/
|
||||
validateConfigSchema(config, source = null) {
|
||||
validateSchema = validateSchema || ajv.compile(configSchema);
|
||||
|
@ -1044,7 +936,7 @@ class ConfigValidator {
|
|||
throw new Error(`ESLint configuration in ${source} is invalid:\n${this.formatErrors(validateSchema.errors)}`);
|
||||
}
|
||||
|
||||
if (Object.hasOwn(config, "ecmaFeatures")) {
|
||||
if (Object.hasOwnProperty.call(config, "ecmaFeatures")) {
|
||||
emitDeprecationWarning(source, "ESLINT_LEGACY_ECMAFEATURES");
|
||||
}
|
||||
}
|
||||
|
@ -1053,8 +945,8 @@ class ConfigValidator {
|
|||
* Validates an entire config object.
|
||||
* @param {Object} config The config object to validate.
|
||||
* @param {string} source The name of the configuration source to report in any errors.
|
||||
* @param {(ruleId:string) => Object} [getAdditionalRule] A map from strings to loaded rules.
|
||||
* @param {(envId:string) => Object} [getAdditionalEnv] A map from strings to loaded envs.
|
||||
* @param {function(ruleId:string): Object} [getAdditionalRule] A map from strings to loaded rules.
|
||||
* @param {function(envId:string): Object} [getAdditionalEnv] A map from strings to loaded envs.
|
||||
* @returns {void}
|
||||
*/
|
||||
validate(config, source, getAdditionalRule, getAdditionalEnv) {
|
||||
|
|
2
node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs.map
generated
vendored
2
node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs.map
generated
vendored
File diff suppressed because one or more lines are too long
250
node_modules/@eslint/eslintrc/dist/eslintrc.cjs
generated
vendored
250
node_modules/@eslint/eslintrc/dist/eslintrc.cjs
generated
vendored
|
@ -3,18 +3,18 @@
|
|||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var debugOrig = require('debug');
|
||||
var fs = require('node:fs');
|
||||
var fs = require('fs');
|
||||
var importFresh = require('import-fresh');
|
||||
var Module = require('node:module');
|
||||
var path = require('node:path');
|
||||
var Module = require('module');
|
||||
var path = require('path');
|
||||
var stripComments = require('strip-json-comments');
|
||||
var assert = require('node:assert');
|
||||
var assert = require('assert');
|
||||
var ignore = require('ignore');
|
||||
var util = require('node:util');
|
||||
var util = require('util');
|
||||
var minimatch = require('minimatch');
|
||||
var Ajv = require('ajv');
|
||||
var globals = require('globals');
|
||||
var os = require('node:os');
|
||||
var os = require('os');
|
||||
|
||||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
||||
|
||||
|
@ -142,9 +142,6 @@ const DotPatterns = Object.freeze([".*", "!.eslintrc.*", "!../"]);
|
|||
// Public
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Represents a set of glob patterns to ignore against a base path.
|
||||
*/
|
||||
class IgnorePattern {
|
||||
|
||||
/**
|
||||
|
@ -181,7 +178,9 @@ class IgnorePattern {
|
|||
debug$3("Create with: %o", ignorePatterns);
|
||||
|
||||
const basePath = getCommonAncestorPath(ignorePatterns.map(p => p.basePath));
|
||||
const patterns = ignorePatterns.flatMap(p => p.getPatternsRelativeTo(basePath));
|
||||
const patterns = [].concat(
|
||||
...ignorePatterns.map(p => p.getPatternsRelativeTo(basePath))
|
||||
);
|
||||
const ig = ignore__default["default"]({ allowRelativePaths: true }).add([...DotPatterns, ...patterns]);
|
||||
const dotIg = ignore__default["default"]({ allowRelativePaths: true }).add(patterns);
|
||||
|
||||
|
@ -381,10 +380,10 @@ class ExtractedConfig {
|
|||
*/
|
||||
toCompatibleObjectAsConfigFileContent() {
|
||||
const {
|
||||
/* eslint-disable no-unused-vars -- needed to make `config` correct */
|
||||
/* eslint-disable no-unused-vars */
|
||||
configNameOfNoInlineConfig: _ignore1,
|
||||
processor: _ignore2,
|
||||
/* eslint-enable no-unused-vars -- needed to make `config` correct */
|
||||
/* eslint-enable no-unused-vars */
|
||||
ignores,
|
||||
...config
|
||||
} = this;
|
||||
|
@ -576,7 +575,6 @@ class PluginConflictError extends Error {
|
|||
* @param {Record<string, DependentPlugin>} target The destination to merge
|
||||
* @param {Record<string, DependentPlugin>|undefined} source The source to merge.
|
||||
* @returns {void}
|
||||
* @throws {PluginConflictError} When a plugin was conflicted.
|
||||
*/
|
||||
function mergePlugins(target, source) {
|
||||
if (!isNonNullObject(source)) {
|
||||
|
@ -657,7 +655,6 @@ function mergeRuleConfigs(target, source) {
|
|||
* @param {ConfigArray} instance The config elements.
|
||||
* @param {number[]} indices The indices to use.
|
||||
* @returns {ExtractedConfig} The extracted config.
|
||||
* @throws {Error} When a plugin is conflicted.
|
||||
*/
|
||||
function createConfig(instance, indices) {
|
||||
const config = new ExtractedConfig();
|
||||
|
@ -719,18 +716,31 @@ function createConfig(instance, indices) {
|
|||
* @param {string} pluginId The plugin ID for prefix.
|
||||
* @param {Record<string,T>} defs The definitions to collect.
|
||||
* @param {Map<string, U>} map The map to output.
|
||||
* @param {function(T): U} [normalize] The normalize function for each value.
|
||||
* @returns {void}
|
||||
*/
|
||||
function collect(pluginId, defs, map) {
|
||||
function collect(pluginId, defs, map, normalize) {
|
||||
if (defs) {
|
||||
const prefix = pluginId && `${pluginId}/`;
|
||||
|
||||
for (const [key, value] of Object.entries(defs)) {
|
||||
map.set(`${prefix}${key}`, value);
|
||||
map.set(
|
||||
`${prefix}${key}`,
|
||||
normalize ? normalize(value) : value
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize a rule definition.
|
||||
* @param {Function|Rule} rule The rule definition to normalize.
|
||||
* @returns {Rule} The normalized rule definition.
|
||||
*/
|
||||
function normalizePluginRule(rule) {
|
||||
return typeof rule === "function" ? { create: rule } : rule;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the mutation methods from a given map.
|
||||
* @param {Map<any, any>} map The map object to delete.
|
||||
|
@ -772,7 +782,7 @@ function initPluginMemberMaps(elements, slots) {
|
|||
|
||||
collect(pluginId, plugin.environments, slots.envMap);
|
||||
collect(pluginId, plugin.processors, slots.processorMap);
|
||||
collect(pluginId, plugin.rules, slots.ruleMap);
|
||||
collect(pluginId, plugin.rules, slots.ruleMap, normalizePluginRule);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -991,8 +1001,8 @@ class ConfigDependency {
|
|||
this.importerPath = importerPath;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line jsdoc/require-description
|
||||
/**
|
||||
* Converts this instance to a JSON compatible object.
|
||||
* @returns {Object} a JSON compatible object.
|
||||
*/
|
||||
toJSON() {
|
||||
|
@ -1006,14 +1016,14 @@ class ConfigDependency {
|
|||
return obj;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line jsdoc/require-description
|
||||
/**
|
||||
* Custom inspect method for Node.js `console.log()`.
|
||||
* @returns {Object} an object to display by `console.log()`.
|
||||
*/
|
||||
[util__default["default"].inspect.custom]() {
|
||||
const {
|
||||
definition: _ignore1, // eslint-disable-line no-unused-vars -- needed to make `obj` correct
|
||||
original: _ignore2, // eslint-disable-line no-unused-vars -- needed to make `obj` correct
|
||||
definition: _ignore1, // eslint-disable-line no-unused-vars
|
||||
original: _ignore2, // eslint-disable-line no-unused-vars
|
||||
...obj
|
||||
} = this;
|
||||
|
||||
|
@ -1112,7 +1122,6 @@ class OverrideTester {
|
|||
* @param {string|string[]} excludedFiles The glob patterns for excluded files.
|
||||
* @param {string} basePath The path to the base directory to test paths.
|
||||
* @returns {OverrideTester|null} The created instance or `null`.
|
||||
* @throws {Error} When invalid patterns are given.
|
||||
*/
|
||||
static create(files, excludedFiles, basePath) {
|
||||
const includePatterns = normalizePatterns(files);
|
||||
|
@ -1202,7 +1211,6 @@ class OverrideTester {
|
|||
* Test if a given path is matched or not.
|
||||
* @param {string} filePath The absolute path to the target file.
|
||||
* @returns {boolean} `true` if the path was matched.
|
||||
* @throws {Error} When invalid `filePath` is given.
|
||||
*/
|
||||
test(filePath) {
|
||||
if (typeof filePath !== "string" || !path__default["default"].isAbsolute(filePath)) {
|
||||
|
@ -1216,8 +1224,8 @@ class OverrideTester {
|
|||
));
|
||||
}
|
||||
|
||||
// eslint-disable-next-line jsdoc/require-description
|
||||
/**
|
||||
* Converts this instance to a JSON compatible object.
|
||||
* @returns {Object} a JSON compatible object.
|
||||
*/
|
||||
toJSON() {
|
||||
|
@ -1233,8 +1241,8 @@ class OverrideTester {
|
|||
};
|
||||
}
|
||||
|
||||
// eslint-disable-next-line jsdoc/require-description
|
||||
/**
|
||||
* Custom inspect method for Node.js `console.log()`.
|
||||
* @returns {Object} an object to display by `console.log()`.
|
||||
*/
|
||||
[util__default["default"].inspect.custom]() {
|
||||
|
@ -1262,7 +1270,7 @@ const RULE_SEVERITY_STRINGS = ["off", "warn", "error"],
|
|||
map[value] = index;
|
||||
return map;
|
||||
}, {}),
|
||||
VALID_SEVERITIES = new Set([0, 1, 2, "off", "warn", "error"]);
|
||||
VALID_SEVERITIES = [0, 1, 2, "off", "warn", "error"];
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Public Interface
|
||||
|
@ -1332,7 +1340,7 @@ function isValidSeverity(ruleConfig) {
|
|||
if (typeof severity === "string") {
|
||||
severity = severity.toLowerCase();
|
||||
}
|
||||
return VALID_SEVERITIES.has(severity);
|
||||
return VALID_SEVERITIES.indexOf(severity) !== -1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1614,69 +1622,12 @@ var ajvOrig = (additionalOptions = {}) => {
|
|||
});
|
||||
|
||||
ajv.addMetaSchema(metaSchema);
|
||||
// eslint-disable-next-line no-underscore-dangle -- part of the API
|
||||
// eslint-disable-next-line no-underscore-dangle
|
||||
ajv._opts.defaultMeta = metaSchema.id;
|
||||
|
||||
return ajv;
|
||||
};
|
||||
|
||||
/**
|
||||
* @fileoverview Applies default rule options
|
||||
* @author JoshuaKGoldberg
|
||||
*/
|
||||
|
||||
/**
|
||||
* Check if the variable contains an object strictly rejecting arrays
|
||||
* @param {unknown} value an object
|
||||
* @returns {boolean} Whether value is an object
|
||||
*/
|
||||
function isObjectNotArray(value) {
|
||||
return typeof value === "object" && value !== null && !Array.isArray(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deeply merges second on top of first, creating a new {} object if needed.
|
||||
* @param {T} first Base, default value.
|
||||
* @param {U} second User-specified value.
|
||||
* @returns {T | U | (T & U)} Merged equivalent of second on top of first.
|
||||
*/
|
||||
function deepMergeObjects(first, second) {
|
||||
if (second === void 0) {
|
||||
return first;
|
||||
}
|
||||
|
||||
if (!isObjectNotArray(first) || !isObjectNotArray(second)) {
|
||||
return second;
|
||||
}
|
||||
|
||||
const result = { ...first, ...second };
|
||||
|
||||
for (const key of Object.keys(second)) {
|
||||
if (Object.prototype.propertyIsEnumerable.call(first, key)) {
|
||||
result[key] = deepMergeObjects(first[key], second[key]);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deeply merges second on top of first, creating a new [] array if needed.
|
||||
* @param {T[] | undefined} first Base, default values.
|
||||
* @param {U[] | undefined} second User-specified values.
|
||||
* @returns {(T | U | (T & U))[]} Merged equivalent of second on top of first.
|
||||
*/
|
||||
function deepMergeArrays(first, second) {
|
||||
if (!first || !second) {
|
||||
return second || first || [];
|
||||
}
|
||||
|
||||
return [
|
||||
...first.map((value, i) => deepMergeObjects(value, second[i])),
|
||||
...second.slice(first.length)
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @fileoverview Defines a schema for configs.
|
||||
* @author Sylvan Mably
|
||||
|
@ -1774,7 +1725,7 @@ function getDiff(current, prev) {
|
|||
const retv = {};
|
||||
|
||||
for (const [key, value] of Object.entries(current)) {
|
||||
if (!Object.hasOwn(prev, key)) {
|
||||
if (!Object.hasOwnProperty.call(prev, key)) {
|
||||
retv[key] = value;
|
||||
}
|
||||
}
|
||||
|
@ -1987,20 +1938,10 @@ const severityMap = {
|
|||
|
||||
const validated = new WeakSet();
|
||||
|
||||
// JSON schema that disallows passing any options
|
||||
const noOptionsSchema = Object.freeze({
|
||||
type: "array",
|
||||
minItems: 0,
|
||||
maxItems: 0
|
||||
});
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Exports
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Validator for configuration objects.
|
||||
*/
|
||||
class ConfigValidator {
|
||||
constructor({ builtInRules = new Map() } = {}) {
|
||||
this.builtInRules = builtInRules;
|
||||
|
@ -2008,36 +1949,17 @@ class ConfigValidator {
|
|||
|
||||
/**
|
||||
* Gets a complete options schema for a rule.
|
||||
* @param {Rule} rule A rule object
|
||||
* @throws {TypeError} If `meta.schema` is specified but is not an array, object or `false`.
|
||||
* @returns {Object|null} JSON Schema for the rule's options.
|
||||
* `null` if rule wasn't passed or its `meta.schema` is `false`.
|
||||
* @param {{create: Function, schema: (Array|null)}} rule A new-style rule object
|
||||
* @returns {Object} JSON Schema for the rule's options.
|
||||
*/
|
||||
getRuleOptionsSchema(rule) {
|
||||
if (!rule) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!rule.meta) {
|
||||
return { ...noOptionsSchema }; // default if `meta.schema` is not specified
|
||||
}
|
||||
const schema = rule.schema || rule.meta && rule.meta.schema;
|
||||
|
||||
const schema = rule.meta.schema;
|
||||
|
||||
if (typeof schema === "undefined") {
|
||||
return { ...noOptionsSchema }; // default if `meta.schema` is not specified
|
||||
}
|
||||
|
||||
// `schema:false` is an allowed explicit opt-out of options validation for the rule
|
||||
if (schema === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (typeof schema !== "object" || schema === null) {
|
||||
throw new TypeError("Rule's `meta.schema` must be an array or object");
|
||||
}
|
||||
|
||||
// ESLint-specific array form needs to be converted into a valid JSON Schema definition
|
||||
// Given a tuple of schemas, insert warning level at the beginning
|
||||
if (Array.isArray(schema)) {
|
||||
if (schema.length) {
|
||||
return {
|
||||
|
@ -2047,20 +1969,22 @@ class ConfigValidator {
|
|||
maxItems: schema.length
|
||||
};
|
||||
}
|
||||
return {
|
||||
type: "array",
|
||||
minItems: 0,
|
||||
maxItems: 0
|
||||
};
|
||||
|
||||
// `schema:[]` is an explicit way to specify that the rule does not accept any options
|
||||
return { ...noOptionsSchema };
|
||||
}
|
||||
|
||||
// `schema:<object>` is assumed to be a valid JSON Schema definition
|
||||
return schema;
|
||||
// Given a full schema, leave it alone
|
||||
return schema || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a rule's severity and returns the severity value. Throws an error if the severity is invalid.
|
||||
* @param {options} options The given options for the rule.
|
||||
* @returns {number|string} The rule's severity value
|
||||
* @throws {Error} If the severity is invalid.
|
||||
*/
|
||||
validateRuleSeverity(options) {
|
||||
const severity = Array.isArray(options) ? options[0] : options;
|
||||
|
@ -2079,32 +2003,20 @@ class ConfigValidator {
|
|||
* @param {{create: Function}} rule The rule to validate
|
||||
* @param {Array} localOptions The options for the rule, excluding severity
|
||||
* @returns {void}
|
||||
* @throws {Error} If the options are invalid.
|
||||
*/
|
||||
validateRuleSchema(rule, localOptions) {
|
||||
if (!ruleValidators.has(rule)) {
|
||||
try {
|
||||
const schema = this.getRuleOptionsSchema(rule);
|
||||
const schema = this.getRuleOptionsSchema(rule);
|
||||
|
||||
if (schema) {
|
||||
ruleValidators.set(rule, ajv.compile(schema));
|
||||
}
|
||||
} catch (err) {
|
||||
const errorWithCode = new Error(err.message, { cause: err });
|
||||
|
||||
errorWithCode.code = "ESLINT_INVALID_RULE_OPTIONS_SCHEMA";
|
||||
|
||||
throw errorWithCode;
|
||||
if (schema) {
|
||||
ruleValidators.set(rule, ajv.compile(schema));
|
||||
}
|
||||
}
|
||||
|
||||
const validateRule = ruleValidators.get(rule);
|
||||
|
||||
if (validateRule) {
|
||||
const mergedOptions = deepMergeArrays(rule.meta?.defaultOptions, localOptions);
|
||||
|
||||
validateRule(mergedOptions);
|
||||
|
||||
validateRule(localOptions);
|
||||
if (validateRule.errors) {
|
||||
throw new Error(validateRule.errors.map(
|
||||
error => `\tValue ${JSON.stringify(error.data)} ${error.message}.\n`
|
||||
|
@ -2121,7 +2033,6 @@ class ConfigValidator {
|
|||
* @param {string|null} source The name of the configuration source to report in any errors. If null or undefined,
|
||||
* no source is prepended to the message.
|
||||
* @returns {void}
|
||||
* @throws {Error} If the options are invalid.
|
||||
*/
|
||||
validateRuleOptions(rule, ruleId, options, source = null) {
|
||||
try {
|
||||
|
@ -2131,21 +2042,13 @@ class ConfigValidator {
|
|||
this.validateRuleSchema(rule, Array.isArray(options) ? options.slice(1) : []);
|
||||
}
|
||||
} catch (err) {
|
||||
let enhancedMessage = err.code === "ESLINT_INVALID_RULE_OPTIONS_SCHEMA"
|
||||
? `Error while processing options validation schema of rule '${ruleId}': ${err.message}`
|
||||
: `Configuration for rule "${ruleId}" is invalid:\n${err.message}`;
|
||||
const enhancedMessage = `Configuration for rule "${ruleId}" is invalid:\n${err.message}`;
|
||||
|
||||
if (typeof source === "string") {
|
||||
enhancedMessage = `${source}:\n\t${enhancedMessage}`;
|
||||
throw new Error(`${source}:\n\t${enhancedMessage}`);
|
||||
} else {
|
||||
throw new Error(enhancedMessage);
|
||||
}
|
||||
|
||||
const enhancedError = new Error(enhancedMessage, { cause: err });
|
||||
|
||||
if (err.code) {
|
||||
enhancedError.code = err.code;
|
||||
}
|
||||
|
||||
throw enhancedError;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2153,9 +2056,8 @@ class ConfigValidator {
|
|||
* Validates an environment object
|
||||
* @param {Object} environment The environment config object to validate.
|
||||
* @param {string} source The name of the configuration source to report in any errors.
|
||||
* @param {(envId:string) => Object} [getAdditionalEnv] A map from strings to loaded environments.
|
||||
* @param {function(envId:string): Object} [getAdditionalEnv] A map from strings to loaded environments.
|
||||
* @returns {void}
|
||||
* @throws {Error} If the environment is invalid.
|
||||
*/
|
||||
validateEnvironment(
|
||||
environment,
|
||||
|
@ -2183,7 +2085,7 @@ class ConfigValidator {
|
|||
* Validates a rules config object
|
||||
* @param {Object} rulesConfig The rules config object to validate.
|
||||
* @param {string} source The name of the configuration source to report in any errors.
|
||||
* @param {(ruleId:string) => Object} getAdditionalRule A map from strings to loaded rules
|
||||
* @param {function(ruleId:string): Object} getAdditionalRule A map from strings to loaded rules
|
||||
* @returns {void}
|
||||
*/
|
||||
validateRules(
|
||||
|
@ -2227,9 +2129,8 @@ class ConfigValidator {
|
|||
* Validate `processor` configuration.
|
||||
* @param {string|undefined} processorName The processor name.
|
||||
* @param {string} source The name of config file.
|
||||
* @param {(id:string) => Processor} getProcessor The getter of defined processors.
|
||||
* @param {function(id:string): Processor} getProcessor The getter of defined processors.
|
||||
* @returns {void}
|
||||
* @throws {Error} If the processor is invalid.
|
||||
*/
|
||||
validateProcessor(processorName, source, getProcessor) {
|
||||
if (processorName && !getProcessor(processorName)) {
|
||||
|
@ -2268,7 +2169,6 @@ class ConfigValidator {
|
|||
* @param {Object} config The config object to validate.
|
||||
* @param {string} source The name of the configuration source to report in any errors.
|
||||
* @returns {void}
|
||||
* @throws {Error} If the config is invalid.
|
||||
*/
|
||||
validateConfigSchema(config, source = null) {
|
||||
validateSchema = validateSchema || ajv.compile(configSchema);
|
||||
|
@ -2277,7 +2177,7 @@ class ConfigValidator {
|
|||
throw new Error(`ESLint configuration in ${source} is invalid:\n${this.formatErrors(validateSchema.errors)}`);
|
||||
}
|
||||
|
||||
if (Object.hasOwn(config, "ecmaFeatures")) {
|
||||
if (Object.hasOwnProperty.call(config, "ecmaFeatures")) {
|
||||
emitDeprecationWarning(source, "ESLINT_LEGACY_ECMAFEATURES");
|
||||
}
|
||||
}
|
||||
|
@ -2286,8 +2186,8 @@ class ConfigValidator {
|
|||
* Validates an entire config object.
|
||||
* @param {Object} config The config object to validate.
|
||||
* @param {string} source The name of the configuration source to report in any errors.
|
||||
* @param {(ruleId:string) => Object} [getAdditionalRule] A map from strings to loaded rules.
|
||||
* @param {(envId:string) => Object} [getAdditionalEnv] A map from strings to loaded envs.
|
||||
* @param {function(ruleId:string): Object} [getAdditionalRule] A map from strings to loaded rules.
|
||||
* @param {function(envId:string): Object} [getAdditionalEnv] A map from strings to loaded envs.
|
||||
* @returns {void}
|
||||
*/
|
||||
validate(config, source, getAdditionalRule, getAdditionalEnv) {
|
||||
|
@ -2440,7 +2340,6 @@ const createRequire = Module__default["default"].createRequire;
|
|||
* @param {string} relativeToPath An absolute path indicating the module that `moduleName` should be resolved relative to. This must be
|
||||
* a file rather than a directory, but the file need not actually exist.
|
||||
* @returns {string} The absolute path that would result from calling `require.resolve(moduleName)` in a file located at `relativeToPath`
|
||||
* @throws {Error} When the module cannot be resolved.
|
||||
*/
|
||||
function resolve(moduleName, relativeToPath) {
|
||||
try {
|
||||
|
@ -2701,7 +2600,7 @@ function loadPackageJSONConfigFile(filePath) {
|
|||
try {
|
||||
const packageData = loadJSONConfigFile(filePath);
|
||||
|
||||
if (!Object.hasOwn(packageData, "eslintConfig")) {
|
||||
if (!Object.hasOwnProperty.call(packageData, "eslintConfig")) {
|
||||
throw Object.assign(
|
||||
new Error("package.json file doesn't have 'eslintConfig' field."),
|
||||
{ code: "ESLINT_CONFIG_FIELD_NOT_FOUND" }
|
||||
|
@ -2720,7 +2619,6 @@ function loadPackageJSONConfigFile(filePath) {
|
|||
* Loads a `.eslintignore` from a file.
|
||||
* @param {string} filePath The filename to load.
|
||||
* @returns {string[]} The ignore patterns from the file.
|
||||
* @throws {Error} If the file cannot be read.
|
||||
* @private
|
||||
*/
|
||||
function loadESLintIgnoreFile(filePath) {
|
||||
|
@ -2793,7 +2691,7 @@ function loadConfigFile(filePath) {
|
|||
function writeDebugLogForLoading(request, relativeTo, filePath) {
|
||||
/* istanbul ignore next */
|
||||
if (debug$2.enabled) {
|
||||
let nameAndVersion = null; // eslint-disable-line no-useless-assignment -- known bug in the rule
|
||||
let nameAndVersion = null;
|
||||
|
||||
try {
|
||||
const packageJsonPath = resolve(
|
||||
|
@ -2958,7 +2856,6 @@ class ConfigArrayFactory {
|
|||
* @param {Object} [options] The options.
|
||||
* @param {string} [options.basePath] The base path to resolve relative paths in `overrides[].files`, `overrides[].excludedFiles`, and `ignorePatterns`.
|
||||
* @param {string} [options.name] The config name.
|
||||
* @throws {Error} If the config file is invalid.
|
||||
* @returns {ConfigArray} Loaded config. An empty `ConfigArray` if any config doesn't exist.
|
||||
*/
|
||||
loadInDirectory(directoryPath, { basePath, name } = {}) {
|
||||
|
@ -3044,7 +2941,6 @@ class ConfigArrayFactory {
|
|||
/**
|
||||
* Load `.eslintignore` file in the current working directory.
|
||||
* @returns {ConfigArray} Loaded config. An empty `ConfigArray` if any config doesn't exist.
|
||||
* @throws {Error} If the ignore file is invalid.
|
||||
*/
|
||||
loadDefaultESLintIgnore() {
|
||||
const slots = internalSlotsMap$1.get(this);
|
||||
|
@ -3057,7 +2953,7 @@ class ConfigArrayFactory {
|
|||
if (fs__default["default"].existsSync(packageJsonPath)) {
|
||||
const data = loadJSONConfigFile(packageJsonPath);
|
||||
|
||||
if (Object.hasOwn(data, "eslintIgnore")) {
|
||||
if (Object.hasOwnProperty.call(data, "eslintIgnore")) {
|
||||
if (!Array.isArray(data.eslintIgnore)) {
|
||||
throw new Error("Package.json eslintIgnore property requires an array of paths");
|
||||
}
|
||||
|
@ -3246,7 +3142,6 @@ class ConfigArrayFactory {
|
|||
* @param {string} extendName The name of a base config.
|
||||
* @param {ConfigArrayFactoryLoadingContext} ctx The loading context.
|
||||
* @returns {IterableIterator<ConfigArrayElement>} The normalized config.
|
||||
* @throws {Error} If the extended config file can't be loaded.
|
||||
* @private
|
||||
*/
|
||||
_loadExtends(extendName, ctx) {
|
||||
|
@ -3270,7 +3165,6 @@ class ConfigArrayFactory {
|
|||
* @param {string} extendName The name of a base config.
|
||||
* @param {ConfigArrayFactoryLoadingContext} ctx The loading context.
|
||||
* @returns {IterableIterator<ConfigArrayElement>} The normalized config.
|
||||
* @throws {Error} If the extended config file can't be loaded.
|
||||
* @private
|
||||
*/
|
||||
_loadExtendedBuiltInConfig(extendName, ctx) {
|
||||
|
@ -3320,7 +3214,6 @@ class ConfigArrayFactory {
|
|||
* @param {string} extendName The name of a base config.
|
||||
* @param {ConfigArrayFactoryLoadingContext} ctx The loading context.
|
||||
* @returns {IterableIterator<ConfigArrayElement>} The normalized config.
|
||||
* @throws {Error} If the extended config file can't be loaded.
|
||||
* @private
|
||||
*/
|
||||
_loadExtendedPluginConfig(extendName, ctx) {
|
||||
|
@ -3358,7 +3251,6 @@ class ConfigArrayFactory {
|
|||
* @param {string} extendName The name of a base config.
|
||||
* @param {ConfigArrayFactoryLoadingContext} ctx The loading context.
|
||||
* @returns {IterableIterator<ConfigArrayElement>} The normalized config.
|
||||
* @throws {Error} If the extended config file can't be loaded.
|
||||
* @private
|
||||
*/
|
||||
_loadExtendedShareableConfig(extendName, ctx) {
|
||||
|
@ -3780,7 +3672,7 @@ function createCLIConfigArray({
|
|||
*/
|
||||
class ConfigurationNotFoundError extends Error {
|
||||
|
||||
|
||||
// eslint-disable-next-line jsdoc/require-description
|
||||
/**
|
||||
* @param {string} directoryPath The directory path.
|
||||
*/
|
||||
|
@ -3932,7 +3824,6 @@ class CascadingConfigArrayFactory {
|
|||
* @param {string} directoryPath The path to a leaf directory.
|
||||
* @param {boolean} configsExistInSubdirs `true` if configurations exist in subdirectories.
|
||||
* @returns {ConfigArray} The loaded config.
|
||||
* @throws {Error} If a config file is invalid.
|
||||
* @private
|
||||
*/
|
||||
_loadConfigInAncestors(directoryPath, configsExistInSubdirs = false) {
|
||||
|
@ -4034,7 +3925,6 @@ class CascadingConfigArrayFactory {
|
|||
* @param {string} directoryPath The path to the leaf directory to find config files.
|
||||
* @param {boolean} ignoreNotFoundError If `true` then it doesn't throw `ConfigurationNotFoundError`.
|
||||
* @returns {ConfigArray} The loaded config.
|
||||
* @throws {Error} If a config file is invalid.
|
||||
* @private
|
||||
*/
|
||||
_finalizeConfigArray(configArray, directoryPath, ignoreNotFoundError) {
|
||||
|
@ -4071,7 +3961,7 @@ class CascadingConfigArrayFactory {
|
|||
!directoryPath.startsWith(homePath)
|
||||
) {
|
||||
const lastElement =
|
||||
personalConfigArray.at(-1);
|
||||
personalConfigArray[personalConfigArray.length - 1];
|
||||
|
||||
emitDeprecationWarning(
|
||||
lastElement.filePath,
|
||||
|
@ -4143,7 +4033,6 @@ const cafactory = Symbol("cafactory");
|
|||
* @param {ReadOnlyMap<string,Processor>} options.pluginProcessors A map of plugin processor
|
||||
* names to objects.
|
||||
* @returns {Object} A flag-config-style config object.
|
||||
* @throws {Error} If a plugin or environment cannot be resolved.
|
||||
*/
|
||||
function translateESLintRC(eslintrcConfig, {
|
||||
resolveConfigRelativeTo,
|
||||
|
@ -4326,7 +4215,7 @@ class FlatCompat {
|
|||
this[cafactory] = new ConfigArrayFactory({
|
||||
cwd: baseDirectory,
|
||||
resolvePluginsRelativeTo,
|
||||
getEslintAllConfig() {
|
||||
getEslintAllConfig: () => {
|
||||
|
||||
if (!allConfig) {
|
||||
throw new TypeError("Missing parameter 'allConfig' in FlatCompat constructor.");
|
||||
|
@ -4334,7 +4223,7 @@ class FlatCompat {
|
|||
|
||||
return allConfig;
|
||||
},
|
||||
getEslintRecommendedConfig() {
|
||||
getEslintRecommendedConfig: () => {
|
||||
|
||||
if (!recommendedConfig) {
|
||||
throw new TypeError("Missing parameter 'recommendedConfig' in FlatCompat constructor.");
|
||||
|
@ -4442,7 +4331,6 @@ const Legacy = {
|
|||
OverrideTester,
|
||||
getUsedExtractedConfigs,
|
||||
environments,
|
||||
loadConfigFile,
|
||||
|
||||
// shared
|
||||
ConfigOps,
|
||||
|
|
2
node_modules/@eslint/eslintrc/dist/eslintrc.cjs.map
generated
vendored
2
node_modules/@eslint/eslintrc/dist/eslintrc.cjs.map
generated
vendored
File diff suppressed because one or more lines are too long
76
node_modules/@eslint/eslintrc/dist/eslintrc.d.cts
generated
vendored
76
node_modules/@eslint/eslintrc/dist/eslintrc.d.cts
generated
vendored
|
@ -1,76 +0,0 @@
|
|||
/**
|
||||
* @fileoverview This file contains the core types for ESLint. It was initially extracted
|
||||
* from the `@types/eslint__eslintrc` package.
|
||||
*/
|
||||
|
||||
/*
|
||||
* MIT License
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE
|
||||
*/
|
||||
|
||||
import type { Linter } from "eslint";
|
||||
|
||||
/**
|
||||
* A compatibility class for working with configs.
|
||||
*/
|
||||
export class FlatCompat {
|
||||
constructor({
|
||||
baseDirectory,
|
||||
resolvePluginsRelativeTo,
|
||||
recommendedConfig,
|
||||
allConfig,
|
||||
}?: {
|
||||
/**
|
||||
* default: process.cwd()
|
||||
*/
|
||||
baseDirectory?: string;
|
||||
resolvePluginsRelativeTo?: string;
|
||||
recommendedConfig?: Linter.LegacyConfig;
|
||||
allConfig?: Linter.LegacyConfig;
|
||||
});
|
||||
|
||||
/**
|
||||
* Translates an ESLintRC-style config into a flag-config-style config.
|
||||
* @param eslintrcConfig The ESLintRC-style config object.
|
||||
* @returns A flag-config-style config object.
|
||||
*/
|
||||
config(eslintrcConfig: Linter.LegacyConfig): Linter.Config[];
|
||||
|
||||
/**
|
||||
* Translates the `env` section of an ESLintRC-style config.
|
||||
* @param envConfig The `env` section of an ESLintRC config.
|
||||
* @returns An array of flag-config objects representing the environments.
|
||||
*/
|
||||
env(envConfig: { [name: string]: boolean }): Linter.Config[];
|
||||
|
||||
/**
|
||||
* Translates the `extends` section of an ESLintRC-style config.
|
||||
* @param configsToExtend The names of the configs to load.
|
||||
* @returns An array of flag-config objects representing the config.
|
||||
*/
|
||||
extends(...configsToExtend: string[]): Linter.Config[];
|
||||
|
||||
/**
|
||||
* Translates the `plugins` section of an ESLintRC-style config.
|
||||
* @param plugins The names of the plugins to load.
|
||||
* @returns An array of flag-config objects representing the plugins.
|
||||
*/
|
||||
plugins(...plugins: string[]): Linter.Config[];
|
||||
}
|
10
node_modules/@eslint/eslintrc/lib/cascading-config-array-factory.js
generated
vendored
10
node_modules/@eslint/eslintrc/lib/cascading-config-array-factory.js
generated
vendored
|
@ -23,8 +23,8 @@
|
|||
//------------------------------------------------------------------------------
|
||||
|
||||
import debugOrig from "debug";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import os from "os";
|
||||
import path from "path";
|
||||
|
||||
import { ConfigArrayFactory } from "./config-array-factory.js";
|
||||
import {
|
||||
|
@ -193,7 +193,7 @@ function createCLIConfigArray({
|
|||
*/
|
||||
class ConfigurationNotFoundError extends Error {
|
||||
|
||||
|
||||
// eslint-disable-next-line jsdoc/require-description
|
||||
/**
|
||||
* @param {string} directoryPath The directory path.
|
||||
*/
|
||||
|
@ -345,7 +345,6 @@ class CascadingConfigArrayFactory {
|
|||
* @param {string} directoryPath The path to a leaf directory.
|
||||
* @param {boolean} configsExistInSubdirs `true` if configurations exist in subdirectories.
|
||||
* @returns {ConfigArray} The loaded config.
|
||||
* @throws {Error} If a config file is invalid.
|
||||
* @private
|
||||
*/
|
||||
_loadConfigInAncestors(directoryPath, configsExistInSubdirs = false) {
|
||||
|
@ -447,7 +446,6 @@ class CascadingConfigArrayFactory {
|
|||
* @param {string} directoryPath The path to the leaf directory to find config files.
|
||||
* @param {boolean} ignoreNotFoundError If `true` then it doesn't throw `ConfigurationNotFoundError`.
|
||||
* @returns {ConfigArray} The loaded config.
|
||||
* @throws {Error} If a config file is invalid.
|
||||
* @private
|
||||
*/
|
||||
_finalizeConfigArray(configArray, directoryPath, ignoreNotFoundError) {
|
||||
|
@ -484,7 +482,7 @@ class CascadingConfigArrayFactory {
|
|||
!directoryPath.startsWith(homePath)
|
||||
) {
|
||||
const lastElement =
|
||||
personalConfigArray.at(-1);
|
||||
personalConfigArray[personalConfigArray.length - 1];
|
||||
|
||||
emitDeprecationWarning(
|
||||
lastElement.filePath,
|
||||
|
|
25
node_modules/@eslint/eslintrc/lib/config-array-factory.js
generated
vendored
25
node_modules/@eslint/eslintrc/lib/config-array-factory.js
generated
vendored
|
@ -39,10 +39,10 @@
|
|||
//------------------------------------------------------------------------------
|
||||
|
||||
import debugOrig from "debug";
|
||||
import fs from "node:fs";
|
||||
import fs from "fs";
|
||||
import importFresh from "import-fresh";
|
||||
import { createRequire } from "node:module";
|
||||
import path from "node:path";
|
||||
import { createRequire } from "module";
|
||||
import path from "path";
|
||||
import stripComments from "strip-json-comments";
|
||||
|
||||
import {
|
||||
|
@ -254,7 +254,7 @@ function loadPackageJSONConfigFile(filePath) {
|
|||
try {
|
||||
const packageData = loadJSONConfigFile(filePath);
|
||||
|
||||
if (!Object.hasOwn(packageData, "eslintConfig")) {
|
||||
if (!Object.hasOwnProperty.call(packageData, "eslintConfig")) {
|
||||
throw Object.assign(
|
||||
new Error("package.json file doesn't have 'eslintConfig' field."),
|
||||
{ code: "ESLINT_CONFIG_FIELD_NOT_FOUND" }
|
||||
|
@ -273,7 +273,6 @@ function loadPackageJSONConfigFile(filePath) {
|
|||
* Loads a `.eslintignore` from a file.
|
||||
* @param {string} filePath The filename to load.
|
||||
* @returns {string[]} The ignore patterns from the file.
|
||||
* @throws {Error} If the file cannot be read.
|
||||
* @private
|
||||
*/
|
||||
function loadESLintIgnoreFile(filePath) {
|
||||
|
@ -346,7 +345,7 @@ function loadConfigFile(filePath) {
|
|||
function writeDebugLogForLoading(request, relativeTo, filePath) {
|
||||
/* istanbul ignore next */
|
||||
if (debug.enabled) {
|
||||
let nameAndVersion = null; // eslint-disable-line no-useless-assignment -- known bug in the rule
|
||||
let nameAndVersion = null;
|
||||
|
||||
try {
|
||||
const packageJsonPath = ModuleResolver.resolve(
|
||||
|
@ -511,7 +510,6 @@ class ConfigArrayFactory {
|
|||
* @param {Object} [options] The options.
|
||||
* @param {string} [options.basePath] The base path to resolve relative paths in `overrides[].files`, `overrides[].excludedFiles`, and `ignorePatterns`.
|
||||
* @param {string} [options.name] The config name.
|
||||
* @throws {Error} If the config file is invalid.
|
||||
* @returns {ConfigArray} Loaded config. An empty `ConfigArray` if any config doesn't exist.
|
||||
*/
|
||||
loadInDirectory(directoryPath, { basePath, name } = {}) {
|
||||
|
@ -597,7 +595,6 @@ class ConfigArrayFactory {
|
|||
/**
|
||||
* Load `.eslintignore` file in the current working directory.
|
||||
* @returns {ConfigArray} Loaded config. An empty `ConfigArray` if any config doesn't exist.
|
||||
* @throws {Error} If the ignore file is invalid.
|
||||
*/
|
||||
loadDefaultESLintIgnore() {
|
||||
const slots = internalSlotsMap.get(this);
|
||||
|
@ -610,7 +607,7 @@ class ConfigArrayFactory {
|
|||
if (fs.existsSync(packageJsonPath)) {
|
||||
const data = loadJSONConfigFile(packageJsonPath);
|
||||
|
||||
if (Object.hasOwn(data, "eslintIgnore")) {
|
||||
if (Object.hasOwnProperty.call(data, "eslintIgnore")) {
|
||||
if (!Array.isArray(data.eslintIgnore)) {
|
||||
throw new Error("Package.json eslintIgnore property requires an array of paths");
|
||||
}
|
||||
|
@ -799,7 +796,6 @@ class ConfigArrayFactory {
|
|||
* @param {string} extendName The name of a base config.
|
||||
* @param {ConfigArrayFactoryLoadingContext} ctx The loading context.
|
||||
* @returns {IterableIterator<ConfigArrayElement>} The normalized config.
|
||||
* @throws {Error} If the extended config file can't be loaded.
|
||||
* @private
|
||||
*/
|
||||
_loadExtends(extendName, ctx) {
|
||||
|
@ -823,7 +819,6 @@ class ConfigArrayFactory {
|
|||
* @param {string} extendName The name of a base config.
|
||||
* @param {ConfigArrayFactoryLoadingContext} ctx The loading context.
|
||||
* @returns {IterableIterator<ConfigArrayElement>} The normalized config.
|
||||
* @throws {Error} If the extended config file can't be loaded.
|
||||
* @private
|
||||
*/
|
||||
_loadExtendedBuiltInConfig(extendName, ctx) {
|
||||
|
@ -873,7 +868,6 @@ class ConfigArrayFactory {
|
|||
* @param {string} extendName The name of a base config.
|
||||
* @param {ConfigArrayFactoryLoadingContext} ctx The loading context.
|
||||
* @returns {IterableIterator<ConfigArrayElement>} The normalized config.
|
||||
* @throws {Error} If the extended config file can't be loaded.
|
||||
* @private
|
||||
*/
|
||||
_loadExtendedPluginConfig(extendName, ctx) {
|
||||
|
@ -911,7 +905,6 @@ class ConfigArrayFactory {
|
|||
* @param {string} extendName The name of a base config.
|
||||
* @param {ConfigArrayFactoryLoadingContext} ctx The loading context.
|
||||
* @returns {IterableIterator<ConfigArrayElement>} The normalized config.
|
||||
* @throws {Error} If the extended config file can't be loaded.
|
||||
* @private
|
||||
*/
|
||||
_loadExtendedShareableConfig(extendName, ctx) {
|
||||
|
@ -1155,8 +1148,4 @@ class ConfigArrayFactory {
|
|||
}
|
||||
}
|
||||
|
||||
export {
|
||||
ConfigArrayFactory,
|
||||
createContext,
|
||||
loadConfigFile
|
||||
};
|
||||
export { ConfigArrayFactory, createContext };
|
||||
|
|
21
node_modules/@eslint/eslintrc/lib/config-array/config-array.js
generated
vendored
21
node_modules/@eslint/eslintrc/lib/config-array/config-array.js
generated
vendored
|
@ -178,7 +178,6 @@ class PluginConflictError extends Error {
|
|||
* @param {Record<string, DependentPlugin>} target The destination to merge
|
||||
* @param {Record<string, DependentPlugin>|undefined} source The source to merge.
|
||||
* @returns {void}
|
||||
* @throws {PluginConflictError} When a plugin was conflicted.
|
||||
*/
|
||||
function mergePlugins(target, source) {
|
||||
if (!isNonNullObject(source)) {
|
||||
|
@ -259,7 +258,6 @@ function mergeRuleConfigs(target, source) {
|
|||
* @param {ConfigArray} instance The config elements.
|
||||
* @param {number[]} indices The indices to use.
|
||||
* @returns {ExtractedConfig} The extracted config.
|
||||
* @throws {Error} When a plugin is conflicted.
|
||||
*/
|
||||
function createConfig(instance, indices) {
|
||||
const config = new ExtractedConfig();
|
||||
|
@ -321,18 +319,31 @@ function createConfig(instance, indices) {
|
|||
* @param {string} pluginId The plugin ID for prefix.
|
||||
* @param {Record<string,T>} defs The definitions to collect.
|
||||
* @param {Map<string, U>} map The map to output.
|
||||
* @param {function(T): U} [normalize] The normalize function for each value.
|
||||
* @returns {void}
|
||||
*/
|
||||
function collect(pluginId, defs, map) {
|
||||
function collect(pluginId, defs, map, normalize) {
|
||||
if (defs) {
|
||||
const prefix = pluginId && `${pluginId}/`;
|
||||
|
||||
for (const [key, value] of Object.entries(defs)) {
|
||||
map.set(`${prefix}${key}`, value);
|
||||
map.set(
|
||||
`${prefix}${key}`,
|
||||
normalize ? normalize(value) : value
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize a rule definition.
|
||||
* @param {Function|Rule} rule The rule definition to normalize.
|
||||
* @returns {Rule} The normalized rule definition.
|
||||
*/
|
||||
function normalizePluginRule(rule) {
|
||||
return typeof rule === "function" ? { create: rule } : rule;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the mutation methods from a given map.
|
||||
* @param {Map<any, any>} map The map object to delete.
|
||||
|
@ -374,7 +385,7 @@ function initPluginMemberMaps(elements, slots) {
|
|||
|
||||
collect(pluginId, plugin.environments, slots.envMap);
|
||||
collect(pluginId, plugin.processors, slots.processorMap);
|
||||
collect(pluginId, plugin.rules, slots.ruleMap);
|
||||
collect(pluginId, plugin.rules, slots.ruleMap, normalizePluginRule);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
10
node_modules/@eslint/eslintrc/lib/config-array/config-dependency.js
generated
vendored
10
node_modules/@eslint/eslintrc/lib/config-array/config-dependency.js
generated
vendored
|
@ -15,7 +15,7 @@
|
|||
* @author Toru Nagashima <https://github.com/mysticatea>
|
||||
*/
|
||||
|
||||
import util from "node:util";
|
||||
import util from "util";
|
||||
|
||||
/**
|
||||
* The class is to store parsers or plugins.
|
||||
|
@ -88,8 +88,8 @@ class ConfigDependency {
|
|||
this.importerPath = importerPath;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line jsdoc/require-description
|
||||
/**
|
||||
* Converts this instance to a JSON compatible object.
|
||||
* @returns {Object} a JSON compatible object.
|
||||
*/
|
||||
toJSON() {
|
||||
|
@ -103,14 +103,14 @@ class ConfigDependency {
|
|||
return obj;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line jsdoc/require-description
|
||||
/**
|
||||
* Custom inspect method for Node.js `console.log()`.
|
||||
* @returns {Object} an object to display by `console.log()`.
|
||||
*/
|
||||
[util.inspect.custom]() {
|
||||
const {
|
||||
definition: _ignore1, // eslint-disable-line no-unused-vars -- needed to make `obj` correct
|
||||
original: _ignore2, // eslint-disable-line no-unused-vars -- needed to make `obj` correct
|
||||
definition: _ignore1, // eslint-disable-line no-unused-vars
|
||||
original: _ignore2, // eslint-disable-line no-unused-vars
|
||||
...obj
|
||||
} = this;
|
||||
|
||||
|
|
4
node_modules/@eslint/eslintrc/lib/config-array/extracted-config.js
generated
vendored
4
node_modules/@eslint/eslintrc/lib/config-array/extracted-config.js
generated
vendored
|
@ -120,10 +120,10 @@ class ExtractedConfig {
|
|||
*/
|
||||
toCompatibleObjectAsConfigFileContent() {
|
||||
const {
|
||||
/* eslint-disable no-unused-vars -- needed to make `config` correct */
|
||||
/* eslint-disable no-unused-vars */
|
||||
configNameOfNoInlineConfig: _ignore1,
|
||||
processor: _ignore2,
|
||||
/* eslint-enable no-unused-vars -- needed to make `config` correct */
|
||||
/* eslint-enable no-unused-vars */
|
||||
ignores,
|
||||
...config
|
||||
} = this;
|
||||
|
|
11
node_modules/@eslint/eslintrc/lib/config-array/ignore-pattern.js
generated
vendored
11
node_modules/@eslint/eslintrc/lib/config-array/ignore-pattern.js
generated
vendored
|
@ -32,8 +32,8 @@
|
|||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
import assert from "node:assert";
|
||||
import path from "node:path";
|
||||
import assert from "assert";
|
||||
import path from "path";
|
||||
import ignore from "ignore";
|
||||
import debugOrig from "debug";
|
||||
|
||||
|
@ -117,9 +117,6 @@ const DotPatterns = Object.freeze([".*", "!.eslintrc.*", "!../"]);
|
|||
// Public
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Represents a set of glob patterns to ignore against a base path.
|
||||
*/
|
||||
class IgnorePattern {
|
||||
|
||||
/**
|
||||
|
@ -156,7 +153,9 @@ class IgnorePattern {
|
|||
debug("Create with: %o", ignorePatterns);
|
||||
|
||||
const basePath = getCommonAncestorPath(ignorePatterns.map(p => p.basePath));
|
||||
const patterns = ignorePatterns.flatMap(p => p.getPatternsRelativeTo(basePath));
|
||||
const patterns = [].concat(
|
||||
...ignorePatterns.map(p => p.getPatternsRelativeTo(basePath))
|
||||
);
|
||||
const ig = ignore({ allowRelativePaths: true }).add([...DotPatterns, ...patterns]);
|
||||
const dotIg = ignore({ allowRelativePaths: true }).add(patterns);
|
||||
|
||||
|
|
12
node_modules/@eslint/eslintrc/lib/config-array/override-tester.js
generated
vendored
12
node_modules/@eslint/eslintrc/lib/config-array/override-tester.js
generated
vendored
|
@ -17,9 +17,9 @@
|
|||
* @author Toru Nagashima <https://github.com/mysticatea>
|
||||
*/
|
||||
|
||||
import assert from "node:assert";
|
||||
import path from "node:path";
|
||||
import util from "node:util";
|
||||
import assert from "assert";
|
||||
import path from "path";
|
||||
import util from "util";
|
||||
import minimatch from "minimatch";
|
||||
|
||||
const { Minimatch } = minimatch;
|
||||
|
@ -94,7 +94,6 @@ class OverrideTester {
|
|||
* @param {string|string[]} excludedFiles The glob patterns for excluded files.
|
||||
* @param {string} basePath The path to the base directory to test paths.
|
||||
* @returns {OverrideTester|null} The created instance or `null`.
|
||||
* @throws {Error} When invalid patterns are given.
|
||||
*/
|
||||
static create(files, excludedFiles, basePath) {
|
||||
const includePatterns = normalizePatterns(files);
|
||||
|
@ -184,7 +183,6 @@ class OverrideTester {
|
|||
* Test if a given path is matched or not.
|
||||
* @param {string} filePath The absolute path to the target file.
|
||||
* @returns {boolean} `true` if the path was matched.
|
||||
* @throws {Error} When invalid `filePath` is given.
|
||||
*/
|
||||
test(filePath) {
|
||||
if (typeof filePath !== "string" || !path.isAbsolute(filePath)) {
|
||||
|
@ -198,8 +196,8 @@ class OverrideTester {
|
|||
));
|
||||
}
|
||||
|
||||
// eslint-disable-next-line jsdoc/require-description
|
||||
/**
|
||||
* Converts this instance to a JSON compatible object.
|
||||
* @returns {Object} a JSON compatible object.
|
||||
*/
|
||||
toJSON() {
|
||||
|
@ -215,8 +213,8 @@ class OverrideTester {
|
|||
};
|
||||
}
|
||||
|
||||
// eslint-disable-next-line jsdoc/require-description
|
||||
/**
|
||||
* Custom inspect method for Node.js `console.log()`.
|
||||
* @returns {Object} an object to display by `console.log()`.
|
||||
*/
|
||||
[util.inspect.custom]() {
|
||||
|
|
7
node_modules/@eslint/eslintrc/lib/flat-compat.js
generated
vendored
7
node_modules/@eslint/eslintrc/lib/flat-compat.js
generated
vendored
|
@ -8,7 +8,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
import createDebug from "debug";
|
||||
import path from "node:path";
|
||||
import path from "path";
|
||||
|
||||
import environments from "../conf/environments.js";
|
||||
import { ConfigArrayFactory } from "./config-array-factory.js";
|
||||
|
@ -37,7 +37,6 @@ const cafactory = Symbol("cafactory");
|
|||
* @param {ReadOnlyMap<string,Processor>} options.pluginProcessors A map of plugin processor
|
||||
* names to objects.
|
||||
* @returns {Object} A flag-config-style config object.
|
||||
* @throws {Error} If a plugin or environment cannot be resolved.
|
||||
*/
|
||||
function translateESLintRC(eslintrcConfig, {
|
||||
resolveConfigRelativeTo,
|
||||
|
@ -220,7 +219,7 @@ class FlatCompat {
|
|||
this[cafactory] = new ConfigArrayFactory({
|
||||
cwd: baseDirectory,
|
||||
resolvePluginsRelativeTo,
|
||||
getEslintAllConfig() {
|
||||
getEslintAllConfig: () => {
|
||||
|
||||
if (!allConfig) {
|
||||
throw new TypeError("Missing parameter 'allConfig' in FlatCompat constructor.");
|
||||
|
@ -228,7 +227,7 @@ class FlatCompat {
|
|||
|
||||
return allConfig;
|
||||
},
|
||||
getEslintRecommendedConfig() {
|
||||
getEslintRecommendedConfig: () => {
|
||||
|
||||
if (!recommendedConfig) {
|
||||
throw new TypeError("Missing parameter 'recommendedConfig' in FlatCompat constructor.");
|
||||
|
|
4
node_modules/@eslint/eslintrc/lib/index.js
generated
vendored
4
node_modules/@eslint/eslintrc/lib/index.js
generated
vendored
|
@ -8,8 +8,7 @@
|
|||
|
||||
import {
|
||||
ConfigArrayFactory,
|
||||
createContext as createConfigArrayFactoryContext,
|
||||
loadConfigFile
|
||||
createContext as createConfigArrayFactoryContext
|
||||
} from "./config-array-factory.js";
|
||||
|
||||
import { CascadingConfigArrayFactory } from "./cascading-config-array-factory.js";
|
||||
|
@ -40,7 +39,6 @@ const Legacy = {
|
|||
OverrideTester,
|
||||
getUsedExtractedConfigs,
|
||||
environments,
|
||||
loadConfigFile,
|
||||
|
||||
// shared
|
||||
ConfigOps,
|
||||
|
|
2
node_modules/@eslint/eslintrc/lib/shared/ajv.js
generated
vendored
2
node_modules/@eslint/eslintrc/lib/shared/ajv.js
generated
vendored
|
@ -184,7 +184,7 @@ export default (additionalOptions = {}) => {
|
|||
});
|
||||
|
||||
ajv.addMetaSchema(metaSchema);
|
||||
// eslint-disable-next-line no-underscore-dangle -- part of the API
|
||||
// eslint-disable-next-line no-underscore-dangle
|
||||
ajv._opts.defaultMeta = metaSchema.id;
|
||||
|
||||
return ajv;
|
||||
|
|
4
node_modules/@eslint/eslintrc/lib/shared/config-ops.js
generated
vendored
4
node_modules/@eslint/eslintrc/lib/shared/config-ops.js
generated
vendored
|
@ -13,7 +13,7 @@ const RULE_SEVERITY_STRINGS = ["off", "warn", "error"],
|
|||
map[value] = index;
|
||||
return map;
|
||||
}, {}),
|
||||
VALID_SEVERITIES = new Set([0, 1, 2, "off", "warn", "error"]);
|
||||
VALID_SEVERITIES = [0, 1, 2, "off", "warn", "error"];
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Public Interface
|
||||
|
@ -83,7 +83,7 @@ function isValidSeverity(ruleConfig) {
|
|||
if (typeof severity === "string") {
|
||||
severity = severity.toLowerCase();
|
||||
}
|
||||
return VALID_SEVERITIES.has(severity);
|
||||
return VALID_SEVERITIES.indexOf(severity) !== -1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
112
node_modules/@eslint/eslintrc/lib/shared/config-validator.js
generated
vendored
112
node_modules/@eslint/eslintrc/lib/shared/config-validator.js
generated
vendored
|
@ -3,23 +3,16 @@
|
|||
* @author Brandon Mills
|
||||
*/
|
||||
|
||||
/* eslint class-methods-use-this: "off" -- not needed in this file */
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Typedefs
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @typedef {import("../shared/types").Rule} Rule */
|
||||
/* eslint class-methods-use-this: "off" */
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
import util from "node:util";
|
||||
import util from "util";
|
||||
import * as ConfigOps from "./config-ops.js";
|
||||
import { emitDeprecationWarning } from "./deprecation-warnings.js";
|
||||
import ajvOrig from "./ajv.js";
|
||||
import { deepMergeArrays } from "./deep-merge-arrays.js";
|
||||
import configSchema from "../../conf/config-schema.js";
|
||||
import BuiltInEnvironments from "../../conf/environments.js";
|
||||
|
||||
|
@ -40,20 +33,10 @@ const severityMap = {
|
|||
|
||||
const validated = new WeakSet();
|
||||
|
||||
// JSON schema that disallows passing any options
|
||||
const noOptionsSchema = Object.freeze({
|
||||
type: "array",
|
||||
minItems: 0,
|
||||
maxItems: 0
|
||||
});
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Exports
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Validator for configuration objects.
|
||||
*/
|
||||
export default class ConfigValidator {
|
||||
constructor({ builtInRules = new Map() } = {}) {
|
||||
this.builtInRules = builtInRules;
|
||||
|
@ -61,36 +44,17 @@ export default class ConfigValidator {
|
|||
|
||||
/**
|
||||
* Gets a complete options schema for a rule.
|
||||
* @param {Rule} rule A rule object
|
||||
* @throws {TypeError} If `meta.schema` is specified but is not an array, object or `false`.
|
||||
* @returns {Object|null} JSON Schema for the rule's options.
|
||||
* `null` if rule wasn't passed or its `meta.schema` is `false`.
|
||||
* @param {{create: Function, schema: (Array|null)}} rule A new-style rule object
|
||||
* @returns {Object} JSON Schema for the rule's options.
|
||||
*/
|
||||
getRuleOptionsSchema(rule) {
|
||||
if (!rule) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!rule.meta) {
|
||||
return { ...noOptionsSchema }; // default if `meta.schema` is not specified
|
||||
}
|
||||
const schema = rule.schema || rule.meta && rule.meta.schema;
|
||||
|
||||
const schema = rule.meta.schema;
|
||||
|
||||
if (typeof schema === "undefined") {
|
||||
return { ...noOptionsSchema }; // default if `meta.schema` is not specified
|
||||
}
|
||||
|
||||
// `schema:false` is an allowed explicit opt-out of options validation for the rule
|
||||
if (schema === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (typeof schema !== "object" || schema === null) {
|
||||
throw new TypeError("Rule's `meta.schema` must be an array or object");
|
||||
}
|
||||
|
||||
// ESLint-specific array form needs to be converted into a valid JSON Schema definition
|
||||
// Given a tuple of schemas, insert warning level at the beginning
|
||||
if (Array.isArray(schema)) {
|
||||
if (schema.length) {
|
||||
return {
|
||||
|
@ -100,20 +64,22 @@ export default class ConfigValidator {
|
|||
maxItems: schema.length
|
||||
};
|
||||
}
|
||||
return {
|
||||
type: "array",
|
||||
minItems: 0,
|
||||
maxItems: 0
|
||||
};
|
||||
|
||||
// `schema:[]` is an explicit way to specify that the rule does not accept any options
|
||||
return { ...noOptionsSchema };
|
||||
}
|
||||
|
||||
// `schema:<object>` is assumed to be a valid JSON Schema definition
|
||||
return schema;
|
||||
// Given a full schema, leave it alone
|
||||
return schema || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a rule's severity and returns the severity value. Throws an error if the severity is invalid.
|
||||
* @param {options} options The given options for the rule.
|
||||
* @returns {number|string} The rule's severity value
|
||||
* @throws {Error} If the severity is invalid.
|
||||
*/
|
||||
validateRuleSeverity(options) {
|
||||
const severity = Array.isArray(options) ? options[0] : options;
|
||||
|
@ -132,32 +98,20 @@ export default class ConfigValidator {
|
|||
* @param {{create: Function}} rule The rule to validate
|
||||
* @param {Array} localOptions The options for the rule, excluding severity
|
||||
* @returns {void}
|
||||
* @throws {Error} If the options are invalid.
|
||||
*/
|
||||
validateRuleSchema(rule, localOptions) {
|
||||
if (!ruleValidators.has(rule)) {
|
||||
try {
|
||||
const schema = this.getRuleOptionsSchema(rule);
|
||||
const schema = this.getRuleOptionsSchema(rule);
|
||||
|
||||
if (schema) {
|
||||
ruleValidators.set(rule, ajv.compile(schema));
|
||||
}
|
||||
} catch (err) {
|
||||
const errorWithCode = new Error(err.message, { cause: err });
|
||||
|
||||
errorWithCode.code = "ESLINT_INVALID_RULE_OPTIONS_SCHEMA";
|
||||
|
||||
throw errorWithCode;
|
||||
if (schema) {
|
||||
ruleValidators.set(rule, ajv.compile(schema));
|
||||
}
|
||||
}
|
||||
|
||||
const validateRule = ruleValidators.get(rule);
|
||||
|
||||
if (validateRule) {
|
||||
const mergedOptions = deepMergeArrays(rule.meta?.defaultOptions, localOptions);
|
||||
|
||||
validateRule(mergedOptions);
|
||||
|
||||
validateRule(localOptions);
|
||||
if (validateRule.errors) {
|
||||
throw new Error(validateRule.errors.map(
|
||||
error => `\tValue ${JSON.stringify(error.data)} ${error.message}.\n`
|
||||
|
@ -174,7 +128,6 @@ export default class ConfigValidator {
|
|||
* @param {string|null} source The name of the configuration source to report in any errors. If null or undefined,
|
||||
* no source is prepended to the message.
|
||||
* @returns {void}
|
||||
* @throws {Error} If the options are invalid.
|
||||
*/
|
||||
validateRuleOptions(rule, ruleId, options, source = null) {
|
||||
try {
|
||||
|
@ -184,21 +137,13 @@ export default class ConfigValidator {
|
|||
this.validateRuleSchema(rule, Array.isArray(options) ? options.slice(1) : []);
|
||||
}
|
||||
} catch (err) {
|
||||
let enhancedMessage = err.code === "ESLINT_INVALID_RULE_OPTIONS_SCHEMA"
|
||||
? `Error while processing options validation schema of rule '${ruleId}': ${err.message}`
|
||||
: `Configuration for rule "${ruleId}" is invalid:\n${err.message}`;
|
||||
const enhancedMessage = `Configuration for rule "${ruleId}" is invalid:\n${err.message}`;
|
||||
|
||||
if (typeof source === "string") {
|
||||
enhancedMessage = `${source}:\n\t${enhancedMessage}`;
|
||||
throw new Error(`${source}:\n\t${enhancedMessage}`);
|
||||
} else {
|
||||
throw new Error(enhancedMessage);
|
||||
}
|
||||
|
||||
const enhancedError = new Error(enhancedMessage, { cause: err });
|
||||
|
||||
if (err.code) {
|
||||
enhancedError.code = err.code;
|
||||
}
|
||||
|
||||
throw enhancedError;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -206,9 +151,8 @@ export default class ConfigValidator {
|
|||
* Validates an environment object
|
||||
* @param {Object} environment The environment config object to validate.
|
||||
* @param {string} source The name of the configuration source to report in any errors.
|
||||
* @param {(envId:string) => Object} [getAdditionalEnv] A map from strings to loaded environments.
|
||||
* @param {function(envId:string): Object} [getAdditionalEnv] A map from strings to loaded environments.
|
||||
* @returns {void}
|
||||
* @throws {Error} If the environment is invalid.
|
||||
*/
|
||||
validateEnvironment(
|
||||
environment,
|
||||
|
@ -236,7 +180,7 @@ export default class ConfigValidator {
|
|||
* Validates a rules config object
|
||||
* @param {Object} rulesConfig The rules config object to validate.
|
||||
* @param {string} source The name of the configuration source to report in any errors.
|
||||
* @param {(ruleId:string) => Object} getAdditionalRule A map from strings to loaded rules
|
||||
* @param {function(ruleId:string): Object} getAdditionalRule A map from strings to loaded rules
|
||||
* @returns {void}
|
||||
*/
|
||||
validateRules(
|
||||
|
@ -280,9 +224,8 @@ export default class ConfigValidator {
|
|||
* Validate `processor` configuration.
|
||||
* @param {string|undefined} processorName The processor name.
|
||||
* @param {string} source The name of config file.
|
||||
* @param {(id:string) => Processor} getProcessor The getter of defined processors.
|
||||
* @param {function(id:string): Processor} getProcessor The getter of defined processors.
|
||||
* @returns {void}
|
||||
* @throws {Error} If the processor is invalid.
|
||||
*/
|
||||
validateProcessor(processorName, source, getProcessor) {
|
||||
if (processorName && !getProcessor(processorName)) {
|
||||
|
@ -321,7 +264,6 @@ export default class ConfigValidator {
|
|||
* @param {Object} config The config object to validate.
|
||||
* @param {string} source The name of the configuration source to report in any errors.
|
||||
* @returns {void}
|
||||
* @throws {Error} If the config is invalid.
|
||||
*/
|
||||
validateConfigSchema(config, source = null) {
|
||||
validateSchema = validateSchema || ajv.compile(configSchema);
|
||||
|
@ -330,7 +272,7 @@ export default class ConfigValidator {
|
|||
throw new Error(`ESLint configuration in ${source} is invalid:\n${this.formatErrors(validateSchema.errors)}`);
|
||||
}
|
||||
|
||||
if (Object.hasOwn(config, "ecmaFeatures")) {
|
||||
if (Object.hasOwnProperty.call(config, "ecmaFeatures")) {
|
||||
emitDeprecationWarning(source, "ESLINT_LEGACY_ECMAFEATURES");
|
||||
}
|
||||
}
|
||||
|
@ -339,8 +281,8 @@ export default class ConfigValidator {
|
|||
* Validates an entire config object.
|
||||
* @param {Object} config The config object to validate.
|
||||
* @param {string} source The name of the configuration source to report in any errors.
|
||||
* @param {(ruleId:string) => Object} [getAdditionalRule] A map from strings to loaded rules.
|
||||
* @param {(envId:string) => Object} [getAdditionalEnv] A map from strings to loaded envs.
|
||||
* @param {function(ruleId:string): Object} [getAdditionalRule] A map from strings to loaded rules.
|
||||
* @param {function(envId:string): Object} [getAdditionalEnv] A map from strings to loaded envs.
|
||||
* @returns {void}
|
||||
*/
|
||||
validate(config, source, getAdditionalRule, getAdditionalEnv) {
|
||||
|
|
58
node_modules/@eslint/eslintrc/lib/shared/deep-merge-arrays.js
generated
vendored
58
node_modules/@eslint/eslintrc/lib/shared/deep-merge-arrays.js
generated
vendored
|
@ -1,58 +0,0 @@
|
|||
/**
|
||||
* @fileoverview Applies default rule options
|
||||
* @author JoshuaKGoldberg
|
||||
*/
|
||||
|
||||
/**
|
||||
* Check if the variable contains an object strictly rejecting arrays
|
||||
* @param {unknown} value an object
|
||||
* @returns {boolean} Whether value is an object
|
||||
*/
|
||||
function isObjectNotArray(value) {
|
||||
return typeof value === "object" && value !== null && !Array.isArray(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deeply merges second on top of first, creating a new {} object if needed.
|
||||
* @param {T} first Base, default value.
|
||||
* @param {U} second User-specified value.
|
||||
* @returns {T | U | (T & U)} Merged equivalent of second on top of first.
|
||||
*/
|
||||
function deepMergeObjects(first, second) {
|
||||
if (second === void 0) {
|
||||
return first;
|
||||
}
|
||||
|
||||
if (!isObjectNotArray(first) || !isObjectNotArray(second)) {
|
||||
return second;
|
||||
}
|
||||
|
||||
const result = { ...first, ...second };
|
||||
|
||||
for (const key of Object.keys(second)) {
|
||||
if (Object.prototype.propertyIsEnumerable.call(first, key)) {
|
||||
result[key] = deepMergeObjects(first[key], second[key]);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deeply merges second on top of first, creating a new [] array if needed.
|
||||
* @param {T[] | undefined} first Base, default values.
|
||||
* @param {U[] | undefined} second User-specified values.
|
||||
* @returns {(T | U | (T & U))[]} Merged equivalent of second on top of first.
|
||||
*/
|
||||
function deepMergeArrays(first, second) {
|
||||
if (!first || !second) {
|
||||
return second || first || [];
|
||||
}
|
||||
|
||||
return [
|
||||
...first.map((value, i) => deepMergeObjects(value, second[i])),
|
||||
...second.slice(first.length)
|
||||
];
|
||||
}
|
||||
|
||||
export { deepMergeArrays };
|
2
node_modules/@eslint/eslintrc/lib/shared/deprecation-warnings.js
generated
vendored
2
node_modules/@eslint/eslintrc/lib/shared/deprecation-warnings.js
generated
vendored
|
@ -7,7 +7,7 @@
|
|||
// Requirements
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
import path from "node:path";
|
||||
import path from "path";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Private
|
||||
|
|
3
node_modules/@eslint/eslintrc/lib/shared/relative-module-resolver.js
generated
vendored
3
node_modules/@eslint/eslintrc/lib/shared/relative-module-resolver.js
generated
vendored
|
@ -3,7 +3,7 @@
|
|||
* @author Teddy Katz
|
||||
*/
|
||||
|
||||
import Module from "node:module";
|
||||
import Module from "module";
|
||||
|
||||
/*
|
||||
* `Module.createRequire` is added in v12.2.0. It supports URL as well.
|
||||
|
@ -17,7 +17,6 @@ const createRequire = Module.createRequire;
|
|||
* @param {string} relativeToPath An absolute path indicating the module that `moduleName` should be resolved relative to. This must be
|
||||
* a file rather than a directory, but the file need not actually exist.
|
||||
* @returns {string} The absolute path that would result from calling `require.resolve(moduleName)` in a file located at `relativeToPath`
|
||||
* @throws {Error} When the module cannot be resolved.
|
||||
*/
|
||||
function resolve(moduleName, relativeToPath) {
|
||||
try {
|
||||
|
|
76
node_modules/@eslint/eslintrc/lib/types/index.d.ts
generated
vendored
76
node_modules/@eslint/eslintrc/lib/types/index.d.ts
generated
vendored
|
@ -1,76 +0,0 @@
|
|||
/**
|
||||
* @fileoverview This file contains the core types for ESLint. It was initially extracted
|
||||
* from the `@types/eslint__eslintrc` package.
|
||||
*/
|
||||
|
||||
/*
|
||||
* MIT License
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE
|
||||
*/
|
||||
|
||||
import type { Linter } from "eslint";
|
||||
|
||||
/**
|
||||
* A compatibility class for working with configs.
|
||||
*/
|
||||
export class FlatCompat {
|
||||
constructor({
|
||||
baseDirectory,
|
||||
resolvePluginsRelativeTo,
|
||||
recommendedConfig,
|
||||
allConfig,
|
||||
}?: {
|
||||
/**
|
||||
* default: process.cwd()
|
||||
*/
|
||||
baseDirectory?: string;
|
||||
resolvePluginsRelativeTo?: string;
|
||||
recommendedConfig?: Linter.LegacyConfig;
|
||||
allConfig?: Linter.LegacyConfig;
|
||||
});
|
||||
|
||||
/**
|
||||
* Translates an ESLintRC-style config into a flag-config-style config.
|
||||
* @param eslintrcConfig The ESLintRC-style config object.
|
||||
* @returns A flag-config-style config object.
|
||||
*/
|
||||
config(eslintrcConfig: Linter.LegacyConfig): Linter.Config[];
|
||||
|
||||
/**
|
||||
* Translates the `env` section of an ESLintRC-style config.
|
||||
* @param envConfig The `env` section of an ESLintRC config.
|
||||
* @returns An array of flag-config objects representing the environments.
|
||||
*/
|
||||
env(envConfig: { [name: string]: boolean }): Linter.Config[];
|
||||
|
||||
/**
|
||||
* Translates the `extends` section of an ESLintRC-style config.
|
||||
* @param configsToExtend The names of the configs to load.
|
||||
* @returns An array of flag-config objects representing the config.
|
||||
*/
|
||||
extends(...configsToExtend: string[]): Linter.Config[];
|
||||
|
||||
/**
|
||||
* Translates the `plugins` section of an ESLintRC-style config.
|
||||
* @param plugins The names of the plugins to load.
|
||||
* @returns An array of flag-config objects representing the plugins.
|
||||
*/
|
||||
plugins(...plugins: string[]): Linter.Config[];
|
||||
}
|
28
node_modules/@eslint/eslintrc/package.json
generated
vendored
28
node_modules/@eslint/eslintrc/package.json
generated
vendored
|
@ -1,15 +1,13 @@
|
|||
{
|
||||
"name": "@eslint/eslintrc",
|
||||
"version": "3.3.1",
|
||||
"version": "2.1.4",
|
||||
"description": "The legacy ESLintRC config file format for ESLint",
|
||||
"type": "module",
|
||||
"main": "./dist/eslintrc.cjs",
|
||||
"types": "./dist/eslintrc.d.cts",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./lib/index.js",
|
||||
"require": "./dist/eslintrc.cjs",
|
||||
"types": "./lib/types/index.d.ts"
|
||||
"require": "./dist/eslintrc.cjs"
|
||||
},
|
||||
"./package.json": "./package.json",
|
||||
"./universal": {
|
||||
|
@ -28,7 +26,7 @@
|
|||
"access": "public"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rollup -c && node -e \"fs.copyFileSync('./lib/types/index.d.ts', './dist/eslintrc.d.cts')\"",
|
||||
"build": "rollup -c",
|
||||
"lint": "eslint . --report-unused-disable-directives",
|
||||
"lint:fix": "npm run lint -- --fix",
|
||||
"prepare": "npm run build",
|
||||
|
@ -37,8 +35,7 @@
|
|||
"release:generate:beta": "eslint-generate-prerelease beta",
|
||||
"release:generate:rc": "eslint-generate-prerelease rc",
|
||||
"release:publish": "eslint-publish-release",
|
||||
"test": "mocha -R progress -c 'tests/lib/*.cjs' && c8 mocha -R progress -c 'tests/lib/**/*.js'",
|
||||
"test:types": "tsc -p tests/lib/types/tsconfig.json"
|
||||
"test": "mocha -R progress -c 'tests/lib/*.cjs' && c8 mocha -R progress -c 'tests/lib/**/*.js'"
|
||||
},
|
||||
"repository": "eslint/eslintrc",
|
||||
"funding": "https://opencollective.com/eslint",
|
||||
|
@ -56,22 +53,23 @@
|
|||
"devDependencies": {
|
||||
"c8": "^7.7.3",
|
||||
"chai": "^4.3.4",
|
||||
"eslint": "^9.20.1",
|
||||
"eslint-config-eslint": "^11.0.0",
|
||||
"eslint": "^7.31.0",
|
||||
"eslint-config-eslint": "^7.0.0",
|
||||
"eslint-plugin-jsdoc": "^35.4.1",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"eslint-release": "^3.2.0",
|
||||
"fs-teardown": "^0.1.3",
|
||||
"mocha": "^9.0.3",
|
||||
"rollup": "^2.70.1",
|
||||
"shelljs": "^0.8.5",
|
||||
"shelljs": "^0.8.4",
|
||||
"sinon": "^11.1.2",
|
||||
"temp-dir": "^2.0.0",
|
||||
"typescript": "^5.7.3"
|
||||
"temp-dir": "^2.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"ajv": "^6.12.4",
|
||||
"debug": "^4.3.2",
|
||||
"espree": "^10.0.1",
|
||||
"globals": "^14.0.0",
|
||||
"espree": "^9.6.0",
|
||||
"globals": "^13.19.0",
|
||||
"ignore": "^5.2.0",
|
||||
"import-fresh": "^3.2.1",
|
||||
"js-yaml": "^4.1.0",
|
||||
|
@ -79,6 +77,6 @@
|
|||
"strip-json-comments": "^3.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
||||
}
|
||||
}
|
||||
|
|
3
node_modules/@eslint/eslintrc/universal.js
generated
vendored
3
node_modules/@eslint/eslintrc/universal.js
generated
vendored
|
@ -1,5 +1,3 @@
|
|||
/* global module, require -- required for CJS file */
|
||||
|
||||
// Jest (and probably some other runtimes with custom implementations of
|
||||
// `require`) doesn't support `exports` in `package.json`, so this file is here
|
||||
// to help them load this module. Note that it is also `.js` and not `.cjs` for
|
||||
|
@ -7,4 +5,5 @@
|
|||
// since Jest doesn't respect `module` outside of ESM mode it still works in
|
||||
// this case (and the `require` in _this_ file does specify the extension).
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
module.exports = require("./dist/eslintrc-universal.cjs");
|
||||
|
|
64
node_modules/@eslint/js/README.md
generated
vendored
64
node_modules/@eslint/js/README.md
generated
vendored
|
@ -8,8 +8,8 @@ The beginnings of separating out JavaScript-specific functionality from ESLint.
|
|||
|
||||
Right now, this plugin contains two configurations:
|
||||
|
||||
- `recommended` - enables the rules recommended by the ESLint team (the replacement for `"eslint:recommended"`)
|
||||
- `all` - enables all ESLint rules (the replacement for `"eslint:all"`)
|
||||
* `recommended` - enables the rules recommended by the ESLint team (the replacement for `"eslint:recommended"`)
|
||||
* `all` - enables all ESLint rules (the replacement for `"eslint:all"`)
|
||||
|
||||
## Installation
|
||||
|
||||
|
@ -22,46 +22,34 @@ npm install @eslint/js -D
|
|||
Use in your `eslint.config.js` file anytime you want to extend one of the configs:
|
||||
|
||||
```js
|
||||
import { defineConfig } from "eslint/config";
|
||||
import js from "@eslint/js";
|
||||
|
||||
export default defineConfig([
|
||||
// apply recommended rules to JS files
|
||||
{
|
||||
name: "your-project/recommended-rules",
|
||||
files: ["**/*.js"],
|
||||
plugins: {
|
||||
js,
|
||||
},
|
||||
extends: ["js/recommended"],
|
||||
},
|
||||
export default [
|
||||
|
||||
// apply recommended rules to JS files with an override
|
||||
{
|
||||
name: "your-project/recommended-rules-with-override",
|
||||
files: ["**/*.js"],
|
||||
plugins: {
|
||||
js,
|
||||
},
|
||||
extends: ["js/recommended"],
|
||||
rules: {
|
||||
"no-unused-vars": "warn",
|
||||
},
|
||||
},
|
||||
// apply recommended rules to JS files
|
||||
{
|
||||
files: ["**/*.js"],
|
||||
rules: js.configs.recommended.rules
|
||||
},
|
||||
|
||||
// apply all rules to JS files
|
||||
{
|
||||
name: "your-project/all-rules",
|
||||
files: ["**/*.js"],
|
||||
plugins: {
|
||||
js,
|
||||
},
|
||||
extends: ["js/all"],
|
||||
rules: {
|
||||
"no-unused-vars": "warn",
|
||||
},
|
||||
},
|
||||
]);
|
||||
// apply recommended rules to JS files with an override
|
||||
{
|
||||
files: ["**/*.js"],
|
||||
rules: {
|
||||
...js.configs.recommended.rules,
|
||||
"no-unused-vars": "warn"
|
||||
}
|
||||
},
|
||||
|
||||
// apply all rules to JS files
|
||||
{
|
||||
files: ["**/*.js"],
|
||||
rules: {
|
||||
...js.configs.all.rules,
|
||||
"no-unused-vars": "warn"
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## License
|
||||
|
|
13
node_modules/@eslint/js/package.json
generated
vendored
13
node_modules/@eslint/js/package.json
generated
vendored
|
@ -1,18 +1,13 @@
|
|||
{
|
||||
"name": "@eslint/js",
|
||||
"version": "9.33.0",
|
||||
"version": "8.57.1",
|
||||
"description": "ESLint JavaScript language implementation",
|
||||
"funding": "https://eslint.org/donate",
|
||||
"main": "./src/index.js",
|
||||
"types": "./types/index.d.ts",
|
||||
"scripts": {
|
||||
"test:types": "tsc -p tests/types/tsconfig.json"
|
||||
},
|
||||
"scripts": {},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"README.md",
|
||||
"src",
|
||||
"types"
|
||||
"src"
|
||||
],
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
|
@ -31,6 +26,6 @@
|
|||
],
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
||||
}
|
||||
}
|
||||
|
|
13
node_modules/@eslint/js/src/configs/eslint-all.js
generated
vendored
13
node_modules/@eslint/js/src/configs/eslint-all.js
generated
vendored
|
@ -4,13 +4,7 @@
|
|||
*/
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
* IMPORTANT!
|
||||
*
|
||||
* We cannot add a "name" property to this object because it's still used in eslintrc
|
||||
* which doesn't support the "name" property. If we add a "name" property, it will
|
||||
* cause an error.
|
||||
*/
|
||||
/* eslint quote-props: off -- autogenerated so don't lint */
|
||||
|
||||
module.exports = Object.freeze({
|
||||
"rules": {
|
||||
|
@ -42,6 +36,7 @@ module.exports = Object.freeze({
|
|||
"id-length": "error",
|
||||
"id-match": "error",
|
||||
"init-declarations": "error",
|
||||
"line-comment-position": "error",
|
||||
"logical-assignment-operators": "error",
|
||||
"max-classes-per-file": "error",
|
||||
"max-depth": "error",
|
||||
|
@ -50,6 +45,7 @@ module.exports = Object.freeze({
|
|||
"max-nested-callbacks": "error",
|
||||
"max-params": "error",
|
||||
"max-statements": "error",
|
||||
"multiline-comment-style": "error",
|
||||
"new-cap": "error",
|
||||
"no-alert": "error",
|
||||
"no-array-constructor": "error",
|
||||
|
@ -118,6 +114,7 @@ module.exports = Object.freeze({
|
|||
"no-new": "error",
|
||||
"no-new-func": "error",
|
||||
"no-new-native-nonconstructor": "error",
|
||||
"no-new-symbol": "error",
|
||||
"no-new-wrappers": "error",
|
||||
"no-nonoctal-decimal-escape": "error",
|
||||
"no-obj-calls": "error",
|
||||
|
@ -149,7 +146,6 @@ module.exports = Object.freeze({
|
|||
"no-ternary": "error",
|
||||
"no-this-before-super": "error",
|
||||
"no-throw-literal": "error",
|
||||
"no-unassigned-vars": "error",
|
||||
"no-undef": "error",
|
||||
"no-undef-init": "error",
|
||||
"no-undefined": "error",
|
||||
|
@ -167,7 +163,6 @@ module.exports = Object.freeze({
|
|||
"no-unused-private-class-members": "error",
|
||||
"no-unused-vars": "error",
|
||||
"no-use-before-define": "error",
|
||||
"no-useless-assignment": "error",
|
||||
"no-useless-backreference": "error",
|
||||
"no-useless-call": "error",
|
||||
"no-useless-catch": "error",
|
||||
|
|
135
node_modules/@eslint/js/src/configs/eslint-recommended.js
generated
vendored
135
node_modules/@eslint/js/src/configs/eslint-recommended.js
generated
vendored
|
@ -8,76 +8,69 @@
|
|||
|
||||
/* eslint sort-keys: ["error", "asc"] -- Long, so make more readable */
|
||||
|
||||
/*
|
||||
* IMPORTANT!
|
||||
*
|
||||
* We cannot add a "name" property to this object because it's still used in eslintrc
|
||||
* which doesn't support the "name" property. If we add a "name" property, it will
|
||||
* cause an error.
|
||||
*/
|
||||
|
||||
/** @type {import("../lib/shared/types").ConfigData} */
|
||||
module.exports = Object.freeze({
|
||||
rules: Object.freeze({
|
||||
"constructor-super": "error",
|
||||
"for-direction": "error",
|
||||
"getter-return": "error",
|
||||
"no-async-promise-executor": "error",
|
||||
"no-case-declarations": "error",
|
||||
"no-class-assign": "error",
|
||||
"no-compare-neg-zero": "error",
|
||||
"no-cond-assign": "error",
|
||||
"no-const-assign": "error",
|
||||
"no-constant-binary-expression": "error",
|
||||
"no-constant-condition": "error",
|
||||
"no-control-regex": "error",
|
||||
"no-debugger": "error",
|
||||
"no-delete-var": "error",
|
||||
"no-dupe-args": "error",
|
||||
"no-dupe-class-members": "error",
|
||||
"no-dupe-else-if": "error",
|
||||
"no-dupe-keys": "error",
|
||||
"no-duplicate-case": "error",
|
||||
"no-empty": "error",
|
||||
"no-empty-character-class": "error",
|
||||
"no-empty-pattern": "error",
|
||||
"no-empty-static-block": "error",
|
||||
"no-ex-assign": "error",
|
||||
"no-extra-boolean-cast": "error",
|
||||
"no-fallthrough": "error",
|
||||
"no-func-assign": "error",
|
||||
"no-global-assign": "error",
|
||||
"no-import-assign": "error",
|
||||
"no-invalid-regexp": "error",
|
||||
"no-irregular-whitespace": "error",
|
||||
"no-loss-of-precision": "error",
|
||||
"no-misleading-character-class": "error",
|
||||
"no-new-native-nonconstructor": "error",
|
||||
"no-nonoctal-decimal-escape": "error",
|
||||
"no-obj-calls": "error",
|
||||
"no-octal": "error",
|
||||
"no-prototype-builtins": "error",
|
||||
"no-redeclare": "error",
|
||||
"no-regex-spaces": "error",
|
||||
"no-self-assign": "error",
|
||||
"no-setter-return": "error",
|
||||
"no-shadow-restricted-names": "error",
|
||||
"no-sparse-arrays": "error",
|
||||
"no-this-before-super": "error",
|
||||
"no-undef": "error",
|
||||
"no-unexpected-multiline": "error",
|
||||
"no-unreachable": "error",
|
||||
"no-unsafe-finally": "error",
|
||||
"no-unsafe-negation": "error",
|
||||
"no-unsafe-optional-chaining": "error",
|
||||
"no-unused-labels": "error",
|
||||
"no-unused-private-class-members": "error",
|
||||
"no-unused-vars": "error",
|
||||
"no-useless-backreference": "error",
|
||||
"no-useless-catch": "error",
|
||||
"no-useless-escape": "error",
|
||||
"no-with": "error",
|
||||
"require-yield": "error",
|
||||
"use-isnan": "error",
|
||||
"valid-typeof": "error",
|
||||
}),
|
||||
rules: Object.freeze({
|
||||
"constructor-super": "error",
|
||||
"for-direction": "error",
|
||||
"getter-return": "error",
|
||||
"no-async-promise-executor": "error",
|
||||
"no-case-declarations": "error",
|
||||
"no-class-assign": "error",
|
||||
"no-compare-neg-zero": "error",
|
||||
"no-cond-assign": "error",
|
||||
"no-const-assign": "error",
|
||||
"no-constant-condition": "error",
|
||||
"no-control-regex": "error",
|
||||
"no-debugger": "error",
|
||||
"no-delete-var": "error",
|
||||
"no-dupe-args": "error",
|
||||
"no-dupe-class-members": "error",
|
||||
"no-dupe-else-if": "error",
|
||||
"no-dupe-keys": "error",
|
||||
"no-duplicate-case": "error",
|
||||
"no-empty": "error",
|
||||
"no-empty-character-class": "error",
|
||||
"no-empty-pattern": "error",
|
||||
"no-ex-assign": "error",
|
||||
"no-extra-boolean-cast": "error",
|
||||
"no-extra-semi": "error",
|
||||
"no-fallthrough": "error",
|
||||
"no-func-assign": "error",
|
||||
"no-global-assign": "error",
|
||||
"no-import-assign": "error",
|
||||
"no-inner-declarations": "error",
|
||||
"no-invalid-regexp": "error",
|
||||
"no-irregular-whitespace": "error",
|
||||
"no-loss-of-precision": "error",
|
||||
"no-misleading-character-class": "error",
|
||||
"no-mixed-spaces-and-tabs": "error",
|
||||
"no-new-symbol": "error",
|
||||
"no-nonoctal-decimal-escape": "error",
|
||||
"no-obj-calls": "error",
|
||||
"no-octal": "error",
|
||||
"no-prototype-builtins": "error",
|
||||
"no-redeclare": "error",
|
||||
"no-regex-spaces": "error",
|
||||
"no-self-assign": "error",
|
||||
"no-setter-return": "error",
|
||||
"no-shadow-restricted-names": "error",
|
||||
"no-sparse-arrays": "error",
|
||||
"no-this-before-super": "error",
|
||||
"no-undef": "error",
|
||||
"no-unexpected-multiline": "error",
|
||||
"no-unreachable": "error",
|
||||
"no-unsafe-finally": "error",
|
||||
"no-unsafe-negation": "error",
|
||||
"no-unsafe-optional-chaining": "error",
|
||||
"no-unused-labels": "error",
|
||||
"no-unused-vars": "error",
|
||||
"no-useless-backreference": "error",
|
||||
"no-useless-catch": "error",
|
||||
"no-useless-escape": "error",
|
||||
"no-with": "error",
|
||||
"require-yield": "error",
|
||||
"use-isnan": "error",
|
||||
"valid-typeof": "error"
|
||||
})
|
||||
});
|
||||
|
|
14
node_modules/@eslint/js/src/index.js
generated
vendored
14
node_modules/@eslint/js/src/index.js
generated
vendored
|
@ -5,19 +5,13 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { name, version } = require("../package.json");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Public Interface
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
module.exports = {
|
||||
meta: {
|
||||
name,
|
||||
version,
|
||||
},
|
||||
configs: {
|
||||
all: require("./configs/eslint-all"),
|
||||
recommended: require("./configs/eslint-recommended"),
|
||||
},
|
||||
configs: {
|
||||
all: require("./configs/eslint-all"),
|
||||
recommended: require("./configs/eslint-recommended")
|
||||
}
|
||||
};
|
||||
|
|
14
node_modules/@eslint/js/types/index.d.ts
generated
vendored
14
node_modules/@eslint/js/types/index.d.ts
generated
vendored
|
@ -1,14 +0,0 @@
|
|||
import type { Linter } from "eslint";
|
||||
|
||||
declare const js: {
|
||||
readonly meta: {
|
||||
readonly name: string;
|
||||
readonly version: string;
|
||||
};
|
||||
readonly configs: {
|
||||
readonly recommended: { readonly rules: Readonly<Linter.RulesRecord> };
|
||||
readonly all: { readonly rules: Readonly<Linter.RulesRecord> };
|
||||
};
|
||||
};
|
||||
|
||||
export = js;
|
201
node_modules/@eslint/object-schema/LICENSE
generated
vendored
201
node_modules/@eslint/object-schema/LICENSE
generated
vendored
|
@ -1,201 +0,0 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
242
node_modules/@eslint/object-schema/README.md
generated
vendored
242
node_modules/@eslint/object-schema/README.md
generated
vendored
|
@ -1,242 +0,0 @@
|
|||
# ObjectSchema Package
|
||||
|
||||
## Overview
|
||||
|
||||
A JavaScript object merge/validation utility where you can define a different merge and validation strategy for each key. This is helpful when you need to validate complex data structures and then merge them in a way that is more complex than `Object.assign()`. This is used in the [`@eslint/config-array`](https://npmjs.com/package/@eslint/config-array) package but can also be used on its own.
|
||||
|
||||
## Installation
|
||||
|
||||
For Node.js and compatible runtimes:
|
||||
|
||||
```shell
|
||||
npm install @eslint/object-schema
|
||||
# or
|
||||
yarn add @eslint/object-schema
|
||||
# or
|
||||
pnpm install @eslint/object-schema
|
||||
# or
|
||||
bun install @eslint/object-schema
|
||||
```
|
||||
|
||||
For Deno:
|
||||
|
||||
```shell
|
||||
deno add @eslint/object-schema
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Import the `ObjectSchema` constructor:
|
||||
|
||||
```js
|
||||
// using ESM
|
||||
import { ObjectSchema } from "@eslint/object-schema";
|
||||
|
||||
// using CommonJS
|
||||
const { ObjectSchema } = require("@eslint/object-schema");
|
||||
|
||||
const schema = new ObjectSchema({
|
||||
// define a definition for the "downloads" key
|
||||
downloads: {
|
||||
required: true,
|
||||
merge(value1, value2) {
|
||||
return value1 + value2;
|
||||
},
|
||||
validate(value) {
|
||||
if (typeof value !== "number") {
|
||||
throw new Error("Expected downloads to be a number.");
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
// define a strategy for the "versions" key
|
||||
version: {
|
||||
required: true,
|
||||
merge(value1, value2) {
|
||||
return value1.concat(value2);
|
||||
},
|
||||
validate(value) {
|
||||
if (!Array.isArray(value)) {
|
||||
throw new Error("Expected versions to be an array.");
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const record1 = {
|
||||
downloads: 25,
|
||||
versions: ["v1.0.0", "v1.1.0", "v1.2.0"],
|
||||
};
|
||||
|
||||
const record2 = {
|
||||
downloads: 125,
|
||||
versions: ["v2.0.0", "v2.1.0", "v3.0.0"],
|
||||
};
|
||||
|
||||
// make sure the records are valid
|
||||
schema.validate(record1);
|
||||
schema.validate(record2);
|
||||
|
||||
// merge together (schema.merge() accepts any number of objects)
|
||||
const result = schema.merge(record1, record2);
|
||||
|
||||
// result looks like this:
|
||||
|
||||
const result = {
|
||||
downloads: 75,
|
||||
versions: ["v1.0.0", "v1.1.0", "v1.2.0", "v2.0.0", "v2.1.0", "v3.0.0"],
|
||||
};
|
||||
```
|
||||
|
||||
## Tips and Tricks
|
||||
|
||||
### Named merge strategies
|
||||
|
||||
Instead of specifying a `merge()` method, you can specify one of the following strings to use a default merge strategy:
|
||||
|
||||
- `"assign"` - use `Object.assign()` to merge the two values into one object.
|
||||
- `"overwrite"` - the second value always replaces the first.
|
||||
- `"replace"` - the second value replaces the first if the second is not `undefined`.
|
||||
|
||||
For example:
|
||||
|
||||
```js
|
||||
const schema = new ObjectSchema({
|
||||
name: {
|
||||
merge: "replace",
|
||||
validate() {},
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
### Named validation strategies
|
||||
|
||||
Instead of specifying a `validate()` method, you can specify one of the following strings to use a default validation strategy:
|
||||
|
||||
- `"array"` - value must be an array.
|
||||
- `"boolean"` - value must be a boolean.
|
||||
- `"number"` - value must be a number.
|
||||
- `"object"` - value must be an object.
|
||||
- `"object?"` - value must be an object or null.
|
||||
- `"string"` - value must be a string.
|
||||
- `"string!"` - value must be a non-empty string.
|
||||
|
||||
For example:
|
||||
|
||||
```js
|
||||
const schema = new ObjectSchema({
|
||||
name: {
|
||||
merge: "replace",
|
||||
validate: "string",
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
### Subschemas
|
||||
|
||||
If you are defining a key that is, itself, an object, you can simplify the process by using a subschema. Instead of defining `merge()` and `validate()`, assign a `schema` key that contains a schema definition, like this:
|
||||
|
||||
```js
|
||||
const schema = new ObjectSchema({
|
||||
name: {
|
||||
schema: {
|
||||
first: {
|
||||
merge: "replace",
|
||||
validate: "string",
|
||||
},
|
||||
last: {
|
||||
merge: "replace",
|
||||
validate: "string",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
schema.validate({
|
||||
name: {
|
||||
first: "n",
|
||||
last: "z",
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
### Remove Keys During Merge
|
||||
|
||||
If the merge strategy for a key returns `undefined`, then the key will not appear in the final object. For example:
|
||||
|
||||
```js
|
||||
const schema = new ObjectSchema({
|
||||
date: {
|
||||
merge() {
|
||||
return undefined;
|
||||
},
|
||||
validate(value) {
|
||||
Date.parse(value); // throws an error when invalid
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const object1 = { date: "5/5/2005" };
|
||||
const object2 = { date: "6/6/2006" };
|
||||
|
||||
const result = schema.merge(object1, object2);
|
||||
|
||||
console.log("date" in result); // false
|
||||
```
|
||||
|
||||
### Requiring Another Key Be Present
|
||||
|
||||
If you'd like the presence of one key to require the presence of another key, you can use the `requires` property to specify an array of other properties that any key requires. For example:
|
||||
|
||||
```js
|
||||
const schema = new ObjectSchema();
|
||||
|
||||
const schema = new ObjectSchema({
|
||||
date: {
|
||||
merge() {
|
||||
return undefined;
|
||||
},
|
||||
validate(value) {
|
||||
Date.parse(value); // throws an error when invalid
|
||||
},
|
||||
},
|
||||
time: {
|
||||
requires: ["date"],
|
||||
merge(first, second) {
|
||||
return second;
|
||||
},
|
||||
validate(value) {
|
||||
// ...
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// throws error: Key "time" requires keys "date"
|
||||
schema.validate({
|
||||
time: "13:45",
|
||||
});
|
||||
```
|
||||
|
||||
In this example, even though `date` is an optional key, it is required to be present whenever `time` is present.
|
||||
|
||||
## License
|
||||
|
||||
Apache 2.0
|
||||
|
||||
<!-- NOTE: This section is autogenerated. Do not manually edit.-->
|
||||
<!--sponsorsstart-->
|
||||
|
||||
## Sponsors
|
||||
|
||||
The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://eslint.org/donate)
|
||||
to get your logo on our READMEs and [website](https://eslint.org/sponsors).
|
||||
|
||||
<h3>Platinum Sponsors</h3>
|
||||
<p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="128"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="128"></a></p><h3>Gold Sponsors</h3>
|
||||
<p><a href="https://qlty.sh/"><img src="https://images.opencollective.com/qltysh/33d157d/logo.png" alt="Qlty Software" height="96"></a> <a href="https://trunk.io/"><img src="https://images.opencollective.com/trunkio/fb92d60/avatar.png" alt="trunk.io" height="96"></a></p><h3>Silver Sponsors</h3>
|
||||
<p><a href="https://www.serptriumph.com/"><img src="https://images.opencollective.com/serp-triumph5/fea3074/logo.png" alt="SERP Triumph" height="64"></a> <a href="https://www.jetbrains.com/"><img src="https://images.opencollective.com/jetbrains/fe76f99/logo.png" alt="JetBrains" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a> <a href="https://americanexpress.io"><img src="https://avatars.githubusercontent.com/u/3853301" alt="American Express" height="64"></a></p><h3>Bronze Sponsors</h3>
|
||||
<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://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" 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://nolebase.ayaka.io"><img src="https://avatars.githubusercontent.com/u/11081491" alt="Neko" height="32"></a> <a href="https://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104" alt="Nx" height="32"></a> <a href="https://opensource.mercedes-benz.com/"><img src="https://avatars.githubusercontent.com/u/34240465" alt="Mercedes-Benz Group" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774" alt="HeroCoders" height="32"></a></p>
|
||||
<h3>Technology Sponsors</h3>
|
||||
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.
|
||||
<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>
|
||||
<!--sponsorsend-->
|
455
node_modules/@eslint/object-schema/dist/cjs/index.cjs
generated
vendored
455
node_modules/@eslint/object-schema/dist/cjs/index.cjs
generated
vendored
|
@ -1,455 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
/**
|
||||
* @fileoverview Merge Strategy
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Class
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Container class for several different merge strategies.
|
||||
*/
|
||||
class MergeStrategy {
|
||||
/**
|
||||
* Merges two keys by overwriting the first with the second.
|
||||
* @param {*} value1 The value from the first object key.
|
||||
* @param {*} value2 The value from the second object key.
|
||||
* @returns {*} The second value.
|
||||
*/
|
||||
static overwrite(value1, value2) {
|
||||
return value2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges two keys by replacing the first with the second only if the
|
||||
* second is defined.
|
||||
* @param {*} value1 The value from the first object key.
|
||||
* @param {*} value2 The value from the second object key.
|
||||
* @returns {*} The second value if it is defined.
|
||||
*/
|
||||
static replace(value1, value2) {
|
||||
if (typeof value2 !== "undefined") {
|
||||
return value2;
|
||||
}
|
||||
|
||||
return value1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges two properties by assigning properties from the second to the first.
|
||||
* @param {*} value1 The value from the first object key.
|
||||
* @param {*} value2 The value from the second object key.
|
||||
* @returns {*} A new object containing properties from both value1 and
|
||||
* value2.
|
||||
*/
|
||||
static assign(value1, value2) {
|
||||
return Object.assign({}, value1, value2);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @fileoverview Validation Strategy
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Class
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Container class for several different validation strategies.
|
||||
*/
|
||||
class ValidationStrategy {
|
||||
/**
|
||||
* Validates that a value is an array.
|
||||
* @param {*} value The value to validate.
|
||||
* @returns {void}
|
||||
* @throws {TypeError} If the value is invalid.
|
||||
*/
|
||||
static array(value) {
|
||||
if (!Array.isArray(value)) {
|
||||
throw new TypeError("Expected an array.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates that a value is a boolean.
|
||||
* @param {*} value The value to validate.
|
||||
* @returns {void}
|
||||
* @throws {TypeError} If the value is invalid.
|
||||
*/
|
||||
static boolean(value) {
|
||||
if (typeof value !== "boolean") {
|
||||
throw new TypeError("Expected a Boolean.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates that a value is a number.
|
||||
* @param {*} value The value to validate.
|
||||
* @returns {void}
|
||||
* @throws {TypeError} If the value is invalid.
|
||||
*/
|
||||
static number(value) {
|
||||
if (typeof value !== "number") {
|
||||
throw new TypeError("Expected a number.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates that a value is a object.
|
||||
* @param {*} value The value to validate.
|
||||
* @returns {void}
|
||||
* @throws {TypeError} If the value is invalid.
|
||||
*/
|
||||
static object(value) {
|
||||
if (!value || typeof value !== "object") {
|
||||
throw new TypeError("Expected an object.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates that a value is a object or null.
|
||||
* @param {*} value The value to validate.
|
||||
* @returns {void}
|
||||
* @throws {TypeError} If the value is invalid.
|
||||
*/
|
||||
static "object?"(value) {
|
||||
if (typeof value !== "object") {
|
||||
throw new TypeError("Expected an object or null.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates that a value is a string.
|
||||
* @param {*} value The value to validate.
|
||||
* @returns {void}
|
||||
* @throws {TypeError} If the value is invalid.
|
||||
*/
|
||||
static string(value) {
|
||||
if (typeof value !== "string") {
|
||||
throw new TypeError("Expected a string.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates that a value is a non-empty string.
|
||||
* @param {*} value The value to validate.
|
||||
* @returns {void}
|
||||
* @throws {TypeError} If the value is invalid.
|
||||
*/
|
||||
static "string!"(value) {
|
||||
if (typeof value !== "string" || value.length === 0) {
|
||||
throw new TypeError("Expected a non-empty string.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @fileoverview Object Schema
|
||||
*/
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Types
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/** @typedef {import("./types.ts").ObjectDefinition} ObjectDefinition */
|
||||
/** @typedef {import("./types.ts").PropertyDefinition} PropertyDefinition */
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Private
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Validates a schema strategy.
|
||||
* @param {string} name The name of the key this strategy is for.
|
||||
* @param {PropertyDefinition} definition The strategy for the object key.
|
||||
* @returns {void}
|
||||
* @throws {Error} When the strategy is missing a name.
|
||||
* @throws {Error} When the strategy is missing a merge() method.
|
||||
* @throws {Error} When the strategy is missing a validate() method.
|
||||
*/
|
||||
function validateDefinition(name, definition) {
|
||||
let hasSchema = false;
|
||||
if (definition.schema) {
|
||||
if (typeof definition.schema === "object") {
|
||||
hasSchema = true;
|
||||
} else {
|
||||
throw new TypeError("Schema must be an object.");
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof definition.merge === "string") {
|
||||
if (!(definition.merge in MergeStrategy)) {
|
||||
throw new TypeError(
|
||||
`Definition for key "${name}" missing valid merge strategy.`,
|
||||
);
|
||||
}
|
||||
} else if (!hasSchema && typeof definition.merge !== "function") {
|
||||
throw new TypeError(
|
||||
`Definition for key "${name}" must have a merge property.`,
|
||||
);
|
||||
}
|
||||
|
||||
if (typeof definition.validate === "string") {
|
||||
if (!(definition.validate in ValidationStrategy)) {
|
||||
throw new TypeError(
|
||||
`Definition for key "${name}" missing valid validation strategy.`,
|
||||
);
|
||||
}
|
||||
} else if (!hasSchema && typeof definition.validate !== "function") {
|
||||
throw new TypeError(
|
||||
`Definition for key "${name}" must have a validate() method.`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Errors
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Error when an unexpected key is found.
|
||||
*/
|
||||
class UnexpectedKeyError extends Error {
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {string} key The key that was unexpected.
|
||||
*/
|
||||
constructor(key) {
|
||||
super(`Unexpected key "${key}" found.`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Error when a required key is missing.
|
||||
*/
|
||||
class MissingKeyError extends Error {
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {string} key The key that was missing.
|
||||
*/
|
||||
constructor(key) {
|
||||
super(`Missing required key "${key}".`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Error when a key requires other keys that are missing.
|
||||
*/
|
||||
class MissingDependentKeysError extends Error {
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {string} key The key that was unexpected.
|
||||
* @param {Array<string>} requiredKeys The keys that are required.
|
||||
*/
|
||||
constructor(key, requiredKeys) {
|
||||
super(`Key "${key}" requires keys "${requiredKeys.join('", "')}".`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper error for errors occuring during a merge or validate operation.
|
||||
*/
|
||||
class WrapperError extends Error {
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {string} key The object key causing the error.
|
||||
* @param {Error} source The source error.
|
||||
*/
|
||||
constructor(key, source) {
|
||||
super(`Key "${key}": ${source.message}`, { cause: source });
|
||||
|
||||
// copy over custom properties that aren't represented
|
||||
for (const sourceKey of Object.keys(source)) {
|
||||
if (!(sourceKey in this)) {
|
||||
this[sourceKey] = source[sourceKey];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Main
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Represents an object validation/merging schema.
|
||||
*/
|
||||
class ObjectSchema {
|
||||
/**
|
||||
* Track all definitions in the schema by key.
|
||||
* @type {Map<string, PropertyDefinition>}
|
||||
*/
|
||||
#definitions = new Map();
|
||||
|
||||
/**
|
||||
* Separately track any keys that are required for faster validtion.
|
||||
* @type {Map<string, PropertyDefinition>}
|
||||
*/
|
||||
#requiredKeys = new Map();
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {ObjectDefinition} definitions The schema definitions.
|
||||
*/
|
||||
constructor(definitions) {
|
||||
if (!definitions) {
|
||||
throw new Error("Schema definitions missing.");
|
||||
}
|
||||
|
||||
// add in all strategies
|
||||
for (const key of Object.keys(definitions)) {
|
||||
validateDefinition(key, definitions[key]);
|
||||
|
||||
// normalize merge and validate methods if subschema is present
|
||||
if (typeof definitions[key].schema === "object") {
|
||||
const schema = new ObjectSchema(definitions[key].schema);
|
||||
definitions[key] = {
|
||||
...definitions[key],
|
||||
merge(first = {}, second = {}) {
|
||||
return schema.merge(first, second);
|
||||
},
|
||||
validate(value) {
|
||||
ValidationStrategy.object(value);
|
||||
schema.validate(value);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
// normalize the merge method in case there's a string
|
||||
if (typeof definitions[key].merge === "string") {
|
||||
definitions[key] = {
|
||||
...definitions[key],
|
||||
merge: MergeStrategy[
|
||||
/** @type {string} */ (definitions[key].merge)
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
// normalize the validate method in case there's a string
|
||||
if (typeof definitions[key].validate === "string") {
|
||||
definitions[key] = {
|
||||
...definitions[key],
|
||||
validate:
|
||||
ValidationStrategy[
|
||||
/** @type {string} */ (definitions[key].validate)
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
this.#definitions.set(key, definitions[key]);
|
||||
|
||||
if (definitions[key].required) {
|
||||
this.#requiredKeys.set(key, definitions[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if a strategy has been registered for the given object key.
|
||||
* @param {string} key The object key to find a strategy for.
|
||||
* @returns {boolean} True if the key has a strategy registered, false if not.
|
||||
*/
|
||||
hasKey(key) {
|
||||
return this.#definitions.has(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges objects together to create a new object comprised of the keys
|
||||
* of the all objects. Keys are merged based on the each key's merge
|
||||
* strategy.
|
||||
* @param {...Object} objects The objects to merge.
|
||||
* @returns {Object} A new object with a mix of all objects' keys.
|
||||
* @throws {Error} If any object is invalid.
|
||||
*/
|
||||
merge(...objects) {
|
||||
// double check arguments
|
||||
if (objects.length < 2) {
|
||||
throw new TypeError("merge() requires at least two arguments.");
|
||||
}
|
||||
|
||||
if (
|
||||
objects.some(
|
||||
object => object === null || typeof object !== "object",
|
||||
)
|
||||
) {
|
||||
throw new TypeError("All arguments must be objects.");
|
||||
}
|
||||
|
||||
return objects.reduce((result, object) => {
|
||||
this.validate(object);
|
||||
|
||||
for (const [key, strategy] of this.#definitions) {
|
||||
try {
|
||||
if (key in result || key in object) {
|
||||
const merge = /** @type {Function} */ (strategy.merge);
|
||||
const value = merge.call(
|
||||
this,
|
||||
result[key],
|
||||
object[key],
|
||||
);
|
||||
if (value !== undefined) {
|
||||
result[key] = value;
|
||||
}
|
||||
}
|
||||
} catch (ex) {
|
||||
throw new WrapperError(key, ex);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}, {});
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates an object's keys based on the validate strategy for each key.
|
||||
* @param {Object} object The object to validate.
|
||||
* @returns {void}
|
||||
* @throws {Error} When the object is invalid.
|
||||
*/
|
||||
validate(object) {
|
||||
// check existing keys first
|
||||
for (const key of Object.keys(object)) {
|
||||
// check to see if the key is defined
|
||||
if (!this.hasKey(key)) {
|
||||
throw new UnexpectedKeyError(key);
|
||||
}
|
||||
|
||||
// validate existing keys
|
||||
const definition = this.#definitions.get(key);
|
||||
|
||||
// first check to see if any other keys are required
|
||||
if (Array.isArray(definition.requires)) {
|
||||
if (
|
||||
!definition.requires.every(otherKey => otherKey in object)
|
||||
) {
|
||||
throw new MissingDependentKeysError(
|
||||
key,
|
||||
definition.requires,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// now apply remaining validation strategy
|
||||
try {
|
||||
const validate = /** @type {Function} */ (definition.validate);
|
||||
validate.call(definition, object[key]);
|
||||
} catch (ex) {
|
||||
throw new WrapperError(key, ex);
|
||||
}
|
||||
}
|
||||
|
||||
// ensure required keys aren't missing
|
||||
for (const [key] of this.#requiredKeys) {
|
||||
if (!(key in object)) {
|
||||
throw new MissingKeyError(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exports.MergeStrategy = MergeStrategy;
|
||||
exports.ObjectSchema = ObjectSchema;
|
||||
exports.ValidationStrategy = ValidationStrategy;
|
123
node_modules/@eslint/object-schema/dist/cjs/index.d.cts
generated
vendored
123
node_modules/@eslint/object-schema/dist/cjs/index.d.cts
generated
vendored
|
@ -1,123 +0,0 @@
|
|||
export type ObjectDefinition = import("./types.cts").ObjectDefinition;
|
||||
export type PropertyDefinition = import("./types.cts").PropertyDefinition;
|
||||
/**
|
||||
* @fileoverview Merge Strategy
|
||||
*/
|
||||
/**
|
||||
* Container class for several different merge strategies.
|
||||
*/
|
||||
export class MergeStrategy {
|
||||
/**
|
||||
* Merges two keys by overwriting the first with the second.
|
||||
* @param {*} value1 The value from the first object key.
|
||||
* @param {*} value2 The value from the second object key.
|
||||
* @returns {*} The second value.
|
||||
*/
|
||||
static overwrite(value1: any, value2: any): any;
|
||||
/**
|
||||
* Merges two keys by replacing the first with the second only if the
|
||||
* second is defined.
|
||||
* @param {*} value1 The value from the first object key.
|
||||
* @param {*} value2 The value from the second object key.
|
||||
* @returns {*} The second value if it is defined.
|
||||
*/
|
||||
static replace(value1: any, value2: any): any;
|
||||
/**
|
||||
* Merges two properties by assigning properties from the second to the first.
|
||||
* @param {*} value1 The value from the first object key.
|
||||
* @param {*} value2 The value from the second object key.
|
||||
* @returns {*} A new object containing properties from both value1 and
|
||||
* value2.
|
||||
*/
|
||||
static assign(value1: any, value2: any): any;
|
||||
}
|
||||
/**
|
||||
* Represents an object validation/merging schema.
|
||||
*/
|
||||
export class ObjectSchema {
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {ObjectDefinition} definitions The schema definitions.
|
||||
*/
|
||||
constructor(definitions: ObjectDefinition);
|
||||
/**
|
||||
* Determines if a strategy has been registered for the given object key.
|
||||
* @param {string} key The object key to find a strategy for.
|
||||
* @returns {boolean} True if the key has a strategy registered, false if not.
|
||||
*/
|
||||
hasKey(key: string): boolean;
|
||||
/**
|
||||
* Merges objects together to create a new object comprised of the keys
|
||||
* of the all objects. Keys are merged based on the each key's merge
|
||||
* strategy.
|
||||
* @param {...Object} objects The objects to merge.
|
||||
* @returns {Object} A new object with a mix of all objects' keys.
|
||||
* @throws {Error} If any object is invalid.
|
||||
*/
|
||||
merge(...objects: any[]): any;
|
||||
/**
|
||||
* Validates an object's keys based on the validate strategy for each key.
|
||||
* @param {Object} object The object to validate.
|
||||
* @returns {void}
|
||||
* @throws {Error} When the object is invalid.
|
||||
*/
|
||||
validate(object: any): void;
|
||||
#private;
|
||||
}
|
||||
/**
|
||||
* @fileoverview Validation Strategy
|
||||
*/
|
||||
/**
|
||||
* Container class for several different validation strategies.
|
||||
*/
|
||||
export class ValidationStrategy {
|
||||
/**
|
||||
* Validates that a value is an array.
|
||||
* @param {*} value The value to validate.
|
||||
* @returns {void}
|
||||
* @throws {TypeError} If the value is invalid.
|
||||
*/
|
||||
static array(value: any): void;
|
||||
/**
|
||||
* Validates that a value is a boolean.
|
||||
* @param {*} value The value to validate.
|
||||
* @returns {void}
|
||||
* @throws {TypeError} If the value is invalid.
|
||||
*/
|
||||
static boolean(value: any): void;
|
||||
/**
|
||||
* Validates that a value is a number.
|
||||
* @param {*} value The value to validate.
|
||||
* @returns {void}
|
||||
* @throws {TypeError} If the value is invalid.
|
||||
*/
|
||||
static number(value: any): void;
|
||||
/**
|
||||
* Validates that a value is a object.
|
||||
* @param {*} value The value to validate.
|
||||
* @returns {void}
|
||||
* @throws {TypeError} If the value is invalid.
|
||||
*/
|
||||
static object(value: any): void;
|
||||
/**
|
||||
* Validates that a value is a object or null.
|
||||
* @param {*} value The value to validate.
|
||||
* @returns {void}
|
||||
* @throws {TypeError} If the value is invalid.
|
||||
*/
|
||||
static "object?"(value: any): void;
|
||||
/**
|
||||
* Validates that a value is a string.
|
||||
* @param {*} value The value to validate.
|
||||
* @returns {void}
|
||||
* @throws {TypeError} If the value is invalid.
|
||||
*/
|
||||
static string(value: any): void;
|
||||
/**
|
||||
* Validates that a value is a non-empty string.
|
||||
* @param {*} value The value to validate.
|
||||
* @returns {void}
|
||||
* @throws {TypeError} If the value is invalid.
|
||||
*/
|
||||
static "string!"(value: any): void;
|
||||
}
|
57
node_modules/@eslint/object-schema/dist/cjs/types.ts
generated
vendored
57
node_modules/@eslint/object-schema/dist/cjs/types.ts
generated
vendored
|
@ -1,57 +0,0 @@
|
|||
/**
|
||||
* @fileoverview Types for object-schema package.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Built-in validation strategies.
|
||||
*/
|
||||
export type BuiltInValidationStrategy =
|
||||
| "array"
|
||||
| "boolean"
|
||||
| "number"
|
||||
| "object"
|
||||
| "object?"
|
||||
| "string"
|
||||
| "string!";
|
||||
|
||||
/**
|
||||
* Built-in merge strategies.
|
||||
*/
|
||||
export type BuiltInMergeStrategy = "assign" | "overwrite" | "replace";
|
||||
|
||||
/**
|
||||
* Property definition.
|
||||
*/
|
||||
export interface PropertyDefinition {
|
||||
/**
|
||||
* Indicates if the property is required.
|
||||
*/
|
||||
required: boolean;
|
||||
|
||||
/**
|
||||
* The other properties that must be present when this property is used.
|
||||
*/
|
||||
requires?: string[];
|
||||
|
||||
/**
|
||||
* The strategy to merge the property.
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/eslint/rewrite/pull/90#discussion_r1687206213
|
||||
merge: BuiltInMergeStrategy | ((target: any, source: any) => any);
|
||||
|
||||
/**
|
||||
* The strategy to validate the property.
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/eslint/rewrite/pull/90#discussion_r1687206213
|
||||
validate: BuiltInValidationStrategy | ((value: any) => void);
|
||||
|
||||
/**
|
||||
* The schema for the object value of this property.
|
||||
*/
|
||||
schema?: ObjectDefinition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Object definition.
|
||||
*/
|
||||
export type ObjectDefinition = Record<string, PropertyDefinition>;
|
123
node_modules/@eslint/object-schema/dist/esm/index.d.ts
generated
vendored
123
node_modules/@eslint/object-schema/dist/esm/index.d.ts
generated
vendored
|
@ -1,123 +0,0 @@
|
|||
export type ObjectDefinition = import("./types.ts").ObjectDefinition;
|
||||
export type PropertyDefinition = import("./types.ts").PropertyDefinition;
|
||||
/**
|
||||
* @fileoverview Merge Strategy
|
||||
*/
|
||||
/**
|
||||
* Container class for several different merge strategies.
|
||||
*/
|
||||
export class MergeStrategy {
|
||||
/**
|
||||
* Merges two keys by overwriting the first with the second.
|
||||
* @param {*} value1 The value from the first object key.
|
||||
* @param {*} value2 The value from the second object key.
|
||||
* @returns {*} The second value.
|
||||
*/
|
||||
static overwrite(value1: any, value2: any): any;
|
||||
/**
|
||||
* Merges two keys by replacing the first with the second only if the
|
||||
* second is defined.
|
||||
* @param {*} value1 The value from the first object key.
|
||||
* @param {*} value2 The value from the second object key.
|
||||
* @returns {*} The second value if it is defined.
|
||||
*/
|
||||
static replace(value1: any, value2: any): any;
|
||||
/**
|
||||
* Merges two properties by assigning properties from the second to the first.
|
||||
* @param {*} value1 The value from the first object key.
|
||||
* @param {*} value2 The value from the second object key.
|
||||
* @returns {*} A new object containing properties from both value1 and
|
||||
* value2.
|
||||
*/
|
||||
static assign(value1: any, value2: any): any;
|
||||
}
|
||||
/**
|
||||
* Represents an object validation/merging schema.
|
||||
*/
|
||||
export class ObjectSchema {
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {ObjectDefinition} definitions The schema definitions.
|
||||
*/
|
||||
constructor(definitions: ObjectDefinition);
|
||||
/**
|
||||
* Determines if a strategy has been registered for the given object key.
|
||||
* @param {string} key The object key to find a strategy for.
|
||||
* @returns {boolean} True if the key has a strategy registered, false if not.
|
||||
*/
|
||||
hasKey(key: string): boolean;
|
||||
/**
|
||||
* Merges objects together to create a new object comprised of the keys
|
||||
* of the all objects. Keys are merged based on the each key's merge
|
||||
* strategy.
|
||||
* @param {...Object} objects The objects to merge.
|
||||
* @returns {Object} A new object with a mix of all objects' keys.
|
||||
* @throws {Error} If any object is invalid.
|
||||
*/
|
||||
merge(...objects: any[]): any;
|
||||
/**
|
||||
* Validates an object's keys based on the validate strategy for each key.
|
||||
* @param {Object} object The object to validate.
|
||||
* @returns {void}
|
||||
* @throws {Error} When the object is invalid.
|
||||
*/
|
||||
validate(object: any): void;
|
||||
#private;
|
||||
}
|
||||
/**
|
||||
* @fileoverview Validation Strategy
|
||||
*/
|
||||
/**
|
||||
* Container class for several different validation strategies.
|
||||
*/
|
||||
export class ValidationStrategy {
|
||||
/**
|
||||
* Validates that a value is an array.
|
||||
* @param {*} value The value to validate.
|
||||
* @returns {void}
|
||||
* @throws {TypeError} If the value is invalid.
|
||||
*/
|
||||
static array(value: any): void;
|
||||
/**
|
||||
* Validates that a value is a boolean.
|
||||
* @param {*} value The value to validate.
|
||||
* @returns {void}
|
||||
* @throws {TypeError} If the value is invalid.
|
||||
*/
|
||||
static boolean(value: any): void;
|
||||
/**
|
||||
* Validates that a value is a number.
|
||||
* @param {*} value The value to validate.
|
||||
* @returns {void}
|
||||
* @throws {TypeError} If the value is invalid.
|
||||
*/
|
||||
static number(value: any): void;
|
||||
/**
|
||||
* Validates that a value is a object.
|
||||
* @param {*} value The value to validate.
|
||||
* @returns {void}
|
||||
* @throws {TypeError} If the value is invalid.
|
||||
*/
|
||||
static object(value: any): void;
|
||||
/**
|
||||
* Validates that a value is a object or null.
|
||||
* @param {*} value The value to validate.
|
||||
* @returns {void}
|
||||
* @throws {TypeError} If the value is invalid.
|
||||
*/
|
||||
static "object?"(value: any): void;
|
||||
/**
|
||||
* Validates that a value is a string.
|
||||
* @param {*} value The value to validate.
|
||||
* @returns {void}
|
||||
* @throws {TypeError} If the value is invalid.
|
||||
*/
|
||||
static string(value: any): void;
|
||||
/**
|
||||
* Validates that a value is a non-empty string.
|
||||
* @param {*} value The value to validate.
|
||||
* @returns {void}
|
||||
* @throws {TypeError} If the value is invalid.
|
||||
*/
|
||||
static "string!"(value: any): void;
|
||||
}
|
452
node_modules/@eslint/object-schema/dist/esm/index.js
generated
vendored
452
node_modules/@eslint/object-schema/dist/esm/index.js
generated
vendored
|
@ -1,452 +0,0 @@
|
|||
// @ts-self-types="./index.d.ts"
|
||||
/**
|
||||
* @fileoverview Merge Strategy
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Class
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Container class for several different merge strategies.
|
||||
*/
|
||||
class MergeStrategy {
|
||||
/**
|
||||
* Merges two keys by overwriting the first with the second.
|
||||
* @param {*} value1 The value from the first object key.
|
||||
* @param {*} value2 The value from the second object key.
|
||||
* @returns {*} The second value.
|
||||
*/
|
||||
static overwrite(value1, value2) {
|
||||
return value2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges two keys by replacing the first with the second only if the
|
||||
* second is defined.
|
||||
* @param {*} value1 The value from the first object key.
|
||||
* @param {*} value2 The value from the second object key.
|
||||
* @returns {*} The second value if it is defined.
|
||||
*/
|
||||
static replace(value1, value2) {
|
||||
if (typeof value2 !== "undefined") {
|
||||
return value2;
|
||||
}
|
||||
|
||||
return value1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges two properties by assigning properties from the second to the first.
|
||||
* @param {*} value1 The value from the first object key.
|
||||
* @param {*} value2 The value from the second object key.
|
||||
* @returns {*} A new object containing properties from both value1 and
|
||||
* value2.
|
||||
*/
|
||||
static assign(value1, value2) {
|
||||
return Object.assign({}, value1, value2);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @fileoverview Validation Strategy
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Class
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Container class for several different validation strategies.
|
||||
*/
|
||||
class ValidationStrategy {
|
||||
/**
|
||||
* Validates that a value is an array.
|
||||
* @param {*} value The value to validate.
|
||||
* @returns {void}
|
||||
* @throws {TypeError} If the value is invalid.
|
||||
*/
|
||||
static array(value) {
|
||||
if (!Array.isArray(value)) {
|
||||
throw new TypeError("Expected an array.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates that a value is a boolean.
|
||||
* @param {*} value The value to validate.
|
||||
* @returns {void}
|
||||
* @throws {TypeError} If the value is invalid.
|
||||
*/
|
||||
static boolean(value) {
|
||||
if (typeof value !== "boolean") {
|
||||
throw new TypeError("Expected a Boolean.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates that a value is a number.
|
||||
* @param {*} value The value to validate.
|
||||
* @returns {void}
|
||||
* @throws {TypeError} If the value is invalid.
|
||||
*/
|
||||
static number(value) {
|
||||
if (typeof value !== "number") {
|
||||
throw new TypeError("Expected a number.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates that a value is a object.
|
||||
* @param {*} value The value to validate.
|
||||
* @returns {void}
|
||||
* @throws {TypeError} If the value is invalid.
|
||||
*/
|
||||
static object(value) {
|
||||
if (!value || typeof value !== "object") {
|
||||
throw new TypeError("Expected an object.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates that a value is a object or null.
|
||||
* @param {*} value The value to validate.
|
||||
* @returns {void}
|
||||
* @throws {TypeError} If the value is invalid.
|
||||
*/
|
||||
static "object?"(value) {
|
||||
if (typeof value !== "object") {
|
||||
throw new TypeError("Expected an object or null.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates that a value is a string.
|
||||
* @param {*} value The value to validate.
|
||||
* @returns {void}
|
||||
* @throws {TypeError} If the value is invalid.
|
||||
*/
|
||||
static string(value) {
|
||||
if (typeof value !== "string") {
|
||||
throw new TypeError("Expected a string.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates that a value is a non-empty string.
|
||||
* @param {*} value The value to validate.
|
||||
* @returns {void}
|
||||
* @throws {TypeError} If the value is invalid.
|
||||
*/
|
||||
static "string!"(value) {
|
||||
if (typeof value !== "string" || value.length === 0) {
|
||||
throw new TypeError("Expected a non-empty string.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @fileoverview Object Schema
|
||||
*/
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Types
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/** @typedef {import("./types.ts").ObjectDefinition} ObjectDefinition */
|
||||
/** @typedef {import("./types.ts").PropertyDefinition} PropertyDefinition */
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Private
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Validates a schema strategy.
|
||||
* @param {string} name The name of the key this strategy is for.
|
||||
* @param {PropertyDefinition} definition The strategy for the object key.
|
||||
* @returns {void}
|
||||
* @throws {Error} When the strategy is missing a name.
|
||||
* @throws {Error} When the strategy is missing a merge() method.
|
||||
* @throws {Error} When the strategy is missing a validate() method.
|
||||
*/
|
||||
function validateDefinition(name, definition) {
|
||||
let hasSchema = false;
|
||||
if (definition.schema) {
|
||||
if (typeof definition.schema === "object") {
|
||||
hasSchema = true;
|
||||
} else {
|
||||
throw new TypeError("Schema must be an object.");
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof definition.merge === "string") {
|
||||
if (!(definition.merge in MergeStrategy)) {
|
||||
throw new TypeError(
|
||||
`Definition for key "${name}" missing valid merge strategy.`,
|
||||
);
|
||||
}
|
||||
} else if (!hasSchema && typeof definition.merge !== "function") {
|
||||
throw new TypeError(
|
||||
`Definition for key "${name}" must have a merge property.`,
|
||||
);
|
||||
}
|
||||
|
||||
if (typeof definition.validate === "string") {
|
||||
if (!(definition.validate in ValidationStrategy)) {
|
||||
throw new TypeError(
|
||||
`Definition for key "${name}" missing valid validation strategy.`,
|
||||
);
|
||||
}
|
||||
} else if (!hasSchema && typeof definition.validate !== "function") {
|
||||
throw new TypeError(
|
||||
`Definition for key "${name}" must have a validate() method.`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Errors
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Error when an unexpected key is found.
|
||||
*/
|
||||
class UnexpectedKeyError extends Error {
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {string} key The key that was unexpected.
|
||||
*/
|
||||
constructor(key) {
|
||||
super(`Unexpected key "${key}" found.`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Error when a required key is missing.
|
||||
*/
|
||||
class MissingKeyError extends Error {
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {string} key The key that was missing.
|
||||
*/
|
||||
constructor(key) {
|
||||
super(`Missing required key "${key}".`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Error when a key requires other keys that are missing.
|
||||
*/
|
||||
class MissingDependentKeysError extends Error {
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {string} key The key that was unexpected.
|
||||
* @param {Array<string>} requiredKeys The keys that are required.
|
||||
*/
|
||||
constructor(key, requiredKeys) {
|
||||
super(`Key "${key}" requires keys "${requiredKeys.join('", "')}".`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper error for errors occuring during a merge or validate operation.
|
||||
*/
|
||||
class WrapperError extends Error {
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {string} key The object key causing the error.
|
||||
* @param {Error} source The source error.
|
||||
*/
|
||||
constructor(key, source) {
|
||||
super(`Key "${key}": ${source.message}`, { cause: source });
|
||||
|
||||
// copy over custom properties that aren't represented
|
||||
for (const sourceKey of Object.keys(source)) {
|
||||
if (!(sourceKey in this)) {
|
||||
this[sourceKey] = source[sourceKey];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Main
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Represents an object validation/merging schema.
|
||||
*/
|
||||
class ObjectSchema {
|
||||
/**
|
||||
* Track all definitions in the schema by key.
|
||||
* @type {Map<string, PropertyDefinition>}
|
||||
*/
|
||||
#definitions = new Map();
|
||||
|
||||
/**
|
||||
* Separately track any keys that are required for faster validtion.
|
||||
* @type {Map<string, PropertyDefinition>}
|
||||
*/
|
||||
#requiredKeys = new Map();
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {ObjectDefinition} definitions The schema definitions.
|
||||
*/
|
||||
constructor(definitions) {
|
||||
if (!definitions) {
|
||||
throw new Error("Schema definitions missing.");
|
||||
}
|
||||
|
||||
// add in all strategies
|
||||
for (const key of Object.keys(definitions)) {
|
||||
validateDefinition(key, definitions[key]);
|
||||
|
||||
// normalize merge and validate methods if subschema is present
|
||||
if (typeof definitions[key].schema === "object") {
|
||||
const schema = new ObjectSchema(definitions[key].schema);
|
||||
definitions[key] = {
|
||||
...definitions[key],
|
||||
merge(first = {}, second = {}) {
|
||||
return schema.merge(first, second);
|
||||
},
|
||||
validate(value) {
|
||||
ValidationStrategy.object(value);
|
||||
schema.validate(value);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
// normalize the merge method in case there's a string
|
||||
if (typeof definitions[key].merge === "string") {
|
||||
definitions[key] = {
|
||||
...definitions[key],
|
||||
merge: MergeStrategy[
|
||||
/** @type {string} */ (definitions[key].merge)
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
// normalize the validate method in case there's a string
|
||||
if (typeof definitions[key].validate === "string") {
|
||||
definitions[key] = {
|
||||
...definitions[key],
|
||||
validate:
|
||||
ValidationStrategy[
|
||||
/** @type {string} */ (definitions[key].validate)
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
this.#definitions.set(key, definitions[key]);
|
||||
|
||||
if (definitions[key].required) {
|
||||
this.#requiredKeys.set(key, definitions[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if a strategy has been registered for the given object key.
|
||||
* @param {string} key The object key to find a strategy for.
|
||||
* @returns {boolean} True if the key has a strategy registered, false if not.
|
||||
*/
|
||||
hasKey(key) {
|
||||
return this.#definitions.has(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges objects together to create a new object comprised of the keys
|
||||
* of the all objects. Keys are merged based on the each key's merge
|
||||
* strategy.
|
||||
* @param {...Object} objects The objects to merge.
|
||||
* @returns {Object} A new object with a mix of all objects' keys.
|
||||
* @throws {Error} If any object is invalid.
|
||||
*/
|
||||
merge(...objects) {
|
||||
// double check arguments
|
||||
if (objects.length < 2) {
|
||||
throw new TypeError("merge() requires at least two arguments.");
|
||||
}
|
||||
|
||||
if (
|
||||
objects.some(
|
||||
object => object === null || typeof object !== "object",
|
||||
)
|
||||
) {
|
||||
throw new TypeError("All arguments must be objects.");
|
||||
}
|
||||
|
||||
return objects.reduce((result, object) => {
|
||||
this.validate(object);
|
||||
|
||||
for (const [key, strategy] of this.#definitions) {
|
||||
try {
|
||||
if (key in result || key in object) {
|
||||
const merge = /** @type {Function} */ (strategy.merge);
|
||||
const value = merge.call(
|
||||
this,
|
||||
result[key],
|
||||
object[key],
|
||||
);
|
||||
if (value !== undefined) {
|
||||
result[key] = value;
|
||||
}
|
||||
}
|
||||
} catch (ex) {
|
||||
throw new WrapperError(key, ex);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}, {});
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates an object's keys based on the validate strategy for each key.
|
||||
* @param {Object} object The object to validate.
|
||||
* @returns {void}
|
||||
* @throws {Error} When the object is invalid.
|
||||
*/
|
||||
validate(object) {
|
||||
// check existing keys first
|
||||
for (const key of Object.keys(object)) {
|
||||
// check to see if the key is defined
|
||||
if (!this.hasKey(key)) {
|
||||
throw new UnexpectedKeyError(key);
|
||||
}
|
||||
|
||||
// validate existing keys
|
||||
const definition = this.#definitions.get(key);
|
||||
|
||||
// first check to see if any other keys are required
|
||||
if (Array.isArray(definition.requires)) {
|
||||
if (
|
||||
!definition.requires.every(otherKey => otherKey in object)
|
||||
) {
|
||||
throw new MissingDependentKeysError(
|
||||
key,
|
||||
definition.requires,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// now apply remaining validation strategy
|
||||
try {
|
||||
const validate = /** @type {Function} */ (definition.validate);
|
||||
validate.call(definition, object[key]);
|
||||
} catch (ex) {
|
||||
throw new WrapperError(key, ex);
|
||||
}
|
||||
}
|
||||
|
||||
// ensure required keys aren't missing
|
||||
for (const [key] of this.#requiredKeys) {
|
||||
if (!(key in object)) {
|
||||
throw new MissingKeyError(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export { MergeStrategy, ObjectSchema, ValidationStrategy };
|
40
node_modules/@eslint/object-schema/dist/esm/types.d.ts
generated
vendored
40
node_modules/@eslint/object-schema/dist/esm/types.d.ts
generated
vendored
|
@ -1,40 +0,0 @@
|
|||
/**
|
||||
* @fileoverview Types for object-schema package.
|
||||
*/
|
||||
/**
|
||||
* Built-in validation strategies.
|
||||
*/
|
||||
export type BuiltInValidationStrategy = "array" | "boolean" | "number" | "object" | "object?" | "string" | "string!";
|
||||
/**
|
||||
* Built-in merge strategies.
|
||||
*/
|
||||
export type BuiltInMergeStrategy = "assign" | "overwrite" | "replace";
|
||||
/**
|
||||
* Property definition.
|
||||
*/
|
||||
export interface PropertyDefinition {
|
||||
/**
|
||||
* Indicates if the property is required.
|
||||
*/
|
||||
required: boolean;
|
||||
/**
|
||||
* The other properties that must be present when this property is used.
|
||||
*/
|
||||
requires?: string[];
|
||||
/**
|
||||
* The strategy to merge the property.
|
||||
*/
|
||||
merge: BuiltInMergeStrategy | ((target: any, source: any) => any);
|
||||
/**
|
||||
* The strategy to validate the property.
|
||||
*/
|
||||
validate: BuiltInValidationStrategy | ((value: any) => void);
|
||||
/**
|
||||
* The schema for the object value of this property.
|
||||
*/
|
||||
schema?: ObjectDefinition;
|
||||
}
|
||||
/**
|
||||
* Object definition.
|
||||
*/
|
||||
export type ObjectDefinition = Record<string, PropertyDefinition>;
|
57
node_modules/@eslint/object-schema/dist/esm/types.ts
generated
vendored
57
node_modules/@eslint/object-schema/dist/esm/types.ts
generated
vendored
|
@ -1,57 +0,0 @@
|
|||
/**
|
||||
* @fileoverview Types for object-schema package.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Built-in validation strategies.
|
||||
*/
|
||||
export type BuiltInValidationStrategy =
|
||||
| "array"
|
||||
| "boolean"
|
||||
| "number"
|
||||
| "object"
|
||||
| "object?"
|
||||
| "string"
|
||||
| "string!";
|
||||
|
||||
/**
|
||||
* Built-in merge strategies.
|
||||
*/
|
||||
export type BuiltInMergeStrategy = "assign" | "overwrite" | "replace";
|
||||
|
||||
/**
|
||||
* Property definition.
|
||||
*/
|
||||
export interface PropertyDefinition {
|
||||
/**
|
||||
* Indicates if the property is required.
|
||||
*/
|
||||
required: boolean;
|
||||
|
||||
/**
|
||||
* The other properties that must be present when this property is used.
|
||||
*/
|
||||
requires?: string[];
|
||||
|
||||
/**
|
||||
* The strategy to merge the property.
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/eslint/rewrite/pull/90#discussion_r1687206213
|
||||
merge: BuiltInMergeStrategy | ((target: any, source: any) => any);
|
||||
|
||||
/**
|
||||
* The strategy to validate the property.
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/eslint/rewrite/pull/90#discussion_r1687206213
|
||||
validate: BuiltInValidationStrategy | ((value: any) => void);
|
||||
|
||||
/**
|
||||
* The schema for the object value of this property.
|
||||
*/
|
||||
schema?: ObjectDefinition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Object definition.
|
||||
*/
|
||||
export type ObjectDefinition = Record<string, PropertyDefinition>;
|
60
node_modules/@eslint/object-schema/package.json
generated
vendored
60
node_modules/@eslint/object-schema/package.json
generated
vendored
|
@ -1,60 +0,0 @@
|
|||
{
|
||||
"name": "@eslint/object-schema",
|
||||
"version": "2.1.6",
|
||||
"description": "An object schema merger/validator",
|
||||
"type": "module",
|
||||
"main": "dist/esm/index.js",
|
||||
"types": "dist/esm/index.d.ts",
|
||||
"exports": {
|
||||
"require": {
|
||||
"types": "./dist/cjs/index.d.cts",
|
||||
"default": "./dist/cjs/index.cjs"
|
||||
},
|
||||
"import": {
|
||||
"types": "./dist/esm/index.d.ts",
|
||||
"default": "./dist/esm/index.js"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"directories": {
|
||||
"test": "tests"
|
||||
},
|
||||
"scripts": {
|
||||
"build:cts": "node ../../tools/build-cts.js dist/esm/index.d.ts dist/cjs/index.d.cts",
|
||||
"build": "rollup -c && tsc -p tsconfig.esm.json && npm run build:cts",
|
||||
"test:jsr": "npx jsr@latest publish --dry-run",
|
||||
"test": "mocha tests/",
|
||||
"test:coverage": "c8 npm test"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/eslint/rewrite.git"
|
||||
},
|
||||
"keywords": [
|
||||
"object",
|
||||
"validation",
|
||||
"schema",
|
||||
"merge"
|
||||
],
|
||||
"author": "Nicholas C. Zakas",
|
||||
"license": "Apache-2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/eslint/rewrite/issues"
|
||||
},
|
||||
"homepage": "https://github.com/eslint/rewrite#readme",
|
||||
"devDependencies": {
|
||||
"c8": "^9.1.0",
|
||||
"mocha": "^10.4.0",
|
||||
"rollup": "^4.16.2",
|
||||
"rollup-plugin-copy": "^3.5.0",
|
||||
"typescript": "^5.4.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
}
|
||||
}
|
201
node_modules/@eslint/plugin-kit/LICENSE
generated
vendored
201
node_modules/@eslint/plugin-kit/LICENSE
generated
vendored
|
@ -1,201 +0,0 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
271
node_modules/@eslint/plugin-kit/README.md
generated
vendored
271
node_modules/@eslint/plugin-kit/README.md
generated
vendored
|
@ -1,271 +0,0 @@
|
|||
# ESLint Plugin Kit
|
||||
|
||||
## Description
|
||||
|
||||
A collection of utilities to help build ESLint plugins.
|
||||
|
||||
## Installation
|
||||
|
||||
For Node.js and compatible runtimes:
|
||||
|
||||
```shell
|
||||
npm install @eslint/plugin-kit
|
||||
# or
|
||||
yarn add @eslint/plugin-kit
|
||||
# or
|
||||
pnpm install @eslint/plugin-kit
|
||||
# or
|
||||
bun add @eslint/plugin-kit
|
||||
```
|
||||
|
||||
For Deno:
|
||||
|
||||
```shell
|
||||
deno add @eslint/plugin-kit
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
This package exports the following utilities:
|
||||
|
||||
- [`ConfigCommentParser`](#configcommentparser) - used to parse ESLint configuration comments (i.e., `/* eslint-disable rule */`)
|
||||
- [`VisitNodeStep` and `CallMethodStep`](#visitnodestep-and-callmethodstep) - used to help implement `SourceCode#traverse()`
|
||||
- [`Directive`](#directive) - used to help implement `SourceCode#getDisableDirectives()`
|
||||
- [`TextSourceCodeBase`](#textsourcecodebase) - base class to help implement the `SourceCode` interface
|
||||
|
||||
### `ConfigCommentParser`
|
||||
|
||||
To use the `ConfigCommentParser` class, import it from the package and create a new instance, such as:
|
||||
|
||||
```js
|
||||
import { ConfigCommentParser } from "@eslint/plugin-kit";
|
||||
|
||||
// create a new instance
|
||||
const commentParser = new ConfigCommentParser();
|
||||
|
||||
// pass in a comment string without the comment delimiters
|
||||
const directive = commentParser.parseDirective(
|
||||
"eslint-disable prefer-const, semi -- I don't want to use these.",
|
||||
);
|
||||
|
||||
// will be undefined when a directive can't be parsed
|
||||
if (directive) {
|
||||
console.log(directive.label); // "eslint-disable"
|
||||
console.log(directive.value); // "prefer-const, semi"
|
||||
console.log(directive.justification); // "I don't want to use these."
|
||||
}
|
||||
```
|
||||
|
||||
There are different styles of directive values that you'll need to parse separately to get the correct format:
|
||||
|
||||
```js
|
||||
import { ConfigCommentParser } from "@eslint/plugin-kit";
|
||||
|
||||
// create a new instance
|
||||
const commentParser = new ConfigCommentParser();
|
||||
|
||||
// list format
|
||||
const list = commentParser.parseListConfig("prefer-const, semi");
|
||||
console.log(Object.entries(list)); // [["prefer-const", true], ["semi", true]]
|
||||
|
||||
// string format
|
||||
const strings = commentParser.parseStringConfig("foo:off, bar");
|
||||
console.log(Object.entries(strings)); // [["foo", "off"], ["bar", null]]
|
||||
|
||||
// JSON-like config format
|
||||
const jsonLike = commentParser.parseJSONLikeConfig(
|
||||
"semi:[error, never], prefer-const: warn",
|
||||
);
|
||||
console.log(Object.entries(jsonLike.config)); // [["semi", ["error", "never"]], ["prefer-const", "warn"]]
|
||||
```
|
||||
|
||||
### `VisitNodeStep` and `CallMethodStep`
|
||||
|
||||
The `VisitNodeStep` and `CallMethodStep` classes represent steps in the traversal of source code. They implement the correct interfaces to return from the `SourceCode#traverse()` method.
|
||||
|
||||
The `VisitNodeStep` class is the more common of the two, where you are describing a visit to a particular node during the traversal. The constructor accepts three arguments:
|
||||
|
||||
- `target` - the node being visited. This is used to determine the method to call inside of a rule. For instance, if the node's type is `Literal` then ESLint will call a method named `Literal()` on the rule (if present).
|
||||
- `phase` - either 1 for enter or 2 for exit.
|
||||
- `args` - an array of arguments to pass into the visitor method of a rule.
|
||||
|
||||
For example:
|
||||
|
||||
```js
|
||||
import { VisitNodeStep } from "@eslint/plugin-kit";
|
||||
|
||||
class MySourceCode {
|
||||
traverse() {
|
||||
const steps = [];
|
||||
|
||||
for (const { node, parent, phase } of iterator(this.ast)) {
|
||||
steps.push(
|
||||
new VisitNodeStep({
|
||||
target: node,
|
||||
phase: phase === "enter" ? 1 : 2,
|
||||
args: [node, parent],
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
return steps;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The `CallMethodStep` class is less common and is used to tell ESLint to call a specific method on the rule. The constructor accepts two arguments:
|
||||
|
||||
- `target` - the name of the method to call, frequently beginning with `"on"` such as `"onCodePathStart"`.
|
||||
- `args` - an array of arguments to pass to the method.
|
||||
|
||||
For example:
|
||||
|
||||
```js
|
||||
import { VisitNodeStep, CallMethodStep } from "@eslint/plugin-kit";
|
||||
|
||||
class MySourceCode {
|
||||
traverse() {
|
||||
const steps = [];
|
||||
|
||||
for (const { node, parent, phase } of iterator(this.ast)) {
|
||||
steps.push(
|
||||
new VisitNodeStep({
|
||||
target: node,
|
||||
phase: phase === "enter" ? 1 : 2,
|
||||
args: [node, parent],
|
||||
}),
|
||||
);
|
||||
|
||||
// call a method indicating how many times we've been through the loop
|
||||
steps.push(
|
||||
new CallMethodStep({
|
||||
target: "onIteration",
|
||||
args: [steps.length]
|
||||
});
|
||||
)
|
||||
}
|
||||
|
||||
return steps;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### `Directive`
|
||||
|
||||
The `Directive` class represents a disable directive in the source code and implements the `Directive` interface from `@eslint/core`. You can tell ESLint about disable directives using the `SourceCode#getDisableDirectives()` method, where part of the return value is an array of `Directive` objects. Here's an example:
|
||||
|
||||
```js
|
||||
import { Directive, ConfigCommentParser } from "@eslint/plugin-kit";
|
||||
|
||||
class MySourceCode {
|
||||
getDisableDirectives() {
|
||||
const directives = [];
|
||||
const problems = [];
|
||||
const commentParser = new ConfigCommentParser();
|
||||
|
||||
// read in the inline config nodes to check each one
|
||||
this.getInlineConfigNodes().forEach(comment => {
|
||||
// Step 1: Parse the directive
|
||||
const { label, value, justification } =
|
||||
commentParser.parseDirective(comment.value);
|
||||
|
||||
// Step 2: Extract the directive value and create the `Directive` object
|
||||
switch (label) {
|
||||
case "eslint-disable":
|
||||
case "eslint-enable":
|
||||
case "eslint-disable-next-line":
|
||||
case "eslint-disable-line": {
|
||||
const directiveType = label.slice("eslint-".length);
|
||||
|
||||
directives.push(
|
||||
new Directive({
|
||||
type: directiveType,
|
||||
node: comment,
|
||||
value,
|
||||
justification,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
// ignore any comments that don't begin with known labels
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
directives,
|
||||
problems,
|
||||
};
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### `TextSourceCodeBase`
|
||||
|
||||
The `TextSourceCodeBase` class is intended to be a base class that has several of the common members found in `SourceCode` objects already implemented. Those members are:
|
||||
|
||||
- `lines` - an array of text lines that is created automatically when the constructor is called.
|
||||
- `getLoc(node)` - gets the location of a node. Works for nodes that have the ESLint-style `loc` property and nodes that have the Unist-style [`position` property](https://github.com/syntax-tree/unist?tab=readme-ov-file#position). If you're using an AST with a different location format, you'll still need to implement this method yourself.
|
||||
- `getRange(node)` - gets the range of a node within the source text. Works for nodes that have the ESLint-style `range` property and nodes that have the Unist-style [`position` property](https://github.com/syntax-tree/unist?tab=readme-ov-file#position). If you're using an AST with a different range format, you'll still need to implement this method yourself.
|
||||
- `getText(nodeOrToken, charsBefore, charsAfter)` - gets the source text for the given node or token that has range information attached. Optionally, can return additional characters before and after the given node or token. As long as `getRange()` is properly implemented, this method will just work.
|
||||
- `getAncestors(node)` - returns the ancestry of the node. In order for this to work, you must implement the `getParent()` method yourself.
|
||||
|
||||
Here's an example:
|
||||
|
||||
```js
|
||||
import { TextSourceCodeBase } from "@eslint/plugin-kit";
|
||||
|
||||
export class MySourceCode extends TextSourceCodeBase {
|
||||
#parents = new Map();
|
||||
|
||||
constructor({ ast, text }) {
|
||||
super({ ast, text });
|
||||
}
|
||||
|
||||
getParent(node) {
|
||||
return this.#parents.get(node);
|
||||
}
|
||||
|
||||
traverse() {
|
||||
const steps = [];
|
||||
|
||||
for (const { node, parent, phase } of iterator(this.ast)) {
|
||||
//save the parent information
|
||||
this.#parent.set(node, parent);
|
||||
|
||||
steps.push(
|
||||
new VisitNodeStep({
|
||||
target: node,
|
||||
phase: phase === "enter" ? 1 : 2,
|
||||
args: [node, parent],
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
return steps;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
In general, it's safe to collect the parent information during the `traverse()` method as `getParent()` and `getAncestor()` will only be called from rules once the AST has been traversed at least once.
|
||||
|
||||
## License
|
||||
|
||||
Apache 2.0
|
||||
|
||||
<!-- NOTE: This section is autogenerated. Do not manually edit.-->
|
||||
<!--sponsorsstart-->
|
||||
|
||||
## Sponsors
|
||||
|
||||
The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. [Become a Sponsor](https://eslint.org/donate)
|
||||
to get your logo on our READMEs and [website](https://eslint.org/sponsors).
|
||||
|
||||
<h3>Platinum Sponsors</h3>
|
||||
<p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="128"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="128"></a></p><h3>Gold Sponsors</h3>
|
||||
<p><a href="https://qlty.sh/"><img src="https://images.opencollective.com/qltysh/33d157d/logo.png" alt="Qlty Software" height="96"></a> <a href="https://trunk.io/"><img src="https://images.opencollective.com/trunkio/fb92d60/avatar.png" alt="trunk.io" height="96"></a> <a href="https://shopify.engineering/"><img src="https://avatars.githubusercontent.com/u/8085" alt="Shopify" height="96"></a></p><h3>Silver Sponsors</h3>
|
||||
<p><a href="https://vite.dev/"><img src="https://images.opencollective.com/vite/e6d15e1/logo.png" alt="Vite" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a> <a href="https://americanexpress.io"><img src="https://avatars.githubusercontent.com/u/3853301" alt="American Express" 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>
|
||||
<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://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" 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://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104" alt="Nx" height="32"></a> <a href="https://opensource.mercedes-benz.com/"><img src="https://avatars.githubusercontent.com/u/34240465" alt="Mercedes-Benz Group" 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="LambdaTest" height="32"></a></p>
|
||||
<h3>Technology Sponsors</h3>
|
||||
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.
|
||||
<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>
|
||||
<!--sponsorsend-->
|
620
node_modules/@eslint/plugin-kit/dist/cjs/index.cjs
generated
vendored
620
node_modules/@eslint/plugin-kit/dist/cjs/index.cjs
generated
vendored
|
@ -1,620 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
var levn = require('levn');
|
||||
|
||||
/**
|
||||
* @fileoverview Config Comment Parser
|
||||
* @author Nicholas C. Zakas
|
||||
*/
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Type Definitions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/** @typedef {import("@eslint/core").RuleConfig} RuleConfig */
|
||||
/** @typedef {import("@eslint/core").RulesConfig} RulesConfig */
|
||||
/** @typedef {import("./types.ts").StringConfig} StringConfig */
|
||||
/** @typedef {import("./types.ts").BooleanConfig} BooleanConfig */
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
const directivesPattern = /^([a-z]+(?:-[a-z]+)*)(?:\s|$)/u;
|
||||
const validSeverities = new Set([0, 1, 2, "off", "warn", "error"]);
|
||||
|
||||
/**
|
||||
* Determines if the severity in the rule configuration is valid.
|
||||
* @param {RuleConfig} ruleConfig A rule's configuration.
|
||||
* @returns {boolean} `true` if the severity is valid, otherwise `false`.
|
||||
*/
|
||||
function isSeverityValid(ruleConfig) {
|
||||
const severity = Array.isArray(ruleConfig) ? ruleConfig[0] : ruleConfig;
|
||||
return validSeverities.has(severity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if all severities in the rules configuration are valid.
|
||||
* @param {RulesConfig} rulesConfig The rules configuration to check.
|
||||
* @returns {boolean} `true` if all severities are valid, otherwise `false`.
|
||||
*/
|
||||
function isEverySeverityValid(rulesConfig) {
|
||||
return Object.values(rulesConfig).every(isSeverityValid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a directive comment.
|
||||
*/
|
||||
class DirectiveComment {
|
||||
/**
|
||||
* The label of the directive, such as "eslint", "eslint-disable", etc.
|
||||
* @type {string}
|
||||
*/
|
||||
label = "";
|
||||
|
||||
/**
|
||||
* The value of the directive (the string after the label).
|
||||
* @type {string}
|
||||
*/
|
||||
value = "";
|
||||
|
||||
/**
|
||||
* The justification of the directive (the string after the --).
|
||||
* @type {string}
|
||||
*/
|
||||
justification = "";
|
||||
|
||||
/**
|
||||
* Creates a new directive comment.
|
||||
* @param {string} label The label of the directive.
|
||||
* @param {string} value The value of the directive.
|
||||
* @param {string} justification The justification of the directive.
|
||||
*/
|
||||
constructor(label, value, justification) {
|
||||
this.label = label;
|
||||
this.value = value;
|
||||
this.justification = justification;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Public Interface
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Object to parse ESLint configuration comments.
|
||||
*/
|
||||
class ConfigCommentParser {
|
||||
/**
|
||||
* Parses a list of "name:string_value" or/and "name" options divided by comma or
|
||||
* whitespace. Used for "global" comments.
|
||||
* @param {string} string The string to parse.
|
||||
* @returns {StringConfig} Result map object of names and string values, or null values if no value was provided.
|
||||
*/
|
||||
parseStringConfig(string) {
|
||||
const items = /** @type {StringConfig} */ ({});
|
||||
|
||||
// Collapse whitespace around `:` and `,` to make parsing easier
|
||||
const trimmedString = string
|
||||
.trim()
|
||||
.replace(/(?<!\s)\s*([:,])\s*/gu, "$1");
|
||||
|
||||
trimmedString.split(/\s|,+/u).forEach(name => {
|
||||
if (!name) {
|
||||
return;
|
||||
}
|
||||
|
||||
// value defaults to null (if not provided), e.g: "foo" => ["foo", null]
|
||||
const [key, value = null] = name.split(":");
|
||||
|
||||
items[key] = value;
|
||||
});
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a JSON-like config.
|
||||
* @param {string} string The string to parse.
|
||||
* @returns {({ok: true, config: RulesConfig}|{ok: false, error: {message: string}})} Result map object
|
||||
*/
|
||||
parseJSONLikeConfig(string) {
|
||||
// Parses a JSON-like comment by the same way as parsing CLI option.
|
||||
try {
|
||||
const items =
|
||||
/** @type {RulesConfig} */ (levn.parse("Object", string)) || {};
|
||||
|
||||
/*
|
||||
* When the configuration has any invalid severities, it should be completely
|
||||
* ignored. This is because the configuration is not valid and should not be
|
||||
* applied.
|
||||
*
|
||||
* For example, the following configuration is invalid:
|
||||
*
|
||||
* "no-alert: 2 no-console: 2"
|
||||
*
|
||||
* This results in a configuration of { "no-alert": "2 no-console: 2" }, which is
|
||||
* not valid. In this case, the configuration should be ignored.
|
||||
*/
|
||||
if (isEverySeverityValid(items)) {
|
||||
return {
|
||||
ok: true,
|
||||
config: items,
|
||||
};
|
||||
}
|
||||
} catch {
|
||||
// levn parsing error: ignore to parse the string by a fallback.
|
||||
}
|
||||
|
||||
/*
|
||||
* Optionator cannot parse commaless notations.
|
||||
* But we are supporting that. So this is a fallback for that.
|
||||
*/
|
||||
const normalizedString = string
|
||||
.replace(/(?<![-a-zA-Z0-9/])([-a-zA-Z0-9/]+):/gu, '"$1":')
|
||||
.replace(/(\]|[0-9])\s+(?=")/u, "$1,");
|
||||
|
||||
try {
|
||||
const items = JSON.parse(`{${normalizedString}}`);
|
||||
|
||||
return {
|
||||
ok: true,
|
||||
config: items,
|
||||
};
|
||||
} catch (ex) {
|
||||
const errorMessage = ex instanceof Error ? ex.message : String(ex);
|
||||
|
||||
return {
|
||||
ok: false,
|
||||
error: {
|
||||
message: `Failed to parse JSON from '${normalizedString}': ${errorMessage}`,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a config of values separated by comma.
|
||||
* @param {string} string The string to parse.
|
||||
* @returns {BooleanConfig} Result map of values and true values
|
||||
*/
|
||||
parseListConfig(string) {
|
||||
const items = /** @type {BooleanConfig} */ ({});
|
||||
|
||||
string.split(",").forEach(name => {
|
||||
const trimmedName = name
|
||||
.trim()
|
||||
.replace(
|
||||
/^(?<quote>['"]?)(?<ruleId>.*)\k<quote>$/su,
|
||||
"$<ruleId>",
|
||||
);
|
||||
|
||||
if (trimmedName) {
|
||||
items[trimmedName] = true;
|
||||
}
|
||||
});
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the directive and the justification from a given directive comment and trim them.
|
||||
* @param {string} value The comment text to extract.
|
||||
* @returns {{directivePart: string, justificationPart: string}} The extracted directive and justification.
|
||||
*/
|
||||
#extractDirectiveComment(value) {
|
||||
const match = /\s-{2,}\s/u.exec(value);
|
||||
|
||||
if (!match) {
|
||||
return { directivePart: value.trim(), justificationPart: "" };
|
||||
}
|
||||
|
||||
const directive = value.slice(0, match.index).trim();
|
||||
const justification = value.slice(match.index + match[0].length).trim();
|
||||
|
||||
return { directivePart: directive, justificationPart: justification };
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a directive comment into directive text and value.
|
||||
* @param {string} string The string with the directive to be parsed.
|
||||
* @returns {DirectiveComment|undefined} The parsed directive or `undefined` if the directive is invalid.
|
||||
*/
|
||||
parseDirective(string) {
|
||||
const { directivePart, justificationPart } =
|
||||
this.#extractDirectiveComment(string);
|
||||
const match = directivesPattern.exec(directivePart);
|
||||
|
||||
if (!match) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const directiveText = match[1];
|
||||
const directiveValue = directivePart.slice(
|
||||
match.index + directiveText.length,
|
||||
);
|
||||
|
||||
return new DirectiveComment(
|
||||
directiveText,
|
||||
directiveValue.trim(),
|
||||
justificationPart,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @fileoverview A collection of helper classes for implementing `SourceCode`.
|
||||
* @author Nicholas C. Zakas
|
||||
*/
|
||||
|
||||
/* eslint class-methods-use-this: off -- Required to complete interface. */
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Type Definitions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/** @typedef {import("@eslint/core").VisitTraversalStep} VisitTraversalStep */
|
||||
/** @typedef {import("@eslint/core").CallTraversalStep} CallTraversalStep */
|
||||
/** @typedef {import("@eslint/core").TraversalStep} TraversalStep */
|
||||
/** @typedef {import("@eslint/core").SourceLocation} SourceLocation */
|
||||
/** @typedef {import("@eslint/core").SourceLocationWithOffset} SourceLocationWithOffset */
|
||||
/** @typedef {import("@eslint/core").SourceRange} SourceRange */
|
||||
/** @typedef {import("@eslint/core").Directive} IDirective */
|
||||
/** @typedef {import("@eslint/core").DirectiveType} DirectiveType */
|
||||
/** @typedef {import("@eslint/core").SourceCodeBaseTypeOptions} SourceCodeBaseTypeOptions */
|
||||
/**
|
||||
* @typedef {import("@eslint/core").TextSourceCode<Options>} TextSourceCode<Options>
|
||||
* @template {SourceCodeBaseTypeOptions} [Options=SourceCodeBaseTypeOptions]
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Determines if a node has ESTree-style loc information.
|
||||
* @param {object} node The node to check.
|
||||
* @returns {node is {loc:SourceLocation}} `true` if the node has ESTree-style loc information, `false` if not.
|
||||
*/
|
||||
function hasESTreeStyleLoc(node) {
|
||||
return "loc" in node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if a node has position-style loc information.
|
||||
* @param {object} node The node to check.
|
||||
* @returns {node is {position:SourceLocation}} `true` if the node has position-style range information, `false` if not.
|
||||
*/
|
||||
function hasPosStyleLoc(node) {
|
||||
return "position" in node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if a node has ESTree-style range information.
|
||||
* @param {object} node The node to check.
|
||||
* @returns {node is {range:SourceRange}} `true` if the node has ESTree-style range information, `false` if not.
|
||||
*/
|
||||
function hasESTreeStyleRange(node) {
|
||||
return "range" in node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if a node has position-style range information.
|
||||
* @param {object} node The node to check.
|
||||
* @returns {node is {position:SourceLocationWithOffset}} `true` if the node has position-style range information, `false` if not.
|
||||
*/
|
||||
function hasPosStyleRange(node) {
|
||||
return "position" in node;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Exports
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* A class to represent a step in the traversal process where a node is visited.
|
||||
* @implements {VisitTraversalStep}
|
||||
*/
|
||||
class VisitNodeStep {
|
||||
/**
|
||||
* The type of the step.
|
||||
* @type {"visit"}
|
||||
* @readonly
|
||||
*/
|
||||
type = "visit";
|
||||
|
||||
/**
|
||||
* The kind of the step. Represents the same data as the `type` property
|
||||
* but it's a number for performance.
|
||||
* @type {1}
|
||||
* @readonly
|
||||
*/
|
||||
kind = 1;
|
||||
|
||||
/**
|
||||
* The target of the step.
|
||||
* @type {object}
|
||||
*/
|
||||
target;
|
||||
|
||||
/**
|
||||
* The phase of the step.
|
||||
* @type {1|2}
|
||||
*/
|
||||
phase;
|
||||
|
||||
/**
|
||||
* The arguments of the step.
|
||||
* @type {Array<any>}
|
||||
*/
|
||||
args;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {Object} options The options for the step.
|
||||
* @param {object} options.target The target of the step.
|
||||
* @param {1|2} options.phase The phase of the step.
|
||||
* @param {Array<any>} options.args The arguments of the step.
|
||||
*/
|
||||
constructor({ target, phase, args }) {
|
||||
this.target = target;
|
||||
this.phase = phase;
|
||||
this.args = args;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A class to represent a step in the traversal process where a
|
||||
* method is called.
|
||||
* @implements {CallTraversalStep}
|
||||
*/
|
||||
class CallMethodStep {
|
||||
/**
|
||||
* The type of the step.
|
||||
* @type {"call"}
|
||||
* @readonly
|
||||
*/
|
||||
type = "call";
|
||||
|
||||
/**
|
||||
* The kind of the step. Represents the same data as the `type` property
|
||||
* but it's a number for performance.
|
||||
* @type {2}
|
||||
* @readonly
|
||||
*/
|
||||
kind = 2;
|
||||
|
||||
/**
|
||||
* The name of the method to call.
|
||||
* @type {string}
|
||||
*/
|
||||
target;
|
||||
|
||||
/**
|
||||
* The arguments to pass to the method.
|
||||
* @type {Array<any>}
|
||||
*/
|
||||
args;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {Object} options The options for the step.
|
||||
* @param {string} options.target The target of the step.
|
||||
* @param {Array<any>} options.args The arguments of the step.
|
||||
*/
|
||||
constructor({ target, args }) {
|
||||
this.target = target;
|
||||
this.args = args;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A class to represent a directive comment.
|
||||
* @implements {IDirective}
|
||||
*/
|
||||
class Directive {
|
||||
/**
|
||||
* The type of directive.
|
||||
* @type {DirectiveType}
|
||||
* @readonly
|
||||
*/
|
||||
type;
|
||||
|
||||
/**
|
||||
* The node representing the directive.
|
||||
* @type {unknown}
|
||||
* @readonly
|
||||
*/
|
||||
node;
|
||||
|
||||
/**
|
||||
* Everything after the "eslint-disable" portion of the directive,
|
||||
* but before the "--" that indicates the justification.
|
||||
* @type {string}
|
||||
* @readonly
|
||||
*/
|
||||
value;
|
||||
|
||||
/**
|
||||
* The justification for the directive.
|
||||
* @type {string}
|
||||
* @readonly
|
||||
*/
|
||||
justification;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {Object} options The options for the directive.
|
||||
* @param {"disable"|"enable"|"disable-next-line"|"disable-line"} options.type The type of directive.
|
||||
* @param {unknown} options.node The node representing the directive.
|
||||
* @param {string} options.value The value of the directive.
|
||||
* @param {string} options.justification The justification for the directive.
|
||||
*/
|
||||
constructor({ type, node, value, justification }) {
|
||||
this.type = type;
|
||||
this.node = node;
|
||||
this.value = value;
|
||||
this.justification = justification;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Source Code Base Object
|
||||
* @template {SourceCodeBaseTypeOptions & {SyntaxElementWithLoc: object}} [Options=SourceCodeBaseTypeOptions & {SyntaxElementWithLoc: object}]
|
||||
* @implements {TextSourceCode<Options>}
|
||||
*/
|
||||
class TextSourceCodeBase {
|
||||
/**
|
||||
* The lines of text in the source code.
|
||||
* @type {Array<string>}
|
||||
*/
|
||||
#lines;
|
||||
|
||||
/**
|
||||
* The AST of the source code.
|
||||
* @type {Options['RootNode']}
|
||||
*/
|
||||
ast;
|
||||
|
||||
/**
|
||||
* The text of the source code.
|
||||
* @type {string}
|
||||
*/
|
||||
text;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {Object} options The options for the instance.
|
||||
* @param {string} options.text The source code text.
|
||||
* @param {Options['RootNode']} options.ast The root AST node.
|
||||
* @param {RegExp} [options.lineEndingPattern] The pattern to match lineEndings in the source code.
|
||||
*/
|
||||
constructor({ text, ast, lineEndingPattern = /\r?\n/u }) {
|
||||
this.ast = ast;
|
||||
this.text = text;
|
||||
this.#lines = text.split(lineEndingPattern);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the loc information for the given node or token.
|
||||
* @param {Options['SyntaxElementWithLoc']} nodeOrToken The node or token to get the loc information for.
|
||||
* @returns {SourceLocation} The loc information for the node or token.
|
||||
* @throws {Error} If the node or token does not have loc information.
|
||||
*/
|
||||
getLoc(nodeOrToken) {
|
||||
if (hasESTreeStyleLoc(nodeOrToken)) {
|
||||
return nodeOrToken.loc;
|
||||
}
|
||||
|
||||
if (hasPosStyleLoc(nodeOrToken)) {
|
||||
return nodeOrToken.position;
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
"Custom getLoc() method must be implemented in the subclass.",
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the range information for the given node or token.
|
||||
* @param {Options['SyntaxElementWithLoc']} nodeOrToken The node or token to get the range information for.
|
||||
* @returns {SourceRange} The range information for the node or token.
|
||||
* @throws {Error} If the node or token does not have range information.
|
||||
*/
|
||||
getRange(nodeOrToken) {
|
||||
if (hasESTreeStyleRange(nodeOrToken)) {
|
||||
return nodeOrToken.range;
|
||||
}
|
||||
|
||||
if (hasPosStyleRange(nodeOrToken)) {
|
||||
return [
|
||||
nodeOrToken.position.start.offset,
|
||||
nodeOrToken.position.end.offset,
|
||||
];
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
"Custom getRange() method must be implemented in the subclass.",
|
||||
);
|
||||
}
|
||||
|
||||
/* eslint-disable no-unused-vars -- Required to complete interface. */
|
||||
/**
|
||||
* Returns the parent of the given node.
|
||||
* @param {Options['SyntaxElementWithLoc']} node The node to get the parent of.
|
||||
* @returns {Options['SyntaxElementWithLoc']|undefined} The parent of the node.
|
||||
* @throws {Error} If the method is not implemented in the subclass.
|
||||
*/
|
||||
getParent(node) {
|
||||
throw new Error("Not implemented.");
|
||||
}
|
||||
/* eslint-enable no-unused-vars -- Required to complete interface. */
|
||||
|
||||
/**
|
||||
* Gets all the ancestors of a given node
|
||||
* @param {Options['SyntaxElementWithLoc']} node The node
|
||||
* @returns {Array<Options['SyntaxElementWithLoc']>} All the ancestor nodes in the AST, not including the provided node, starting
|
||||
* from the root node at index 0 and going inwards to the parent node.
|
||||
* @throws {TypeError} When `node` is missing.
|
||||
*/
|
||||
getAncestors(node) {
|
||||
if (!node) {
|
||||
throw new TypeError("Missing required argument: node.");
|
||||
}
|
||||
|
||||
const ancestorsStartingAtParent = [];
|
||||
|
||||
for (
|
||||
let ancestor = this.getParent(node);
|
||||
ancestor;
|
||||
ancestor = this.getParent(ancestor)
|
||||
) {
|
||||
ancestorsStartingAtParent.push(ancestor);
|
||||
}
|
||||
|
||||
return ancestorsStartingAtParent.reverse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the source code for the given node.
|
||||
* @param {Options['SyntaxElementWithLoc']} [node] The AST node to get the text for.
|
||||
* @param {number} [beforeCount] The number of characters before the node to retrieve.
|
||||
* @param {number} [afterCount] The number of characters after the node to retrieve.
|
||||
* @returns {string} The text representing the AST node.
|
||||
* @public
|
||||
*/
|
||||
getText(node, beforeCount, afterCount) {
|
||||
if (node) {
|
||||
const range = this.getRange(node);
|
||||
return this.text.slice(
|
||||
Math.max(range[0] - (beforeCount || 0), 0),
|
||||
range[1] + (afterCount || 0),
|
||||
);
|
||||
}
|
||||
return this.text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the entire source text split into an array of lines.
|
||||
* @returns {Array<string>} The source text as an array of lines.
|
||||
* @public
|
||||
*/
|
||||
get lines() {
|
||||
return this.#lines;
|
||||
}
|
||||
|
||||
/**
|
||||
* Traverse the source code and return the steps that were taken.
|
||||
* @returns {Iterable<TraversalStep>} The steps that were taken while traversing the source code.
|
||||
*/
|
||||
traverse() {
|
||||
throw new Error("Not implemented.");
|
||||
}
|
||||
}
|
||||
|
||||
exports.CallMethodStep = CallMethodStep;
|
||||
exports.ConfigCommentParser = ConfigCommentParser;
|
||||
exports.Directive = Directive;
|
||||
exports.TextSourceCodeBase = TextSourceCodeBase;
|
||||
exports.VisitNodeStep = VisitNodeStep;
|
298
node_modules/@eslint/plugin-kit/dist/cjs/index.d.cts
generated
vendored
298
node_modules/@eslint/plugin-kit/dist/cjs/index.d.cts
generated
vendored
|
@ -1,298 +0,0 @@
|
|||
export type VisitTraversalStep = import("@eslint/core").VisitTraversalStep;
|
||||
export type CallTraversalStep = import("@eslint/core").CallTraversalStep;
|
||||
export type TraversalStep = import("@eslint/core").TraversalStep;
|
||||
export type SourceLocation = import("@eslint/core").SourceLocation;
|
||||
export type SourceLocationWithOffset = import("@eslint/core").SourceLocationWithOffset;
|
||||
export type SourceRange = import("@eslint/core").SourceRange;
|
||||
export type IDirective = import("@eslint/core").Directive;
|
||||
export type DirectiveType = import("@eslint/core").DirectiveType;
|
||||
export type SourceCodeBaseTypeOptions = import("@eslint/core").SourceCodeBaseTypeOptions;
|
||||
/**
|
||||
* <Options>
|
||||
*/
|
||||
export type TextSourceCode<Options extends SourceCodeBaseTypeOptions = import("@eslint/core").SourceCodeBaseTypeOptions> = import("@eslint/core").TextSourceCode<Options>;
|
||||
export type RuleConfig = import("@eslint/core").RuleConfig;
|
||||
export type RulesConfig = import("@eslint/core").RulesConfig;
|
||||
export type StringConfig = import("./types.cts").StringConfig;
|
||||
export type BooleanConfig = import("./types.cts").BooleanConfig;
|
||||
/**
|
||||
* A class to represent a step in the traversal process where a
|
||||
* method is called.
|
||||
* @implements {CallTraversalStep}
|
||||
*/
|
||||
export class CallMethodStep implements CallTraversalStep {
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {Object} options The options for the step.
|
||||
* @param {string} options.target The target of the step.
|
||||
* @param {Array<any>} options.args The arguments of the step.
|
||||
*/
|
||||
constructor({ target, args }: {
|
||||
target: string;
|
||||
args: Array<any>;
|
||||
});
|
||||
/**
|
||||
* The type of the step.
|
||||
* @type {"call"}
|
||||
* @readonly
|
||||
*/
|
||||
readonly type: "call";
|
||||
/**
|
||||
* The kind of the step. Represents the same data as the `type` property
|
||||
* but it's a number for performance.
|
||||
* @type {2}
|
||||
* @readonly
|
||||
*/
|
||||
readonly kind: 2;
|
||||
/**
|
||||
* The name of the method to call.
|
||||
* @type {string}
|
||||
*/
|
||||
target: string;
|
||||
/**
|
||||
* The arguments to pass to the method.
|
||||
* @type {Array<any>}
|
||||
*/
|
||||
args: Array<any>;
|
||||
}
|
||||
/**
|
||||
* Object to parse ESLint configuration comments.
|
||||
*/
|
||||
export class ConfigCommentParser {
|
||||
/**
|
||||
* Parses a list of "name:string_value" or/and "name" options divided by comma or
|
||||
* whitespace. Used for "global" comments.
|
||||
* @param {string} string The string to parse.
|
||||
* @returns {StringConfig} Result map object of names and string values, or null values if no value was provided.
|
||||
*/
|
||||
parseStringConfig(string: string): StringConfig;
|
||||
/**
|
||||
* Parses a JSON-like config.
|
||||
* @param {string} string The string to parse.
|
||||
* @returns {({ok: true, config: RulesConfig}|{ok: false, error: {message: string}})} Result map object
|
||||
*/
|
||||
parseJSONLikeConfig(string: string): ({
|
||||
ok: true;
|
||||
config: RulesConfig;
|
||||
} | {
|
||||
ok: false;
|
||||
error: {
|
||||
message: string;
|
||||
};
|
||||
});
|
||||
/**
|
||||
* Parses a config of values separated by comma.
|
||||
* @param {string} string The string to parse.
|
||||
* @returns {BooleanConfig} Result map of values and true values
|
||||
*/
|
||||
parseListConfig(string: string): BooleanConfig;
|
||||
/**
|
||||
* Parses a directive comment into directive text and value.
|
||||
* @param {string} string The string with the directive to be parsed.
|
||||
* @returns {DirectiveComment|undefined} The parsed directive or `undefined` if the directive is invalid.
|
||||
*/
|
||||
parseDirective(string: string): DirectiveComment | undefined;
|
||||
#private;
|
||||
}
|
||||
/**
|
||||
* A class to represent a directive comment.
|
||||
* @implements {IDirective}
|
||||
*/
|
||||
export class Directive implements IDirective {
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {Object} options The options for the directive.
|
||||
* @param {"disable"|"enable"|"disable-next-line"|"disable-line"} options.type The type of directive.
|
||||
* @param {unknown} options.node The node representing the directive.
|
||||
* @param {string} options.value The value of the directive.
|
||||
* @param {string} options.justification The justification for the directive.
|
||||
*/
|
||||
constructor({ type, node, value, justification }: {
|
||||
type: "disable" | "enable" | "disable-next-line" | "disable-line";
|
||||
node: unknown;
|
||||
value: string;
|
||||
justification: string;
|
||||
});
|
||||
/**
|
||||
* The type of directive.
|
||||
* @type {DirectiveType}
|
||||
* @readonly
|
||||
*/
|
||||
readonly type: DirectiveType;
|
||||
/**
|
||||
* The node representing the directive.
|
||||
* @type {unknown}
|
||||
* @readonly
|
||||
*/
|
||||
readonly node: unknown;
|
||||
/**
|
||||
* Everything after the "eslint-disable" portion of the directive,
|
||||
* but before the "--" that indicates the justification.
|
||||
* @type {string}
|
||||
* @readonly
|
||||
*/
|
||||
readonly value: string;
|
||||
/**
|
||||
* The justification for the directive.
|
||||
* @type {string}
|
||||
* @readonly
|
||||
*/
|
||||
readonly justification: string;
|
||||
}
|
||||
/**
|
||||
* Source Code Base Object
|
||||
* @template {SourceCodeBaseTypeOptions & {SyntaxElementWithLoc: object}} [Options=SourceCodeBaseTypeOptions & {SyntaxElementWithLoc: object}]
|
||||
* @implements {TextSourceCode<Options>}
|
||||
*/
|
||||
export class TextSourceCodeBase<Options extends SourceCodeBaseTypeOptions & {
|
||||
SyntaxElementWithLoc: object;
|
||||
} = import("@eslint/core").SourceCodeBaseTypeOptions & {
|
||||
SyntaxElementWithLoc: object;
|
||||
}> implements TextSourceCode<Options> {
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {Object} options The options for the instance.
|
||||
* @param {string} options.text The source code text.
|
||||
* @param {Options['RootNode']} options.ast The root AST node.
|
||||
* @param {RegExp} [options.lineEndingPattern] The pattern to match lineEndings in the source code.
|
||||
*/
|
||||
constructor({ text, ast, lineEndingPattern }: {
|
||||
text: string;
|
||||
ast: Options["RootNode"];
|
||||
lineEndingPattern?: RegExp;
|
||||
});
|
||||
/**
|
||||
* The AST of the source code.
|
||||
* @type {Options['RootNode']}
|
||||
*/
|
||||
ast: Options["RootNode"];
|
||||
/**
|
||||
* The text of the source code.
|
||||
* @type {string}
|
||||
*/
|
||||
text: string;
|
||||
/**
|
||||
* Returns the loc information for the given node or token.
|
||||
* @param {Options['SyntaxElementWithLoc']} nodeOrToken The node or token to get the loc information for.
|
||||
* @returns {SourceLocation} The loc information for the node or token.
|
||||
* @throws {Error} If the node or token does not have loc information.
|
||||
*/
|
||||
getLoc(nodeOrToken: Options["SyntaxElementWithLoc"]): SourceLocation;
|
||||
/**
|
||||
* Returns the range information for the given node or token.
|
||||
* @param {Options['SyntaxElementWithLoc']} nodeOrToken The node or token to get the range information for.
|
||||
* @returns {SourceRange} The range information for the node or token.
|
||||
* @throws {Error} If the node or token does not have range information.
|
||||
*/
|
||||
getRange(nodeOrToken: Options["SyntaxElementWithLoc"]): SourceRange;
|
||||
/**
|
||||
* Returns the parent of the given node.
|
||||
* @param {Options['SyntaxElementWithLoc']} node The node to get the parent of.
|
||||
* @returns {Options['SyntaxElementWithLoc']|undefined} The parent of the node.
|
||||
* @throws {Error} If the method is not implemented in the subclass.
|
||||
*/
|
||||
getParent(node: Options["SyntaxElementWithLoc"]): Options["SyntaxElementWithLoc"] | undefined;
|
||||
/**
|
||||
* Gets all the ancestors of a given node
|
||||
* @param {Options['SyntaxElementWithLoc']} node The node
|
||||
* @returns {Array<Options['SyntaxElementWithLoc']>} All the ancestor nodes in the AST, not including the provided node, starting
|
||||
* from the root node at index 0 and going inwards to the parent node.
|
||||
* @throws {TypeError} When `node` is missing.
|
||||
*/
|
||||
getAncestors(node: Options["SyntaxElementWithLoc"]): Array<Options["SyntaxElementWithLoc"]>;
|
||||
/**
|
||||
* Gets the source code for the given node.
|
||||
* @param {Options['SyntaxElementWithLoc']} [node] The AST node to get the text for.
|
||||
* @param {number} [beforeCount] The number of characters before the node to retrieve.
|
||||
* @param {number} [afterCount] The number of characters after the node to retrieve.
|
||||
* @returns {string} The text representing the AST node.
|
||||
* @public
|
||||
*/
|
||||
public getText(node?: Options["SyntaxElementWithLoc"], beforeCount?: number, afterCount?: number): string;
|
||||
/**
|
||||
* Gets the entire source text split into an array of lines.
|
||||
* @returns {Array<string>} The source text as an array of lines.
|
||||
* @public
|
||||
*/
|
||||
public get lines(): Array<string>;
|
||||
/**
|
||||
* Traverse the source code and return the steps that were taken.
|
||||
* @returns {Iterable<TraversalStep>} The steps that were taken while traversing the source code.
|
||||
*/
|
||||
traverse(): Iterable<TraversalStep>;
|
||||
#private;
|
||||
}
|
||||
/**
|
||||
* A class to represent a step in the traversal process where a node is visited.
|
||||
* @implements {VisitTraversalStep}
|
||||
*/
|
||||
export class VisitNodeStep implements VisitTraversalStep {
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {Object} options The options for the step.
|
||||
* @param {object} options.target The target of the step.
|
||||
* @param {1|2} options.phase The phase of the step.
|
||||
* @param {Array<any>} options.args The arguments of the step.
|
||||
*/
|
||||
constructor({ target, phase, args }: {
|
||||
target: object;
|
||||
phase: 1 | 2;
|
||||
args: Array<any>;
|
||||
});
|
||||
/**
|
||||
* The type of the step.
|
||||
* @type {"visit"}
|
||||
* @readonly
|
||||
*/
|
||||
readonly type: "visit";
|
||||
/**
|
||||
* The kind of the step. Represents the same data as the `type` property
|
||||
* but it's a number for performance.
|
||||
* @type {1}
|
||||
* @readonly
|
||||
*/
|
||||
readonly kind: 1;
|
||||
/**
|
||||
* The target of the step.
|
||||
* @type {object}
|
||||
*/
|
||||
target: object;
|
||||
/**
|
||||
* The phase of the step.
|
||||
* @type {1|2}
|
||||
*/
|
||||
phase: 1 | 2;
|
||||
/**
|
||||
* The arguments of the step.
|
||||
* @type {Array<any>}
|
||||
*/
|
||||
args: Array<any>;
|
||||
}
|
||||
/**
|
||||
* Represents a directive comment.
|
||||
*/
|
||||
declare class DirectiveComment {
|
||||
/**
|
||||
* Creates a new directive comment.
|
||||
* @param {string} label The label of the directive.
|
||||
* @param {string} value The value of the directive.
|
||||
* @param {string} justification The justification of the directive.
|
||||
*/
|
||||
constructor(label: string, value: string, justification: string);
|
||||
/**
|
||||
* The label of the directive, such as "eslint", "eslint-disable", etc.
|
||||
* @type {string}
|
||||
*/
|
||||
label: string;
|
||||
/**
|
||||
* The value of the directive (the string after the label).
|
||||
* @type {string}
|
||||
*/
|
||||
value: string;
|
||||
/**
|
||||
* The justification of the directive (the string after the --).
|
||||
* @type {string}
|
||||
*/
|
||||
justification: string;
|
||||
}
|
||||
export {};
|
7
node_modules/@eslint/plugin-kit/dist/cjs/types.cts
generated
vendored
7
node_modules/@eslint/plugin-kit/dist/cjs/types.cts
generated
vendored
|
@ -1,7 +0,0 @@
|
|||
/**
|
||||
* @fileoverview Types for the plugin-kit package.
|
||||
* @author Nicholas C. Zakas
|
||||
*/
|
||||
|
||||
export type StringConfig = Record<string, string | null>;
|
||||
export type BooleanConfig = Record<string, boolean>;
|
298
node_modules/@eslint/plugin-kit/dist/esm/index.d.ts
generated
vendored
298
node_modules/@eslint/plugin-kit/dist/esm/index.d.ts
generated
vendored
|
@ -1,298 +0,0 @@
|
|||
export type VisitTraversalStep = import("@eslint/core").VisitTraversalStep;
|
||||
export type CallTraversalStep = import("@eslint/core").CallTraversalStep;
|
||||
export type TraversalStep = import("@eslint/core").TraversalStep;
|
||||
export type SourceLocation = import("@eslint/core").SourceLocation;
|
||||
export type SourceLocationWithOffset = import("@eslint/core").SourceLocationWithOffset;
|
||||
export type SourceRange = import("@eslint/core").SourceRange;
|
||||
export type IDirective = import("@eslint/core").Directive;
|
||||
export type DirectiveType = import("@eslint/core").DirectiveType;
|
||||
export type SourceCodeBaseTypeOptions = import("@eslint/core").SourceCodeBaseTypeOptions;
|
||||
/**
|
||||
* <Options>
|
||||
*/
|
||||
export type TextSourceCode<Options extends SourceCodeBaseTypeOptions = import("@eslint/core").SourceCodeBaseTypeOptions> = import("@eslint/core").TextSourceCode<Options>;
|
||||
export type RuleConfig = import("@eslint/core").RuleConfig;
|
||||
export type RulesConfig = import("@eslint/core").RulesConfig;
|
||||
export type StringConfig = import("./types.ts").StringConfig;
|
||||
export type BooleanConfig = import("./types.ts").BooleanConfig;
|
||||
/**
|
||||
* A class to represent a step in the traversal process where a
|
||||
* method is called.
|
||||
* @implements {CallTraversalStep}
|
||||
*/
|
||||
export class CallMethodStep implements CallTraversalStep {
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {Object} options The options for the step.
|
||||
* @param {string} options.target The target of the step.
|
||||
* @param {Array<any>} options.args The arguments of the step.
|
||||
*/
|
||||
constructor({ target, args }: {
|
||||
target: string;
|
||||
args: Array<any>;
|
||||
});
|
||||
/**
|
||||
* The type of the step.
|
||||
* @type {"call"}
|
||||
* @readonly
|
||||
*/
|
||||
readonly type: "call";
|
||||
/**
|
||||
* The kind of the step. Represents the same data as the `type` property
|
||||
* but it's a number for performance.
|
||||
* @type {2}
|
||||
* @readonly
|
||||
*/
|
||||
readonly kind: 2;
|
||||
/**
|
||||
* The name of the method to call.
|
||||
* @type {string}
|
||||
*/
|
||||
target: string;
|
||||
/**
|
||||
* The arguments to pass to the method.
|
||||
* @type {Array<any>}
|
||||
*/
|
||||
args: Array<any>;
|
||||
}
|
||||
/**
|
||||
* Object to parse ESLint configuration comments.
|
||||
*/
|
||||
export class ConfigCommentParser {
|
||||
/**
|
||||
* Parses a list of "name:string_value" or/and "name" options divided by comma or
|
||||
* whitespace. Used for "global" comments.
|
||||
* @param {string} string The string to parse.
|
||||
* @returns {StringConfig} Result map object of names and string values, or null values if no value was provided.
|
||||
*/
|
||||
parseStringConfig(string: string): StringConfig;
|
||||
/**
|
||||
* Parses a JSON-like config.
|
||||
* @param {string} string The string to parse.
|
||||
* @returns {({ok: true, config: RulesConfig}|{ok: false, error: {message: string}})} Result map object
|
||||
*/
|
||||
parseJSONLikeConfig(string: string): ({
|
||||
ok: true;
|
||||
config: RulesConfig;
|
||||
} | {
|
||||
ok: false;
|
||||
error: {
|
||||
message: string;
|
||||
};
|
||||
});
|
||||
/**
|
||||
* Parses a config of values separated by comma.
|
||||
* @param {string} string The string to parse.
|
||||
* @returns {BooleanConfig} Result map of values and true values
|
||||
*/
|
||||
parseListConfig(string: string): BooleanConfig;
|
||||
/**
|
||||
* Parses a directive comment into directive text and value.
|
||||
* @param {string} string The string with the directive to be parsed.
|
||||
* @returns {DirectiveComment|undefined} The parsed directive or `undefined` if the directive is invalid.
|
||||
*/
|
||||
parseDirective(string: string): DirectiveComment | undefined;
|
||||
#private;
|
||||
}
|
||||
/**
|
||||
* A class to represent a directive comment.
|
||||
* @implements {IDirective}
|
||||
*/
|
||||
export class Directive implements IDirective {
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {Object} options The options for the directive.
|
||||
* @param {"disable"|"enable"|"disable-next-line"|"disable-line"} options.type The type of directive.
|
||||
* @param {unknown} options.node The node representing the directive.
|
||||
* @param {string} options.value The value of the directive.
|
||||
* @param {string} options.justification The justification for the directive.
|
||||
*/
|
||||
constructor({ type, node, value, justification }: {
|
||||
type: "disable" | "enable" | "disable-next-line" | "disable-line";
|
||||
node: unknown;
|
||||
value: string;
|
||||
justification: string;
|
||||
});
|
||||
/**
|
||||
* The type of directive.
|
||||
* @type {DirectiveType}
|
||||
* @readonly
|
||||
*/
|
||||
readonly type: DirectiveType;
|
||||
/**
|
||||
* The node representing the directive.
|
||||
* @type {unknown}
|
||||
* @readonly
|
||||
*/
|
||||
readonly node: unknown;
|
||||
/**
|
||||
* Everything after the "eslint-disable" portion of the directive,
|
||||
* but before the "--" that indicates the justification.
|
||||
* @type {string}
|
||||
* @readonly
|
||||
*/
|
||||
readonly value: string;
|
||||
/**
|
||||
* The justification for the directive.
|
||||
* @type {string}
|
||||
* @readonly
|
||||
*/
|
||||
readonly justification: string;
|
||||
}
|
||||
/**
|
||||
* Source Code Base Object
|
||||
* @template {SourceCodeBaseTypeOptions & {SyntaxElementWithLoc: object}} [Options=SourceCodeBaseTypeOptions & {SyntaxElementWithLoc: object}]
|
||||
* @implements {TextSourceCode<Options>}
|
||||
*/
|
||||
export class TextSourceCodeBase<Options extends SourceCodeBaseTypeOptions & {
|
||||
SyntaxElementWithLoc: object;
|
||||
} = import("@eslint/core").SourceCodeBaseTypeOptions & {
|
||||
SyntaxElementWithLoc: object;
|
||||
}> implements TextSourceCode<Options> {
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {Object} options The options for the instance.
|
||||
* @param {string} options.text The source code text.
|
||||
* @param {Options['RootNode']} options.ast The root AST node.
|
||||
* @param {RegExp} [options.lineEndingPattern] The pattern to match lineEndings in the source code.
|
||||
*/
|
||||
constructor({ text, ast, lineEndingPattern }: {
|
||||
text: string;
|
||||
ast: Options["RootNode"];
|
||||
lineEndingPattern?: RegExp;
|
||||
});
|
||||
/**
|
||||
* The AST of the source code.
|
||||
* @type {Options['RootNode']}
|
||||
*/
|
||||
ast: Options["RootNode"];
|
||||
/**
|
||||
* The text of the source code.
|
||||
* @type {string}
|
||||
*/
|
||||
text: string;
|
||||
/**
|
||||
* Returns the loc information for the given node or token.
|
||||
* @param {Options['SyntaxElementWithLoc']} nodeOrToken The node or token to get the loc information for.
|
||||
* @returns {SourceLocation} The loc information for the node or token.
|
||||
* @throws {Error} If the node or token does not have loc information.
|
||||
*/
|
||||
getLoc(nodeOrToken: Options["SyntaxElementWithLoc"]): SourceLocation;
|
||||
/**
|
||||
* Returns the range information for the given node or token.
|
||||
* @param {Options['SyntaxElementWithLoc']} nodeOrToken The node or token to get the range information for.
|
||||
* @returns {SourceRange} The range information for the node or token.
|
||||
* @throws {Error} If the node or token does not have range information.
|
||||
*/
|
||||
getRange(nodeOrToken: Options["SyntaxElementWithLoc"]): SourceRange;
|
||||
/**
|
||||
* Returns the parent of the given node.
|
||||
* @param {Options['SyntaxElementWithLoc']} node The node to get the parent of.
|
||||
* @returns {Options['SyntaxElementWithLoc']|undefined} The parent of the node.
|
||||
* @throws {Error} If the method is not implemented in the subclass.
|
||||
*/
|
||||
getParent(node: Options["SyntaxElementWithLoc"]): Options["SyntaxElementWithLoc"] | undefined;
|
||||
/**
|
||||
* Gets all the ancestors of a given node
|
||||
* @param {Options['SyntaxElementWithLoc']} node The node
|
||||
* @returns {Array<Options['SyntaxElementWithLoc']>} All the ancestor nodes in the AST, not including the provided node, starting
|
||||
* from the root node at index 0 and going inwards to the parent node.
|
||||
* @throws {TypeError} When `node` is missing.
|
||||
*/
|
||||
getAncestors(node: Options["SyntaxElementWithLoc"]): Array<Options["SyntaxElementWithLoc"]>;
|
||||
/**
|
||||
* Gets the source code for the given node.
|
||||
* @param {Options['SyntaxElementWithLoc']} [node] The AST node to get the text for.
|
||||
* @param {number} [beforeCount] The number of characters before the node to retrieve.
|
||||
* @param {number} [afterCount] The number of characters after the node to retrieve.
|
||||
* @returns {string} The text representing the AST node.
|
||||
* @public
|
||||
*/
|
||||
public getText(node?: Options["SyntaxElementWithLoc"], beforeCount?: number, afterCount?: number): string;
|
||||
/**
|
||||
* Gets the entire source text split into an array of lines.
|
||||
* @returns {Array<string>} The source text as an array of lines.
|
||||
* @public
|
||||
*/
|
||||
public get lines(): Array<string>;
|
||||
/**
|
||||
* Traverse the source code and return the steps that were taken.
|
||||
* @returns {Iterable<TraversalStep>} The steps that were taken while traversing the source code.
|
||||
*/
|
||||
traverse(): Iterable<TraversalStep>;
|
||||
#private;
|
||||
}
|
||||
/**
|
||||
* A class to represent a step in the traversal process where a node is visited.
|
||||
* @implements {VisitTraversalStep}
|
||||
*/
|
||||
export class VisitNodeStep implements VisitTraversalStep {
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {Object} options The options for the step.
|
||||
* @param {object} options.target The target of the step.
|
||||
* @param {1|2} options.phase The phase of the step.
|
||||
* @param {Array<any>} options.args The arguments of the step.
|
||||
*/
|
||||
constructor({ target, phase, args }: {
|
||||
target: object;
|
||||
phase: 1 | 2;
|
||||
args: Array<any>;
|
||||
});
|
||||
/**
|
||||
* The type of the step.
|
||||
* @type {"visit"}
|
||||
* @readonly
|
||||
*/
|
||||
readonly type: "visit";
|
||||
/**
|
||||
* The kind of the step. Represents the same data as the `type` property
|
||||
* but it's a number for performance.
|
||||
* @type {1}
|
||||
* @readonly
|
||||
*/
|
||||
readonly kind: 1;
|
||||
/**
|
||||
* The target of the step.
|
||||
* @type {object}
|
||||
*/
|
||||
target: object;
|
||||
/**
|
||||
* The phase of the step.
|
||||
* @type {1|2}
|
||||
*/
|
||||
phase: 1 | 2;
|
||||
/**
|
||||
* The arguments of the step.
|
||||
* @type {Array<any>}
|
||||
*/
|
||||
args: Array<any>;
|
||||
}
|
||||
/**
|
||||
* Represents a directive comment.
|
||||
*/
|
||||
declare class DirectiveComment {
|
||||
/**
|
||||
* Creates a new directive comment.
|
||||
* @param {string} label The label of the directive.
|
||||
* @param {string} value The value of the directive.
|
||||
* @param {string} justification The justification of the directive.
|
||||
*/
|
||||
constructor(label: string, value: string, justification: string);
|
||||
/**
|
||||
* The label of the directive, such as "eslint", "eslint-disable", etc.
|
||||
* @type {string}
|
||||
*/
|
||||
label: string;
|
||||
/**
|
||||
* The value of the directive (the string after the label).
|
||||
* @type {string}
|
||||
*/
|
||||
value: string;
|
||||
/**
|
||||
* The justification of the directive (the string after the --).
|
||||
* @type {string}
|
||||
*/
|
||||
justification: string;
|
||||
}
|
||||
export {};
|
615
node_modules/@eslint/plugin-kit/dist/esm/index.js
generated
vendored
615
node_modules/@eslint/plugin-kit/dist/esm/index.js
generated
vendored
|
@ -1,615 +0,0 @@
|
|||
// @ts-self-types="./index.d.ts"
|
||||
import levn from 'levn';
|
||||
|
||||
/**
|
||||
* @fileoverview Config Comment Parser
|
||||
* @author Nicholas C. Zakas
|
||||
*/
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Type Definitions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/** @typedef {import("@eslint/core").RuleConfig} RuleConfig */
|
||||
/** @typedef {import("@eslint/core").RulesConfig} RulesConfig */
|
||||
/** @typedef {import("./types.ts").StringConfig} StringConfig */
|
||||
/** @typedef {import("./types.ts").BooleanConfig} BooleanConfig */
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
const directivesPattern = /^([a-z]+(?:-[a-z]+)*)(?:\s|$)/u;
|
||||
const validSeverities = new Set([0, 1, 2, "off", "warn", "error"]);
|
||||
|
||||
/**
|
||||
* Determines if the severity in the rule configuration is valid.
|
||||
* @param {RuleConfig} ruleConfig A rule's configuration.
|
||||
* @returns {boolean} `true` if the severity is valid, otherwise `false`.
|
||||
*/
|
||||
function isSeverityValid(ruleConfig) {
|
||||
const severity = Array.isArray(ruleConfig) ? ruleConfig[0] : ruleConfig;
|
||||
return validSeverities.has(severity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if all severities in the rules configuration are valid.
|
||||
* @param {RulesConfig} rulesConfig The rules configuration to check.
|
||||
* @returns {boolean} `true` if all severities are valid, otherwise `false`.
|
||||
*/
|
||||
function isEverySeverityValid(rulesConfig) {
|
||||
return Object.values(rulesConfig).every(isSeverityValid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a directive comment.
|
||||
*/
|
||||
class DirectiveComment {
|
||||
/**
|
||||
* The label of the directive, such as "eslint", "eslint-disable", etc.
|
||||
* @type {string}
|
||||
*/
|
||||
label = "";
|
||||
|
||||
/**
|
||||
* The value of the directive (the string after the label).
|
||||
* @type {string}
|
||||
*/
|
||||
value = "";
|
||||
|
||||
/**
|
||||
* The justification of the directive (the string after the --).
|
||||
* @type {string}
|
||||
*/
|
||||
justification = "";
|
||||
|
||||
/**
|
||||
* Creates a new directive comment.
|
||||
* @param {string} label The label of the directive.
|
||||
* @param {string} value The value of the directive.
|
||||
* @param {string} justification The justification of the directive.
|
||||
*/
|
||||
constructor(label, value, justification) {
|
||||
this.label = label;
|
||||
this.value = value;
|
||||
this.justification = justification;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Public Interface
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Object to parse ESLint configuration comments.
|
||||
*/
|
||||
class ConfigCommentParser {
|
||||
/**
|
||||
* Parses a list of "name:string_value" or/and "name" options divided by comma or
|
||||
* whitespace. Used for "global" comments.
|
||||
* @param {string} string The string to parse.
|
||||
* @returns {StringConfig} Result map object of names and string values, or null values if no value was provided.
|
||||
*/
|
||||
parseStringConfig(string) {
|
||||
const items = /** @type {StringConfig} */ ({});
|
||||
|
||||
// Collapse whitespace around `:` and `,` to make parsing easier
|
||||
const trimmedString = string
|
||||
.trim()
|
||||
.replace(/(?<!\s)\s*([:,])\s*/gu, "$1");
|
||||
|
||||
trimmedString.split(/\s|,+/u).forEach(name => {
|
||||
if (!name) {
|
||||
return;
|
||||
}
|
||||
|
||||
// value defaults to null (if not provided), e.g: "foo" => ["foo", null]
|
||||
const [key, value = null] = name.split(":");
|
||||
|
||||
items[key] = value;
|
||||
});
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a JSON-like config.
|
||||
* @param {string} string The string to parse.
|
||||
* @returns {({ok: true, config: RulesConfig}|{ok: false, error: {message: string}})} Result map object
|
||||
*/
|
||||
parseJSONLikeConfig(string) {
|
||||
// Parses a JSON-like comment by the same way as parsing CLI option.
|
||||
try {
|
||||
const items =
|
||||
/** @type {RulesConfig} */ (levn.parse("Object", string)) || {};
|
||||
|
||||
/*
|
||||
* When the configuration has any invalid severities, it should be completely
|
||||
* ignored. This is because the configuration is not valid and should not be
|
||||
* applied.
|
||||
*
|
||||
* For example, the following configuration is invalid:
|
||||
*
|
||||
* "no-alert: 2 no-console: 2"
|
||||
*
|
||||
* This results in a configuration of { "no-alert": "2 no-console: 2" }, which is
|
||||
* not valid. In this case, the configuration should be ignored.
|
||||
*/
|
||||
if (isEverySeverityValid(items)) {
|
||||
return {
|
||||
ok: true,
|
||||
config: items,
|
||||
};
|
||||
}
|
||||
} catch {
|
||||
// levn parsing error: ignore to parse the string by a fallback.
|
||||
}
|
||||
|
||||
/*
|
||||
* Optionator cannot parse commaless notations.
|
||||
* But we are supporting that. So this is a fallback for that.
|
||||
*/
|
||||
const normalizedString = string
|
||||
.replace(/(?<![-a-zA-Z0-9/])([-a-zA-Z0-9/]+):/gu, '"$1":')
|
||||
.replace(/(\]|[0-9])\s+(?=")/u, "$1,");
|
||||
|
||||
try {
|
||||
const items = JSON.parse(`{${normalizedString}}`);
|
||||
|
||||
return {
|
||||
ok: true,
|
||||
config: items,
|
||||
};
|
||||
} catch (ex) {
|
||||
const errorMessage = ex instanceof Error ? ex.message : String(ex);
|
||||
|
||||
return {
|
||||
ok: false,
|
||||
error: {
|
||||
message: `Failed to parse JSON from '${normalizedString}': ${errorMessage}`,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a config of values separated by comma.
|
||||
* @param {string} string The string to parse.
|
||||
* @returns {BooleanConfig} Result map of values and true values
|
||||
*/
|
||||
parseListConfig(string) {
|
||||
const items = /** @type {BooleanConfig} */ ({});
|
||||
|
||||
string.split(",").forEach(name => {
|
||||
const trimmedName = name
|
||||
.trim()
|
||||
.replace(
|
||||
/^(?<quote>['"]?)(?<ruleId>.*)\k<quote>$/su,
|
||||
"$<ruleId>",
|
||||
);
|
||||
|
||||
if (trimmedName) {
|
||||
items[trimmedName] = true;
|
||||
}
|
||||
});
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the directive and the justification from a given directive comment and trim them.
|
||||
* @param {string} value The comment text to extract.
|
||||
* @returns {{directivePart: string, justificationPart: string}} The extracted directive and justification.
|
||||
*/
|
||||
#extractDirectiveComment(value) {
|
||||
const match = /\s-{2,}\s/u.exec(value);
|
||||
|
||||
if (!match) {
|
||||
return { directivePart: value.trim(), justificationPart: "" };
|
||||
}
|
||||
|
||||
const directive = value.slice(0, match.index).trim();
|
||||
const justification = value.slice(match.index + match[0].length).trim();
|
||||
|
||||
return { directivePart: directive, justificationPart: justification };
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a directive comment into directive text and value.
|
||||
* @param {string} string The string with the directive to be parsed.
|
||||
* @returns {DirectiveComment|undefined} The parsed directive or `undefined` if the directive is invalid.
|
||||
*/
|
||||
parseDirective(string) {
|
||||
const { directivePart, justificationPart } =
|
||||
this.#extractDirectiveComment(string);
|
||||
const match = directivesPattern.exec(directivePart);
|
||||
|
||||
if (!match) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const directiveText = match[1];
|
||||
const directiveValue = directivePart.slice(
|
||||
match.index + directiveText.length,
|
||||
);
|
||||
|
||||
return new DirectiveComment(
|
||||
directiveText,
|
||||
directiveValue.trim(),
|
||||
justificationPart,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @fileoverview A collection of helper classes for implementing `SourceCode`.
|
||||
* @author Nicholas C. Zakas
|
||||
*/
|
||||
|
||||
/* eslint class-methods-use-this: off -- Required to complete interface. */
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Type Definitions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/** @typedef {import("@eslint/core").VisitTraversalStep} VisitTraversalStep */
|
||||
/** @typedef {import("@eslint/core").CallTraversalStep} CallTraversalStep */
|
||||
/** @typedef {import("@eslint/core").TraversalStep} TraversalStep */
|
||||
/** @typedef {import("@eslint/core").SourceLocation} SourceLocation */
|
||||
/** @typedef {import("@eslint/core").SourceLocationWithOffset} SourceLocationWithOffset */
|
||||
/** @typedef {import("@eslint/core").SourceRange} SourceRange */
|
||||
/** @typedef {import("@eslint/core").Directive} IDirective */
|
||||
/** @typedef {import("@eslint/core").DirectiveType} DirectiveType */
|
||||
/** @typedef {import("@eslint/core").SourceCodeBaseTypeOptions} SourceCodeBaseTypeOptions */
|
||||
/**
|
||||
* @typedef {import("@eslint/core").TextSourceCode<Options>} TextSourceCode<Options>
|
||||
* @template {SourceCodeBaseTypeOptions} [Options=SourceCodeBaseTypeOptions]
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Helpers
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Determines if a node has ESTree-style loc information.
|
||||
* @param {object} node The node to check.
|
||||
* @returns {node is {loc:SourceLocation}} `true` if the node has ESTree-style loc information, `false` if not.
|
||||
*/
|
||||
function hasESTreeStyleLoc(node) {
|
||||
return "loc" in node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if a node has position-style loc information.
|
||||
* @param {object} node The node to check.
|
||||
* @returns {node is {position:SourceLocation}} `true` if the node has position-style range information, `false` if not.
|
||||
*/
|
||||
function hasPosStyleLoc(node) {
|
||||
return "position" in node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if a node has ESTree-style range information.
|
||||
* @param {object} node The node to check.
|
||||
* @returns {node is {range:SourceRange}} `true` if the node has ESTree-style range information, `false` if not.
|
||||
*/
|
||||
function hasESTreeStyleRange(node) {
|
||||
return "range" in node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if a node has position-style range information.
|
||||
* @param {object} node The node to check.
|
||||
* @returns {node is {position:SourceLocationWithOffset}} `true` if the node has position-style range information, `false` if not.
|
||||
*/
|
||||
function hasPosStyleRange(node) {
|
||||
return "position" in node;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Exports
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* A class to represent a step in the traversal process where a node is visited.
|
||||
* @implements {VisitTraversalStep}
|
||||
*/
|
||||
class VisitNodeStep {
|
||||
/**
|
||||
* The type of the step.
|
||||
* @type {"visit"}
|
||||
* @readonly
|
||||
*/
|
||||
type = "visit";
|
||||
|
||||
/**
|
||||
* The kind of the step. Represents the same data as the `type` property
|
||||
* but it's a number for performance.
|
||||
* @type {1}
|
||||
* @readonly
|
||||
*/
|
||||
kind = 1;
|
||||
|
||||
/**
|
||||
* The target of the step.
|
||||
* @type {object}
|
||||
*/
|
||||
target;
|
||||
|
||||
/**
|
||||
* The phase of the step.
|
||||
* @type {1|2}
|
||||
*/
|
||||
phase;
|
||||
|
||||
/**
|
||||
* The arguments of the step.
|
||||
* @type {Array<any>}
|
||||
*/
|
||||
args;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {Object} options The options for the step.
|
||||
* @param {object} options.target The target of the step.
|
||||
* @param {1|2} options.phase The phase of the step.
|
||||
* @param {Array<any>} options.args The arguments of the step.
|
||||
*/
|
||||
constructor({ target, phase, args }) {
|
||||
this.target = target;
|
||||
this.phase = phase;
|
||||
this.args = args;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A class to represent a step in the traversal process where a
|
||||
* method is called.
|
||||
* @implements {CallTraversalStep}
|
||||
*/
|
||||
class CallMethodStep {
|
||||
/**
|
||||
* The type of the step.
|
||||
* @type {"call"}
|
||||
* @readonly
|
||||
*/
|
||||
type = "call";
|
||||
|
||||
/**
|
||||
* The kind of the step. Represents the same data as the `type` property
|
||||
* but it's a number for performance.
|
||||
* @type {2}
|
||||
* @readonly
|
||||
*/
|
||||
kind = 2;
|
||||
|
||||
/**
|
||||
* The name of the method to call.
|
||||
* @type {string}
|
||||
*/
|
||||
target;
|
||||
|
||||
/**
|
||||
* The arguments to pass to the method.
|
||||
* @type {Array<any>}
|
||||
*/
|
||||
args;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {Object} options The options for the step.
|
||||
* @param {string} options.target The target of the step.
|
||||
* @param {Array<any>} options.args The arguments of the step.
|
||||
*/
|
||||
constructor({ target, args }) {
|
||||
this.target = target;
|
||||
this.args = args;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A class to represent a directive comment.
|
||||
* @implements {IDirective}
|
||||
*/
|
||||
class Directive {
|
||||
/**
|
||||
* The type of directive.
|
||||
* @type {DirectiveType}
|
||||
* @readonly
|
||||
*/
|
||||
type;
|
||||
|
||||
/**
|
||||
* The node representing the directive.
|
||||
* @type {unknown}
|
||||
* @readonly
|
||||
*/
|
||||
node;
|
||||
|
||||
/**
|
||||
* Everything after the "eslint-disable" portion of the directive,
|
||||
* but before the "--" that indicates the justification.
|
||||
* @type {string}
|
||||
* @readonly
|
||||
*/
|
||||
value;
|
||||
|
||||
/**
|
||||
* The justification for the directive.
|
||||
* @type {string}
|
||||
* @readonly
|
||||
*/
|
||||
justification;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {Object} options The options for the directive.
|
||||
* @param {"disable"|"enable"|"disable-next-line"|"disable-line"} options.type The type of directive.
|
||||
* @param {unknown} options.node The node representing the directive.
|
||||
* @param {string} options.value The value of the directive.
|
||||
* @param {string} options.justification The justification for the directive.
|
||||
*/
|
||||
constructor({ type, node, value, justification }) {
|
||||
this.type = type;
|
||||
this.node = node;
|
||||
this.value = value;
|
||||
this.justification = justification;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Source Code Base Object
|
||||
* @template {SourceCodeBaseTypeOptions & {SyntaxElementWithLoc: object}} [Options=SourceCodeBaseTypeOptions & {SyntaxElementWithLoc: object}]
|
||||
* @implements {TextSourceCode<Options>}
|
||||
*/
|
||||
class TextSourceCodeBase {
|
||||
/**
|
||||
* The lines of text in the source code.
|
||||
* @type {Array<string>}
|
||||
*/
|
||||
#lines;
|
||||
|
||||
/**
|
||||
* The AST of the source code.
|
||||
* @type {Options['RootNode']}
|
||||
*/
|
||||
ast;
|
||||
|
||||
/**
|
||||
* The text of the source code.
|
||||
* @type {string}
|
||||
*/
|
||||
text;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
* @param {Object} options The options for the instance.
|
||||
* @param {string} options.text The source code text.
|
||||
* @param {Options['RootNode']} options.ast The root AST node.
|
||||
* @param {RegExp} [options.lineEndingPattern] The pattern to match lineEndings in the source code.
|
||||
*/
|
||||
constructor({ text, ast, lineEndingPattern = /\r?\n/u }) {
|
||||
this.ast = ast;
|
||||
this.text = text;
|
||||
this.#lines = text.split(lineEndingPattern);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the loc information for the given node or token.
|
||||
* @param {Options['SyntaxElementWithLoc']} nodeOrToken The node or token to get the loc information for.
|
||||
* @returns {SourceLocation} The loc information for the node or token.
|
||||
* @throws {Error} If the node or token does not have loc information.
|
||||
*/
|
||||
getLoc(nodeOrToken) {
|
||||
if (hasESTreeStyleLoc(nodeOrToken)) {
|
||||
return nodeOrToken.loc;
|
||||
}
|
||||
|
||||
if (hasPosStyleLoc(nodeOrToken)) {
|
||||
return nodeOrToken.position;
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
"Custom getLoc() method must be implemented in the subclass.",
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the range information for the given node or token.
|
||||
* @param {Options['SyntaxElementWithLoc']} nodeOrToken The node or token to get the range information for.
|
||||
* @returns {SourceRange} The range information for the node or token.
|
||||
* @throws {Error} If the node or token does not have range information.
|
||||
*/
|
||||
getRange(nodeOrToken) {
|
||||
if (hasESTreeStyleRange(nodeOrToken)) {
|
||||
return nodeOrToken.range;
|
||||
}
|
||||
|
||||
if (hasPosStyleRange(nodeOrToken)) {
|
||||
return [
|
||||
nodeOrToken.position.start.offset,
|
||||
nodeOrToken.position.end.offset,
|
||||
];
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
"Custom getRange() method must be implemented in the subclass.",
|
||||
);
|
||||
}
|
||||
|
||||
/* eslint-disable no-unused-vars -- Required to complete interface. */
|
||||
/**
|
||||
* Returns the parent of the given node.
|
||||
* @param {Options['SyntaxElementWithLoc']} node The node to get the parent of.
|
||||
* @returns {Options['SyntaxElementWithLoc']|undefined} The parent of the node.
|
||||
* @throws {Error} If the method is not implemented in the subclass.
|
||||
*/
|
||||
getParent(node) {
|
||||
throw new Error("Not implemented.");
|
||||
}
|
||||
/* eslint-enable no-unused-vars -- Required to complete interface. */
|
||||
|
||||
/**
|
||||
* Gets all the ancestors of a given node
|
||||
* @param {Options['SyntaxElementWithLoc']} node The node
|
||||
* @returns {Array<Options['SyntaxElementWithLoc']>} All the ancestor nodes in the AST, not including the provided node, starting
|
||||
* from the root node at index 0 and going inwards to the parent node.
|
||||
* @throws {TypeError} When `node` is missing.
|
||||
*/
|
||||
getAncestors(node) {
|
||||
if (!node) {
|
||||
throw new TypeError("Missing required argument: node.");
|
||||
}
|
||||
|
||||
const ancestorsStartingAtParent = [];
|
||||
|
||||
for (
|
||||
let ancestor = this.getParent(node);
|
||||
ancestor;
|
||||
ancestor = this.getParent(ancestor)
|
||||
) {
|
||||
ancestorsStartingAtParent.push(ancestor);
|
||||
}
|
||||
|
||||
return ancestorsStartingAtParent.reverse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the source code for the given node.
|
||||
* @param {Options['SyntaxElementWithLoc']} [node] The AST node to get the text for.
|
||||
* @param {number} [beforeCount] The number of characters before the node to retrieve.
|
||||
* @param {number} [afterCount] The number of characters after the node to retrieve.
|
||||
* @returns {string} The text representing the AST node.
|
||||
* @public
|
||||
*/
|
||||
getText(node, beforeCount, afterCount) {
|
||||
if (node) {
|
||||
const range = this.getRange(node);
|
||||
return this.text.slice(
|
||||
Math.max(range[0] - (beforeCount || 0), 0),
|
||||
range[1] + (afterCount || 0),
|
||||
);
|
||||
}
|
||||
return this.text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the entire source text split into an array of lines.
|
||||
* @returns {Array<string>} The source text as an array of lines.
|
||||
* @public
|
||||
*/
|
||||
get lines() {
|
||||
return this.#lines;
|
||||
}
|
||||
|
||||
/**
|
||||
* Traverse the source code and return the steps that were taken.
|
||||
* @returns {Iterable<TraversalStep>} The steps that were taken while traversing the source code.
|
||||
*/
|
||||
traverse() {
|
||||
throw new Error("Not implemented.");
|
||||
}
|
||||
}
|
||||
|
||||
export { CallMethodStep, ConfigCommentParser, Directive, TextSourceCodeBase, VisitNodeStep };
|
6
node_modules/@eslint/plugin-kit/dist/esm/types.d.ts
generated
vendored
6
node_modules/@eslint/plugin-kit/dist/esm/types.d.ts
generated
vendored
|
@ -1,6 +0,0 @@
|
|||
/**
|
||||
* @fileoverview Types for the plugin-kit package.
|
||||
* @author Nicholas C. Zakas
|
||||
*/
|
||||
export type StringConfig = Record<string, string | null>;
|
||||
export type BooleanConfig = Record<string, boolean>;
|
7
node_modules/@eslint/plugin-kit/dist/esm/types.ts
generated
vendored
7
node_modules/@eslint/plugin-kit/dist/esm/types.ts
generated
vendored
|
@ -1,7 +0,0 @@
|
|||
/**
|
||||
* @fileoverview Types for the plugin-kit package.
|
||||
* @author Nicholas C. Zakas
|
||||
*/
|
||||
|
||||
export type StringConfig = Record<string, string | null>;
|
||||
export type BooleanConfig = Record<string, boolean>;
|
61
node_modules/@eslint/plugin-kit/package.json
generated
vendored
61
node_modules/@eslint/plugin-kit/package.json
generated
vendored
|
@ -1,61 +0,0 @@
|
|||
{
|
||||
"name": "@eslint/plugin-kit",
|
||||
"version": "0.3.5",
|
||||
"description": "Utilities for building ESLint plugins.",
|
||||
"author": "Nicholas C. Zakas",
|
||||
"type": "module",
|
||||
"main": "dist/esm/index.js",
|
||||
"types": "dist/esm/index.d.ts",
|
||||
"exports": {
|
||||
"require": {
|
||||
"types": "./dist/cjs/index.d.cts",
|
||||
"default": "./dist/cjs/index.cjs"
|
||||
},
|
||||
"import": {
|
||||
"types": "./dist/esm/index.d.ts",
|
||||
"default": "./dist/esm/index.js"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/eslint/rewrite.git",
|
||||
"directory": "packages/plugin-kit"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/eslint/rewrite/issues"
|
||||
},
|
||||
"homepage": "https://github.com/eslint/rewrite/tree/main/packages/plugin-kit#readme",
|
||||
"scripts": {
|
||||
"build:dedupe-types": "node ../../tools/dedupe-types.js dist/cjs/index.cjs dist/esm/index.js",
|
||||
"build:cts": "node ../../tools/build-cts.js dist/esm/index.d.ts dist/cjs/index.d.cts",
|
||||
"build": "rollup -c && npm run build:dedupe-types && tsc -p tsconfig.esm.json && npm run build:cts",
|
||||
"pretest": "npm run build",
|
||||
"test": "mocha tests/",
|
||||
"test:coverage": "c8 npm test",
|
||||
"test:jsr": "npx jsr@latest publish --dry-run",
|
||||
"test:types": "tsc -p tests/types/tsconfig.json"
|
||||
},
|
||||
"keywords": [
|
||||
"eslint",
|
||||
"eslintplugin",
|
||||
"eslint-plugin"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@eslint/core": "^0.15.2",
|
||||
"levn": "^0.4.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/levn": "^0.4.0",
|
||||
"rollup-plugin-copy": "^3.5.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||
}
|
||||
}
|
201
node_modules/@humanfs/core/LICENSE
generated
vendored
201
node_modules/@humanfs/core/LICENSE
generated
vendored
|
@ -1,201 +0,0 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue