更新前端静态网页获取方式,放弃使用后端获取api

This commit is contained in:
2025-09-09 10:47:51 +08:00
parent 6889ca37e5
commit 44a4f1bae1
25558 changed files with 2463152 additions and 153 deletions

20
frontend/node_modules/eslint-webpack-plugin/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,20 @@
Copyright JS Foundation and other contributors
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.

325
frontend/node_modules/eslint-webpack-plugin/README.md generated vendored Normal file
View File

@@ -0,0 +1,325 @@
<div align="center">
<a href="https://github.com/eslint/eslint"><img width="200" height="200" src="https://cdn.worldvectorlogo.com/logos/eslint.svg"></a>
<a href="https://github.com/webpack/webpack"><img width="200" height="200" src="https://webpack.js.org/assets/icon-square-big.svg"></a>
</div>
[![npm][npm]][npm-url]
[![node][node]][node-url]
[![tests][tests]][tests-url]
[![coverage][cover]][cover-url]
[![chat][chat]][chat-url]
[![size][size]][size-url]
# eslint-webpack-plugin
> This is eslint-webpack-plugin 3.0 which works only with webpack 5. For the webpack 4, see the [2.x branch](https://github.com/webpack-contrib/eslint-webpack-plugin/tree/2.x).
This plugin uses [`eslint`](https://eslint.org/) to find and fix problems in your JavaScript code
## Getting Started
To begin, you'll need to install `eslint-webpack-plugin`:
```console
npm install eslint-webpack-plugin --save-dev
```
or
```console
yarn add -D eslint-webpack-plugin
```
or
```console
pnpm add -D eslint-webpack-plugin
```
> **Note**
>
> You also need to install `eslint >= 7` from npm, if you haven't already:
```console
npm install eslint --save-dev
```
or
```console
yarn add -D eslint
```
or
```console
pnpm add -D eslint
```
Then add the plugin to your webpack config. For example:
```js
const ESLintPlugin = require('eslint-webpack-plugin');
module.exports = {
// ...
plugins: [new ESLintPlugin(options)],
// ...
};
```
## Options
You can pass [eslint options](https://eslint.org/docs/developer-guide/nodejs-api#-new-eslintoptions).
> **Note**
>
> The config option you provide will be passed to the `ESLint` class.
> This is a different set of options than what you'd specify in `package.json` or `.eslintrc`.
> See the [eslint docs](https://eslint.org/docs/developer-guide/nodejs-api#-new-eslintoptions) for more details.
> **Warning**:
>
> In eslint-webpack-plugin version 1 the options were passed to the now deprecated [CLIEngine](https://eslint.org/docs/developer-guide/nodejs-api#cliengine).
### `context`
- Type:
```ts
type context = string;
```
- Default: `compiler.context`
A string indicating the root of your files.
### `eslintPath`
- Type:
```ts
type eslintPath = string;
```
- Default: `eslint`
Path to `eslint` instance that will be used for linting. If the `eslintPath` is a folder like a official eslint, or specify a `formatter` option. now you don't have to install `eslint`.
### `extensions`
- Type:
```ts
type extensions = string | Array<string>;
```
- Default: `'js'`
Specify extensions that should be checked.
### `exclude`
- Type:
```ts
type exclude = string | Array<string>;
```
- Default: `'node_modules'`
Specify the files and/or directories to exclude. Must be relative to `options.context`.
### `resourceQueryExclude`
- Type:
```ts
type resourceQueryExclude = RegExp | Array<RegExp>;
```
- Default: `[]`
Specify the resource query to exclude.
### `files`
- Type:
```ts
type files = string | Array<string>;
```
- Default: `null`
Specify directories, files, or globs. Must be relative to `options.context`.
Directories are traversed recursively looking for files matching `options.extensions`.
File and glob patterns ignore `options.extensions`.
### `fix`
- Type:
```ts
type fix = boolean;
```
- Default: `false`
Will enable [ESLint autofix feature](https://eslint.org/docs/developer-guide/nodejs-api#-eslintoutputfixesresults).
**Be careful: this option will change source files.**
### `formatter`
- Type:
```ts
type formatter = string| (
results: Array<import('eslint').ESLint.LintResult>,
data?: import('eslint').ESLint.LintResultData | undefined
) => string
```
- Default: `'stylish'`
Accepts a function that will have one argument: an array of eslint messages (object). The function must return the output as a string. You can use official [eslint formatters](https://eslint.org/docs/user-guide/formatters/).
### `lintDirtyModulesOnly`
- Type:
```ts
type lintDirtyModulesOnly = boolean;
```
- Default: `false`
Lint only changed files, skip lint on start.
### `threads`
- Type:
```ts
type threads = boolean | number;
```
- Default: `false`
Will run lint tasks across a thread pool. The pool size is automatic unless you specify a number.
### Errors and Warning
**By default the plugin will auto adjust error reporting depending on eslint errors/warnings counts.**
You can still force this behavior by using `emitError` **or** `emitWarning` options:
#### `emitError`
- Type:
```ts
type emitError = boolean;
```
- Default: `true`
The errors found will always be emitted, to disable set to `false`.
#### `emitWarning`
- Type:
```ts
type emitWarning = boolean;
```
- Default: `true`
The warnings found will always be emitted, to disable set to `false`.
#### `failOnError`
- Type:
```ts
type failOnError = boolean;
```
- Default: `true`
Will cause the module build to fail if there are any errors, to disable set to `false`.
#### `failOnWarning`
- Type:
```ts
type failOnWarning = boolean;
```
- Default: `false`
Will cause the module build to fail if there are any warnings, if set to `true`.
#### `quiet`
- Type:
```ts
type quiet = boolean;
```
- Default: `false`
Will process and report errors only and ignore warnings, if set to `true`.
#### `outputReport`
- Type:
```ts
type outputReport =
| boolean
| {
filePath?: string | undefined;
formatter?:
| (
| string
| ((
results: Array<import('eslint').ESLint.LintResult>,
data?: import('eslint').ESLint.LintResultData | undefined
) => string)
)
| undefined;
};
```
- Default: `false`
Write the output of the errors to a file, for example a checkstyle xml file for use for reporting on Jenkins CI.
The `filePath` is an absolute path or relative to the webpack config: `output.path`.
You can pass in a different `formatter` for the output file,
if none is passed in the default/configured formatter will be used.
## Changelog
[Changelog](CHANGELOG.md)
## License
[MIT](./LICENSE)
[npm]: https://img.shields.io/npm/v/eslint-webpack-plugin.svg
[npm-url]: https://npmjs.com/package/eslint-webpack-plugin
[node]: https://img.shields.io/node/v/eslint-webpack-plugin.svg
[node-url]: https://nodejs.org
[tests]: https://github.com/webpack-contrib/eslint-webpack-plugin/workflows/eslint-webpack-plugin/badge.svg
[tests-url]: https://github.com/webpack-contrib/eslint-webpack-plugin/actions
[cover]: https://codecov.io/gh/webpack-contrib/eslint-webpack-plugin/branch/master/graph/badge.svg
[cover-url]: https://codecov.io/gh/webpack-contrib/eslint-webpack-plugin
[chat]: https://badges.gitter.im/webpack/webpack.svg
[chat-url]: https://gitter.im/webpack/webpack
[size]: https://packagephobia.now.sh/badge?p=eslint-webpack-plugin
[size-url]: https://packagephobia.now.sh/result?p=eslint-webpack-plugin

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) Facebook, Inc. and its affiliates.
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.

View File

@@ -0,0 +1,251 @@
# jest-worker
Module for executing heavy tasks under forked processes in parallel, by providing a `Promise` based interface, minimum overhead, and bound workers.
The module works by providing an absolute path of the module to be loaded in all forked processes. All methods are exposed on the parent process as promises, so they can be `await`'ed. Child (worker) methods can either be synchronous or asynchronous.
The module also implements support for bound workers. Binding a worker means that, based on certain parameters, the same task will always be executed by the same worker. The way bound workers work is by using the returned string of the `computeWorkerKey` method. If the string was used before for a task, the call will be queued to the related worker that processed the task earlier; if not, it will be executed by the first available worker, then sticked to the worker that executed it; so the next time it will be processed by the same worker. If you have no preference on the worker executing the task, but you have defined a `computeWorkerKey` method because you want _some_ of the tasks to be sticked, you can return `null` from it.
The list of exposed methods can be explicitly provided via the `exposedMethods` option. If it is not provided, it will be obtained by requiring the child module into the main process, and analyzed via reflection. Check the "minimal example" section for a valid one.
## Install
```sh
yarn add jest-worker
```
## Example
This example covers the minimal usage:
### File `parent.js`
```js
import {Worker as JestWorker} from 'jest-worker';
async function main() {
const worker = new JestWorker(require.resolve('./worker'));
const result = await worker.hello('Alice'); // "Hello, Alice"
}
main();
```
### File `worker.js`
```js
export function hello(param) {
return `Hello, ${param}`;
}
```
## Experimental worker
Node shipped with [`worker_threads`](https://nodejs.org/api/worker_threads.html), a "threading API" that uses `SharedArrayBuffers` to communicate between the main process and its child threads. This feature can significantly improve the communication time between parent and child processes in `jest-worker`.
To use `worker_threads` instead of default `child_process` you have to pass `enableWorkerThreads: true` when instantiating the worker.
## API
The `Worker` export is a constructor that is initialized by passing the worker path, plus an options object.
### `workerPath: string` (required)
Node module name or absolute path of the file to be loaded in the child processes. Use `require.resolve` to transform a relative path into an absolute one.
### `options: Object` (optional)
#### `computeWorkerKey: (method: string, ...args: Array<unknown>) => string | null` (optional)
Every time a method exposed via the API is called, `computeWorkerKey` is also called in order to bound the call to a worker. This is useful for workers that are able to cache the result or part of it. You bound calls to a worker by making `computeWorkerKey` return the same identifier for all different calls. If you do not want to bind the call to any worker, return `null`.
The callback you provide is called with the method name, plus all the rest of the arguments of the call. Thus, you have full control to decide what to return. Check a practical example on bound workers under the "bound worker usage" section.
By default, no process is bound to any worker.
#### `enableWorkerThreads: boolean` (optional)
By default, `jest-worker` will use `child_process` threads to spawn new Node.js processes. If you prefer [`worker_threads`](https://nodejs.org/api/worker_threads.html) instead, pass `enableWorkerThreads: true`.
#### `exposedMethods: ReadonlyArray<string>` (optional)
List of method names that can be called on the child processes from the parent process. You cannot expose any method named like a public `Worker` method, or starting with `_`. If you use method auto-discovery, then these methods will not be exposed, even if they exist.
#### `forkOptions: ForkOptions` (optional)
Allow customizing all options passed to `child_process.fork`. By default, some values are set (`cwd`, `env`, `execArgv` and `serialization`), but you can override them and customize the rest. For a list of valid values, check [the Node documentation](https://nodejs.org/api/child_process.html#child_process_child_process_fork_modulepath_args_options).
#### `maxRetries: number` (optional)
Maximum amount of times that a dead child can be re-spawned, per call. Defaults to `3`, pass `Infinity` to allow endless retries.
#### `numWorkers: number` (optional)
Amount of workers to spawn. Defaults to the number of CPUs minus 1.
#### `resourceLimits: ResourceLimits` (optional)
The `resourceLimits` option which will be passed to `worker_threads` workers.
#### `setupArgs: Array<unknown>` (optional)
The arguments that will be passed to the `setup` method during initialization.
#### `taskQueue: TaskQueue` (optional)
The task queue defines in which order tasks (method calls) are processed by the workers. `jest-worker` ships with a `FifoQueue` and `PriorityQueue`:
- `FifoQueue` (default): Processes the method calls (tasks) in the call order.
- `PriorityQueue`: Processes the method calls by a computed priority in natural ordering (lower priorities first). Tasks with the same priority are processed in any order (FIFO not guaranteed). The constructor accepts a single argument, the function that is passed the name of the called function and the arguments and returns a numerical value for the priority: `new require('jest-worker').PriorityQueue((method, filename) => filename.length)`.
#### `WorkerPool: new (workerPath: string, options?: WorkerPoolOptions) => WorkerPoolInterface` (optional)
Provide a custom WorkerPool class to be used for spawning child processes.
#### `workerSchedulingPolicy: 'round-robin' | 'in-order'` (optional)
Specifies the policy how tasks are assigned to workers if multiple workers are _idle_:
- `round-robin` (default): The task will be sequentially distributed onto the workers. The first task is assigned to the worker 1, the second to the worker 2, to ensure that the work is distributed across workers.
- `in-order`: The task will be assigned to the first free worker starting with worker 1 and only assign the work to worker 2 if the worker 1 is busy.
Tasks are always assigned to the first free worker as soon as tasks start to queue up. The scheduling policy does not define the task scheduling which is always first-in, first-out.
## JestWorker
### Methods
The returned `JestWorker` instance has all the exposed methods, plus some additional ones to interact with the workers itself:
#### `getStdout(): Readable`
Returns a `ReadableStream` where the standard output of all workers is piped. Note that the `silent` option of the child workers must be set to `true` to make it work. This is the default set by `jest-worker`, but keep it in mind when overriding options through `forkOptions`.
#### `getStderr(): Readable`
Returns a `ReadableStream` where the standard error of all workers is piped. Note that the `silent` option of the child workers must be set to `true` to make it work. This is the default set by `jest-worker`, but keep it in mind when overriding options through `forkOptions`.
#### `end()`
Finishes the workers by killing all workers. No further calls can be done to the `Worker` instance.
Returns a Promise that resolves with `{ forceExited: boolean }` once all workers are dead. If `forceExited` is `true`, at least one of the workers did not exit gracefully, which likely happened because it executed a leaky task that left handles open. This should be avoided, force exiting workers is a last resort to prevent creating lots of orphans.
**Note:**
`await`ing the `end()` Promise immediately after the workers are no longer needed before proceeding to do other useful things in your program may not be a good idea. If workers have to be force exited, `jest-worker` may go through multiple stages of force exiting (e.g. SIGTERM, later SIGKILL) and give the worker overall around 1 second time to exit on its own. During this time, your program will wait, even though it may not be necessary that all workers are dead before continuing execution.
Consider deliberately leaving this Promise floating (unhandled resolution). After your program has done the rest of its work and is about to exit, the Node process will wait for the Promise to resolve after all workers are dead as the last event loop task. That way you parallelized computation time of your program and waiting time and you didn't delay the outputs of your program unnecessarily.
### Worker IDs
Each worker has a unique id (index that starts with `'1'`), which is available inside the worker as `process.env.JEST_WORKER_ID`.
## Setting up and tearing down the child process
The child process can define two special methods (both of them can be asynchronous):
- `setup()`: If defined, it's executed before the first call to any method in the child.
- `teardown()`: If defined, it's executed when the farm ends.
# More examples
## Standard usage
This example covers the standard usage:
### File `parent.js`
```js
import {Worker as JestWorker} from 'jest-worker';
async function main() {
const myWorker = new JestWorker(require.resolve('./worker'), {
exposedMethods: ['foo', 'bar', 'getWorkerId'],
numWorkers: 4,
});
console.log(await myWorker.foo('Alice')); // "Hello from foo: Alice"
console.log(await myWorker.bar('Bob')); // "Hello from bar: Bob"
console.log(await myWorker.getWorkerId()); // "3" -> this message has sent from the 3rd worker
const {forceExited} = await myWorker.end();
if (forceExited) {
console.error('Workers failed to exit gracefully');
}
}
main();
```
### File `worker.js`
```js
export function foo(param) {
return `Hello from foo: ${param}`;
}
export function bar(param) {
return `Hello from bar: ${param}`;
}
export function getWorkerId() {
return process.env.JEST_WORKER_ID;
}
```
## Bound worker usage:
This example covers the usage with a `computeWorkerKey` method:
### File `parent.js`
```js
import {Worker as JestWorker} from 'jest-worker';
async function main() {
const myWorker = new JestWorker(require.resolve('./worker'), {
computeWorkerKey: (method, filename) => filename,
});
// Transform the given file, within the first available worker.
console.log(await myWorker.transform('/tmp/foo.js'));
// Wait a bit.
await sleep(10000);
// Transform the same file again. Will immediately return because the
// transformed file is cached in the worker, and `computeWorkerKey` ensures
// the same worker that processed the file the first time will process it now.
console.log(await myWorker.transform('/tmp/foo.js'));
const {forceExited} = await myWorker.end();
if (forceExited) {
console.error('Workers failed to exit gracefully');
}
}
main();
```
### File `worker.js`
```js
import babel from '@babel/core';
const cache = Object.create(null);
export function transform(filename) {
if (cache[filename]) {
return cache[filename];
}
// jest-worker can handle both immediate results and thenables. If a
// thenable is returned, it will be await'ed until it resolves.
return babel.transformFileAsync(filename).then(result => {
cache[filename] = result;
return result;
});
}
```

View File

@@ -0,0 +1,40 @@
{
"name": "jest-worker",
"version": "28.1.3",
"repository": {
"type": "git",
"url": "https://github.com/facebook/jest.git",
"directory": "packages/jest-worker"
},
"license": "MIT",
"main": "./build/index.js",
"types": "./build/index.d.ts",
"exports": {
".": {
"types": "./build/index.d.ts",
"default": "./build/index.js"
},
"./package.json": "./package.json"
},
"dependencies": {
"@types/node": "*",
"merge-stream": "^2.0.0",
"supports-color": "^8.0.0"
},
"devDependencies": {
"@tsd/typescript": "~4.7.4",
"@types/merge-stream": "^1.1.2",
"@types/supports-color": "^8.1.0",
"get-stream": "^6.0.0",
"jest-leak-detector": "^28.1.3",
"tsd-lite": "^0.5.6",
"worker-farm": "^1.6.0"
},
"engines": {
"node": "^12.13.0 || ^14.15.0 || ^16.10.0 || >=17.0.0"
},
"publishConfig": {
"access": "public"
},
"gitHead": "2cce069800dab3fc8ca7c469b32d2e2b2f7e2bb1"
}

View File

@@ -0,0 +1,24 @@
/* eslint-env browser */
'use strict';
function getChromeVersion() {
const matches = /(Chrome|Chromium)\/(?<chromeVersion>\d+)\./.exec(navigator.userAgent);
if (!matches) {
return;
}
return Number.parseInt(matches.groups.chromeVersion, 10);
}
const colorSupport = getChromeVersion() >= 69 ? {
level: 1,
hasBasic: true,
has256: false,
has16m: false
} : false;
module.exports = {
stdout: colorSupport,
stderr: colorSupport
};

View File

@@ -0,0 +1,152 @@
'use strict';
const os = require('os');
const tty = require('tty');
const hasFlag = require('has-flag');
const {env} = process;
let flagForceColor;
if (hasFlag('no-color') ||
hasFlag('no-colors') ||
hasFlag('color=false') ||
hasFlag('color=never')) {
flagForceColor = 0;
} else if (hasFlag('color') ||
hasFlag('colors') ||
hasFlag('color=true') ||
hasFlag('color=always')) {
flagForceColor = 1;
}
function envForceColor() {
if ('FORCE_COLOR' in env) {
if (env.FORCE_COLOR === 'true') {
return 1;
}
if (env.FORCE_COLOR === 'false') {
return 0;
}
return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
}
}
function translateLevel(level) {
if (level === 0) {
return false;
}
return {
level,
hasBasic: true,
has256: level >= 2,
has16m: level >= 3
};
}
function supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) {
const noFlagForceColor = envForceColor();
if (noFlagForceColor !== undefined) {
flagForceColor = noFlagForceColor;
}
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
if (forceColor === 0) {
return 0;
}
if (sniffFlags) {
if (hasFlag('color=16m') ||
hasFlag('color=full') ||
hasFlag('color=truecolor')) {
return 3;
}
if (hasFlag('color=256')) {
return 2;
}
}
if (haveStream && !streamIsTTY && forceColor === undefined) {
return 0;
}
const min = forceColor || 0;
if (env.TERM === 'dumb') {
return min;
}
if (process.platform === 'win32') {
// Windows 10 build 10586 is the first Windows release that supports 256 colors.
// Windows 10 build 14931 is the first release that supports 16m/TrueColor.
const osRelease = os.release().split('.');
if (
Number(osRelease[0]) >= 10 &&
Number(osRelease[2]) >= 10586
) {
return Number(osRelease[2]) >= 14931 ? 3 : 2;
}
return 1;
}
if ('CI' in env) {
if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'GITHUB_ACTIONS', 'BUILDKITE', 'DRONE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
return 1;
}
return min;
}
if ('TEAMCITY_VERSION' in env) {
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
}
if (env.COLORTERM === 'truecolor') {
return 3;
}
if ('TERM_PROGRAM' in env) {
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
switch (env.TERM_PROGRAM) {
case 'iTerm.app':
return version >= 3 ? 3 : 2;
case 'Apple_Terminal':
return 2;
// No default
}
}
if (/-256(color)?$/i.test(env.TERM)) {
return 2;
}
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
return 1;
}
if ('COLORTERM' in env) {
return 1;
}
return min;
}
function getSupportLevel(stream, options = {}) {
const level = supportsColor(stream, {
streamIsTTY: stream && stream.isTTY,
...options
});
return translateLevel(level);
}
module.exports = {
supportsColor: getSupportLevel,
stdout: getSupportLevel({isTTY: tty.isatty(1)}),
stderr: getSupportLevel({isTTY: tty.isatty(2)})
};

View File

@@ -0,0 +1,9 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
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.

View File

@@ -0,0 +1,58 @@
{
"name": "supports-color",
"version": "8.1.1",
"description": "Detect whether a terminal supports color",
"license": "MIT",
"repository": "chalk/supports-color",
"funding": "https://github.com/chalk/supports-color?sponsor=1",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "https://sindresorhus.com"
},
"engines": {
"node": ">=10"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js",
"browser.js"
],
"exports": {
"node": "./index.js",
"default": "./browser.js"
},
"keywords": [
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"ansi",
"styles",
"tty",
"rgb",
"256",
"shell",
"xterm",
"command-line",
"support",
"supports",
"capability",
"detect",
"truecolor",
"16m"
],
"dependencies": {
"has-flag": "^4.0.0"
},
"devDependencies": {
"ava": "^2.4.0",
"import-fresh": "^3.2.2",
"xo": "^0.35.0"
},
"browser": "browser.js"
}

View File

@@ -0,0 +1,77 @@
# supports-color
> Detect whether a terminal supports color
## Install
```
$ npm install supports-color
```
## Usage
```js
const supportsColor = require('supports-color');
if (supportsColor.stdout) {
console.log('Terminal stdout supports color');
}
if (supportsColor.stdout.has256) {
console.log('Terminal stdout supports 256 colors');
}
if (supportsColor.stderr.has16m) {
console.log('Terminal stderr supports 16 million colors (truecolor)');
}
```
## API
Returns an `Object` with a `stdout` and `stderr` property for testing either streams. Each property is an `Object`, or `false` if color is not supported.
The `stdout`/`stderr` objects specifies a level of support for color through a `.level` property and a corresponding flag:
- `.level = 1` and `.hasBasic = true`: Basic color support (16 colors)
- `.level = 2` and `.has256 = true`: 256 color support
- `.level = 3` and `.has16m = true`: Truecolor support (16 million colors)
### `require('supports-color').supportsColor(stream, options?)`
Additionally, `supports-color` exposes the `.supportsColor()` function that takes an arbitrary write stream (e.g. `process.stdout`) and an optional options object to (re-)evaluate color support for an arbitrary stream.
For example, `require('supports-color').stdout` is the equivalent of `require('supports-color').supportsColor(process.stdout)`.
The options object supports a single boolean property `sniffFlags`. By default it is `true`, which instructs `supportsColor()` to sniff `process.argv` for the multitude of `--color` flags (see _Info_ below). If `false`, then `process.argv` is not considered when determining color support.
## Info
It obeys the `--color` and `--no-color` CLI flags.
For situations where using `--color` is not possible, use the environment variable `FORCE_COLOR=1` (level 1), `FORCE_COLOR=2` (level 2), or `FORCE_COLOR=3` (level 3) to forcefully enable color, or `FORCE_COLOR=0` to forcefully disable. The use of `FORCE_COLOR` overrides all other color support checks.
Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=16m` flags, respectively.
## Related
- [supports-color-cli](https://github.com/chalk/supports-color-cli) - CLI for this module
- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right
## Maintainers
- [Sindre Sorhus](https://github.com/sindresorhus)
- [Josh Junon](https://github.com/qix-)
---
<div align="center">
<b>
<a href="https://tidelift.com/subscription/pkg/npm-supports-color?utm_source=npm-supports-color&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
</b>
<br>
<sub>
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
</sub>
</div>
---

View File

@@ -0,0 +1,92 @@
{
"name": "eslint-webpack-plugin",
"version": "3.2.0",
"description": "A ESLint plugin for webpack",
"license": "MIT",
"repository": "webpack-contrib/eslint-webpack-plugin",
"author": "Ricardo Gobbo de Souza <ricardogobbosouza@yahoo.com.br>",
"homepage": "https://github.com/webpack-contrib/eslint-webpack-plugin",
"bugs": "https://github.com/webpack-contrib/eslint-webpack-plugin/issues",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/webpack"
},
"main": "dist/index.js",
"types": "types/index.d.ts",
"engines": {
"node": ">= 12.13.0"
},
"scripts": {
"start": "npm run build -- -w",
"clean": "del-cli dist types",
"prebuild": "npm run clean",
"build:types": "tsc --declaration --emitDeclarationOnly --outDir types && prettier \"types/**/*.ts\" --write",
"build:code": "cross-env NODE_ENV=production babel src -d dist --copy-files",
"build": "npm-run-all -p \"build:**\"",
"commitlint": "commitlint --from=master",
"security": "npm audit",
"lint:prettier": "prettier -w --list-different .",
"lint:js": "eslint --cache .",
"lint:types": "tsc --pretty --noEmit",
"lint": "npm-run-all -l -p \"lint:**\"",
"test:only": "cross-env NODE_ENV=test jest --testTimeout=60000",
"test:watch": "npm run test:only -- --watch",
"test:coverage": "npm run test:only -- --collectCoverageFrom=\"src/**/*.js\" --coverage",
"pretest": "npm run lint",
"test": "npm run test:coverage",
"prepare": "npm run build",
"release": "standard-version"
},
"files": [
"dist",
"types"
],
"peerDependencies": {
"eslint": "^7.0.0 || ^8.0.0",
"webpack": "^5.0.0"
},
"dependencies": {
"@types/eslint": "^7.29.0 || ^8.4.1",
"jest-worker": "^28.0.2",
"micromatch": "^4.0.5",
"normalize-path": "^3.0.0",
"schema-utils": "^4.0.0"
},
"devDependencies": {
"@babel/cli": "^7.17.10",
"@babel/core": "^7.17.10",
"@babel/preset-env": "^7.17.10",
"@commitlint/cli": "^16.2.4",
"@commitlint/config-conventional": "^16.2.4",
"@types/fs-extra": "^9.0.13",
"@types/micromatch": "^4.0.2",
"@types/normalize-path": "^3.0.0",
"@types/webpack": "^5.28.0",
"@webpack-contrib/eslint-config-webpack": "^3.0.0",
"babel-eslint": "^10.1.0",
"babel-jest": "^28.0.3",
"chokidar": "^3.5.3",
"cross-env": "^7.0.3",
"del": "^6.0.0",
"del-cli": "^4.0.1",
"eslint": "^8.14.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"fs-extra": "^10.1.0",
"husky": "^7.0.4",
"jest": "^28.0.3",
"lint-staged": "^12.4.1",
"npm-run-all": "^4.1.5",
"prettier": "^2.6.2",
"standard-version": "^9.3.2",
"typescript": "^4.6.4",
"webpack": "^5.72.0"
},
"keywords": [
"eslint",
"lint",
"linter",
"plugin",
"webpack"
]
}

View File

@@ -0,0 +1,8 @@
export = ESLintError;
declare class ESLintError extends Error {
/**
* @param {string=} messages
*/
constructor(messages?: string | undefined);
stack: string;
}

View File

@@ -0,0 +1,48 @@
export type ESLint = import('eslint').ESLint;
export type LintResult = import('eslint').ESLint.LintResult;
export type Options = import('./options').Options;
export type AsyncTask = () => Promise<void>;
export type LintTask = (files: string | string[]) => Promise<LintResult[]>;
export type Linter = {
threads: number;
ESLint: ESLint;
eslint: ESLint;
lintFiles: LintTask;
cleanup: AsyncTask;
};
export type Worker = JestWorker & {
lintFiles: LintTask;
};
/** @typedef {import('eslint').ESLint} ESLint */
/** @typedef {import('eslint').ESLint.LintResult} LintResult */
/** @typedef {import('./options').Options} Options */
/** @typedef {() => Promise<void>} AsyncTask */
/** @typedef {(files: string|string[]) => Promise<LintResult[]>} LintTask */
/** @typedef {{threads: number, ESLint: ESLint, eslint: ESLint, lintFiles: LintTask, cleanup: AsyncTask}} Linter */
/** @typedef {JestWorker & {lintFiles: LintTask}} Worker */
/**
* @param {Options} options
* @returns {Linter}
*/
export function loadESLint(options: Options): Linter;
/**
* @param {string|undefined} key
* @param {number} poolSize
* @param {Options} options
* @returns {Linter}
*/
export function loadESLintThreaded(
key: string | undefined,
poolSize: number,
options: Options
): Linter;
/**
* @param {string|undefined} key
* @param {Options} options
* @returns {Linter}
*/
export function getESLint(
key: string | undefined,
{ threads, ...options }: Options
): Linter;
import { Worker as JestWorker } from 'jest-worker';

View File

@@ -0,0 +1,39 @@
export = ESLintWebpackPlugin;
declare class ESLintWebpackPlugin {
/**
* @param {Options} options
*/
constructor(options?: Options);
key: string;
options: import('./options').PluginOptions;
/**
* @param {Compiler} compiler
* @param {Omit<Options, 'resourceQueryExclude'> & {resourceQueryExclude: RegExp[]}} options
* @param {string[]} wanted
* @param {string[]} exclude
*/
run(
compiler: Compiler,
options: Omit<Options, 'resourceQueryExclude'> & {
resourceQueryExclude: RegExp[];
},
wanted: string[],
exclude: string[]
): Promise<void>;
/**
* @param {Compiler} compiler
* @returns {void}
*/
apply(compiler: Compiler): void;
/**
*
* @param {Compiler} compiler
* @returns {string}
*/
getContext(compiler: Compiler): string;
}
declare namespace ESLintWebpackPlugin {
export { Compiler, Options };
}
type Compiler = import('webpack').Compiler;
type Options = import('./options').Options;

View File

@@ -0,0 +1,51 @@
export = linter;
/**
* @param {string|undefined} key
* @param {Options} options
* @param {Compilation} compilation
* @returns {{lint: Linter, report: Reporter, threads: number}}
*/
declare function linter(
key: string | undefined,
options: Options,
compilation: Compilation
): {
lint: Linter;
report: Reporter;
threads: number;
};
declare namespace linter {
export {
ESLint,
Formatter,
LintResult,
Compiler,
Compilation,
Options,
FormatterFunction,
GenerateReport,
Report,
Reporter,
Linter,
LintResultMap,
};
}
type Options = import('./options').Options;
type Compilation = import('webpack').Compilation;
type Linter = (files: string | string[]) => void;
type Reporter = () => Promise<Report>;
type ESLint = import('eslint').ESLint;
type Formatter = import('eslint').ESLint.Formatter;
type LintResult = import('eslint').ESLint.LintResult;
type Compiler = import('webpack').Compiler;
type FormatterFunction = import('./options').FormatterFunction;
type GenerateReport = (compilation: Compilation) => Promise<void>;
type Report = {
errors?: ESLintError;
warnings?: ESLintError;
generateReportAsset?: GenerateReport;
};
type LintResultMap = {
[files: string]: import('eslint').ESLint.LintResult;
};
import ESLintError = require('./ESLintError');

View File

@@ -0,0 +1,74 @@
export type ESLintOptions = import('eslint').ESLint.Options;
export type LintResult = import('eslint').ESLint.LintResult;
export type LintResultData = import('eslint').ESLint.LintResultData;
export type FormatterFunction = (
results: LintResult[],
data?: LintResultData | undefined
) => string;
export type OutputReport = {
filePath?: string | undefined;
formatter?: (string | FormatterFunction) | undefined;
};
export type PluginOptions = {
context?: string | undefined;
emitError?: boolean | undefined;
emitWarning?: boolean | undefined;
eslintPath?: string | undefined;
exclude?: (string | string[]) | undefined;
extensions?: (string | string[]) | undefined;
failOnError?: boolean | undefined;
failOnWarning?: boolean | undefined;
files?: (string | string[]) | undefined;
fix?: boolean | undefined;
formatter?: (string | FormatterFunction) | undefined;
lintDirtyModulesOnly?: boolean | undefined;
quiet?: boolean | undefined;
outputReport?: OutputReport | undefined;
threads?: (number | boolean) | undefined;
resourceQueryExclude?: (RegExp | RegExp[]) | undefined;
};
export type Options = PluginOptions & ESLintOptions;
/** @typedef {import("eslint").ESLint.Options} ESLintOptions */
/** @typedef {import('eslint').ESLint.LintResult} LintResult */
/** @typedef {import('eslint').ESLint.LintResultData} LintResultData */
/**
* @callback FormatterFunction
* @param {LintResult[]} results
* @param {LintResultData=} data
* @returns {string}
*/
/**
* @typedef {Object} OutputReport
* @property {string=} filePath
* @property {string|FormatterFunction=} formatter
*/
/**
* @typedef {Object} PluginOptions
* @property {string=} context
* @property {boolean=} emitError
* @property {boolean=} emitWarning
* @property {string=} eslintPath
* @property {string|string[]=} exclude
* @property {string|string[]=} extensions
* @property {boolean=} failOnError
* @property {boolean=} failOnWarning
* @property {string|string[]=} files
* @property {boolean=} fix
* @property {string|FormatterFunction=} formatter
* @property {boolean=} lintDirtyModulesOnly
* @property {boolean=} quiet
* @property {OutputReport=} outputReport
* @property {number|boolean=} threads
* @property {RegExp|RegExp[]=} resourceQueryExclude
*/
/** @typedef {PluginOptions & ESLintOptions} Options */
/**
* @param {Options} pluginOptions
* @returns {PluginOptions}
*/
export function getOptions(pluginOptions: Options): PluginOptions;
/**
* @param {Options} loaderOptions
* @returns {ESLintOptions}
*/
export function getESLintOptions(loaderOptions: Options): ESLintOptions;

View File

@@ -0,0 +1,46 @@
/**
* @template T
* @param {T} value
* @return {
T extends (null | undefined)
? []
: T extends string
? [string]
: T extends readonly unknown[]
? T
: T extends Iterable<infer T>
? T[]
: [T]
}
*/
export function arrify<T>(
value: T
): T extends null | undefined
? []
: T extends string
? [string]
: T extends readonly unknown[]
? T
: T extends Iterable<infer T_1>
? T_1[]
: [T];
/**
* @param {string|string[]} files
* @param {string} context
* @returns {string[]}
*/
export function parseFiles(files: string | string[], context: string): string[];
/**
* @param {string|string[]} patterns
* @param {string|string[]} extensions
* @returns {string[]}
*/
export function parseFoldersToGlobs(
patterns: string | string[],
extensions?: string | string[]
): string[];
/**
* @param {string} _ key, but unused
* @param {any} value
*/
export function jsonStringifyReplacerSortKeys(_: string, value: any): any;

View File

@@ -0,0 +1,12 @@
export type setupOptions = {
/**
* - import path of eslint
*/
eslintPath?: string | undefined;
/**
* - linter options
*/
eslintOptions?: ESLintOptions | undefined;
};
export type ESLint = import('eslint').ESLint;
export type ESLintOptions = import('eslint').ESLint.Options;