3.5.8 Changes

This commit is contained in:
James Ives 2020-07-13 13:09:22 -04:00
parent 5eb7bd324f
commit d914bdd4bc
51 changed files with 1068 additions and 806 deletions

View File

@ -8,10 +8,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.deploy = exports.generateBranch = exports.switchToBaseBranch = exports.init = void 0;
const core_1 = require("@actions/core");
const io_1 = require("@actions/io");
const fs_1 = __importDefault(require("fs"));
const constants_1 = require("./constants");
const execute_1 = require("./execute");
const util_1 = require("./util");
@ -120,7 +124,9 @@ function deploy(action) {
yield execute_1.execute(`rsync -q -av --checksum --progress ${action.folder}/. ${action.targetFolder
? `${temporaryDeploymentDirectory}/${action.targetFolder}`
: temporaryDeploymentDirectory} ${action.clean
? `--delete ${excludes} --exclude CNAME --exclude .nojekyll`
? `--delete ${excludes} ${!fs_1.default.existsSync(`${action.folder}/CNAME`) ? '--exclude CNAME' : ''} ${!fs_1.default.existsSync(`${action.folder}/.nojekyll`)
? '--exclude .nojekyll'
: ''}`
: ''} --exclude .ssh --exclude .git --exclude .github ${action.folder === action.root
? `--exclude ${temporaryDeploymentDirectory}`
: ''}`, action.workspace, action.silent);

View File

@ -28,12 +28,12 @@ function run(configuration) {
core_1.info(`
GitHub Pages Deploy Action 🚀
Getting Started Guide: https://github.com/marketplace/actions/deploy-to-github-pages
🚀 Getting Started Guide: https://github.com/marketplace/actions/deploy-to-github-pages
FAQ/Wiki: https://github.com/JamesIves/github-pages-deploy-action/wiki
🔧 Support: https://github.com/JamesIves/github-pages-deploy-action/issues
Contribute: https://github.com/JamesIves/github-pages-deploy-action/blob/dev/CONTRIBUTING.md
Maintained by James Ives (https://jamesiv.es)`);
📣 Maintained by James Ives (https://jamesiv.es)`);
core_1.info('Checking configuration and starting deployment… 🚦');
const settings = Object.assign(Object.assign({}, constants_1.action), configuration);
// Defines the repository paths and token types.

2
node_modules/@types/jest/README.md generated vendored
View File

@ -8,7 +8,7 @@ This package contains type definitions for Jest (https://jestjs.io/).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jest.
### Additional Details
* Last updated: Wed, 24 Jun 2020 16:52:11 GMT
* Last updated: Mon, 06 Jul 2020 21:06:02 GMT
* Dependencies: none
* Global values: `afterAll`, `afterEach`, `beforeAll`, `beforeEach`, `describe`, `expect`, `fail`, `fdescribe`, `fit`, `it`, `jasmine`, `jest`, `pending`, `spyOn`, `test`, `xdescribe`, `xit`, `xtest`

View File

@ -1099,7 +1099,7 @@ declare namespace jest {
* import { MyClass } from "./libary";
* jest.mock("./library");
*
* const mockedMyClass = MyClass as jest.MockedClass<MyClass>;
* const mockedMyClass = MyClass as jest.MockedClass<typeof MyClass>;
*
* expect(mockedMyClass.mock.calls[0][0]).toBe(42); // Constructor calls
* expect(mockedMyClass.prototype.myMethod.mock.calls[0][0]).toBe(42); // Method calls

View File

@ -1,6 +1,6 @@
{
"name": "@types/jest",
"version": "26.0.3",
"version": "26.0.4",
"description": "TypeScript definitions for Jest",
"license": "MIT",
"contributors": [
@ -159,6 +159,6 @@
"jest-diff": "^25.2.1",
"pretty-format": "^25.2.1"
},
"typesPublisherContentHash": "fd6602981b1501b8a8461f773f6720301e0afa6c6f0f853c66812402b2a40900",
"typesPublisherContentHash": "58ec000306282b9079a6fbf83ec280f44605df27b70df733acf7db8ecea428d5",
"typeScriptVersion": "3.1"
}

4
node_modules/@types/node/README.md generated vendored
View File

@ -8,9 +8,9 @@ This package contains type definitions for Node.js (http://nodejs.org/).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node.
### Additional Details
* Last updated: Wed, 24 Jun 2020 08:56:20 GMT
* Last updated: Mon, 13 Jul 2020 16:24:35 GMT
* Dependencies: none
* Global values: `Buffer`, `Symbol`, `__dirname`, `__filename`, `clearImmediate`, `clearInterval`, `clearTimeout`, `console`, `exports`, `global`, `module`, `process`, `queueMicrotask`, `require`, `setImmediate`, `setInterval`, `setTimeout`
* Global values: `Buffer`, `Symbol`, `__dirname`, `__filename`, `clearImmediate`, `clearInterval`, `clearTimeout`, `exports`, `global`, `module`, `queueMicrotask`, `require`, `setImmediate`, `setInterval`, `setTimeout`
# Credits
These definitions were written by [Microsoft TypeScript](https://github.com/Microsoft), [DefinitelyTyped](https://github.com/DefinitelyTyped), [Alberto Schiabel](https://github.com/jkomyno), [Alexander T.](https://github.com/a-tarasyuk), [Alvis HT Tang](https://github.com/alvis), [Andrew Makarov](https://github.com/r3nya), [Benjamin Toueg](https://github.com/btoueg), [Bruno Scheufler](https://github.com/brunoscheufler), [Chigozirim C.](https://github.com/smac89), [David Junger](https://github.com/touffy), [Deividas Bakanas](https://github.com/DeividasBakanas), [Eugene Y. Q. Shen](https://github.com/eyqs), [Flarna](https://github.com/Flarna), [Hannes Magnusson](https://github.com/Hannes-Magnusson-CK), [Hoàng Văn Khải](https://github.com/KSXGitHub), [Huw](https://github.com/hoo29), [Kelvin Jin](https://github.com/kjin), [Klaus Meinhardt](https://github.com/ajafff), [Lishude](https://github.com/islishude), [Mariusz Wiktorczyk](https://github.com/mwiktorczyk), [Mohsen Azimi](https://github.com/mohsen1), [Nicolas Even](https://github.com/n-e), [Nicolas Voigt](https://github.com/octo-sniffle), [Nikita Galkin](https://github.com/galkin), [Parambir Singh](https://github.com/parambirs), [Sebastian Silbermann](https://github.com/eps1lon), [Simon Schick](https://github.com/SimonSchick), [Thomas den Hollander](https://github.com/ThomasdenH), [Wilco Bakker](https://github.com/WilcoBakker), [wwwy3y3](https://github.com/wwwy3y3), [Samuel Ainsworth](https://github.com/samuela), [Kyle Uehlein](https://github.com/kuehlein), [Jordi Oliveras Rovira](https://github.com/j-oliveras), [Thanik Bhongbhibhat](https://github.com/bhongy), [Marcin Kopacz](https://github.com/chyzwar), [Trivikram Kamat](https://github.com/trivikr), [Minh Son Nguyen](https://github.com/nguymin4), [Junxiao Shi](https://github.com/yoursunny), [Ilia Baryshnikov](https://github.com/qwelias), [ExE Boss](https://github.com/ExE-Boss), [Surasak Chaisurin](https://github.com/Ryan-Willpower), [Piotr Błażejewicz](https://github.com/peterblazejewicz), [Anna Henningsen](https://github.com/addaleax), and [Jason Kwok](https://github.com/JasonHK).

10
node_modules/@types/node/assert.d.ts generated vendored
View File

@ -19,16 +19,16 @@ declare module "assert" {
type AssertPredicate = RegExp | (new() => object) | ((thrown: any) => boolean) | object | Error;
function fail(message?: string | Error): never;
/** @deprecated since v10.0.0 - use fail([message]) or other assert functions instead. */
/** @deprecated since v10.0.0 - use `fail([message])` or other assert functions instead. */
function fail(actual: any, expected: any, message?: string | Error, operator?: string, stackStartFn?: Function): never;
function ok(value: any, message?: string | Error): void;
/** @deprecated since v9.9.0 - use strictEqual() instead. */
/** @deprecated since v9.9.0 - use `strictEqual()` instead. */
function equal(actual: any, expected: any, message?: string | Error): void;
/** @deprecated since v9.9.0 - use notStrictEqual() instead. */
/** @deprecated since v9.9.0 - use `notStrictEqual()` instead. */
function notEqual(actual: any, expected: any, message?: string | Error): void;
/** @deprecated since v9.9.0 - use deepStrictEqual() instead. */
/** @deprecated since v9.9.0 - use `deepStrictEqual()` instead. */
function deepEqual(actual: any, expected: any, message?: string | Error): void;
/** @deprecated since v9.9.0 - use notDeepStrictEqual() instead. */
/** @deprecated since v9.9.0 - use `notDeepStrictEqual()` instead. */
function notDeepEqual(actual: any, expected: any, message?: string | Error): void;
function strictEqual(actual: any, expected: any, message?: string | Error): void;
function notStrictEqual(actual: any, expected: any, message?: string | Error): void;

View File

@ -13,7 +13,7 @@ declare module "buffer" {
export function transcode(source: Uint8Array, fromEnc: TranscodeEncoding, toEnc: TranscodeEncoding): Buffer;
export const SlowBuffer: {
/** @deprecated since v6.0.0, use Buffer.allocUnsafeSlow() */
/** @deprecated since v6.0.0, use `Buffer.allocUnsafeSlow()` */
new(size: number): Buffer;
prototype: Buffer;
};

130
node_modules/@types/node/console.d.ts generated vendored
View File

@ -1,3 +1,133 @@
declare module "console" {
import { InspectOptions } from 'util';
global {
// This needs to be global to avoid TS2403 in case lib.dom.d.ts is present in the same build
interface Console {
Console: NodeJS.ConsoleConstructor;
/**
* A simple assertion test that verifies whether `value` is truthy.
* If it is not, an `AssertionError` is thrown.
* If provided, the error `message` is formatted using `util.format()` and used as the error message.
*/
assert(value: any, message?: string, ...optionalParams: any[]): void;
/**
* When `stdout` is a TTY, calling `console.clear()` will attempt to clear the TTY.
* When `stdout` is not a TTY, this method does nothing.
*/
clear(): void;
/**
* Maintains an internal counter specific to `label` and outputs to `stdout` the number of times `console.count()` has been called with the given `label`.
*/
count(label?: string): void;
/**
* Resets the internal counter specific to `label`.
*/
countReset(label?: string): void;
/**
* The `console.debug()` function is an alias for {@link console.log()}.
*/
debug(message?: any, ...optionalParams: any[]): void;
/**
* Uses {@link util.inspect()} on `obj` and prints the resulting string to `stdout`.
* This function bypasses any custom `inspect()` function defined on `obj`.
*/
dir(obj: any, options?: InspectOptions): void;
/**
* This method calls {@link console.log()} passing it the arguments received. Please note that this method does not produce any XML formatting
*/
dirxml(...data: any[]): void;
/**
* Prints to `stderr` with newline.
*/
error(message?: any, ...optionalParams: any[]): void;
/**
* Increases indentation of subsequent lines by two spaces.
* If one or more `label`s are provided, those are printed first without the additional indentation.
*/
group(...label: any[]): void;
/**
* The `console.groupCollapsed()` function is an alias for {@link console.group()}.
*/
groupCollapsed(...label: any[]): void;
/**
* Decreases indentation of subsequent lines by two spaces.
*/
groupEnd(): void;
/**
* The {@link console.info()} function is an alias for {@link console.log()}.
*/
info(message?: any, ...optionalParams: any[]): void;
/**
* Prints to `stdout` with newline.
*/
log(message?: any, ...optionalParams: any[]): void;
/**
* This method does not display anything unless used in the inspector.
* Prints to `stdout` the array `array` formatted as a table.
*/
table(tabularData: any, properties?: string[]): void;
/**
* Starts a timer that can be used to compute the duration of an operation. Timers are identified by a unique `label`.
*/
time(label?: string): void;
/**
* Stops a timer that was previously started by calling {@link console.time()} and prints the result to `stdout`.
*/
timeEnd(label?: string): void;
/**
* For a timer that was previously started by calling {@link console.time()}, prints the elapsed time and other `data` arguments to `stdout`.
*/
timeLog(label?: string, ...data: any[]): void;
/**
* Prints to `stderr` the string 'Trace :', followed by the {@link util.format()} formatted message and stack trace to the current position in the code.
*/
trace(message?: any, ...optionalParams: any[]): void;
/**
* The {@link console.warn()} function is an alias for {@link console.error()}.
*/
warn(message?: any, ...optionalParams: any[]): void;
// --- Inspector mode only ---
/**
* This method does not display anything unless used in the inspector.
* Starts a JavaScript CPU profile with an optional label.
*/
profile(label?: string): void;
/**
* This method does not display anything unless used in the inspector.
* Stops the current JavaScript CPU profiling session if one has been started and prints the report to the Profiles panel of the inspector.
*/
profileEnd(label?: string): void;
/**
* This method does not display anything unless used in the inspector.
* Adds an event with the label `label` to the Timeline panel of the inspector.
*/
timeStamp(label?: string): void;
}
var console: Console;
namespace NodeJS {
interface ConsoleConstructorOptions {
stdout: WritableStream;
stderr?: WritableStream;
ignoreErrors?: boolean;
colorMode?: boolean | 'auto';
inspectOptions?: InspectOptions;
}
interface ConsoleConstructor {
prototype: Console;
new(stdout: WritableStream, stderr?: WritableStream, ignoreErrors?: boolean): Console;
new(options: ConsoleConstructorOptions): Console;
}
interface Global {
console: typeof console;
}
}
}
export = console;
}

12
node_modules/@types/node/crypto.d.ts generated vendored
View File

@ -178,11 +178,11 @@ declare module "crypto" {
interface CipherGCMOptions extends stream.TransformOptions {
authTagLength?: number;
}
/** @deprecated since v10.0.0 use createCipheriv() */
/** @deprecated since v10.0.0 use `createCipheriv()` */
function createCipher(algorithm: CipherCCMTypes, password: BinaryLike, options: CipherCCMOptions): CipherCCM;
/** @deprecated since v10.0.0 use createCipheriv() */
/** @deprecated since v10.0.0 use `createCipheriv()` */
function createCipher(algorithm: CipherGCMTypes, password: BinaryLike, options?: CipherGCMOptions): CipherGCM;
/** @deprecated since v10.0.0 use createCipheriv() */
/** @deprecated since v10.0.0 use `createCipheriv()` */
function createCipher(algorithm: string, password: BinaryLike, options?: stream.TransformOptions): Cipher;
function createCipheriv(
@ -221,11 +221,11 @@ declare module "crypto" {
setAAD(buffer: Buffer, options?: { plaintextLength: number }): this;
getAuthTag(): Buffer;
}
/** @deprecated since v10.0.0 use createDecipheriv() */
/** @deprecated since v10.0.0 use `createDecipheriv()` */
function createDecipher(algorithm: CipherCCMTypes, password: BinaryLike, options: CipherCCMOptions): DecipherCCM;
/** @deprecated since v10.0.0 use createDecipheriv() */
/** @deprecated since v10.0.0 use `createDecipheriv()` */
function createDecipher(algorithm: CipherGCMTypes, password: BinaryLike, options?: CipherGCMOptions): DecipherGCM;
/** @deprecated since v10.0.0 use createDecipheriv() */
/** @deprecated since v10.0.0 use `createDecipheriv()` */
function createDecipher(algorithm: string, password: BinaryLike, options?: stream.TransformOptions): Decipher;
function createDecipheriv(

2
node_modules/@types/node/dns.d.ts generated vendored
View File

@ -60,7 +60,7 @@ declare module "dns" {
ttl: number;
}
/** @deprecated Use AnyARecord or AnyAaaaRecord instead. */
/** @deprecated Use `AnyARecord` or `AnyAaaaRecord` instead. */
type AnyRecordWithTtl = AnyARecord | AnyAaaaRecord;
interface AnyARecord extends RecordWithTtl {

20
node_modules/@types/node/domain.d.ts generated vendored
View File

@ -1,12 +1,20 @@
declare module "domain" {
import { EventEmitter } from "events";
class Domain extends EventEmitter implements NodeJS.Domain {
run<T>(fn: (...args: any[]) => T, ...args: any[]): T;
add(emitter: EventEmitter | NodeJS.Timer): void;
remove(emitter: EventEmitter | NodeJS.Timer): void;
bind<T extends Function>(cb: T): T;
intercept<T extends Function>(cb: T): T;
global {
namespace NodeJS {
interface Domain extends EventEmitter {
run<T>(fn: (...args: any[]) => T, ...args: any[]): T;
add(emitter: EventEmitter | Timer): void;
remove(emitter: EventEmitter | Timer): void;
bind<T extends Function>(cb: T): T;
intercept<T extends Function>(cb: T): T;
}
}
}
interface Domain extends NodeJS.Domain {}
class Domain extends EventEmitter {
members: Array<EventEmitter | NodeJS.Timer>;
enter(): void;
exit(): void;

23
node_modules/@types/node/events.d.ts generated vendored
View File

@ -56,5 +56,28 @@ declare module "events" {
}
}
global {
namespace NodeJS {
interface EventEmitter {
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
on(event: string | symbol, listener: (...args: any[]) => void): this;
once(event: string | symbol, listener: (...args: any[]) => void): this;
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
off(event: string | symbol, listener: (...args: any[]) => void): this;
removeAllListeners(event?: string | symbol): this;
setMaxListeners(n: number): this;
getMaxListeners(): number;
listeners(event: string | symbol): Function[];
rawListeners(event: string | symbol): Function[];
emit(event: string | symbol, ...args: any[]): boolean;
listenerCount(type: string | symbol): number;
// Added in Node 6...
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
eventNames(): Array<string | symbol>;
}
}
}
export = EventEmitter;
}

2
node_modules/@types/node/fs.d.ts generated vendored
View File

@ -1727,7 +1727,7 @@ declare module "fs" {
/**
* Asynchronously tests whether or not the given path exists by checking with the file system.
* @deprecated
* @deprecated since v1.0.0 Use `fs.stat()` or `fs.access()` instead
* @param path A path to a file or directory. If a URL is provided, it must use the `file:` protocol.
* URL support is _experimental_.
*/

532
node_modules/@types/node/globals.d.ts generated vendored
View File

@ -1,107 +1,3 @@
// This needs to be global to avoid TS2403 in case lib.dom.d.ts is present in the same build
interface Console {
Console: NodeJS.ConsoleConstructor;
/**
* A simple assertion test that verifies whether `value` is truthy.
* If it is not, an `AssertionError` is thrown.
* If provided, the error `message` is formatted using `util.format()` and used as the error message.
*/
assert(value: any, message?: string, ...optionalParams: any[]): void;
/**
* When `stdout` is a TTY, calling `console.clear()` will attempt to clear the TTY.
* When `stdout` is not a TTY, this method does nothing.
*/
clear(): void;
/**
* Maintains an internal counter specific to `label` and outputs to `stdout` the number of times `console.count()` has been called with the given `label`.
*/
count(label?: string): void;
/**
* Resets the internal counter specific to `label`.
*/
countReset(label?: string): void;
/**
* The `console.debug()` function is an alias for {@link console.log()}.
*/
debug(message?: any, ...optionalParams: any[]): void;
/**
* Uses {@link util.inspect()} on `obj` and prints the resulting string to `stdout`.
* This function bypasses any custom `inspect()` function defined on `obj`.
*/
dir(obj: any, options?: NodeJS.InspectOptions): void;
/**
* This method calls {@link console.log()} passing it the arguments received. Please note that this method does not produce any XML formatting
*/
dirxml(...data: any[]): void;
/**
* Prints to `stderr` with newline.
*/
error(message?: any, ...optionalParams: any[]): void;
/**
* Increases indentation of subsequent lines by two spaces.
* If one or more `label`s are provided, those are printed first without the additional indentation.
*/
group(...label: any[]): void;
/**
* The `console.groupCollapsed()` function is an alias for {@link console.group()}.
*/
groupCollapsed(...label: any[]): void;
/**
* Decreases indentation of subsequent lines by two spaces.
*/
groupEnd(): void;
/**
* The {@link console.info()} function is an alias for {@link console.log()}.
*/
info(message?: any, ...optionalParams: any[]): void;
/**
* Prints to `stdout` with newline.
*/
log(message?: any, ...optionalParams: any[]): void;
/**
* This method does not display anything unless used in the inspector.
* Prints to `stdout` the array `array` formatted as a table.
*/
table(tabularData: any, properties?: string[]): void;
/**
* Starts a timer that can be used to compute the duration of an operation. Timers are identified by a unique `label`.
*/
time(label?: string): void;
/**
* Stops a timer that was previously started by calling {@link console.time()} and prints the result to `stdout`.
*/
timeEnd(label?: string): void;
/**
* For a timer that was previously started by calling {@link console.time()}, prints the elapsed time and other `data` arguments to `stdout`.
*/
timeLog(label?: string, ...data: any[]): void;
/**
* Prints to `stderr` the string 'Trace :', followed by the {@link util.format()} formatted message and stack trace to the current position in the code.
*/
trace(message?: any, ...optionalParams: any[]): void;
/**
* The {@link console.warn()} function is an alias for {@link console.error()}.
*/
warn(message?: any, ...optionalParams: any[]): void;
// --- Inspector mode only ---
/**
* This method does not display anything unless used in the inspector.
* Starts a JavaScript CPU profile with an optional label.
*/
profile(label?: string): void;
/**
* This method does not display anything unless used in the inspector.
* Stops the current JavaScript CPU profiling session if one has been started and prints the report to the Profiles panel of the inspector.
*/
profileEnd(label?: string): void;
/**
* This method does not display anything unless used in the inspector.
* Adds an event with the label `label` to the Timeline panel of the inspector.
*/
timeStamp(label?: string): void;
}
// Declare "static" methods in Error
interface ErrorConstructor {
/** Create .stack property on a target object */
@ -140,9 +36,6 @@ interface NodeRequire extends NodeJS.Require {}
interface RequireResolve extends NodeJS.RequireResolve {}
interface NodeModule extends NodeJS.Module {}
declare var process: NodeJS.Process;
declare var console: Console;
declare var __filename: string;
declare var __dirname: string;
@ -453,20 +346,6 @@ declare namespace NodeJS {
sorted?: boolean | ((a: string, b: string) => number);
}
interface ConsoleConstructorOptions {
stdout: WritableStream;
stderr?: WritableStream;
ignoreErrors?: boolean;
colorMode?: boolean | 'auto';
inspectOptions?: InspectOptions;
}
interface ConsoleConstructor {
prototype: Console;
new(stdout: WritableStream, stderr?: WritableStream, ignoreErrors?: boolean): Console;
new(options: ConsoleConstructorOptions): Console;
}
interface CallSite {
/**
* Value of "this"
@ -549,25 +428,6 @@ declare namespace NodeJS {
stack?: string;
}
interface EventEmitter {
addListener(event: string | symbol, listener: (...args: any[]) => void): this;
on(event: string | symbol, listener: (...args: any[]) => void): this;
once(event: string | symbol, listener: (...args: any[]) => void): this;
removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
off(event: string | symbol, listener: (...args: any[]) => void): this;
removeAllListeners(event?: string | symbol): this;
setMaxListeners(n: number): this;
getMaxListeners(): number;
listeners(event: string | symbol): Function[];
rawListeners(event: string | symbol): Function[];
emit(event: string | symbol, ...args: any[]): boolean;
listenerCount(type: string | symbol): number;
// Added in Node 6...
prependListener(event: string | symbol, listener: (...args: any[]) => void): this;
prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this;
eventNames(): Array<string | symbol>;
}
interface ReadableStream extends EventEmitter {
readable: boolean;
read(size?: number): string | Buffer;
@ -593,390 +453,6 @@ declare namespace NodeJS {
interface ReadWriteStream extends ReadableStream, WritableStream { }
interface Domain extends EventEmitter {
run<T>(fn: (...args: any[]) => T, ...args: any[]): T;
add(emitter: EventEmitter | Timer): void;
remove(emitter: EventEmitter | Timer): void;
bind<T extends Function>(cb: T): T;
intercept<T extends Function>(cb: T): T;
addListener(event: string, listener: (...args: any[]) => void): this;
on(event: string, listener: (...args: any[]) => void): this;
once(event: string, listener: (...args: any[]) => void): this;
removeListener(event: string, listener: (...args: any[]) => void): this;
removeAllListeners(event?: string): this;
}
interface MemoryUsage {
rss: number;
heapTotal: number;
heapUsed: number;
external: number;
arrayBuffers: number;
}
interface CpuUsage {
user: number;
system: number;
}
interface ProcessRelease {
name: string;
sourceUrl?: string;
headersUrl?: string;
libUrl?: string;
lts?: string;
}
interface ProcessVersions {
http_parser: string;
node: string;
v8: string;
ares: string;
uv: string;
zlib: string;
modules: string;
openssl: string;
}
type Platform = 'aix'
| 'android'
| 'darwin'
| 'freebsd'
| 'linux'
| 'openbsd'
| 'sunos'
| 'win32'
| 'cygwin'
| 'netbsd';
type Signals =
"SIGABRT" | "SIGALRM" | "SIGBUS" | "SIGCHLD" | "SIGCONT" | "SIGFPE" | "SIGHUP" | "SIGILL" | "SIGINT" | "SIGIO" |
"SIGIOT" | "SIGKILL" | "SIGPIPE" | "SIGPOLL" | "SIGPROF" | "SIGPWR" | "SIGQUIT" | "SIGSEGV" | "SIGSTKFLT" |
"SIGSTOP" | "SIGSYS" | "SIGTERM" | "SIGTRAP" | "SIGTSTP" | "SIGTTIN" | "SIGTTOU" | "SIGUNUSED" | "SIGURG" |
"SIGUSR1" | "SIGUSR2" | "SIGVTALRM" | "SIGWINCH" | "SIGXCPU" | "SIGXFSZ" | "SIGBREAK" | "SIGLOST" | "SIGINFO";
type MultipleResolveType = 'resolve' | 'reject';
type BeforeExitListener = (code: number) => void;
type DisconnectListener = () => void;
type ExitListener = (code: number) => void;
type RejectionHandledListener = (promise: Promise<any>) => void;
type UncaughtExceptionListener = (error: Error) => void;
type UnhandledRejectionListener = (reason: {} | null | undefined, promise: Promise<any>) => void;
type WarningListener = (warning: Error) => void;
type MessageListener = (message: any, sendHandle: any) => void;
type SignalsListener = (signal: Signals) => void;
type NewListenerListener = (type: string | symbol, listener: (...args: any[]) => void) => void;
type RemoveListenerListener = (type: string | symbol, listener: (...args: any[]) => void) => void;
type MultipleResolveListener = (type: MultipleResolveType, promise: Promise<any>, value: any) => void;
interface Socket extends ReadWriteStream {
isTTY?: true;
}
// Alias for compatibility
interface ProcessEnv extends Dict<string> {}
interface HRTime {
(time?: [number, number]): [number, number];
}
interface ProcessReport {
/**
* Directory where the report is written.
* working directory of the Node.js process.
* @default '' indicating that reports are written to the current
*/
directory: string;
/**
* Filename where the report is written.
* The default value is the empty string.
* @default '' the output filename will be comprised of a timestamp,
* PID, and sequence number.
*/
filename: string;
/**
* Returns a JSON-formatted diagnostic report for the running process.
* The report's JavaScript stack trace is taken from err, if present.
*/
getReport(err?: Error): string;
/**
* If true, a diagnostic report is generated on fatal errors,
* such as out of memory errors or failed C++ assertions.
* @default false
*/
reportOnFatalError: boolean;
/**
* If true, a diagnostic report is generated when the process
* receives the signal specified by process.report.signal.
* @defaul false
*/
reportOnSignal: boolean;
/**
* If true, a diagnostic report is generated on uncaught exception.
* @default false
*/
reportOnUncaughtException: boolean;
/**
* The signal used to trigger the creation of a diagnostic report.
* @default 'SIGUSR2'
*/
signal: Signals;
/**
* Writes a diagnostic report to a file. If filename is not provided, the default filename
* includes the date, time, PID, and a sequence number.
* The report's JavaScript stack trace is taken from err, if present.
*
* @param fileName Name of the file where the report is written.
* This should be a relative path, that will be appended to the directory specified in
* `process.report.directory`, or the current working directory of the Node.js process,
* if unspecified.
* @param error A custom error used for reporting the JavaScript stack.
* @return Filename of the generated report.
*/
writeReport(fileName?: string): string;
writeReport(error?: Error): string;
writeReport(fileName?: string, err?: Error): string;
}
interface ResourceUsage {
fsRead: number;
fsWrite: number;
involuntaryContextSwitches: number;
ipcReceived: number;
ipcSent: number;
majorPageFault: number;
maxRSS: number;
minorPageFault: number;
sharedMemorySize: number;
signalsCount: number;
swappedOut: number;
systemCPUTime: number;
unsharedDataSize: number;
unsharedStackSize: number;
userCPUTime: number;
voluntaryContextSwitches: number;
}
interface Process extends EventEmitter {
/**
* Can also be a tty.WriteStream, not typed due to limitations.
*/
stdout: WriteStream;
/**
* Can also be a tty.WriteStream, not typed due to limitations.
*/
stderr: WriteStream;
stdin: ReadStream;
openStdin(): Socket;
argv: string[];
argv0: string;
execArgv: string[];
execPath: string;
abort(): void;
chdir(directory: string): void;
cwd(): string;
debugPort: number;
emitWarning(warning: string | Error, name?: string, ctor?: Function): void;
env: ProcessEnv;
exit(code?: number): never;
exitCode?: number;
getgid(): number;
setgid(id: number | string): void;
getuid(): number;
setuid(id: number | string): void;
geteuid(): number;
seteuid(id: number | string): void;
getegid(): number;
setegid(id: number | string): void;
getgroups(): number[];
setgroups(groups: Array<string | number>): void;
setUncaughtExceptionCaptureCallback(cb: ((err: Error) => void) | null): void;
hasUncaughtExceptionCaptureCallback(): boolean;
version: string;
versions: ProcessVersions;
config: {
target_defaults: {
cflags: any[];
default_configuration: string;
defines: string[];
include_dirs: string[];
libraries: string[];
};
variables: {
clang: number;
host_arch: string;
node_install_npm: boolean;
node_install_waf: boolean;
node_prefix: string;
node_shared_openssl: boolean;
node_shared_v8: boolean;
node_shared_zlib: boolean;
node_use_dtrace: boolean;
node_use_etw: boolean;
node_use_openssl: boolean;
target_arch: string;
v8_no_strict_aliasing: number;
v8_use_snapshot: boolean;
visibility: string;
};
};
kill(pid: number, signal?: string | number): true;
pid: number;
ppid: number;
title: string;
arch: string;
platform: Platform;
memoryUsage(): MemoryUsage;
cpuUsage(previousValue?: CpuUsage): CpuUsage;
nextTick(callback: Function, ...args: any[]): void;
release: ProcessRelease;
features: {
inspector: boolean;
debug: boolean;
uv: boolean;
ipv6: boolean;
tls_alpn: boolean;
tls_sni: boolean;
tls_ocsp: boolean;
tls: boolean;
};
/**
* Can only be set if not in worker thread.
*/
umask(mask: number): number;
uptime(): number;
hrtime: HRTime;
domain: Domain;
// Worker
send?(message: any, sendHandle?: any, options?: { swallowErrors?: boolean}, callback?: (error: Error | null) => void): boolean;
disconnect(): void;
connected: boolean;
/**
* The `process.allowedNodeEnvironmentFlags` property is a special,
* read-only `Set` of flags allowable within the [`NODE_OPTIONS`][]
* environment variable.
*/
allowedNodeEnvironmentFlags: ReadonlySet<string>;
/**
* Only available with `--experimental-report`
*/
report?: ProcessReport;
resourceUsage(): ResourceUsage;
/* EventEmitter */
addListener(event: "beforeExit", listener: BeforeExitListener): this;
addListener(event: "disconnect", listener: DisconnectListener): this;
addListener(event: "exit", listener: ExitListener): this;
addListener(event: "rejectionHandled", listener: RejectionHandledListener): this;
addListener(event: "uncaughtException", listener: UncaughtExceptionListener): this;
addListener(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this;
addListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
addListener(event: "warning", listener: WarningListener): this;
addListener(event: "message", listener: MessageListener): this;
addListener(event: Signals, listener: SignalsListener): this;
addListener(event: "newListener", listener: NewListenerListener): this;
addListener(event: "removeListener", listener: RemoveListenerListener): this;
addListener(event: "multipleResolves", listener: MultipleResolveListener): this;
emit(event: "beforeExit", code: number): boolean;
emit(event: "disconnect"): boolean;
emit(event: "exit", code: number): boolean;
emit(event: "rejectionHandled", promise: Promise<any>): boolean;
emit(event: "uncaughtException", error: Error): boolean;
emit(event: "uncaughtExceptionMonitor", error: Error): boolean;
emit(event: "unhandledRejection", reason: any, promise: Promise<any>): boolean;
emit(event: "warning", warning: Error): boolean;
emit(event: "message", message: any, sendHandle: any): this;
emit(event: Signals, signal: Signals): boolean;
emit(event: "newListener", eventName: string | symbol, listener: (...args: any[]) => void): this;
emit(event: "removeListener", eventName: string, listener: (...args: any[]) => void): this;
emit(event: "multipleResolves", listener: MultipleResolveListener): this;
on(event: "beforeExit", listener: BeforeExitListener): this;
on(event: "disconnect", listener: DisconnectListener): this;
on(event: "exit", listener: ExitListener): this;
on(event: "rejectionHandled", listener: RejectionHandledListener): this;
on(event: "uncaughtException", listener: UncaughtExceptionListener): this;
on(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this;
on(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
on(event: "warning", listener: WarningListener): this;
on(event: "message", listener: MessageListener): this;
on(event: Signals, listener: SignalsListener): this;
on(event: "newListener", listener: NewListenerListener): this;
on(event: "removeListener", listener: RemoveListenerListener): this;
on(event: "multipleResolves", listener: MultipleResolveListener): this;
on(event: string | symbol, listener: (...args: any[]) => void): this;
once(event: "beforeExit", listener: BeforeExitListener): this;
once(event: "disconnect", listener: DisconnectListener): this;
once(event: "exit", listener: ExitListener): this;
once(event: "rejectionHandled", listener: RejectionHandledListener): this;
once(event: "uncaughtException", listener: UncaughtExceptionListener): this;
once(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this;
once(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
once(event: "warning", listener: WarningListener): this;
once(event: "message", listener: MessageListener): this;
once(event: Signals, listener: SignalsListener): this;
once(event: "newListener", listener: NewListenerListener): this;
once(event: "removeListener", listener: RemoveListenerListener): this;
once(event: "multipleResolves", listener: MultipleResolveListener): this;
prependListener(event: "beforeExit", listener: BeforeExitListener): this;
prependListener(event: "disconnect", listener: DisconnectListener): this;
prependListener(event: "exit", listener: ExitListener): this;
prependListener(event: "rejectionHandled", listener: RejectionHandledListener): this;
prependListener(event: "uncaughtException", listener: UncaughtExceptionListener): this;
prependListener(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this;
prependListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
prependListener(event: "warning", listener: WarningListener): this;
prependListener(event: "message", listener: MessageListener): this;
prependListener(event: Signals, listener: SignalsListener): this;
prependListener(event: "newListener", listener: NewListenerListener): this;
prependListener(event: "removeListener", listener: RemoveListenerListener): this;
prependListener(event: "multipleResolves", listener: MultipleResolveListener): this;
prependOnceListener(event: "beforeExit", listener: BeforeExitListener): this;
prependOnceListener(event: "disconnect", listener: DisconnectListener): this;
prependOnceListener(event: "exit", listener: ExitListener): this;
prependOnceListener(event: "rejectionHandled", listener: RejectionHandledListener): this;
prependOnceListener(event: "uncaughtException", listener: UncaughtExceptionListener): this;
prependOnceListener(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this;
prependOnceListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
prependOnceListener(event: "warning", listener: WarningListener): this;
prependOnceListener(event: "message", listener: MessageListener): this;
prependOnceListener(event: Signals, listener: SignalsListener): this;
prependOnceListener(event: "newListener", listener: NewListenerListener): this;
prependOnceListener(event: "removeListener", listener: RemoveListenerListener): this;
prependOnceListener(event: "multipleResolves", listener: MultipleResolveListener): this;
listeners(event: "beforeExit"): BeforeExitListener[];
listeners(event: "disconnect"): DisconnectListener[];
listeners(event: "exit"): ExitListener[];
listeners(event: "rejectionHandled"): RejectionHandledListener[];
listeners(event: "uncaughtException"): UncaughtExceptionListener[];
listeners(event: "uncaughtExceptionMonitor"): UncaughtExceptionListener[];
listeners(event: "unhandledRejection"): UnhandledRejectionListener[];
listeners(event: "warning"): WarningListener[];
listeners(event: "message"): MessageListener[];
listeners(event: Signals): SignalsListener[];
listeners(event: "newListener"): NewListenerListener[];
listeners(event: "removeListener"): RemoveListenerListener[];
listeners(event: "multipleResolves"): MultipleResolveListener[];
}
interface Global {
Array: typeof Array;
ArrayBuffer: typeof ArrayBuffer;
@ -1019,7 +495,6 @@ declare namespace NodeJS {
clearImmediate: (immediateId: Immediate) => void;
clearInterval: (intervalId: Timeout) => void;
clearTimeout: (timeoutId: Timeout) => void;
console: typeof console;
decodeURI: typeof decodeURI;
decodeURIComponent: typeof decodeURIComponent;
encodeURI: typeof encodeURI;
@ -1031,7 +506,6 @@ declare namespace NodeJS {
isNaN: typeof isNaN;
parseFloat: typeof parseFloat;
parseInt: typeof parseInt;
process: Process;
setImmediate: (callback: (...args: any[]) => void, ...args: any[]) => Immediate;
setInterval: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => Timeout;
setTimeout: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => Timeout;
@ -1096,6 +570,12 @@ declare namespace NodeJS {
loaded: boolean;
parent: Module | null;
children: Module[];
/**
* @since 11.14.0
*
* The directory name of the module. This is usually the same as the path.dirname() of the module.id.
*/
path: string;
paths: string[];
}

1
node_modules/@types/node/http.d.ts generated vendored
View File

@ -1,5 +1,4 @@
declare module "http" {
import * as events from "events";
import * as stream from "stream";
import { URL } from "url";
import { Socket, Server as NetServer } from "net";

View File

@ -1,6 +1,6 @@
{
"name": "@types/node",
"version": "14.0.14",
"version": "14.0.23",
"description": "TypeScript definitions for Node.js",
"license": "MIT",
"contributors": [
@ -251,6 +251,6 @@
},
"scripts": {},
"dependencies": {},
"typesPublisherContentHash": "8cd461b1ef1172c83468acd55faa2e179945580cb68adf361b406fd41eed66df",
"typesPublisherContentHash": "804cf921ce926d59cd60cf46be4e11bfc4fcb82f51e61daec706fb27bd4db0ba",
"typeScriptVersion": "3.0"
}

382
node_modules/@types/node/process.d.ts generated vendored
View File

@ -2,12 +2,394 @@ declare module "process" {
import * as tty from "tty";
global {
var process: NodeJS.Process;
namespace NodeJS {
// this namespace merge is here because these are specifically used
// as the type for process.stdin, process.stdout, and process.stderr.
// they can't live in tty.d.ts because we need to disambiguate the imported name.
interface ReadStream extends tty.ReadStream {}
interface WriteStream extends tty.WriteStream {}
interface MemoryUsage {
rss: number;
heapTotal: number;
heapUsed: number;
external: number;
arrayBuffers: number;
}
interface CpuUsage {
user: number;
system: number;
}
interface ProcessRelease {
name: string;
sourceUrl?: string;
headersUrl?: string;
libUrl?: string;
lts?: string;
}
interface ProcessVersions {
http_parser: string;
node: string;
v8: string;
ares: string;
uv: string;
zlib: string;
modules: string;
openssl: string;
}
type Platform = 'aix'
| 'android'
| 'darwin'
| 'freebsd'
| 'linux'
| 'openbsd'
| 'sunos'
| 'win32'
| 'cygwin'
| 'netbsd';
type Signals =
"SIGABRT" | "SIGALRM" | "SIGBUS" | "SIGCHLD" | "SIGCONT" | "SIGFPE" | "SIGHUP" | "SIGILL" | "SIGINT" | "SIGIO" |
"SIGIOT" | "SIGKILL" | "SIGPIPE" | "SIGPOLL" | "SIGPROF" | "SIGPWR" | "SIGQUIT" | "SIGSEGV" | "SIGSTKFLT" |
"SIGSTOP" | "SIGSYS" | "SIGTERM" | "SIGTRAP" | "SIGTSTP" | "SIGTTIN" | "SIGTTOU" | "SIGUNUSED" | "SIGURG" |
"SIGUSR1" | "SIGUSR2" | "SIGVTALRM" | "SIGWINCH" | "SIGXCPU" | "SIGXFSZ" | "SIGBREAK" | "SIGLOST" | "SIGINFO";
type MultipleResolveType = 'resolve' | 'reject';
type BeforeExitListener = (code: number) => void;
type DisconnectListener = () => void;
type ExitListener = (code: number) => void;
type RejectionHandledListener = (promise: Promise<any>) => void;
type UncaughtExceptionListener = (error: Error) => void;
type UnhandledRejectionListener = (reason: {} | null | undefined, promise: Promise<any>) => void;
type WarningListener = (warning: Error) => void;
type MessageListener = (message: any, sendHandle: any) => void;
type SignalsListener = (signal: Signals) => void;
type NewListenerListener = (type: string | symbol, listener: (...args: any[]) => void) => void;
type RemoveListenerListener = (type: string | symbol, listener: (...args: any[]) => void) => void;
type MultipleResolveListener = (type: MultipleResolveType, promise: Promise<any>, value: any) => void;
interface Socket extends ReadWriteStream {
isTTY?: true;
}
// Alias for compatibility
interface ProcessEnv extends Dict<string> {}
interface HRTime {
(time?: [number, number]): [number, number];
}
interface ProcessReport {
/**
* Directory where the report is written.
* working directory of the Node.js process.
* @default '' indicating that reports are written to the current
*/
directory: string;
/**
* Filename where the report is written.
* The default value is the empty string.
* @default '' the output filename will be comprised of a timestamp,
* PID, and sequence number.
*/
filename: string;
/**
* Returns a JSON-formatted diagnostic report for the running process.
* The report's JavaScript stack trace is taken from err, if present.
*/
getReport(err?: Error): string;
/**
* If true, a diagnostic report is generated on fatal errors,
* such as out of memory errors or failed C++ assertions.
* @default false
*/
reportOnFatalError: boolean;
/**
* If true, a diagnostic report is generated when the process
* receives the signal specified by process.report.signal.
* @defaul false
*/
reportOnSignal: boolean;
/**
* If true, a diagnostic report is generated on uncaught exception.
* @default false
*/
reportOnUncaughtException: boolean;
/**
* The signal used to trigger the creation of a diagnostic report.
* @default 'SIGUSR2'
*/
signal: Signals;
/**
* Writes a diagnostic report to a file. If filename is not provided, the default filename
* includes the date, time, PID, and a sequence number.
* The report's JavaScript stack trace is taken from err, if present.
*
* @param fileName Name of the file where the report is written.
* This should be a relative path, that will be appended to the directory specified in
* `process.report.directory`, or the current working directory of the Node.js process,
* if unspecified.
* @param error A custom error used for reporting the JavaScript stack.
* @return Filename of the generated report.
*/
writeReport(fileName?: string): string;
writeReport(error?: Error): string;
writeReport(fileName?: string, err?: Error): string;
}
interface ResourceUsage {
fsRead: number;
fsWrite: number;
involuntaryContextSwitches: number;
ipcReceived: number;
ipcSent: number;
majorPageFault: number;
maxRSS: number;
minorPageFault: number;
sharedMemorySize: number;
signalsCount: number;
swappedOut: number;
systemCPUTime: number;
unsharedDataSize: number;
unsharedStackSize: number;
userCPUTime: number;
voluntaryContextSwitches: number;
}
interface Process extends EventEmitter {
/**
* Can also be a tty.WriteStream, not typed due to limitations.
*/
stdout: WriteStream & {
fd: 1;
};
/**
* Can also be a tty.WriteStream, not typed due to limitations.
*/
stderr: WriteStream & {
fd: 2;
};
stdin: ReadStream & {
fd: 0;
};
openStdin(): Socket;
argv: string[];
argv0: string;
execArgv: string[];
execPath: string;
abort(): void;
chdir(directory: string): void;
cwd(): string;
debugPort: number;
emitWarning(warning: string | Error, name?: string, ctor?: Function): void;
env: ProcessEnv;
exit(code?: number): never;
exitCode?: number;
getgid(): number;
setgid(id: number | string): void;
getuid(): number;
setuid(id: number | string): void;
geteuid(): number;
seteuid(id: number | string): void;
getegid(): number;
setegid(id: number | string): void;
getgroups(): number[];
setgroups(groups: Array<string | number>): void;
setUncaughtExceptionCaptureCallback(cb: ((err: Error) => void) | null): void;
hasUncaughtExceptionCaptureCallback(): boolean;
version: string;
versions: ProcessVersions;
config: {
target_defaults: {
cflags: any[];
default_configuration: string;
defines: string[];
include_dirs: string[];
libraries: string[];
};
variables: {
clang: number;
host_arch: string;
node_install_npm: boolean;
node_install_waf: boolean;
node_prefix: string;
node_shared_openssl: boolean;
node_shared_v8: boolean;
node_shared_zlib: boolean;
node_use_dtrace: boolean;
node_use_etw: boolean;
node_use_openssl: boolean;
target_arch: string;
v8_no_strict_aliasing: number;
v8_use_snapshot: boolean;
visibility: string;
};
};
kill(pid: number, signal?: string | number): true;
pid: number;
ppid: number;
title: string;
arch: string;
platform: Platform;
memoryUsage(): MemoryUsage;
cpuUsage(previousValue?: CpuUsage): CpuUsage;
nextTick(callback: Function, ...args: any[]): void;
release: ProcessRelease;
features: {
inspector: boolean;
debug: boolean;
uv: boolean;
ipv6: boolean;
tls_alpn: boolean;
tls_sni: boolean;
tls_ocsp: boolean;
tls: boolean;
};
/**
* Can only be set if not in worker thread.
*/
umask(mask: number): number;
uptime(): number;
hrtime: HRTime;
domain: Domain;
// Worker
send?(message: any, sendHandle?: any, options?: { swallowErrors?: boolean}, callback?: (error: Error | null) => void): boolean;
disconnect(): void;
connected: boolean;
/**
* The `process.allowedNodeEnvironmentFlags` property is a special,
* read-only `Set` of flags allowable within the [`NODE_OPTIONS`][]
* environment variable.
*/
allowedNodeEnvironmentFlags: ReadonlySet<string>;
/**
* Only available with `--experimental-report`
*/
report?: ProcessReport;
resourceUsage(): ResourceUsage;
/* EventEmitter */
addListener(event: "beforeExit", listener: BeforeExitListener): this;
addListener(event: "disconnect", listener: DisconnectListener): this;
addListener(event: "exit", listener: ExitListener): this;
addListener(event: "rejectionHandled", listener: RejectionHandledListener): this;
addListener(event: "uncaughtException", listener: UncaughtExceptionListener): this;
addListener(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this;
addListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
addListener(event: "warning", listener: WarningListener): this;
addListener(event: "message", listener: MessageListener): this;
addListener(event: Signals, listener: SignalsListener): this;
addListener(event: "newListener", listener: NewListenerListener): this;
addListener(event: "removeListener", listener: RemoveListenerListener): this;
addListener(event: "multipleResolves", listener: MultipleResolveListener): this;
emit(event: "beforeExit", code: number): boolean;
emit(event: "disconnect"): boolean;
emit(event: "exit", code: number): boolean;
emit(event: "rejectionHandled", promise: Promise<any>): boolean;
emit(event: "uncaughtException", error: Error): boolean;
emit(event: "uncaughtExceptionMonitor", error: Error): boolean;
emit(event: "unhandledRejection", reason: any, promise: Promise<any>): boolean;
emit(event: "warning", warning: Error): boolean;
emit(event: "message", message: any, sendHandle: any): this;
emit(event: Signals, signal: Signals): boolean;
emit(event: "newListener", eventName: string | symbol, listener: (...args: any[]) => void): this;
emit(event: "removeListener", eventName: string, listener: (...args: any[]) => void): this;
emit(event: "multipleResolves", listener: MultipleResolveListener): this;
on(event: "beforeExit", listener: BeforeExitListener): this;
on(event: "disconnect", listener: DisconnectListener): this;
on(event: "exit", listener: ExitListener): this;
on(event: "rejectionHandled", listener: RejectionHandledListener): this;
on(event: "uncaughtException", listener: UncaughtExceptionListener): this;
on(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this;
on(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
on(event: "warning", listener: WarningListener): this;
on(event: "message", listener: MessageListener): this;
on(event: Signals, listener: SignalsListener): this;
on(event: "newListener", listener: NewListenerListener): this;
on(event: "removeListener", listener: RemoveListenerListener): this;
on(event: "multipleResolves", listener: MultipleResolveListener): this;
on(event: string | symbol, listener: (...args: any[]) => void): this;
once(event: "beforeExit", listener: BeforeExitListener): this;
once(event: "disconnect", listener: DisconnectListener): this;
once(event: "exit", listener: ExitListener): this;
once(event: "rejectionHandled", listener: RejectionHandledListener): this;
once(event: "uncaughtException", listener: UncaughtExceptionListener): this;
once(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this;
once(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
once(event: "warning", listener: WarningListener): this;
once(event: "message", listener: MessageListener): this;
once(event: Signals, listener: SignalsListener): this;
once(event: "newListener", listener: NewListenerListener): this;
once(event: "removeListener", listener: RemoveListenerListener): this;
once(event: "multipleResolves", listener: MultipleResolveListener): this;
prependListener(event: "beforeExit", listener: BeforeExitListener): this;
prependListener(event: "disconnect", listener: DisconnectListener): this;
prependListener(event: "exit", listener: ExitListener): this;
prependListener(event: "rejectionHandled", listener: RejectionHandledListener): this;
prependListener(event: "uncaughtException", listener: UncaughtExceptionListener): this;
prependListener(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this;
prependListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
prependListener(event: "warning", listener: WarningListener): this;
prependListener(event: "message", listener: MessageListener): this;
prependListener(event: Signals, listener: SignalsListener): this;
prependListener(event: "newListener", listener: NewListenerListener): this;
prependListener(event: "removeListener", listener: RemoveListenerListener): this;
prependListener(event: "multipleResolves", listener: MultipleResolveListener): this;
prependOnceListener(event: "beforeExit", listener: BeforeExitListener): this;
prependOnceListener(event: "disconnect", listener: DisconnectListener): this;
prependOnceListener(event: "exit", listener: ExitListener): this;
prependOnceListener(event: "rejectionHandled", listener: RejectionHandledListener): this;
prependOnceListener(event: "uncaughtException", listener: UncaughtExceptionListener): this;
prependOnceListener(event: "uncaughtExceptionMonitor", listener: UncaughtExceptionListener): this;
prependOnceListener(event: "unhandledRejection", listener: UnhandledRejectionListener): this;
prependOnceListener(event: "warning", listener: WarningListener): this;
prependOnceListener(event: "message", listener: MessageListener): this;
prependOnceListener(event: Signals, listener: SignalsListener): this;
prependOnceListener(event: "newListener", listener: NewListenerListener): this;
prependOnceListener(event: "removeListener", listener: RemoveListenerListener): this;
prependOnceListener(event: "multipleResolves", listener: MultipleResolveListener): this;
listeners(event: "beforeExit"): BeforeExitListener[];
listeners(event: "disconnect"): DisconnectListener[];
listeners(event: "exit"): ExitListener[];
listeners(event: "rejectionHandled"): RejectionHandledListener[];
listeners(event: "uncaughtException"): UncaughtExceptionListener[];
listeners(event: "uncaughtExceptionMonitor"): UncaughtExceptionListener[];
listeners(event: "unhandledRejection"): UnhandledRejectionListener[];
listeners(event: "warning"): WarningListener[];
listeners(event: "message"): MessageListener[];
listeners(event: Signals): SignalsListener[];
listeners(event: "newListener"): NewListenerListener[];
listeners(event: "removeListener"): RemoveListenerListener[];
listeners(event: "multipleResolves"): MultipleResolveListener[];
}
interface Global {
process: Process;
}
}
}

View File

@ -28,6 +28,7 @@ declare module "stream" {
readable: boolean;
readonly readableEncoding: BufferEncoding | null;
readonly readableEnded: boolean;
readonly readableFlowing: boolean | null;
readonly readableHighWaterMark: number;
readonly readableLength: number;
readonly readableObjectMode: boolean;

2
node_modules/@types/node/tls.d.ts generated vendored
View File

@ -726,7 +726,7 @@ declare module "tls" {
function connect(port: number, host?: string, options?: ConnectionOptions, secureConnectListener?: () => void): TLSSocket;
function connect(port: number, options?: ConnectionOptions, secureConnectListener?: () => void): TLSSocket;
/**
* @deprecated
* @deprecated since v0.11.3 Use `tls.TLSSocket` instead.
*/
function createSecurePair(credentials?: SecureContext, isServer?: boolean, requestCert?: boolean, rejectUnauthorized?: boolean): SecurePair;
function createSecureContext(details: SecureContextOptions): SecureContext;

View File

@ -18,5 +18,6 @@
// TypeScript 3.2-specific augmentations:
/// <reference path="fs.d.ts" />
/// <reference path="process.d.ts" />
/// <reference path="util.d.ts" />
/// <reference path="globals.d.ts" />

View File

@ -1,12 +1,6 @@
// tslint:disable-next-line:no-bad-reference
/// <reference path="../globals.d.ts" />
declare namespace NodeJS {
interface HRTime {
bigint(): bigint;
}
}
interface Buffer extends Uint8Array {
readBigUInt64BE(offset?: number): bigint;
readBigUInt64LE(offset?: number): bigint;

12
node_modules/@types/node/ts3.2/process.d.ts generated vendored Normal file
View File

@ -0,0 +1,12 @@
// tslint:disable-next-line:no-bad-reference
/// <reference path="../process.d.ts" />
declare module 'process' {
global {
namespace NodeJS {
interface HRTime {
bigint(): bigint;
}
}
}
}

View File

@ -1,3 +1,10 @@
# [23.18.0](https://github.com/jest-community/eslint-plugin-jest/compare/v23.17.1...v23.18.0) (2020-07-05)
### Features
* **valid-title:** support `mustMatch` & `mustNotMatch` options ([#608](https://github.com/jest-community/eslint-plugin-jest/issues/608)) ([4c7207e](https://github.com/jest-community/eslint-plugin-jest/commit/4c7207ebbb274f7b584225ad65ffb96a4328240e)), closes [#233](https://github.com/jest-community/eslint-plugin-jest/issues/233)
## [23.17.1](https://github.com/jest-community/eslint-plugin-jest/compare/v23.17.0...v23.17.1) (2020-06-23)

View File

@ -152,9 +152,11 @@ describe('foo', () => {
## Options
```ts
interface {
interface Options {
ignoreTypeOfDescribeName?: boolean;
disallowedWords?: string[];
mustNotMatch?: Partial<Record<'describe' | 'test' | 'it', string>> | string;
mustMatch?: Partial<Record<'describe' | 'test' | 'it', string>> | string;
}
```
@ -172,7 +174,7 @@ Default: `[]`
A string array of words that are not allowed to be used in test titles. Matching
is not case-sensitive, and looks for complete words:
Examples of **incorrect** code using `disallowedWords`:
Examples of **incorrect** code when using `disallowedWords`:
```js
// with disallowedWords: ['correct', 'all', 'every', 'properly']
@ -190,3 +192,37 @@ it('correctly sets the value', () => {});
test('that everything is as it should be', () => {});
describe('the proper way to handle things', () => {});
```
#### `mustMatch` & `mustNotMatch`
Defaults: `{}`
Allows enforcing that titles must match or must not match a given Regular
Expression. An object can be provided to apply different Regular Expressions to
specific Jest test function groups (`describe`, `test`, and `it`).
Examples of **incorrect** code when using `mustMatch`:
```js
// with mustMatch: '$that'
describe('the correct way to do things', () => {});
fit('this there!', () => {});
// with mustMatch: { test: '$that' }
describe('the tests that will be run', () => {});
test('the stuff works', () => {});
xtest('errors that are thrown have messages', () => {});
```
Examples of **correct** code when using `mustMatch`:
```js
// with mustMatch: '$that'
describe('that thing that needs to be done', () => {});
fit('that this there!', () => {});
// with mustMatch: { test: '$that' }
describe('the tests that will be run', () => {});
test('that the stuff works', () => {});
xtest('that errors that thrown have messages', () => {});
```

View File

@ -32,45 +32,28 @@ interopRequireDefault(require(moduleName)).default;
const rulesDir = (0, _path.join)(__dirname, 'rules');
const excludedFiles = ['__tests__', 'utils'];
const rules = (0, _fs.readdirSync)(rulesDir).map(rule => (0, _path.parse)(rule).name).filter(rule => !excludedFiles.includes(rule)).reduce((acc, curr) => Object.assign(acc, {
const rules = (0, _fs.readdirSync)(rulesDir).map(rule => (0, _path.parse)(rule).name).filter(rule => !excludedFiles.includes(rule)).reduce((acc, curr) => _objectSpread(_objectSpread({}, acc), {}, {
[curr]: importDefault((0, _path.join)(rulesDir, curr))
}), {});
const recommendedRules = Object.entries(rules).filter(([, rule]) => rule.meta.docs.recommended).reduce((acc, [name, rule]) => _objectSpread(_objectSpread({}, acc), {}, {
[`jest/${name}`]: rule.meta.docs.recommended
}), {});
const allRules = Object.keys(rules).reduce((rules, key) => _objectSpread(_objectSpread({}, rules), {}, {
[`jest/${key}`]: 'error'
}), {});
const createConfig = rules => ({
plugins: ['jest'],
env: {
'jest/globals': true
},
rules
});
module.exports = {
configs: {
all: {
plugins: ['jest'],
env: {
'jest/globals': true
},
rules: allRules
},
recommended: {
plugins: ['jest'],
env: {
'jest/globals': true
},
rules: {
'jest/expect-expect': 'warn',
'jest/no-commented-out-tests': 'warn',
'jest/no-disabled-tests': 'warn',
'jest/no-export': 'error',
'jest/no-focused-tests': 'error',
'jest/no-identical-title': 'error',
'jest/no-jest-import': 'error',
'jest/no-mocks-import': 'error',
'jest/no-jasmine-globals': 'warn',
'jest/no-standalone-expect': 'error',
'jest/no-test-callback': 'error',
'jest/no-test-prefixes': 'error',
'jest/no-try-expect': 'error',
'jest/valid-describe': 'error',
'jest/valid-expect': 'error',
'jest/valid-expect-in-promise': 'error'
}
},
all: createConfig(allRules),
recommended: createConfig(recommendedRules),
style: {
plugins: ['jest'],
rules: {

View File

@ -34,7 +34,7 @@ var _default = (0, _utils.createRule)({
docs: {
category: 'Best Practices',
description: 'Enforce assertion to be made in a test body',
recommended: false
recommended: 'warn'
},
messages: {
noAssertions: 'Test has no assertions'

View File

@ -13,7 +13,7 @@ var _default = (0, _utils.createRule)({
docs: {
category: 'Best Practices',
description: 'Disallow alias methods',
recommended: 'warn'
recommended: false
},
messages: {
replaceAlias: `Replace {{ alias }}() with its canonical name of {{ canonical }}()`

View File

@ -17,7 +17,7 @@ var _default = (0, _utils.createRule)({
docs: {
category: 'Best Practices',
description: 'Disallow commented out tests',
recommended: false
recommended: 'warn'
},
messages: {
commentedTests: 'Some tests seem to be commented'

View File

@ -13,7 +13,7 @@ var _default = (0, _utils.createRule)({
docs: {
category: 'Best Practices',
description: 'Disallow disabled tests',
recommended: false
recommended: 'warn'
},
messages: {
missingFunction: 'Test is missing function argument',

View File

@ -15,7 +15,7 @@ var _default = (0, _utils.createRule)({
docs: {
category: 'Best Practices',
description: 'Prevent exporting from test files',
recommended: false
recommended: 'error'
},
messages: {
unexpectedExport: `Do not export from a test file.`

View File

@ -26,7 +26,7 @@ var _default = (0, _utils.createRule)({
docs: {
category: 'Best Practices',
description: 'Disallow focused tests',
recommended: false
recommended: 'error'
},
messages: {
focusedTest: 'Unexpected focused test.'

View File

@ -15,7 +15,7 @@ var _default = (0, _utils.createRule)({
docs: {
category: 'Best Practices',
description: 'Disallow Jasmine globals',
recommended: 'error'
recommended: 'warn'
},
messages: {
illegalGlobal: 'Illegal usage of global `{{ global }}`, prefer `{{ replacement }}`',

View File

@ -46,7 +46,7 @@ var _default = (0, _utils.createRule)({
docs: {
category: 'Best Practices',
description: 'Prevents expects that are outside of an it or test block.',
recommended: false
recommended: 'error'
},
messages: {
unexpectedExpect: 'Expect must be inside of a test block.'

View File

@ -15,7 +15,7 @@ var _default = (0, _utils.createRule)({
docs: {
category: 'Best Practices',
description: 'Avoid using a callback in asynchronous tests',
recommended: false,
recommended: 'error',
suggestion: true
},
messages: {

View File

@ -13,7 +13,7 @@ var _default = (0, _utils.createRule)({
docs: {
description: 'Prefer using toThrow for exception tests',
category: 'Best Practices',
recommended: false
recommended: 'error'
},
deprecated: true,
replacedBy: ['no-conditional-expect'],

View File

@ -25,7 +25,7 @@ var _default = (0, _utils.createRule)({
docs: {
category: 'Possible Errors',
description: 'Enforce valid `describe()` callback',
recommended: 'warn'
recommended: 'error'
},
messages: {
nameAndCallback: 'Describe requires name and callback arguments',

View File

@ -25,6 +25,23 @@ const doesBinaryExpressionContainStringNode = binaryExp => {
const quoteStringValue = node => node.type === _experimentalUtils.AST_NODE_TYPES.TemplateLiteral ? `\`${node.quasis[0].value.raw}\`` : node.raw;
const compileMatcherPatterns = matchers => {
if (typeof matchers === 'string') {
const matcher = new RegExp(matchers, 'u');
return {
describe: matcher,
test: matcher,
it: matcher
};
}
return {
describe: matchers.describe ? new RegExp(matchers.describe, 'u') : null,
test: matchers.test ? new RegExp(matchers.test, 'u') : null,
it: matchers.it ? new RegExp(matchers.it, 'u') : null
};
};
var _default = (0, _utils.createRule)({
name: __filename,
meta: {
@ -38,7 +55,9 @@ var _default = (0, _utils.createRule)({
emptyTitle: '{{ jestFunctionName }} should not have an empty title',
duplicatePrefix: 'should not have duplicate prefix',
accidentalSpace: 'should not have leading or trailing spaces',
disallowedWord: '"{{ word }}" is not allowed in test titles.'
disallowedWord: '"{{ word }}" is not allowed in test titles.',
mustNotMatch: '{{ jestFunctionName }} should not match {{ pattern }}',
mustMatch: '{{ jestFunctionName }} should match {{ pattern }}'
},
type: 'suggestion',
schema: [{
@ -53,6 +72,44 @@ var _default = (0, _utils.createRule)({
items: {
type: 'string'
}
},
mustNotMatch: {
oneOf: [{
type: 'string'
}, {
type: 'object',
properties: {
describe: {
type: 'string'
},
test: {
type: 'string'
},
it: {
type: 'string'
}
},
additionalProperties: false
}]
},
mustMatch: {
oneOf: [{
type: 'string'
}, {
type: 'object',
properties: {
describe: {
type: 'string'
},
test: {
type: 'string'
},
it: {
type: 'string'
}
},
additionalProperties: false
}]
}
},
additionalProperties: false
@ -66,9 +123,13 @@ var _default = (0, _utils.createRule)({
create(context, [{
ignoreTypeOfDescribeName,
disallowedWords = []
disallowedWords = [],
mustNotMatch,
mustMatch
}]) {
const disallowedWordsRegexp = new RegExp(`\\b(${disallowedWords.join('|')})\\b`, 'iu');
const mustNotMatchPatterns = compileMatcherPatterns(mustNotMatch !== null && mustNotMatch !== void 0 ? mustNotMatch : {});
const mustMatchPatterns = compileMatcherPatterns(mustMatch !== null && mustMatch !== void 0 ? mustMatch : {});
return {
CallExpression(node) {
if (!(0, _utils.isDescribe)(node) && !(0, _utils.isTestCase)(node)) {
@ -142,6 +203,39 @@ var _default = (0, _utils.createRule)({
fix: fixer => [fixer.replaceTextRange(argument.range, quoteStringValue(argument).replace(/^([`'"]).+? /u, '$1'))]
});
}
const [jestFunctionName] = nodeName.split('.');
const mustNotMatchPattern = mustNotMatchPatterns[jestFunctionName];
if (mustNotMatchPattern) {
if (mustNotMatchPattern.test(title)) {
context.report({
messageId: 'mustNotMatch',
node: argument,
data: {
jestFunctionName,
pattern: mustNotMatchPattern
}
});
return;
}
}
const mustMatchPattern = mustMatchPatterns[jestFunctionName];
if (mustMatchPattern) {
if (!mustMatchPattern.test(title)) {
context.report({
messageId: 'mustMatch',
node: argument,
data: {
jestFunctionName,
pattern: mustMatchPattern
}
});
return;
}
}
}
};

View File

@ -1,6 +1,6 @@
{
"name": "eslint-plugin-jest",
"version": "23.17.1",
"version": "23.18.0",
"description": "Eslint rules for Jest",
"keywords": [
"eslint",
@ -23,10 +23,8 @@
"build": "babel --extensions .js,.ts src --out-dir lib --copy-files",
"postbuild": "rimraf lib/__tests__ lib/**/__tests__",
"lint": "eslint . --ignore-pattern '!.eslintrc.js' --ext js,ts",
"prepare": "yarn build && yarn postbuild",
"prepublishOnly": "yarn build",
"prepack": "yarn build",
"prettylint": "prettylint docs/**/*.md README.md package.json",
"pretest": "yarn build",
"test": "jest",
"tools:generate-rules-table": "ts-node -T tools/generate-rules-table",
"typecheck": "tsc -p ."
@ -120,7 +118,7 @@
"eslint-plugin-prettier": "^3.0.0",
"husky": "^3.0.9",
"jest": "^25.2.0",
"jest-runner-eslint": "^0.9.0",
"jest-runner-eslint": "^0.10.0",
"lint-staged": "^9.4.2",
"prettier": "^1.19.1",
"prettylint": "^1.0.0",

20
node_modules/eslint/CHANGELOG.md generated vendored
View File

@ -1,3 +1,23 @@
v7.4.0 - July 3, 2020
* [`f21bad2`](https://github.com/eslint/eslint/commit/f21bad2680406a2671b877f8dba47f4475d0cc64) Docs: fix description for `never` in multiline-ternary (fixes #13368) (#13452) (Milos Djermanovic)
* [`ada2c89`](https://github.com/eslint/eslint/commit/ada2c891298382f82dfabf37cacd59a1057b2bb7) Fix: support typescript generics in arrow-parens (fixes #12570) (#13451) (Milos Djermanovic)
* [`89ee01e`](https://github.com/eslint/eslint/commit/89ee01e083f1e02293bf8d1447f9b0fdb3cb9384) Fix: Revert config cloning (fixes #13447) (#13449) (薛定谔的猫)
* [`0a463db`](https://github.com/eslint/eslint/commit/0a463dbf7cc5a77d442879c9117204d4d38db972) Docs: fix no-multiple-empty-lines examples (fixes #13432) (#13433) (Milos Djermanovic)
* [`ff5317e`](https://github.com/eslint/eslint/commit/ff5317e93425f93cfdf808609551ee67b2032543) Update: Improve array-callback-return report message (#13395) (Philip (flip) Kromer)
* [`3f51930`](https://github.com/eslint/eslint/commit/3f51930eea7cddc921a9ee3cb0328c7b649c0f83) Fix: false positive new with member in no-extra-parens (fixes #12740) (#13375) (YeonJuan)
* [`825a5b9`](https://github.com/eslint/eslint/commit/825a5b98d3d84f6eb72b75f7d8519de763cc8898) Fix: Clarify documentation on implicit ignore behavior (fixes #12348) (#12600) (Scott Hardin)
* [`c139156`](https://github.com/eslint/eslint/commit/c1391566a5f765f25716527de7b5cdee16c0ce36) Sponsors: Sync README with website (ESLint Jenkins)
* [`0c17e9d`](https://github.com/eslint/eslint/commit/0c17e9d2ac307cc288eea6ed7971bd5a7d33321a) Sponsors: Sync README with website (ESLint Jenkins)
* [`c680387`](https://github.com/eslint/eslint/commit/c680387ba61f6dccf0390d24a85d871fa83e9fea) Sponsors: Sync README with website (ESLint Jenkins)
* [`bf3939b`](https://github.com/eslint/eslint/commit/bf3939bbd9a33d0eb96cebe6a53bf61c855f9ba6) Sponsors: Sync README with website (ESLint Jenkins)
* [`7baf02e`](https://github.com/eslint/eslint/commit/7baf02e983af909800261263f125cca901a5bd0f) Sponsors: Sync README with website (ESLint Jenkins)
* [`5c4c3fd`](https://github.com/eslint/eslint/commit/5c4c3fdfbda18a13223ad36f44283adbfee8c496) Sponsors: Sync README with website (ESLint Jenkins)
* [`53912aa`](https://github.com/eslint/eslint/commit/53912aab1856327b399cca26cbb2ba81fd01bfa2) Sponsors: Sync README with website (ESLint Jenkins)
* [`51e42ec`](https://github.com/eslint/eslint/commit/51e42eca3e87d8259815d736ffe81e604f184057) Update: Add option "ignoreGlobals" to camelcase rule (fixes #11716) (#12782) (David Gasperoni)
* [`0655f66`](https://github.com/eslint/eslint/commit/0655f66525d167ca1288167b79a77087cfc8fcf6) Update: improve report location in arrow-body-style (refs #12334) (#13424) (YeonJuan)
* [`d53d69a`](https://github.com/eslint/eslint/commit/d53d69af08cfe55f42e0a0ca725b1014dabccc21) Update: prefer-regex-literal detect regex literals (fixes #12840) (#12842) (Mathias Schreck)
* [`004adae`](https://github.com/eslint/eslint/commit/004adae3f959414f56e44e5884f6221e9dcda142) Update: rename id-blacklist to id-denylist (fixes #13407) (#13408) (Kai Cataldo)
v7.3.1 - June 22, 2020
* [`de77c11`](https://github.com/eslint/eslint/commit/de77c11e7515f2097ff355ddc0d7b6db9c83c892) Fix: Replace Infinity with Number.MAX_SAFE_INTEGER (fixes #13427) (#13435) (Nicholas C. Zakas)

2
node_modules/eslint/README.md generated vendored
View File

@ -256,7 +256,7 @@ The following companies, organizations, and individuals support ESLint's ongoing
<h3>Gold Sponsors</h3>
<p><a href="https://www.shopify.com"><img src="https://images.opencollective.com/shopify/e780cd4/logo.png" alt="Shopify" height="96"></a> <a href="https://www.salesforce.com"><img src="https://images.opencollective.com/salesforce/ca8f997/logo.png" alt="Salesforce" height="96"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="96"></a></p><h3>Silver Sponsors</h3>
<p><a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a> <a href="https://www.ampproject.org/"><img src="https://images.opencollective.com/amp/c8a3b25/logo.png" alt="AMP Project" height="64"></a></p><h3>Bronze Sponsors</h3>
<p><a href="https://www.norgekasino.com"><img src="https://images.opencollective.com/norgekasino/ecfd57a/logo.png" alt="Norgekasino" height="32"></a> <a href="https://www.japanesecasino.com/"><img src="https://images.opencollective.com/japanesecasino/b0ffe3c/logo.png" alt="Japanesecasino" height="32"></a> <a href="https://bruce.agency"><img src="https://images.opencollective.com/brucemade/0c70c59/logo.png" alt="Bruce" height="32"></a> <a href="https://edubirdie.com/"><img src="https://images.opencollective.com/edubirdie2/b1d51ab/logo.png" alt="EduBirdie" height="32"></a> <a href="https://www.casinotop.com/"><img src="https://images.opencollective.com/casinotop-com/10fd95b/logo.png" alt="CasinoTop.com" height="32"></a> <a href="https://www.casinotopp.net/"><img src="https://images.opencollective.com/casino-topp/1dd399a/logo.png" alt="Casino Topp" height="32"></a> <a href="https://writersperhour.com/write-my-essay"><img src="https://images.opencollective.com/writersperhour/5787d4b/logo.png" alt="Writers Per Hour" 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://cooltechzone.com/netflix-vpn"><img src="https://images.opencollective.com/vpn-netflix/4850160/logo.png" alt="vpn netflix" height="32"></a> <a href="https://www.kasinot.fi"><img src="https://images.opencollective.com/kasinot-fi/e09aa2e/logo.png" alt="Kasinot.fi" height="32"></a> <a href="https://www.pelisivut.com"><img src="https://images.opencollective.com/pelisivut/04f08f2/logo.png" alt="Pelisivut" height="32"></a> <a href="https://www.nettikasinot.org"><img src="https://images.opencollective.com/nettikasinot-org/53a4b44/logo.png" alt="Nettikasinot.org" height="32"></a> <a href="https://www.bonus.com.de/freispiele"><img src="https://images.opencollective.com/bonusfinder-deutschland/646169e/logo.png" alt="BonusFinder Deutschland" height="32"></a> <a href="https://www.bugsnag.com/platforms?utm_source=Open Collective&utm_medium=Website&utm_content=open-source&utm_campaign=2019-community&utm_term="><img src="https://images.opencollective.com/bugsnag-stability-monitoring/c2cef36/logo.png" alt="Bugsnag Stability Monitoring" height="32"></a> <a href="https://mixpanel.com"><img src="https://images.opencollective.com/mixpanel/cd682f7/logo.png" alt="Mixpanel" height="32"></a> <a href="https://www.vpsserver.com"><img src="https://images.opencollective.com/vpsservercom/logo.png" alt="VPS Server" height="32"></a> <a href="https://icons8.com"><img src="https://images.opencollective.com/icons8/0b37d14/logo.png" alt="Free Icons by Icons8" height="32"></a> <a href="https://discordapp.com"><img src="https://images.opencollective.com/discordapp/7e3d9a9/logo.png" alt="Discord" height="32"></a> <a href="https://themeisle.com"><img src="https://images.opencollective.com/themeisle/d5592fe/logo.png" alt="ThemeIsle" height="32"></a> <a href="https://tekhattan.com"><img src="https://images.opencollective.com/tekhattan/bc73c28/logo.png" alt="TekHattan" height="32"></a> <a href="https://www.marfeel.com/"><img src="https://images.opencollective.com/marfeel/4b88e30/logo.png" alt="Marfeel" height="32"></a> <a href="http://www.firesticktricks.com"><img src="https://images.opencollective.com/fire-stick-tricks/b8fbe2c/logo.png" alt="Fire Stick Tricks" height="32"></a></p>
<p><a href="https://mytruemedia.com/"><img src="https://images.opencollective.com/my-true-media/03e2168/logo.png" alt="My True Media" height="32"></a> <a href="https://www.norgekasino.com"><img src="https://images.opencollective.com/norgekasino/ecfd57a/logo.png" alt="Norgekasino" height="32"></a> <a href="https://www.japanesecasino.com/"><img src="https://images.opencollective.com/japanesecasino/b0ffe3c/logo.png" alt="Japanesecasino" height="32"></a> <a href="https://bruce.agency"><img src="https://images.opencollective.com/brucemade/0c70c59/logo.png" alt="Bruce" height="32"></a> <a href="https://edubirdie.com/"><img src="https://images.opencollective.com/edubirdie2/b1d51ab/logo.png" alt="EduBirdie" height="32"></a> <a href="https://www.casinotop.com/"><img src="https://images.opencollective.com/casinotop-com/10fd95b/logo.png" alt="CasinoTop.com" height="32"></a> <a href="https://www.casinotopp.net/"><img src="https://images.opencollective.com/casino-topp/1dd399a/logo.png" alt="Casino Topp" height="32"></a> <a href="https://writersperhour.com/write-my-essay"><img src="https://images.opencollective.com/writersperhour/5787d4b/logo.png" alt="Writers Per Hour" 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://www.kasinot.fi"><img src="https://images.opencollective.com/kasinot-fi/e09aa2e/logo.png" alt="Kasinot.fi" height="32"></a> <a href="https://www.pelisivut.com"><img src="https://images.opencollective.com/pelisivut/04f08f2/logo.png" alt="Pelisivut" height="32"></a> <a href="https://www.nettikasinot.org"><img src="https://images.opencollective.com/nettikasinot-org/53a4b44/logo.png" alt="Nettikasinot.org" height="32"></a> <a href="https://www.bonus.com.de/freispiele"><img src="https://images.opencollective.com/bonusfinder-deutschland/646169e/logo.png" alt="BonusFinder Deutschland" height="32"></a> <a href="https://www.bugsnag.com/platforms?utm_source=Open Collective&utm_medium=Website&utm_content=open-source&utm_campaign=2019-community&utm_term="><img src="https://images.opencollective.com/bugsnag-stability-monitoring/c2cef36/logo.png" alt="Bugsnag Stability Monitoring" height="32"></a> <a href="https://mixpanel.com"><img src="https://images.opencollective.com/mixpanel/cd682f7/logo.png" alt="Mixpanel" height="32"></a> <a href="https://www.vpsserver.com"><img src="https://images.opencollective.com/vpsservercom/logo.png" alt="VPS Server" height="32"></a> <a href="https://icons8.com"><img src="https://images.opencollective.com/icons8/6e889f6/logo.png" alt="Icons8: free icons, photos, illustrations, and music" height="32"></a> <a href="https://discordapp.com"><img src="https://images.opencollective.com/discordapp/7e3d9a9/logo.png" alt="Discord" height="32"></a> <a href="https://themeisle.com"><img src="https://images.opencollective.com/themeisle/d5592fe/logo.png" alt="ThemeIsle" height="32"></a> <a href="https://tekhattan.com"><img src="https://images.opencollective.com/tekhattan/bc73c28/logo.png" alt="TekHattan" height="32"></a> <a href="https://www.marfeel.com/"><img src="https://images.opencollective.com/marfeel/4b88e30/logo.png" alt="Marfeel" height="32"></a> <a href="http://www.firesticktricks.com"><img src="https://images.opencollective.com/fire-stick-tricks/b8fbe2c/logo.png" alt="Fire Stick Tricks" height="32"></a></p>
<!--sponsorsend-->
## <a name="technology-sponsors"></a>Technology Sponsors

View File

@ -697,38 +697,6 @@ class ConfigArrayFactory {
ctx.matchBasePath
);
/**
* Cloning the rule's config as we are setting `useDefaults` to true`
* which mutates the config with its default value if present. And when we
* refer to a same variable for config for different rules, that referred variable will
* be mutated and it will be used for both.
*
* Example:
*
* const commonRuleConfig = ['error', {}];
*
* Now if we use this variable as a config for rules like this
*
* {
* rules: {
* "a" : commonRuleConfig,
* "b" : commonRuleConfig,
* }
* }
*
* And if these rules have default values in their schema, their
* config will be mutated with default values, the mutated `commonRuleConfig` will be used for `b` as well and it probably
* throw schema voilation errors.
*
* Refer https://github.com/eslint/eslint/issues/12592
*/
const clonedRulesConfig = rules && JSON.parse(
JSON.stringify(
rules,
(key, value) => (value === Infinity ? Number.MAX_SAFE_INTEGER : value)
)
);
// Flatten `extends`.
for (const extendName of extendList.filter(Boolean)) {
yield* this._loadExtends(extendName, ctx);
@ -763,7 +731,7 @@ class ConfigArrayFactory {
processor,
reportUnusedDisableDirectives,
root,
rules: clonedRulesConfig,
rules,
settings
};

View File

@ -9,8 +9,6 @@
// Requirements
//------------------------------------------------------------------------------
const lodash = require("lodash");
const astUtils = require("./utils/ast-utils");
//------------------------------------------------------------------------------
@ -43,6 +41,19 @@ function isTargetMethod(node) {
);
}
/**
* Returns a human-legible description of an array method
* @param {string} arrayMethodName A method name to fully qualify
* @returns {string} the method name prefixed with `Array.` if it is a class method,
* or else `Array.prototype.` if it is an instance method.
*/
function fullMethodName(arrayMethodName) {
if (["from", "of", "isArray"].includes(arrayMethodName)) {
return "Array.".concat(arrayMethodName);
}
return "Array.prototype.".concat(arrayMethodName);
}
/**
* Checks whether or not a given node is a function expression which is the
* callback of an array method, returning the method name.
@ -153,10 +164,10 @@ module.exports = {
],
messages: {
expectedAtEnd: "Expected to return a value at the end of {{name}}.",
expectedInside: "Expected to return a value in {{name}}.",
expectedReturnValue: "{{name}} expected a return value.",
expectedNoReturnValue: "{{name}} did not expect a return value."
expectedAtEnd: "{{arrayMethodName}}() expects a value to be returned at the end of {{name}}.",
expectedInside: "{{arrayMethodName}}() expects a return value from {{name}}.",
expectedReturnValue: "{{arrayMethodName}}() expects a return value from {{name}}.",
expectedNoReturnValue: "{{arrayMethodName}}() expects no useless return value from {{name}}."
}
},
@ -202,14 +213,13 @@ module.exports = {
}
if (messageId) {
let name = astUtils.getFunctionNameWithKind(node);
const name = astUtils.getFunctionNameWithKind(node);
name = messageId === "expectedNoReturnValue" ? lodash.upperFirst(name) : name;
context.report({
node,
loc: astUtils.getFunctionHeadLoc(node, sourceCode),
messageId,
data: { name }
data: { name, arrayMethodName: fullMethodName(funcInfo.arrayMethodName) }
});
}
}
@ -273,7 +283,8 @@ module.exports = {
node,
messageId,
data: {
name: lodash.upperFirst(astUtils.getFunctionNameWithKind(funcInfo.node))
name: astUtils.getFunctionNameWithKind(funcInfo.node),
arrayMethodName: fullMethodName(funcInfo.arrayMethodName)
}
});
}

View File

@ -136,7 +136,7 @@ module.exports = {
context.report({
node,
loc: arrowBody.loc.start,
loc: arrowBody.loc,
messageId,
fix(fixer) {
const fixes = [];
@ -201,7 +201,7 @@ module.exports = {
if (always || (asNeeded && requireReturnForObjectLiteral && arrowBody.type === "ObjectExpression")) {
context.report({
node,
loc: arrowBody.loc.start,
loc: arrowBody.loc,
messageId: "expectedBlock",
fix(fixer) {
const fixes = [];

View File

@ -15,15 +15,12 @@ const astUtils = require("./utils/ast-utils");
//------------------------------------------------------------------------------
/**
* Get location should be reported by AST node.
* @param {ASTNode} node AST Node.
* @returns {Location} Location information.
* Determines if the given arrow function has block body.
* @param {ASTNode} node `ArrowFunctionExpression` node.
* @returns {boolean} `true` if the function has block body.
*/
function getLocation(node) {
return {
start: node.params[0].loc.start,
end: node.params[node.params.length - 1].loc.end
};
function hasBlockBody(node) {
return node.body.type === "BlockStatement";
}
//------------------------------------------------------------------------------
@ -75,126 +72,112 @@ module.exports = {
const sourceCode = context.getSourceCode();
/**
* Determines whether a arrow function argument end with `)`
* @param {ASTNode} node The arrow function node.
* @returns {void}
* Finds opening paren of parameters for the given arrow function, if it exists.
* It is assumed that the given arrow function has exactly one parameter.
* @param {ASTNode} node `ArrowFunctionExpression` node.
* @returns {Token|null} the opening paren, or `null` if the given arrow function doesn't have parens of parameters.
*/
function parens(node) {
const isAsync = node.async;
const firstTokenOfParam = sourceCode.getFirstToken(node, isAsync ? 1 : 0);
/**
* Remove the parenthesis around a parameter
* @param {Fixer} fixer Fixer
* @returns {string} fixed parameter
*/
function fixParamsWithParenthesis(fixer) {
const paramToken = sourceCode.getTokenAfter(firstTokenOfParam);
/*
* ES8 allows Trailing commas in function parameter lists and calls
* https://github.com/eslint/eslint/issues/8834
*/
const closingParenToken = sourceCode.getTokenAfter(paramToken, astUtils.isClosingParenToken);
const asyncToken = isAsync ? sourceCode.getTokenBefore(firstTokenOfParam) : null;
const shouldAddSpaceForAsync = asyncToken && (asyncToken.range[1] === firstTokenOfParam.range[0]);
return fixer.replaceTextRange([
firstTokenOfParam.range[0],
closingParenToken.range[1]
], `${shouldAddSpaceForAsync ? " " : ""}${paramToken.value}`);
}
/**
* Checks whether there are comments inside the params or not.
* @returns {boolean} `true` if there are comments inside of parens, else `false`
*/
function hasCommentsInParens() {
if (astUtils.isOpeningParenToken(firstTokenOfParam)) {
const closingParenToken = sourceCode.getTokenAfter(node.params[0], astUtils.isClosingParenToken);
return closingParenToken && sourceCode.commentsExistBetween(firstTokenOfParam, closingParenToken);
}
return false;
}
if (hasCommentsInParens()) {
return;
}
// "as-needed", { "requireForBlockBody": true }: x => x
if (
requireForBlockBody &&
node.params[0].type === "Identifier" &&
!node.params[0].typeAnnotation &&
node.body.type !== "BlockStatement" &&
!node.returnType
) {
if (astUtils.isOpeningParenToken(firstTokenOfParam)) {
context.report({
node,
messageId: "unexpectedParensInline",
loc: getLocation(node),
fix: fixParamsWithParenthesis
});
}
return;
}
function findOpeningParenOfParams(node) {
const tokenBeforeParams = sourceCode.getTokenBefore(node.params[0]);
if (
requireForBlockBody &&
node.body.type === "BlockStatement"
tokenBeforeParams &&
astUtils.isOpeningParenToken(tokenBeforeParams) &&
node.range[0] <= tokenBeforeParams.range[0]
) {
if (!astUtils.isOpeningParenToken(firstTokenOfParam)) {
context.report({
node,
messageId: "expectedParensBlock",
loc: getLocation(node),
fix(fixer) {
return fixer.replaceText(firstTokenOfParam, `(${firstTokenOfParam.value})`);
}
});
}
return;
return tokenBeforeParams;
}
// "as-needed": x => x
if (asNeeded &&
node.params[0].type === "Identifier" &&
!node.params[0].typeAnnotation &&
!node.returnType
) {
if (astUtils.isOpeningParenToken(firstTokenOfParam)) {
context.report({
node,
messageId: "unexpectedParens",
loc: getLocation(node),
fix: fixParamsWithParenthesis
});
}
return;
}
return null;
}
if (firstTokenOfParam.type === "Identifier") {
const after = sourceCode.getTokenAfter(firstTokenOfParam);
/**
* Finds closing paren of parameters for the given arrow function.
* It is assumed that the given arrow function has parens of parameters and that it has exactly one parameter.
* @param {ASTNode} node `ArrowFunctionExpression` node.
* @returns {Token} the closing paren of parameters.
*/
function getClosingParenOfParams(node) {
return sourceCode.getTokenAfter(node.params[0], astUtils.isClosingParenToken);
}
// (x) => x
if (after.value !== ")") {
context.report({
node,
messageId: "expectedParens",
loc: getLocation(node),
fix(fixer) {
return fixer.replaceText(firstTokenOfParam, `(${firstTokenOfParam.value})`);
}
});
}
}
/**
* Determines whether the given arrow function has comments inside parens of parameters.
* It is assumed that the given arrow function has parens of parameters.
* @param {ASTNode} node `ArrowFunctionExpression` node.
* @param {Token} openingParen Opening paren of parameters.
* @returns {boolean} `true` if the function has at least one comment inside of parens of parameters.
*/
function hasCommentsInParensOfParams(node, openingParen) {
return sourceCode.commentsExistBetween(openingParen, getClosingParenOfParams(node));
}
/**
* Determines whether the given arrow function has unexpected tokens before opening paren of parameters,
* in which case it will be assumed that the existing parens of parameters are necessary.
* Only tokens within the range of the arrow function (tokens that are part of the arrow function) are taken into account.
* Example: <T>(a) => b
* @param {ASTNode} node `ArrowFunctionExpression` node.
* @param {Token} openingParen Opening paren of parameters.
* @returns {boolean} `true` if the function has at least one unexpected token.
*/
function hasUnexpectedTokensBeforeOpeningParen(node, openingParen) {
const expectedCount = node.async ? 1 : 0;
return sourceCode.getFirstToken(node, { skip: expectedCount }) !== openingParen;
}
return {
"ArrowFunctionExpression[params.length=1]": parens
"ArrowFunctionExpression[params.length=1]"(node) {
const shouldHaveParens = !asNeeded || requireForBlockBody && hasBlockBody(node);
const openingParen = findOpeningParenOfParams(node);
const hasParens = openingParen !== null;
const [param] = node.params;
if (shouldHaveParens && !hasParens) {
context.report({
node,
messageId: requireForBlockBody ? "expectedParensBlock" : "expectedParens",
loc: param.loc,
*fix(fixer) {
yield fixer.insertTextBefore(param, "(");
yield fixer.insertTextAfter(param, ")");
}
});
}
if (
!shouldHaveParens &&
hasParens &&
param.type === "Identifier" &&
!param.typeAnnotation &&
!node.returnType &&
!hasCommentsInParensOfParams(node, openingParen) &&
!hasUnexpectedTokensBeforeOpeningParen(node, openingParen)
) {
context.report({
node,
messageId: requireForBlockBody ? "unexpectedParensInline" : "unexpectedParens",
loc: param.loc,
*fix(fixer) {
const tokenBeforeOpeningParen = sourceCode.getTokenBefore(openingParen);
const closingParen = getClosingParenOfParams(node);
if (
tokenBeforeOpeningParen &&
tokenBeforeOpeningParen.range[1] === openingParen.range[0] &&
!astUtils.canTokensBeAdjacent(tokenBeforeOpeningParen, sourceCode.getFirstToken(param))
) {
yield fixer.insertTextBefore(openingParen, " ");
}
// remove parens, whitespace inside parens, and possible trailing comma
yield fixer.removeRange([openingParen.range[0], param.range[0]]);
yield fixer.removeRange([param.range[1], closingParen.range[1]]);
}
});
}
}
};
}
};

View File

@ -32,6 +32,10 @@ module.exports = {
type: "boolean",
default: false
},
ignoreGlobals: {
type: "boolean",
default: false
},
properties: {
enum: ["always", "never"]
},
@ -61,8 +65,11 @@ module.exports = {
let properties = options.properties || "";
const ignoreDestructuring = options.ignoreDestructuring;
const ignoreImports = options.ignoreImports;
const ignoreGlobals = options.ignoreGlobals;
const allow = options.allow || [];
let globalScope;
if (properties !== "always" && properties !== "never") {
properties = "always";
}
@ -159,6 +166,37 @@ module.exports = {
return false;
}
/**
* Checks whether the given node represents a reference to a global variable that is not declared in the source code.
* These identifiers will be allowed, as it is assumed that user has no control over the names of external global variables.
* @param {ASTNode} node `Identifier` node to check.
* @returns {boolean} `true` if the node is a reference to a global variable.
*/
function isReferenceToGlobalVariable(node) {
const variable = globalScope.set.get(node.name);
return variable && variable.defs.length === 0 &&
variable.references.some(ref => ref.identifier === node);
}
/**
* Checks whether the given node represents a reference to a property of an object in an object literal expression.
* This allows to differentiate between a global variable that is allowed to be used as a reference, and the key
* of the expressed object (which shouldn't be allowed).
* @param {ASTNode} node `Identifier` node to check.
* @returns {boolean} `true` if the node is a property name of an object literal expression
*/
function isPropertyNameInObjectLiteral(node) {
const parent = node.parent;
return (
parent.type === "Property" &&
parent.parent.type === "ObjectExpression" &&
!parent.computed &&
parent.key === node
);
}
/**
* Reports an AST node as a rule violation.
* @param {ASTNode} node The node to report.
@ -174,6 +212,10 @@ module.exports = {
return {
Program() {
globalScope = context.getScope();
},
Identifier(node) {
/*
@ -189,6 +231,11 @@ module.exports = {
return;
}
// Check if it's a global variable
if (ignoreGlobals && isReferenceToGlobalVariable(node) && !isPropertyNameInObjectLiteral(node)) {
return;
}
// MemberExpressions get special rules
if (node.parent.type === "MemberExpression") {

View File

@ -1,6 +1,6 @@
/**
* @fileoverview Rule that warns when identifier names that are
* blacklisted in the configuration are used.
* specified in the configuration are used.
* @author Keith Cirkel (http://keithcirkel.co.uk)
*/
@ -117,7 +117,7 @@ module.exports = {
description: "disallow specified identifiers",
category: "Stylistic Issues",
recommended: false,
url: "https://eslint.org/docs/rules/id-blacklist"
url: "https://eslint.org/docs/rules/id-denylist"
},
schema: {
@ -128,25 +128,25 @@ module.exports = {
uniqueItems: true
},
messages: {
blacklisted: "Identifier '{{name}}' is blacklisted."
restricted: "Identifier '{{name}}' is restricted."
}
},
create(context) {
const blacklist = new Set(context.options);
const denyList = new Set(context.options);
const reportedNodes = new Set();
let globalScope;
/**
* Checks whether the given name is blacklisted.
* Checks whether the given name is restricted.
* @param {string} name The name to check.
* @returns {boolean} `true` if the name is blacklisted.
* @returns {boolean} `true` if the name is restricted.
* @private
*/
function isBlacklisted(name) {
return blacklist.has(name);
function isRestricted(name) {
return denyList.has(name);
}
/**
@ -172,8 +172,8 @@ module.exports = {
/*
* Member access has special rules for checking property names.
* Read access to a property with a blacklisted name is allowed, because it can be on an object that user has no control over.
* Write access isn't allowed, because it potentially creates a new property with a blacklisted name.
* Read access to a property with a restricted name is allowed, because it can be on an object that user has no control over.
* Write access isn't allowed, because it potentially creates a new property with a restricted name.
*/
if (
parent.type === "MemberExpression" &&
@ -205,7 +205,7 @@ module.exports = {
if (!reportedNodes.has(node)) {
context.report({
node,
messageId: "blacklisted",
messageId: "restricted",
data: {
name: node.name
}
@ -221,7 +221,7 @@ module.exports = {
},
Identifier(node) {
if (isBlacklisted(node.name) && shouldCheck(node)) {
if (isRestricted(node.name) && shouldCheck(node)) {
report(node);
}
}

View File

@ -56,7 +56,10 @@ module.exports = new LazyLoadingRuleMap(Object.entries({
"grouped-accessor-pairs": () => require("./grouped-accessor-pairs"),
"guard-for-in": () => require("./guard-for-in"),
"handle-callback-err": () => require("./handle-callback-err"),
"id-blacklist": () => require("./id-blacklist"),
// Renamed to id-denylist.
"id-blacklist": () => require("./id-denylist"),
"id-denylist": () => require("./id-denylist"),
"id-length": () => require("./id-length"),
"id-match": () => require("./id-match"),
"implicit-arrow-linebreak": () => require("./implicit-arrow-linebreak"),

View File

@ -710,6 +710,20 @@ module.exports = {
reportsBuffer.reports = reportsBuffer.reports.filter(r => r.node !== node);
}
/**
* Checks whether a node is a MemberExpression at NewExpression's callee.
* @param {ASTNode} node node to check.
* @returns {boolean} True if the node is a MemberExpression at NewExpression's callee. false otherwise.
*/
function isMemberExpInNewCallee(node) {
if (node.type === "MemberExpression") {
return node.parent.type === "NewExpression" && node.parent.callee === node
? true
: node.parent.object === node && isMemberExpInNewCallee(node.parent);
}
return false;
}
return {
ArrayExpression(node) {
node.elements
@ -950,7 +964,11 @@ module.exports = {
LogicalExpression: checkBinaryLogical,
MemberExpression(node) {
const nodeObjHasExcessParens = hasExcessParens(node.object) &&
const shouldAllowWrapOnce = isMemberExpInNewCallee(node) &&
doesMemberExpressionContainCallExpression(node);
const nodeObjHasExcessParens = shouldAllowWrapOnce
? hasDoubleExcessParens(node.object)
: hasExcessParens(node.object) &&
!(
isImmediateFunctionPrototypeMethodCall(node.parent) &&
node.parent.callee === node &&
@ -974,8 +992,8 @@ module.exports = {
}
if (nodeObjHasExcessParens &&
node.object.type === "CallExpression" &&
node.parent.type !== "NewExpression") {
node.object.type === "CallExpression"
) {
report(node.object);
}

View File

@ -25,6 +25,15 @@ function isStringLiteral(node) {
return node.type === "Literal" && typeof node.value === "string";
}
/**
* Determines whether the given node is a regex literal.
* @param {ASTNode} node Node to check.
* @returns {boolean} True if the node is a regex literal.
*/
function isRegexLiteral(node) {
return node.type === "Literal" && Object.prototype.hasOwnProperty.call(node, "regex");
}
/**
* Determines whether the given node is a template literal without expressions.
* @param {ASTNode} node Node to check.
@ -50,14 +59,28 @@ module.exports = {
url: "https://eslint.org/docs/rules/prefer-regex-literals"
},
schema: [],
schema: [
{
type: "object",
properties: {
disallowRedundantWrapping: {
type: "boolean",
default: false
}
},
additionalProperties: false
}
],
messages: {
unexpectedRegExp: "Use a regular expression literal instead of the 'RegExp' constructor."
unexpectedRegExp: "Use a regular expression literal instead of the 'RegExp' constructor.",
unexpectedRedundantRegExp: "Regular expression literal is unnecessarily wrapped within a 'RegExp' constructor.",
unexpectedRedundantRegExpWithFlags: "Use regular expression literal with flags instead of the 'RegExp' constructor."
}
},
create(context) {
const [{ disallowRedundantWrapping = false } = {}] = context.options;
/**
* Determines whether the given identifier node is a reference to a global variable.
@ -98,6 +121,40 @@ module.exports = {
isStringRawTaggedStaticTemplateLiteral(node);
}
/**
* Determines whether the relevant arguments of the given are all static string literals.
* @param {ASTNode} node Node to check.
* @returns {boolean} True if all arguments are static strings.
*/
function hasOnlyStaticStringArguments(node) {
const args = node.arguments;
if ((args.length === 1 || args.length === 2) && args.every(isStaticString)) {
return true;
}
return false;
}
/**
* Determines whether the arguments of the given node indicate that a regex literal is unnecessarily wrapped.
* @param {ASTNode} node Node to check.
* @returns {boolean} True if the node already contains a regex literal argument.
*/
function isUnnecessarilyWrappedRegexLiteral(node) {
const args = node.arguments;
if (args.length === 1 && isRegexLiteral(args[0])) {
return true;
}
if (args.length === 2 && isRegexLiteral(args[0]) && isStaticString(args[1])) {
return true;
}
return false;
}
return {
Program() {
const scope = context.getScope();
@ -110,12 +167,13 @@ module.exports = {
};
for (const { node } of tracker.iterateGlobalReferences(traceMap)) {
const args = node.arguments;
if (
(args.length === 1 || args.length === 2) &&
args.every(isStaticString)
) {
if (disallowRedundantWrapping && isUnnecessarilyWrappedRegexLiteral(node)) {
if (node.arguments.length === 2) {
context.report({ node, messageId: "unexpectedRedundantRegExpWithFlags" });
} else {
context.report({ node, messageId: "unexpectedRedundantRegExp" });
}
} else if (hasOnlyStaticStringArguments(node)) {
context.report({ node, messageId: "unexpectedRegExp" });
}
}

2
node_modules/eslint/package.json generated vendored
View File

@ -1,6 +1,6 @@
{
"name": "eslint",
"version": "7.3.1",
"version": "7.4.0",
"author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
"description": "An AST-based pattern checker for JavaScript.",
"bin": {