From 3adcfe70adc6728822c012372509fb6ee8b53c4b Mon Sep 17 00:00:00 2001 From: Jarom Loveridge Date: Thu, 27 Sep 2018 21:42:14 -0600 Subject: [PATCH 1/6] chore(flow-types): Update flow-typed definitions. Newly provided definitions: * get-port * getos New definition via `flow-typed install`: * rimraf --- flow-typed/npm/babel-eslint_vx.x.x.js | 97 +- flow-typed/npm/babel-jest_vx.x.x.js | 4 +- .../npm/cz-conventional-changelog_vx.x.x.js | 4 +- flow-typed/npm/decompress_v4.2.x.js | 41 + .../npm/eslint-config-airbnb-base_vx.x.x.js | 18 +- .../npm/eslint-config-prettier_vx.x.x.js | 18 +- .../npm/eslint-plugin-flowtype_vx.x.x.js | 102 +- flow-typed/npm/eslint-plugin-import_vx.x.x.js | 67 +- .../npm/eslint-plugin-prettier_vx.x.x.js | 4 +- flow-typed/npm/eslint_vx.x.x.js | 353 +++-- flow-typed/npm/get-port_v3.2.x.js | 15 + flow-typed/npm/get-port_vx.x.x.js | 33 - flow-typed/npm/getos_v3.1.x.js | 29 + flow-typed/npm/jest_v20.x.x.js | 483 ------- flow-typed/npm/jest_v23.x.x.js | 1146 +++++++++++++++++ flow-typed/npm/mkdirp_v0.5.x.js | 13 + flow-typed/npm/npm-run-all_vx.x.x.js | 4 +- flow-typed/npm/prettier_v1.x.x.js | 178 +++ flow-typed/npm/prettier_vx.x.x.js | 66 - flow-typed/npm/rimraf_v2.x.x.js | 18 + flow-typed/npm/rimraf_vx.x.x.js | 39 - flow-typed/npm/semantic-release_vx.x.x.js | 135 +- flow-typed/npm/tmp_vx.x.x.js | 4 +- flow-typed/npm/uuid_v3.x.x.js | 115 +- 24 files changed, 2205 insertions(+), 781 deletions(-) create mode 100644 flow-typed/npm/decompress_v4.2.x.js create mode 100644 flow-typed/npm/get-port_v3.2.x.js delete mode 100644 flow-typed/npm/get-port_vx.x.x.js create mode 100644 flow-typed/npm/getos_v3.1.x.js delete mode 100644 flow-typed/npm/jest_v20.x.x.js create mode 100644 flow-typed/npm/jest_v23.x.x.js create mode 100644 flow-typed/npm/mkdirp_v0.5.x.js create mode 100644 flow-typed/npm/prettier_v1.x.x.js delete mode 100644 flow-typed/npm/prettier_vx.x.x.js create mode 100644 flow-typed/npm/rimraf_v2.x.x.js delete mode 100644 flow-typed/npm/rimraf_vx.x.x.js diff --git a/flow-typed/npm/babel-eslint_vx.x.x.js b/flow-typed/npm/babel-eslint_vx.x.x.js index 26f345f6c..1c2ec1dfa 100644 --- a/flow-typed/npm/babel-eslint_vx.x.x.js +++ b/flow-typed/npm/babel-eslint_vx.x.x.js @@ -1,5 +1,5 @@ -// flow-typed signature: aec7ecc0f2e19d71dc843408c2c4461d -// flow-typed version: <>/babel-eslint_v^7.1.1/flow_v0.47.0 +// flow-typed signature: 5454b4b2383aacfc357f78dd3176ffff +// flow-typed version: <>/babel-eslint_v^9.0.0/flow_v0.80.0 /** * This is an autogenerated libdef stub for: @@ -22,59 +22,102 @@ declare module 'babel-eslint' { * require those files directly. Feel free to delete any files that aren't * needed. */ -declare module 'babel-eslint/babylon-to-espree/attachComments' { +declare module 'babel-eslint/lib/analyze-scope' { declare module.exports: any; } -declare module 'babel-eslint/babylon-to-espree/convertComments' { +declare module 'babel-eslint/lib/babylon-to-espree/attachComments' { declare module.exports: any; } -declare module 'babel-eslint/babylon-to-espree/convertTemplateType' { +declare module 'babel-eslint/lib/babylon-to-espree/convertComments' { declare module.exports: any; } -declare module 'babel-eslint/babylon-to-espree/index' { +declare module 'babel-eslint/lib/babylon-to-espree/convertTemplateType' { declare module.exports: any; } -declare module 'babel-eslint/babylon-to-espree/toAST' { +declare module 'babel-eslint/lib/babylon-to-espree/index' { declare module.exports: any; } -declare module 'babel-eslint/babylon-to-espree/toToken' { +declare module 'babel-eslint/lib/babylon-to-espree/toAST' { declare module.exports: any; } -declare module 'babel-eslint/babylon-to-espree/toTokens' { +declare module 'babel-eslint/lib/babylon-to-espree/toToken' { + declare module.exports: any; +} + +declare module 'babel-eslint/lib/babylon-to-espree/toTokens' { + declare module.exports: any; +} + +declare module 'babel-eslint/lib/index' { + declare module.exports: any; +} + +declare module 'babel-eslint/lib/parse-with-patch' { + declare module.exports: any; +} + +declare module 'babel-eslint/lib/parse-with-scope' { + declare module.exports: any; +} + +declare module 'babel-eslint/lib/parse' { + declare module.exports: any; +} + +declare module 'babel-eslint/lib/patch-eslint-scope' { + declare module.exports: any; +} + +declare module 'babel-eslint/lib/visitor-keys' { declare module.exports: any; } // Filename aliases -declare module 'babel-eslint/babylon-to-espree/attachComments.js' { - declare module.exports: $Exports<'babel-eslint/babylon-to-espree/attachComments'>; +declare module 'babel-eslint/lib/analyze-scope.js' { + declare module.exports: $Exports<'babel-eslint/lib/analyze-scope'>; +} +declare module 'babel-eslint/lib/babylon-to-espree/attachComments.js' { + declare module.exports: $Exports<'babel-eslint/lib/babylon-to-espree/attachComments'>; +} +declare module 'babel-eslint/lib/babylon-to-espree/convertComments.js' { + declare module.exports: $Exports<'babel-eslint/lib/babylon-to-espree/convertComments'>; +} +declare module 'babel-eslint/lib/babylon-to-espree/convertTemplateType.js' { + declare module.exports: $Exports<'babel-eslint/lib/babylon-to-espree/convertTemplateType'>; +} +declare module 'babel-eslint/lib/babylon-to-espree/index.js' { + declare module.exports: $Exports<'babel-eslint/lib/babylon-to-espree/index'>; +} +declare module 'babel-eslint/lib/babylon-to-espree/toAST.js' { + declare module.exports: $Exports<'babel-eslint/lib/babylon-to-espree/toAST'>; } -declare module 'babel-eslint/babylon-to-espree/convertComments.js' { - declare module.exports: $Exports<'babel-eslint/babylon-to-espree/convertComments'>; +declare module 'babel-eslint/lib/babylon-to-espree/toToken.js' { + declare module.exports: $Exports<'babel-eslint/lib/babylon-to-espree/toToken'>; } -declare module 'babel-eslint/babylon-to-espree/convertTemplateType.js' { - declare module.exports: $Exports<'babel-eslint/babylon-to-espree/convertTemplateType'>; +declare module 'babel-eslint/lib/babylon-to-espree/toTokens.js' { + declare module.exports: $Exports<'babel-eslint/lib/babylon-to-espree/toTokens'>; } -declare module 'babel-eslint/babylon-to-espree/index.js' { - declare module.exports: $Exports<'babel-eslint/babylon-to-espree/index'>; +declare module 'babel-eslint/lib/index.js' { + declare module.exports: $Exports<'babel-eslint/lib/index'>; } -declare module 'babel-eslint/babylon-to-espree/toAST.js' { - declare module.exports: $Exports<'babel-eslint/babylon-to-espree/toAST'>; +declare module 'babel-eslint/lib/parse-with-patch.js' { + declare module.exports: $Exports<'babel-eslint/lib/parse-with-patch'>; } -declare module 'babel-eslint/babylon-to-espree/toToken.js' { - declare module.exports: $Exports<'babel-eslint/babylon-to-espree/toToken'>; +declare module 'babel-eslint/lib/parse-with-scope.js' { + declare module.exports: $Exports<'babel-eslint/lib/parse-with-scope'>; } -declare module 'babel-eslint/babylon-to-espree/toTokens.js' { - declare module.exports: $Exports<'babel-eslint/babylon-to-espree/toTokens'>; +declare module 'babel-eslint/lib/parse.js' { + declare module.exports: $Exports<'babel-eslint/lib/parse'>; } -declare module 'babel-eslint/index' { - declare module.exports: $Exports<'babel-eslint'>; +declare module 'babel-eslint/lib/patch-eslint-scope.js' { + declare module.exports: $Exports<'babel-eslint/lib/patch-eslint-scope'>; } -declare module 'babel-eslint/index.js' { - declare module.exports: $Exports<'babel-eslint'>; +declare module 'babel-eslint/lib/visitor-keys.js' { + declare module.exports: $Exports<'babel-eslint/lib/visitor-keys'>; } diff --git a/flow-typed/npm/babel-jest_vx.x.x.js b/flow-typed/npm/babel-jest_vx.x.x.js index 646bef977..0e8163ca8 100644 --- a/flow-typed/npm/babel-jest_vx.x.x.js +++ b/flow-typed/npm/babel-jest_vx.x.x.js @@ -1,5 +1,5 @@ -// flow-typed signature: c5f56507f22abc799fee64c0abfe30c0 -// flow-typed version: <>/babel-jest_v^20.0.3/flow_v0.47.0 +// flow-typed signature: 100f17029f54328f1dfa94490bf59822 +// flow-typed version: <>/babel-jest_v^23.6.0/flow_v0.80.0 /** * This is an autogenerated libdef stub for: diff --git a/flow-typed/npm/cz-conventional-changelog_vx.x.x.js b/flow-typed/npm/cz-conventional-changelog_vx.x.x.js index 64bd33ab8..3a2b2ae2c 100644 --- a/flow-typed/npm/cz-conventional-changelog_vx.x.x.js +++ b/flow-typed/npm/cz-conventional-changelog_vx.x.x.js @@ -1,5 +1,5 @@ -// flow-typed signature: 98fa4f62b7a9ad35a7a43f0fc38c54f6 -// flow-typed version: <>/cz-conventional-changelog_v^2.0.0/flow_v0.47.0 +// flow-typed signature: ec6c2145acd80dfdb66741b56c8dd4a7 +// flow-typed version: <>/cz-conventional-changelog_v^2.1.0/flow_v0.80.0 /** * This is an autogenerated libdef stub for: diff --git a/flow-typed/npm/decompress_v4.2.x.js b/flow-typed/npm/decompress_v4.2.x.js new file mode 100644 index 000000000..0cb7ee19f --- /dev/null +++ b/flow-typed/npm/decompress_v4.2.x.js @@ -0,0 +1,41 @@ +/** + * Flowtype definitions for decompress v4.2 + */ + +declare module "decompress" { + declare interface File { + data: Buffer; + mode: number; + mtime: string; + path: string; + type: string; + } + + declare interface DecompressOptions { + /** + * Filter out files before extracting + */ + filter(file: File): boolean; + + /** + * Map files before extracting + */ + map(file: File): File; + + /** + * Array of plugins to use. + * Default: [decompressTar(), decompressTarbz2(), decompressTargz(), decompressUnzip()] + */ + plugins?: any[]; + + /** + * Remove leading directory components from extracted files. + * Default: 0 + */ + strip?: number; + } + + declare var decompress: (input: string | Buffer, output: string, opts?: DecompressOptions) => Promise; + + declare module.exports: typeof decompress; +} diff --git a/flow-typed/npm/eslint-config-airbnb-base_vx.x.x.js b/flow-typed/npm/eslint-config-airbnb-base_vx.x.x.js index 384377684..9deae4de0 100644 --- a/flow-typed/npm/eslint-config-airbnb-base_vx.x.x.js +++ b/flow-typed/npm/eslint-config-airbnb-base_vx.x.x.js @@ -1,5 +1,5 @@ -// flow-typed signature: 7dd13c80f73219071633f222958e8ef8 -// flow-typed version: <>/eslint-config-airbnb-base_v^11.2.0/flow_v0.47.0 +// flow-typed signature: c8ee7810dd58c563a615855bdb1b9de5 +// flow-typed version: <>/eslint-config-airbnb-base_v^13.1.0/flow_v0.80.0 /** * This is an autogenerated libdef stub for: @@ -58,10 +58,18 @@ declare module 'eslint-config-airbnb-base/rules/variables' { declare module.exports: any; } +declare module 'eslint-config-airbnb-base/test/requires' { + declare module.exports: any; +} + declare module 'eslint-config-airbnb-base/test/test-base' { declare module.exports: any; } +declare module 'eslint-config-airbnb-base/whitespace' { + declare module.exports: any; +} + // Filename aliases declare module 'eslint-config-airbnb-base/index' { declare module.exports: $Exports<'eslint-config-airbnb-base'>; @@ -96,6 +104,12 @@ declare module 'eslint-config-airbnb-base/rules/style.js' { declare module 'eslint-config-airbnb-base/rules/variables.js' { declare module.exports: $Exports<'eslint-config-airbnb-base/rules/variables'>; } +declare module 'eslint-config-airbnb-base/test/requires.js' { + declare module.exports: $Exports<'eslint-config-airbnb-base/test/requires'>; +} declare module 'eslint-config-airbnb-base/test/test-base.js' { declare module.exports: $Exports<'eslint-config-airbnb-base/test/test-base'>; } +declare module 'eslint-config-airbnb-base/whitespace.js' { + declare module.exports: $Exports<'eslint-config-airbnb-base/whitespace'>; +} diff --git a/flow-typed/npm/eslint-config-prettier_vx.x.x.js b/flow-typed/npm/eslint-config-prettier_vx.x.x.js index eb71e55fc..01aa09351 100644 --- a/flow-typed/npm/eslint-config-prettier_vx.x.x.js +++ b/flow-typed/npm/eslint-config-prettier_vx.x.x.js @@ -1,5 +1,5 @@ -// flow-typed signature: 476ffef6e88e9a1dc433e0859eaad231 -// flow-typed version: <>/eslint-config-prettier_v^2.1.1/flow_v0.47.0 +// flow-typed signature: 4a8a03bde41dfa420f385bac3f87e785 +// flow-typed version: <>/eslint-config-prettier_v^3.0.1/flow_v0.80.0 /** * This is an autogenerated libdef stub for: @@ -38,6 +38,14 @@ declare module 'eslint-config-prettier/react' { declare module.exports: any; } +declare module 'eslint-config-prettier/standard' { + declare module.exports: any; +} + +declare module 'eslint-config-prettier/unicorn' { + declare module.exports: any; +} + // Filename aliases declare module 'eslint-config-prettier/bin/cli.js' { declare module.exports: $Exports<'eslint-config-prettier/bin/cli'>; @@ -57,3 +65,9 @@ declare module 'eslint-config-prettier/index.js' { declare module 'eslint-config-prettier/react.js' { declare module.exports: $Exports<'eslint-config-prettier/react'>; } +declare module 'eslint-config-prettier/standard.js' { + declare module.exports: $Exports<'eslint-config-prettier/standard'>; +} +declare module 'eslint-config-prettier/unicorn.js' { + declare module.exports: $Exports<'eslint-config-prettier/unicorn'>; +} diff --git a/flow-typed/npm/eslint-plugin-flowtype_vx.x.x.js b/flow-typed/npm/eslint-plugin-flowtype_vx.x.x.js index 1a501d78b..b0553c5fc 100644 --- a/flow-typed/npm/eslint-plugin-flowtype_vx.x.x.js +++ b/flow-typed/npm/eslint-plugin-flowtype_vx.x.x.js @@ -1,5 +1,5 @@ -// flow-typed signature: 76c6377cfbfae74fc012426575a72672 -// flow-typed version: <>/eslint-plugin-flowtype_v^2.34.0/flow_v0.47.0 +// flow-typed signature: 4d32dc16d22d181860348716547d244a +// flow-typed version: <>/eslint-plugin-flowtype_v^2.50.0/flow_v0.80.0 /** * This is an autogenerated libdef stub for: @@ -30,6 +30,26 @@ declare module 'eslint-plugin-flowtype/dist/index' { declare module.exports: any; } +declare module 'eslint-plugin-flowtype/dist/rules/arrayStyle/index' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/arrayStyle/isSimpleType' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/arrayStyle/needWrap' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/arrayStyleComplexType' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/arrayStyleSimpleType' { + declare module.exports: any; +} + declare module 'eslint-plugin-flowtype/dist/rules/booleanStyle' { declare module.exports: any; } @@ -46,10 +66,26 @@ declare module 'eslint-plugin-flowtype/dist/rules/genericSpacing' { declare module.exports: any; } +declare module 'eslint-plugin-flowtype/dist/rules/newlineAfterFlowAnnotation' { + declare module.exports: any; +} + declare module 'eslint-plugin-flowtype/dist/rules/noDupeKeys' { declare module.exports: any; } +declare module 'eslint-plugin-flowtype/dist/rules/noExistentialType' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/noFlowFixMeComments' { + declare module.exports: any; +} + +declare module 'eslint-plugin-flowtype/dist/rules/noMutableArray' { + declare module.exports: any; +} + declare module 'eslint-plugin-flowtype/dist/rules/noPrimitiveConstructorTypes' { declare module.exports: any; } @@ -58,6 +94,10 @@ declare module 'eslint-plugin-flowtype/dist/rules/noTypesMissingFileAnnotation' declare module.exports: any; } +declare module 'eslint-plugin-flowtype/dist/rules/noUnusedExpressions' { + declare module.exports: any; +} + declare module 'eslint-plugin-flowtype/dist/rules/noWeakTypes' { declare module.exports: any; } @@ -66,6 +106,10 @@ declare module 'eslint-plugin-flowtype/dist/rules/objectTypeDelimiter' { declare module.exports: any; } +declare module 'eslint-plugin-flowtype/dist/rules/requireExactType' { + declare module.exports: any; +} + declare module 'eslint-plugin-flowtype/dist/rules/requireParameterType' { declare module.exports: any; } @@ -74,6 +118,10 @@ declare module 'eslint-plugin-flowtype/dist/rules/requireReturnType' { declare module.exports: any; } +declare module 'eslint-plugin-flowtype/dist/rules/requireTypesAtTop' { + declare module.exports: any; +} + declare module 'eslint-plugin-flowtype/dist/rules/requireValidFileAnnotation' { declare module.exports: any; } @@ -126,6 +174,10 @@ declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateTypic declare module.exports: any; } +declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateVariables' { + declare module.exports: any; +} + declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/index' { declare module.exports: any; } @@ -138,6 +190,10 @@ declare module 'eslint-plugin-flowtype/dist/rules/typeIdMatch' { declare module.exports: any; } +declare module 'eslint-plugin-flowtype/dist/rules/typeImportStyle' { + declare module.exports: any; +} + declare module 'eslint-plugin-flowtype/dist/rules/unionIntersectionSpacing' { declare module.exports: any; } @@ -201,6 +257,21 @@ declare module 'eslint-plugin-flowtype/bin/readmeAssertions.js' { declare module 'eslint-plugin-flowtype/dist/index.js' { declare module.exports: $Exports<'eslint-plugin-flowtype/dist/index'>; } +declare module 'eslint-plugin-flowtype/dist/rules/arrayStyle/index.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/arrayStyle/index'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/arrayStyle/isSimpleType.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/arrayStyle/isSimpleType'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/arrayStyle/needWrap.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/arrayStyle/needWrap'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/arrayStyleComplexType.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/arrayStyleComplexType'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/arrayStyleSimpleType.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/arrayStyleSimpleType'>; +} declare module 'eslint-plugin-flowtype/dist/rules/booleanStyle.js' { declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/booleanStyle'>; } @@ -213,27 +284,48 @@ declare module 'eslint-plugin-flowtype/dist/rules/delimiterDangle.js' { declare module 'eslint-plugin-flowtype/dist/rules/genericSpacing.js' { declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/genericSpacing'>; } +declare module 'eslint-plugin-flowtype/dist/rules/newlineAfterFlowAnnotation.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/newlineAfterFlowAnnotation'>; +} declare module 'eslint-plugin-flowtype/dist/rules/noDupeKeys.js' { declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/noDupeKeys'>; } +declare module 'eslint-plugin-flowtype/dist/rules/noExistentialType.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/noExistentialType'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/noFlowFixMeComments.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/noFlowFixMeComments'>; +} +declare module 'eslint-plugin-flowtype/dist/rules/noMutableArray.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/noMutableArray'>; +} declare module 'eslint-plugin-flowtype/dist/rules/noPrimitiveConstructorTypes.js' { declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/noPrimitiveConstructorTypes'>; } declare module 'eslint-plugin-flowtype/dist/rules/noTypesMissingFileAnnotation.js' { declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/noTypesMissingFileAnnotation'>; } +declare module 'eslint-plugin-flowtype/dist/rules/noUnusedExpressions.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/noUnusedExpressions'>; +} declare module 'eslint-plugin-flowtype/dist/rules/noWeakTypes.js' { declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/noWeakTypes'>; } declare module 'eslint-plugin-flowtype/dist/rules/objectTypeDelimiter.js' { declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/objectTypeDelimiter'>; } +declare module 'eslint-plugin-flowtype/dist/rules/requireExactType.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/requireExactType'>; +} declare module 'eslint-plugin-flowtype/dist/rules/requireParameterType.js' { declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/requireParameterType'>; } declare module 'eslint-plugin-flowtype/dist/rules/requireReturnType.js' { declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/requireReturnType'>; } +declare module 'eslint-plugin-flowtype/dist/rules/requireTypesAtTop.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/requireTypesAtTop'>; +} declare module 'eslint-plugin-flowtype/dist/rules/requireValidFileAnnotation.js' { declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/requireValidFileAnnotation'>; } @@ -273,6 +365,9 @@ declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateTypeC declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateTypical.js' { declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateTypical'>; } +declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateVariables.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/typeColonSpacing/evaluateVariables'>; +} declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/index.js' { declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/typeColonSpacing/index'>; } @@ -282,6 +377,9 @@ declare module 'eslint-plugin-flowtype/dist/rules/typeColonSpacing/reporter.js' declare module 'eslint-plugin-flowtype/dist/rules/typeIdMatch.js' { declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/typeIdMatch'>; } +declare module 'eslint-plugin-flowtype/dist/rules/typeImportStyle.js' { + declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/typeImportStyle'>; +} declare module 'eslint-plugin-flowtype/dist/rules/unionIntersectionSpacing.js' { declare module.exports: $Exports<'eslint-plugin-flowtype/dist/rules/unionIntersectionSpacing'>; } diff --git a/flow-typed/npm/eslint-plugin-import_vx.x.x.js b/flow-typed/npm/eslint-plugin-import_vx.x.x.js index 0b32c21c0..dadc940ad 100644 --- a/flow-typed/npm/eslint-plugin-import_vx.x.x.js +++ b/flow-typed/npm/eslint-plugin-import_vx.x.x.js @@ -1,5 +1,5 @@ -// flow-typed signature: 9eb967c73a45d2b171be28455df24670 -// flow-typed version: <>/eslint-plugin-import_v^2.3.0/flow_v0.47.0 +// flow-typed signature: b44eb1bb3d4445b431e9505c3046f2cc +// flow-typed version: <>/eslint-plugin-import_v^2.14.0/flow_v0.80.0 /** * This is an autogenerated libdef stub for: @@ -58,6 +58,10 @@ declare module 'eslint-plugin-import/lib/core/staticRequire' { declare module.exports: any; } +declare module 'eslint-plugin-import/lib/docsUrl' { + declare module.exports: any; +} + declare module 'eslint-plugin-import/lib/ExportMap' { declare module.exports: any; } @@ -74,10 +78,18 @@ declare module 'eslint-plugin-import/lib/rules/default' { declare module.exports: any; } +declare module 'eslint-plugin-import/lib/rules/dynamic-import-chunkname' { + declare module.exports: any; +} + declare module 'eslint-plugin-import/lib/rules/export' { declare module.exports: any; } +declare module 'eslint-plugin-import/lib/rules/exports-last' { + declare module.exports: any; +} + declare module 'eslint-plugin-import/lib/rules/extensions' { declare module.exports: any; } @@ -86,6 +98,10 @@ declare module 'eslint-plugin-import/lib/rules/first' { declare module.exports: any; } +declare module 'eslint-plugin-import/lib/rules/group-exports' { + declare module.exports: any; +} + declare module 'eslint-plugin-import/lib/rules/imports-first' { declare module.exports: any; } @@ -122,6 +138,14 @@ declare module 'eslint-plugin-import/lib/rules/no-commonjs' { declare module.exports: any; } +declare module 'eslint-plugin-import/lib/rules/no-cycle' { + declare module.exports: any; +} + +declare module 'eslint-plugin-import/lib/rules/no-default-export' { + declare module.exports: any; +} + declare module 'eslint-plugin-import/lib/rules/no-deprecated' { declare module.exports: any; } @@ -166,10 +190,18 @@ declare module 'eslint-plugin-import/lib/rules/no-nodejs-modules' { declare module.exports: any; } +declare module 'eslint-plugin-import/lib/rules/no-relative-parent-imports' { + declare module.exports: any; +} + declare module 'eslint-plugin-import/lib/rules/no-restricted-paths' { declare module.exports: any; } +declare module 'eslint-plugin-import/lib/rules/no-self-import' { + declare module.exports: any; +} + declare module 'eslint-plugin-import/lib/rules/no-unassigned-import' { declare module.exports: any; } @@ -178,6 +210,10 @@ declare module 'eslint-plugin-import/lib/rules/no-unresolved' { declare module.exports: any; } +declare module 'eslint-plugin-import/lib/rules/no-useless-path-segments' { + declare module.exports: any; +} + declare module 'eslint-plugin-import/lib/rules/no-webpack-loader-syntax' { declare module.exports: any; } @@ -226,6 +262,9 @@ declare module 'eslint-plugin-import/lib/core/importType.js' { declare module 'eslint-plugin-import/lib/core/staticRequire.js' { declare module.exports: $Exports<'eslint-plugin-import/lib/core/staticRequire'>; } +declare module 'eslint-plugin-import/lib/docsUrl.js' { + declare module.exports: $Exports<'eslint-plugin-import/lib/docsUrl'>; +} declare module 'eslint-plugin-import/lib/ExportMap.js' { declare module.exports: $Exports<'eslint-plugin-import/lib/ExportMap'>; } @@ -238,15 +277,24 @@ declare module 'eslint-plugin-import/lib/index.js' { declare module 'eslint-plugin-import/lib/rules/default.js' { declare module.exports: $Exports<'eslint-plugin-import/lib/rules/default'>; } +declare module 'eslint-plugin-import/lib/rules/dynamic-import-chunkname.js' { + declare module.exports: $Exports<'eslint-plugin-import/lib/rules/dynamic-import-chunkname'>; +} declare module 'eslint-plugin-import/lib/rules/export.js' { declare module.exports: $Exports<'eslint-plugin-import/lib/rules/export'>; } +declare module 'eslint-plugin-import/lib/rules/exports-last.js' { + declare module.exports: $Exports<'eslint-plugin-import/lib/rules/exports-last'>; +} declare module 'eslint-plugin-import/lib/rules/extensions.js' { declare module.exports: $Exports<'eslint-plugin-import/lib/rules/extensions'>; } declare module 'eslint-plugin-import/lib/rules/first.js' { declare module.exports: $Exports<'eslint-plugin-import/lib/rules/first'>; } +declare module 'eslint-plugin-import/lib/rules/group-exports.js' { + declare module.exports: $Exports<'eslint-plugin-import/lib/rules/group-exports'>; +} declare module 'eslint-plugin-import/lib/rules/imports-first.js' { declare module.exports: $Exports<'eslint-plugin-import/lib/rules/imports-first'>; } @@ -274,6 +322,12 @@ declare module 'eslint-plugin-import/lib/rules/no-anonymous-default-export.js' { declare module 'eslint-plugin-import/lib/rules/no-commonjs.js' { declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-commonjs'>; } +declare module 'eslint-plugin-import/lib/rules/no-cycle.js' { + declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-cycle'>; +} +declare module 'eslint-plugin-import/lib/rules/no-default-export.js' { + declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-default-export'>; +} declare module 'eslint-plugin-import/lib/rules/no-deprecated.js' { declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-deprecated'>; } @@ -307,15 +361,24 @@ declare module 'eslint-plugin-import/lib/rules/no-namespace.js' { declare module 'eslint-plugin-import/lib/rules/no-nodejs-modules.js' { declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-nodejs-modules'>; } +declare module 'eslint-plugin-import/lib/rules/no-relative-parent-imports.js' { + declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-relative-parent-imports'>; +} declare module 'eslint-plugin-import/lib/rules/no-restricted-paths.js' { declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-restricted-paths'>; } +declare module 'eslint-plugin-import/lib/rules/no-self-import.js' { + declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-self-import'>; +} declare module 'eslint-plugin-import/lib/rules/no-unassigned-import.js' { declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-unassigned-import'>; } declare module 'eslint-plugin-import/lib/rules/no-unresolved.js' { declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-unresolved'>; } +declare module 'eslint-plugin-import/lib/rules/no-useless-path-segments.js' { + declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-useless-path-segments'>; +} declare module 'eslint-plugin-import/lib/rules/no-webpack-loader-syntax.js' { declare module.exports: $Exports<'eslint-plugin-import/lib/rules/no-webpack-loader-syntax'>; } diff --git a/flow-typed/npm/eslint-plugin-prettier_vx.x.x.js b/flow-typed/npm/eslint-plugin-prettier_vx.x.x.js index 3ad02ecc6..6eb98567a 100644 --- a/flow-typed/npm/eslint-plugin-prettier_vx.x.x.js +++ b/flow-typed/npm/eslint-plugin-prettier_vx.x.x.js @@ -1,5 +1,5 @@ -// flow-typed signature: 8091d22cf7a05c84f5ab19a98141386e -// flow-typed version: <>/eslint-plugin-prettier_v^2.1.1/flow_v0.47.0 +// flow-typed signature: 0278b7a38b132d561ad6b0225258f291 +// flow-typed version: <>/eslint-plugin-prettier_v^2.6.2/flow_v0.80.0 /** * This is an autogenerated libdef stub for: diff --git a/flow-typed/npm/eslint_vx.x.x.js b/flow-typed/npm/eslint_vx.x.x.js index d3fe8a56e..971457b46 100644 --- a/flow-typed/npm/eslint_vx.x.x.js +++ b/flow-typed/npm/eslint_vx.x.x.js @@ -1,5 +1,5 @@ -// flow-typed signature: d3bec4fb7fa8a422ec1a50dc3d374aaa -// flow-typed version: <>/eslint_v^3.14.1/flow_v0.47.0 +// flow-typed signature: 3b4b1ade3e68b0b2c27d52814bfca260 +// flow-typed version: <>/eslint_v^5.5.0/flow_v0.80.0 /** * This is an autogenerated libdef stub for: @@ -26,7 +26,11 @@ declare module 'eslint/bin/eslint' { declare module.exports: any; } -declare module 'eslint/conf/cli-options' { +declare module 'eslint/conf/config-schema' { + declare module.exports: any; +} + +declare module 'eslint/conf/default-cli-options' { declare module.exports: any; } @@ -46,10 +50,6 @@ declare module 'eslint/lib/api' { declare module.exports: any; } -declare module 'eslint/lib/ast-utils' { - declare module.exports: any; -} - declare module 'eslint/lib/cli-engine' { declare module.exports: any; } @@ -94,6 +94,10 @@ declare module 'eslint/lib/config/autoconfig' { declare module.exports: any; } +declare module 'eslint/lib/config/config-cache' { + declare module.exports: any; +} + declare module 'eslint/lib/config/config-file' { declare module.exports: any; } @@ -122,14 +126,6 @@ declare module 'eslint/lib/config/plugins' { declare module.exports: any; } -declare module 'eslint/lib/eslint' { - declare module.exports: any; -} - -declare module 'eslint/lib/file-finder' { - declare module.exports: any; -} - declare module 'eslint/lib/formatters/checkstyle' { declare module.exports: any; } @@ -182,11 +178,7 @@ declare module 'eslint/lib/ignored-paths' { declare module.exports: any; } -declare module 'eslint/lib/internal-rules/internal-consistent-docs-description' { - declare module.exports: any; -} - -declare module 'eslint/lib/internal-rules/internal-no-invalid-meta' { +declare module 'eslint/lib/linter' { declare module.exports: any; } @@ -194,15 +186,11 @@ declare module 'eslint/lib/load-rules' { declare module.exports: any; } -declare module 'eslint/lib/logging' { - declare module.exports: any; -} - declare module 'eslint/lib/options' { declare module.exports: any; } -declare module 'eslint/lib/rule-context' { +declare module 'eslint/lib/report-translator' { declare module.exports: any; } @@ -214,6 +202,10 @@ declare module 'eslint/lib/rules/accessor-pairs' { declare module.exports: any; } +declare module 'eslint/lib/rules/array-bracket-newline' { + declare module.exports: any; +} + declare module 'eslint/lib/rules/array-bracket-spacing' { declare module.exports: any; } @@ -222,6 +214,10 @@ declare module 'eslint/lib/rules/array-callback-return' { declare module.exports: any; } +declare module 'eslint/lib/rules/array-element-newline' { + declare module.exports: any; +} + declare module 'eslint/lib/rules/arrow-body-style' { declare module.exports: any; } @@ -318,6 +314,10 @@ declare module 'eslint/lib/rules/eqeqeq' { declare module.exports: any; } +declare module 'eslint/lib/rules/for-direction' { + declare module.exports: any; +} + declare module 'eslint/lib/rules/func-call-spacing' { declare module.exports: any; } @@ -334,10 +334,18 @@ declare module 'eslint/lib/rules/func-style' { declare module.exports: any; } +declare module 'eslint/lib/rules/function-paren-newline' { + declare module.exports: any; +} + declare module 'eslint/lib/rules/generator-star-spacing' { declare module.exports: any; } +declare module 'eslint/lib/rules/getter-return' { + declare module.exports: any; +} + declare module 'eslint/lib/rules/global-require' { declare module.exports: any; } @@ -362,6 +370,14 @@ declare module 'eslint/lib/rules/id-match' { declare module.exports: any; } +declare module 'eslint/lib/rules/implicit-arrow-linebreak' { + declare module.exports: any; +} + +declare module 'eslint/lib/rules/indent-legacy' { + declare module.exports: any; +} + declare module 'eslint/lib/rules/indent' { declare module.exports: any; } @@ -398,6 +414,14 @@ declare module 'eslint/lib/rules/lines-around-directive' { declare module.exports: any; } +declare module 'eslint/lib/rules/lines-between-class-members' { + declare module.exports: any; +} + +declare module 'eslint/lib/rules/max-classes-per-file' { + declare module.exports: any; +} + declare module 'eslint/lib/rules/max-depth' { declare module.exports: any; } @@ -406,6 +430,10 @@ declare module 'eslint/lib/rules/max-len' { declare module.exports: any; } +declare module 'eslint/lib/rules/max-lines-per-function' { + declare module.exports: any; +} + declare module 'eslint/lib/rules/max-lines' { declare module.exports: any; } @@ -426,6 +454,10 @@ declare module 'eslint/lib/rules/max-statements' { declare module.exports: any; } +declare module 'eslint/lib/rules/multiline-comment-style' { + declare module.exports: any; +} + declare module 'eslint/lib/rules/multiline-ternary' { declare module.exports: any; } @@ -458,6 +490,10 @@ declare module 'eslint/lib/rules/no-array-constructor' { declare module.exports: any; } +declare module 'eslint/lib/rules/no-async-promise-executor' { + declare module.exports: any; +} + declare module 'eslint/lib/rules/no-await-in-loop' { declare module.exports: any; } @@ -466,6 +502,10 @@ declare module 'eslint/lib/rules/no-bitwise' { declare module.exports: any; } +declare module 'eslint/lib/rules/no-buffer-constructor' { + declare module.exports: any; +} + declare module 'eslint/lib/rules/no-caller' { declare module.exports: any; } @@ -678,6 +718,10 @@ declare module 'eslint/lib/rules/no-magic-numbers' { declare module.exports: any; } +declare module 'eslint/lib/rules/no-misleading-character-class' { + declare module.exports: any; +} + declare module 'eslint/lib/rules/no-mixed-operators' { declare module.exports: any; } @@ -1026,6 +1070,10 @@ declare module 'eslint/lib/rules/padded-blocks' { declare module.exports: any; } +declare module 'eslint/lib/rules/padding-line-between-statements' { + declare module.exports: any; +} + declare module 'eslint/lib/rules/prefer-arrow-callback' { declare module.exports: any; } @@ -1042,6 +1090,10 @@ declare module 'eslint/lib/rules/prefer-numeric-literals' { declare module.exports: any; } +declare module 'eslint/lib/rules/prefer-object-spread' { + declare module.exports: any; +} + declare module 'eslint/lib/rules/prefer-promise-reject-errors' { declare module.exports: any; } @@ -1074,6 +1126,10 @@ declare module 'eslint/lib/rules/radix' { declare module.exports: any; } +declare module 'eslint/lib/rules/require-atomic-updates' { + declare module.exports: any; +} + declare module 'eslint/lib/rules/require-await' { declare module.exports: any; } @@ -1082,6 +1138,10 @@ declare module 'eslint/lib/rules/require-jsdoc' { declare module.exports: any; } +declare module 'eslint/lib/rules/require-unicode-regexp' { + declare module.exports: any; +} + declare module 'eslint/lib/rules/require-yield' { declare module.exports: any; } @@ -1094,6 +1154,10 @@ declare module 'eslint/lib/rules/semi-spacing' { declare module.exports: any; } +declare module 'eslint/lib/rules/semi-style' { + declare module.exports: any; +} + declare module 'eslint/lib/rules/semi' { declare module.exports: any; } @@ -1138,6 +1202,10 @@ declare module 'eslint/lib/rules/strict' { declare module.exports: any; } +declare module 'eslint/lib/rules/switch-colon-spacing' { + declare module.exports: any; +} + declare module 'eslint/lib/rules/symbol-description' { declare module.exports: any; } @@ -1186,18 +1254,10 @@ declare module 'eslint/lib/rules/yoda' { declare module.exports: any; } -declare module 'eslint/lib/testers/event-generator-tester' { - declare module.exports: any; -} - declare module 'eslint/lib/testers/rule-tester' { declare module.exports: any; } -declare module 'eslint/lib/timing' { - declare module.exports: any; -} - declare module 'eslint/lib/token-store/backward-token-comment-cursor' { declare module.exports: any; } @@ -1250,7 +1310,19 @@ declare module 'eslint/lib/token-store/utils' { declare module.exports: any; } -declare module 'eslint/lib/util/comment-event-generator' { +declare module 'eslint/lib/util/ajv' { + declare module.exports: any; +} + +declare module 'eslint/lib/util/apply-disable-directives' { + declare module.exports: any; +} + +declare module 'eslint/lib/util/ast-utils' { + declare module.exports: any; +} + +declare module 'eslint/lib/util/file-finder' { declare module.exports: any; } @@ -1258,7 +1330,7 @@ declare module 'eslint/lib/util/fix-tracker' { declare module.exports: any; } -declare module 'eslint/lib/util/glob-util' { +declare module 'eslint/lib/util/glob-utils' { declare module.exports: any; } @@ -1270,23 +1342,39 @@ declare module 'eslint/lib/util/hash' { declare module.exports: any; } +declare module 'eslint/lib/util/interpolate' { + declare module.exports: any; +} + declare module 'eslint/lib/util/keywords' { declare module.exports: any; } +declare module 'eslint/lib/util/lint-result-cache' { + declare module.exports: any; +} + +declare module 'eslint/lib/util/logging' { + declare module.exports: any; +} + declare module 'eslint/lib/util/module-resolver' { declare module.exports: any; } +declare module 'eslint/lib/util/naming' { + declare module.exports: any; +} + declare module 'eslint/lib/util/node-event-generator' { declare module.exports: any; } -declare module 'eslint/lib/util/npm-util' { +declare module 'eslint/lib/util/npm-utils' { declare module.exports: any; } -declare module 'eslint/lib/util/path-util' { +declare module 'eslint/lib/util/path-utils' { declare module.exports: any; } @@ -1298,11 +1386,15 @@ declare module 'eslint/lib/util/rule-fixer' { declare module.exports: any; } +declare module 'eslint/lib/util/safe-emitter' { + declare module.exports: any; +} + declare module 'eslint/lib/util/source-code-fixer' { declare module.exports: any; } -declare module 'eslint/lib/util/source-code-util' { +declare module 'eslint/lib/util/source-code-utils' { declare module.exports: any; } @@ -1310,10 +1402,34 @@ declare module 'eslint/lib/util/source-code' { declare module.exports: any; } +declare module 'eslint/lib/util/timing' { + declare module.exports: any; +} + declare module 'eslint/lib/util/traverser' { declare module.exports: any; } +declare module 'eslint/lib/util/unicode/index' { + declare module.exports: any; +} + +declare module 'eslint/lib/util/unicode/is-combining-character' { + declare module.exports: any; +} + +declare module 'eslint/lib/util/unicode/is-emoji-modifier' { + declare module.exports: any; +} + +declare module 'eslint/lib/util/unicode/is-regional-indicator-symbol' { + declare module.exports: any; +} + +declare module 'eslint/lib/util/unicode/is-surrogate-pair' { + declare module.exports: any; +} + declare module 'eslint/lib/util/xml-escape' { declare module.exports: any; } @@ -1322,8 +1438,11 @@ declare module 'eslint/lib/util/xml-escape' { declare module 'eslint/bin/eslint.js' { declare module.exports: $Exports<'eslint/bin/eslint'>; } -declare module 'eslint/conf/cli-options.js' { - declare module.exports: $Exports<'eslint/conf/cli-options'>; +declare module 'eslint/conf/config-schema.js' { + declare module.exports: $Exports<'eslint/conf/config-schema'>; +} +declare module 'eslint/conf/default-cli-options.js' { + declare module.exports: $Exports<'eslint/conf/default-cli-options'>; } declare module 'eslint/conf/environments.js' { declare module.exports: $Exports<'eslint/conf/environments'>; @@ -1337,9 +1456,6 @@ declare module 'eslint/conf/eslint-recommended.js' { declare module 'eslint/lib/api.js' { declare module.exports: $Exports<'eslint/lib/api'>; } -declare module 'eslint/lib/ast-utils.js' { - declare module.exports: $Exports<'eslint/lib/ast-utils'>; -} declare module 'eslint/lib/cli-engine.js' { declare module.exports: $Exports<'eslint/lib/cli-engine'>; } @@ -1373,6 +1489,9 @@ declare module 'eslint/lib/config.js' { declare module 'eslint/lib/config/autoconfig.js' { declare module.exports: $Exports<'eslint/lib/config/autoconfig'>; } +declare module 'eslint/lib/config/config-cache.js' { + declare module.exports: $Exports<'eslint/lib/config/config-cache'>; +} declare module 'eslint/lib/config/config-file.js' { declare module.exports: $Exports<'eslint/lib/config/config-file'>; } @@ -1394,12 +1513,6 @@ declare module 'eslint/lib/config/environments.js' { declare module 'eslint/lib/config/plugins.js' { declare module.exports: $Exports<'eslint/lib/config/plugins'>; } -declare module 'eslint/lib/eslint.js' { - declare module.exports: $Exports<'eslint/lib/eslint'>; -} -declare module 'eslint/lib/file-finder.js' { - declare module.exports: $Exports<'eslint/lib/file-finder'>; -} declare module 'eslint/lib/formatters/checkstyle.js' { declare module.exports: $Exports<'eslint/lib/formatters/checkstyle'>; } @@ -1439,23 +1552,17 @@ declare module 'eslint/lib/formatters/visualstudio.js' { declare module 'eslint/lib/ignored-paths.js' { declare module.exports: $Exports<'eslint/lib/ignored-paths'>; } -declare module 'eslint/lib/internal-rules/internal-consistent-docs-description.js' { - declare module.exports: $Exports<'eslint/lib/internal-rules/internal-consistent-docs-description'>; -} -declare module 'eslint/lib/internal-rules/internal-no-invalid-meta.js' { - declare module.exports: $Exports<'eslint/lib/internal-rules/internal-no-invalid-meta'>; +declare module 'eslint/lib/linter.js' { + declare module.exports: $Exports<'eslint/lib/linter'>; } declare module 'eslint/lib/load-rules.js' { declare module.exports: $Exports<'eslint/lib/load-rules'>; } -declare module 'eslint/lib/logging.js' { - declare module.exports: $Exports<'eslint/lib/logging'>; -} declare module 'eslint/lib/options.js' { declare module.exports: $Exports<'eslint/lib/options'>; } -declare module 'eslint/lib/rule-context.js' { - declare module.exports: $Exports<'eslint/lib/rule-context'>; +declare module 'eslint/lib/report-translator.js' { + declare module.exports: $Exports<'eslint/lib/report-translator'>; } declare module 'eslint/lib/rules.js' { declare module.exports: $Exports<'eslint/lib/rules'>; @@ -1463,12 +1570,18 @@ declare module 'eslint/lib/rules.js' { declare module 'eslint/lib/rules/accessor-pairs.js' { declare module.exports: $Exports<'eslint/lib/rules/accessor-pairs'>; } +declare module 'eslint/lib/rules/array-bracket-newline.js' { + declare module.exports: $Exports<'eslint/lib/rules/array-bracket-newline'>; +} declare module 'eslint/lib/rules/array-bracket-spacing.js' { declare module.exports: $Exports<'eslint/lib/rules/array-bracket-spacing'>; } declare module 'eslint/lib/rules/array-callback-return.js' { declare module.exports: $Exports<'eslint/lib/rules/array-callback-return'>; } +declare module 'eslint/lib/rules/array-element-newline.js' { + declare module.exports: $Exports<'eslint/lib/rules/array-element-newline'>; +} declare module 'eslint/lib/rules/arrow-body-style.js' { declare module.exports: $Exports<'eslint/lib/rules/arrow-body-style'>; } @@ -1541,6 +1654,9 @@ declare module 'eslint/lib/rules/eol-last.js' { declare module 'eslint/lib/rules/eqeqeq.js' { declare module.exports: $Exports<'eslint/lib/rules/eqeqeq'>; } +declare module 'eslint/lib/rules/for-direction.js' { + declare module.exports: $Exports<'eslint/lib/rules/for-direction'>; +} declare module 'eslint/lib/rules/func-call-spacing.js' { declare module.exports: $Exports<'eslint/lib/rules/func-call-spacing'>; } @@ -1553,9 +1669,15 @@ declare module 'eslint/lib/rules/func-names.js' { declare module 'eslint/lib/rules/func-style.js' { declare module.exports: $Exports<'eslint/lib/rules/func-style'>; } +declare module 'eslint/lib/rules/function-paren-newline.js' { + declare module.exports: $Exports<'eslint/lib/rules/function-paren-newline'>; +} declare module 'eslint/lib/rules/generator-star-spacing.js' { declare module.exports: $Exports<'eslint/lib/rules/generator-star-spacing'>; } +declare module 'eslint/lib/rules/getter-return.js' { + declare module.exports: $Exports<'eslint/lib/rules/getter-return'>; +} declare module 'eslint/lib/rules/global-require.js' { declare module.exports: $Exports<'eslint/lib/rules/global-require'>; } @@ -1574,6 +1696,12 @@ declare module 'eslint/lib/rules/id-length.js' { declare module 'eslint/lib/rules/id-match.js' { declare module.exports: $Exports<'eslint/lib/rules/id-match'>; } +declare module 'eslint/lib/rules/implicit-arrow-linebreak.js' { + declare module.exports: $Exports<'eslint/lib/rules/implicit-arrow-linebreak'>; +} +declare module 'eslint/lib/rules/indent-legacy.js' { + declare module.exports: $Exports<'eslint/lib/rules/indent-legacy'>; +} declare module 'eslint/lib/rules/indent.js' { declare module.exports: $Exports<'eslint/lib/rules/indent'>; } @@ -1601,12 +1729,21 @@ declare module 'eslint/lib/rules/lines-around-comment.js' { declare module 'eslint/lib/rules/lines-around-directive.js' { declare module.exports: $Exports<'eslint/lib/rules/lines-around-directive'>; } +declare module 'eslint/lib/rules/lines-between-class-members.js' { + declare module.exports: $Exports<'eslint/lib/rules/lines-between-class-members'>; +} +declare module 'eslint/lib/rules/max-classes-per-file.js' { + declare module.exports: $Exports<'eslint/lib/rules/max-classes-per-file'>; +} declare module 'eslint/lib/rules/max-depth.js' { declare module.exports: $Exports<'eslint/lib/rules/max-depth'>; } declare module 'eslint/lib/rules/max-len.js' { declare module.exports: $Exports<'eslint/lib/rules/max-len'>; } +declare module 'eslint/lib/rules/max-lines-per-function.js' { + declare module.exports: $Exports<'eslint/lib/rules/max-lines-per-function'>; +} declare module 'eslint/lib/rules/max-lines.js' { declare module.exports: $Exports<'eslint/lib/rules/max-lines'>; } @@ -1622,6 +1759,9 @@ declare module 'eslint/lib/rules/max-statements-per-line.js' { declare module 'eslint/lib/rules/max-statements.js' { declare module.exports: $Exports<'eslint/lib/rules/max-statements'>; } +declare module 'eslint/lib/rules/multiline-comment-style.js' { + declare module.exports: $Exports<'eslint/lib/rules/multiline-comment-style'>; +} declare module 'eslint/lib/rules/multiline-ternary.js' { declare module.exports: $Exports<'eslint/lib/rules/multiline-ternary'>; } @@ -1646,12 +1786,18 @@ declare module 'eslint/lib/rules/no-alert.js' { declare module 'eslint/lib/rules/no-array-constructor.js' { declare module.exports: $Exports<'eslint/lib/rules/no-array-constructor'>; } +declare module 'eslint/lib/rules/no-async-promise-executor.js' { + declare module.exports: $Exports<'eslint/lib/rules/no-async-promise-executor'>; +} declare module 'eslint/lib/rules/no-await-in-loop.js' { declare module.exports: $Exports<'eslint/lib/rules/no-await-in-loop'>; } declare module 'eslint/lib/rules/no-bitwise.js' { declare module.exports: $Exports<'eslint/lib/rules/no-bitwise'>; } +declare module 'eslint/lib/rules/no-buffer-constructor.js' { + declare module.exports: $Exports<'eslint/lib/rules/no-buffer-constructor'>; +} declare module 'eslint/lib/rules/no-caller.js' { declare module.exports: $Exports<'eslint/lib/rules/no-caller'>; } @@ -1811,6 +1957,9 @@ declare module 'eslint/lib/rules/no-loop-func.js' { declare module 'eslint/lib/rules/no-magic-numbers.js' { declare module.exports: $Exports<'eslint/lib/rules/no-magic-numbers'>; } +declare module 'eslint/lib/rules/no-misleading-character-class.js' { + declare module.exports: $Exports<'eslint/lib/rules/no-misleading-character-class'>; +} declare module 'eslint/lib/rules/no-mixed-operators.js' { declare module.exports: $Exports<'eslint/lib/rules/no-mixed-operators'>; } @@ -2072,6 +2221,9 @@ declare module 'eslint/lib/rules/operator-linebreak.js' { declare module 'eslint/lib/rules/padded-blocks.js' { declare module.exports: $Exports<'eslint/lib/rules/padded-blocks'>; } +declare module 'eslint/lib/rules/padding-line-between-statements.js' { + declare module.exports: $Exports<'eslint/lib/rules/padding-line-between-statements'>; +} declare module 'eslint/lib/rules/prefer-arrow-callback.js' { declare module.exports: $Exports<'eslint/lib/rules/prefer-arrow-callback'>; } @@ -2084,6 +2236,9 @@ declare module 'eslint/lib/rules/prefer-destructuring.js' { declare module 'eslint/lib/rules/prefer-numeric-literals.js' { declare module.exports: $Exports<'eslint/lib/rules/prefer-numeric-literals'>; } +declare module 'eslint/lib/rules/prefer-object-spread.js' { + declare module.exports: $Exports<'eslint/lib/rules/prefer-object-spread'>; +} declare module 'eslint/lib/rules/prefer-promise-reject-errors.js' { declare module.exports: $Exports<'eslint/lib/rules/prefer-promise-reject-errors'>; } @@ -2108,12 +2263,18 @@ declare module 'eslint/lib/rules/quotes.js' { declare module 'eslint/lib/rules/radix.js' { declare module.exports: $Exports<'eslint/lib/rules/radix'>; } +declare module 'eslint/lib/rules/require-atomic-updates.js' { + declare module.exports: $Exports<'eslint/lib/rules/require-atomic-updates'>; +} declare module 'eslint/lib/rules/require-await.js' { declare module.exports: $Exports<'eslint/lib/rules/require-await'>; } declare module 'eslint/lib/rules/require-jsdoc.js' { declare module.exports: $Exports<'eslint/lib/rules/require-jsdoc'>; } +declare module 'eslint/lib/rules/require-unicode-regexp.js' { + declare module.exports: $Exports<'eslint/lib/rules/require-unicode-regexp'>; +} declare module 'eslint/lib/rules/require-yield.js' { declare module.exports: $Exports<'eslint/lib/rules/require-yield'>; } @@ -2123,6 +2284,9 @@ declare module 'eslint/lib/rules/rest-spread-spacing.js' { declare module 'eslint/lib/rules/semi-spacing.js' { declare module.exports: $Exports<'eslint/lib/rules/semi-spacing'>; } +declare module 'eslint/lib/rules/semi-style.js' { + declare module.exports: $Exports<'eslint/lib/rules/semi-style'>; +} declare module 'eslint/lib/rules/semi.js' { declare module.exports: $Exports<'eslint/lib/rules/semi'>; } @@ -2156,6 +2320,9 @@ declare module 'eslint/lib/rules/spaced-comment.js' { declare module 'eslint/lib/rules/strict.js' { declare module.exports: $Exports<'eslint/lib/rules/strict'>; } +declare module 'eslint/lib/rules/switch-colon-spacing.js' { + declare module.exports: $Exports<'eslint/lib/rules/switch-colon-spacing'>; +} declare module 'eslint/lib/rules/symbol-description.js' { declare module.exports: $Exports<'eslint/lib/rules/symbol-description'>; } @@ -2192,15 +2359,9 @@ declare module 'eslint/lib/rules/yield-star-spacing.js' { declare module 'eslint/lib/rules/yoda.js' { declare module.exports: $Exports<'eslint/lib/rules/yoda'>; } -declare module 'eslint/lib/testers/event-generator-tester.js' { - declare module.exports: $Exports<'eslint/lib/testers/event-generator-tester'>; -} declare module 'eslint/lib/testers/rule-tester.js' { declare module.exports: $Exports<'eslint/lib/testers/rule-tester'>; } -declare module 'eslint/lib/timing.js' { - declare module.exports: $Exports<'eslint/lib/timing'>; -} declare module 'eslint/lib/token-store/backward-token-comment-cursor.js' { declare module.exports: $Exports<'eslint/lib/token-store/backward-token-comment-cursor'>; } @@ -2240,14 +2401,23 @@ declare module 'eslint/lib/token-store/skip-cursor.js' { declare module 'eslint/lib/token-store/utils.js' { declare module.exports: $Exports<'eslint/lib/token-store/utils'>; } -declare module 'eslint/lib/util/comment-event-generator.js' { - declare module.exports: $Exports<'eslint/lib/util/comment-event-generator'>; +declare module 'eslint/lib/util/ajv.js' { + declare module.exports: $Exports<'eslint/lib/util/ajv'>; +} +declare module 'eslint/lib/util/apply-disable-directives.js' { + declare module.exports: $Exports<'eslint/lib/util/apply-disable-directives'>; +} +declare module 'eslint/lib/util/ast-utils.js' { + declare module.exports: $Exports<'eslint/lib/util/ast-utils'>; +} +declare module 'eslint/lib/util/file-finder.js' { + declare module.exports: $Exports<'eslint/lib/util/file-finder'>; } declare module 'eslint/lib/util/fix-tracker.js' { declare module.exports: $Exports<'eslint/lib/util/fix-tracker'>; } -declare module 'eslint/lib/util/glob-util.js' { - declare module.exports: $Exports<'eslint/lib/util/glob-util'>; +declare module 'eslint/lib/util/glob-utils.js' { + declare module.exports: $Exports<'eslint/lib/util/glob-utils'>; } declare module 'eslint/lib/util/glob.js' { declare module.exports: $Exports<'eslint/lib/util/glob'>; @@ -2255,20 +2425,32 @@ declare module 'eslint/lib/util/glob.js' { declare module 'eslint/lib/util/hash.js' { declare module.exports: $Exports<'eslint/lib/util/hash'>; } +declare module 'eslint/lib/util/interpolate.js' { + declare module.exports: $Exports<'eslint/lib/util/interpolate'>; +} declare module 'eslint/lib/util/keywords.js' { declare module.exports: $Exports<'eslint/lib/util/keywords'>; } +declare module 'eslint/lib/util/lint-result-cache.js' { + declare module.exports: $Exports<'eslint/lib/util/lint-result-cache'>; +} +declare module 'eslint/lib/util/logging.js' { + declare module.exports: $Exports<'eslint/lib/util/logging'>; +} declare module 'eslint/lib/util/module-resolver.js' { declare module.exports: $Exports<'eslint/lib/util/module-resolver'>; } +declare module 'eslint/lib/util/naming.js' { + declare module.exports: $Exports<'eslint/lib/util/naming'>; +} declare module 'eslint/lib/util/node-event-generator.js' { declare module.exports: $Exports<'eslint/lib/util/node-event-generator'>; } -declare module 'eslint/lib/util/npm-util.js' { - declare module.exports: $Exports<'eslint/lib/util/npm-util'>; +declare module 'eslint/lib/util/npm-utils.js' { + declare module.exports: $Exports<'eslint/lib/util/npm-utils'>; } -declare module 'eslint/lib/util/path-util.js' { - declare module.exports: $Exports<'eslint/lib/util/path-util'>; +declare module 'eslint/lib/util/path-utils.js' { + declare module.exports: $Exports<'eslint/lib/util/path-utils'>; } declare module 'eslint/lib/util/patterns/letters.js' { declare module.exports: $Exports<'eslint/lib/util/patterns/letters'>; @@ -2276,18 +2458,39 @@ declare module 'eslint/lib/util/patterns/letters.js' { declare module 'eslint/lib/util/rule-fixer.js' { declare module.exports: $Exports<'eslint/lib/util/rule-fixer'>; } +declare module 'eslint/lib/util/safe-emitter.js' { + declare module.exports: $Exports<'eslint/lib/util/safe-emitter'>; +} declare module 'eslint/lib/util/source-code-fixer.js' { declare module.exports: $Exports<'eslint/lib/util/source-code-fixer'>; } -declare module 'eslint/lib/util/source-code-util.js' { - declare module.exports: $Exports<'eslint/lib/util/source-code-util'>; +declare module 'eslint/lib/util/source-code-utils.js' { + declare module.exports: $Exports<'eslint/lib/util/source-code-utils'>; } declare module 'eslint/lib/util/source-code.js' { declare module.exports: $Exports<'eslint/lib/util/source-code'>; } +declare module 'eslint/lib/util/timing.js' { + declare module.exports: $Exports<'eslint/lib/util/timing'>; +} declare module 'eslint/lib/util/traverser.js' { declare module.exports: $Exports<'eslint/lib/util/traverser'>; } +declare module 'eslint/lib/util/unicode/index.js' { + declare module.exports: $Exports<'eslint/lib/util/unicode/index'>; +} +declare module 'eslint/lib/util/unicode/is-combining-character.js' { + declare module.exports: $Exports<'eslint/lib/util/unicode/is-combining-character'>; +} +declare module 'eslint/lib/util/unicode/is-emoji-modifier.js' { + declare module.exports: $Exports<'eslint/lib/util/unicode/is-emoji-modifier'>; +} +declare module 'eslint/lib/util/unicode/is-regional-indicator-symbol.js' { + declare module.exports: $Exports<'eslint/lib/util/unicode/is-regional-indicator-symbol'>; +} +declare module 'eslint/lib/util/unicode/is-surrogate-pair.js' { + declare module.exports: $Exports<'eslint/lib/util/unicode/is-surrogate-pair'>; +} declare module 'eslint/lib/util/xml-escape.js' { declare module.exports: $Exports<'eslint/lib/util/xml-escape'>; } diff --git a/flow-typed/npm/get-port_v3.2.x.js b/flow-typed/npm/get-port_v3.2.x.js new file mode 100644 index 000000000..c80007eae --- /dev/null +++ b/flow-typed/npm/get-port_v3.2.x.js @@ -0,0 +1,15 @@ +/** + * Flowtype definitions for get-port v3.2 + * Generated by Flowgen from a Typescript Definition + * Flowgen v1.2.3 + * Author: [Joar Wilk](http://twitter.com/joarwilk) + * Repo: http://github.com/joarwilk/flowgen + */ + +declare module "get-port" { + declare var getPort: (options?: { + port?: ?number, + host?: ?string + }) => Promise; + declare module.exports: typeof getPort; +} diff --git a/flow-typed/npm/get-port_vx.x.x.js b/flow-typed/npm/get-port_vx.x.x.js deleted file mode 100644 index 57cdc3cf4..000000000 --- a/flow-typed/npm/get-port_vx.x.x.js +++ /dev/null @@ -1,33 +0,0 @@ -// flow-typed signature: 261cd9f1190db10842d89254ddbbb73d -// flow-typed version: <>/get-port_v^3.1.0/flow_v0.47.0 - -/** - * This is an autogenerated libdef stub for: - * - * 'get-port' - * - * Fill this stub out by replacing all the `any` types. - * - * Once filled out, we encourage you to share your work with the - * community by sending a pull request to: - * https://github.com/flowtype/flow-typed - */ - -declare module 'get-port' { - declare module.exports: any; -} - -/** - * We include stubs for each file inside this npm package in case you need to - * require those files directly. Feel free to delete any files that aren't - * needed. - */ - - -// Filename aliases -declare module 'get-port/index' { - declare module.exports: $Exports<'get-port'>; -} -declare module 'get-port/index.js' { - declare module.exports: $Exports<'get-port'>; -} diff --git a/flow-typed/npm/getos_v3.1.x.js b/flow-typed/npm/getos_v3.1.x.js new file mode 100644 index 000000000..e2a4b7ba9 --- /dev/null +++ b/flow-typed/npm/getos_v3.1.x.js @@ -0,0 +1,29 @@ +/** + * Flowtype definitions for getos_v3.1 + */ + +declare module "getos" { + declare type Os = OtherOs | LinuxOs; + declare interface OtherOs { + os: + | "aix" + | "android" + | "darwin" + | "freebsd" + | "openbsd" + | "sunos" + | "win32" + | "cygwin"; + } + + declare interface LinuxOs { + os: "linux"; + dist: string; + release: string; + codename?: string; + } + + declare var getos: (cb: (err: Error | null, os: Os) => void) => string; + + declare module.exports: typeof getos; +} diff --git a/flow-typed/npm/jest_v20.x.x.js b/flow-typed/npm/jest_v20.x.x.js deleted file mode 100644 index 25fbe318b..000000000 --- a/flow-typed/npm/jest_v20.x.x.js +++ /dev/null @@ -1,483 +0,0 @@ -// flow-typed signature: 336a37cc59a5628d581d11f98d1d94ab -// flow-typed version: ef52b40a4e/jest_v20.x.x/flow_>=v0.33.x - -type JestMockFn = { - (...args: Array): any, - /** - * An object for introspecting mock calls - */ - mock: { - /** - * An array that represents all calls that have been made into this mock - * function. Each call is represented by an array of arguments that were - * passed during the call. - */ - calls: Array>, - /** - * An array that contains all the object instances that have been - * instantiated from this mock function. - */ - instances: mixed - }, - /** - * Resets all information stored in the mockFn.mock.calls and - * mockFn.mock.instances arrays. Often this is useful when you want to clean - * up a mock's usage data between two assertions. - */ - mockClear(): Function, - /** - * Resets all information stored in the mock. This is useful when you want to - * completely restore a mock back to its initial state. - */ - mockReset(): Function, - /** - * Removes the mock and restores the initial implementation. This is useful - * when you want to mock functions in certain test cases and restore the - * original implementation in others. Beware that mockFn.mockRestore only - * works when mock was created with jest.spyOn. Thus you have to take care of - * restoration yourself when manually assigning jest.fn(). - */ - mockRestore(): Function, - /** - * Accepts a function that should be used as the implementation of the mock. - * The mock itself will still record all calls that go into and instances - * that come from itself -- the only difference is that the implementation - * will also be executed when the mock is called. - */ - mockImplementation(fn: Function): JestMockFn, - /** - * Accepts a function that will be used as an implementation of the mock for - * one call to the mocked function. Can be chained so that multiple function - * calls produce different results. - */ - mockImplementationOnce(fn: Function): JestMockFn, - /** - * Just a simple sugar function for returning `this` - */ - mockReturnThis(): void, - /** - * Deprecated: use jest.fn(() => value) instead - */ - mockReturnValue(value: any): JestMockFn, - /** - * Sugar for only returning a value once inside your mock - */ - mockReturnValueOnce(value: any): JestMockFn -}; - -type JestAsymmetricEqualityType = { - /** - * A custom Jasmine equality tester - */ - asymmetricMatch(value: mixed): boolean -}; - -type JestCallsType = { - allArgs(): mixed, - all(): mixed, - any(): boolean, - count(): number, - first(): mixed, - mostRecent(): mixed, - reset(): void -}; - -type JestClockType = { - install(): void, - mockDate(date: Date): void, - tick(milliseconds?: number): void, - uninstall(): void -}; - -type JestMatcherResult = { - message?: string | (() => string), - pass: boolean -}; - -type JestMatcher = (actual: any, expected: any) => JestMatcherResult; - -type JestPromiseType = { - /** - * Use rejects to unwrap the reason of a rejected promise so any other - * matcher can be chained. If the promise is fulfilled the assertion fails. - */ - rejects: JestExpectType, - /** - * Use resolves to unwrap the value of a fulfilled promise so any other - * matcher can be chained. If the promise is rejected the assertion fails. - */ - resolves: JestExpectType -}; - -type JestExpectType = { - not: JestExpectType, - /** - * If you have a mock function, you can use .lastCalledWith to test what - * arguments it was last called with. - */ - lastCalledWith(...args: Array): void, - /** - * toBe just checks that a value is what you expect. It uses === to check - * strict equality. - */ - toBe(value: any): void, - /** - * Use .toHaveBeenCalled to ensure that a mock function got called. - */ - toBeCalled(): void, - /** - * Use .toBeCalledWith to ensure that a mock function was called with - * specific arguments. - */ - toBeCalledWith(...args: Array): void, - /** - * Using exact equality with floating point numbers is a bad idea. Rounding - * means that intuitive things fail. - */ - toBeCloseTo(num: number, delta: any): void, - /** - * Use .toBeDefined to check that a variable is not undefined. - */ - toBeDefined(): void, - /** - * Use .toBeFalsy when you don't care what a value is, you just want to - * ensure a value is false in a boolean context. - */ - toBeFalsy(): void, - /** - * To compare floating point numbers, you can use toBeGreaterThan. - */ - toBeGreaterThan(number: number): void, - /** - * To compare floating point numbers, you can use toBeGreaterThanOrEqual. - */ - toBeGreaterThanOrEqual(number: number): void, - /** - * To compare floating point numbers, you can use toBeLessThan. - */ - toBeLessThan(number: number): void, - /** - * To compare floating point numbers, you can use toBeLessThanOrEqual. - */ - toBeLessThanOrEqual(number: number): void, - /** - * Use .toBeInstanceOf(Class) to check that an object is an instance of a - * class. - */ - toBeInstanceOf(cls: Class<*>): void, - /** - * .toBeNull() is the same as .toBe(null) but the error messages are a bit - * nicer. - */ - toBeNull(): void, - /** - * Use .toBeTruthy when you don't care what a value is, you just want to - * ensure a value is true in a boolean context. - */ - toBeTruthy(): void, - /** - * Use .toBeUndefined to check that a variable is undefined. - */ - toBeUndefined(): void, - /** - * Use .toContain when you want to check that an item is in a list. For - * testing the items in the list, this uses ===, a strict equality check. - */ - toContain(item: any): void, - /** - * Use .toContainEqual when you want to check that an item is in a list. For - * testing the items in the list, this matcher recursively checks the - * equality of all fields, rather than checking for object identity. - */ - toContainEqual(item: any): void, - /** - * Use .toEqual when you want to check that two objects have the same value. - * This matcher recursively checks the equality of all fields, rather than - * checking for object identity. - */ - toEqual(value: any): void, - /** - * Use .toHaveBeenCalled to ensure that a mock function got called. - */ - toHaveBeenCalled(): void, - /** - * Use .toHaveBeenCalledTimes to ensure that a mock function got called exact - * number of times. - */ - toHaveBeenCalledTimes(number: number): void, - /** - * Use .toHaveBeenCalledWith to ensure that a mock function was called with - * specific arguments. - */ - toHaveBeenCalledWith(...args: Array): void, - /** - * Check that an object has a .length property and it is set to a certain - * numeric value. - */ - toHaveLength(number: number): void, - /** - * - */ - toHaveProperty(propPath: string, value?: any): void, - /** - * Use .toMatch to check that a string matches a regular expression. - */ - toMatch(regexp: RegExp): void, - /** - * Use .toMatchObject to check that a javascript object matches a subset of the properties of an object. - */ - toMatchObject(object: Object): void, - /** - * This ensures that a React component matches the most recent snapshot. - */ - toMatchSnapshot(name?: string): void, - /** - * Use .toThrow to test that a function throws when it is called. - * If you want to test that a specific error gets thrown, you can provide an - * argument to toThrow. The argument can be a string for the error message, - * a class for the error, or a regex that should match the error. - * - * Alias: .toThrowError - */ - toThrow(message?: string | Error | RegExp): void, - toThrowError(message?: string | Error | RegExp): void, - /** - * Use .toThrowErrorMatchingSnapshot to test that a function throws a error - * matching the most recent snapshot when it is called. - */ - toThrowErrorMatchingSnapshot(): void -}; - -type JestObjectType = { - /** - * Disables automatic mocking in the module loader. - * - * After this method is called, all `require()`s will return the real - * versions of each module (rather than a mocked version). - */ - disableAutomock(): JestObjectType, - /** - * An un-hoisted version of disableAutomock - */ - autoMockOff(): JestObjectType, - /** - * Enables automatic mocking in the module loader. - */ - enableAutomock(): JestObjectType, - /** - * An un-hoisted version of enableAutomock - */ - autoMockOn(): JestObjectType, - /** - * Clears the mock.calls and mock.instances properties of all mocks. - * Equivalent to calling .mockClear() on every mocked function. - */ - clearAllMocks(): JestObjectType, - /** - * Resets the state of all mocks. Equivalent to calling .mockReset() on every - * mocked function. - */ - resetAllMocks(): JestObjectType, - /** - * Removes any pending timers from the timer system. - */ - clearAllTimers(): void, - /** - * The same as `mock` but not moved to the top of the expectation by - * babel-jest. - */ - doMock(moduleName: string, moduleFactory?: any): JestObjectType, - /** - * The same as `unmock` but not moved to the top of the expectation by - * babel-jest. - */ - dontMock(moduleName: string): JestObjectType, - /** - * Returns a new, unused mock function. Optionally takes a mock - * implementation. - */ - fn(implementation?: Function): JestMockFn, - /** - * Determines if the given function is a mocked function. - */ - isMockFunction(fn: Function): boolean, - /** - * Given the name of a module, use the automatic mocking system to generate a - * mocked version of the module for you. - */ - genMockFromModule(moduleName: string): any, - /** - * Mocks a module with an auto-mocked version when it is being required. - * - * The second argument can be used to specify an explicit module factory that - * is being run instead of using Jest's automocking feature. - * - * The third argument can be used to create virtual mocks -- mocks of modules - * that don't exist anywhere in the system. - */ - mock( - moduleName: string, - moduleFactory?: any, - options?: Object - ): JestObjectType, - /** - * Resets the module registry - the cache of all required modules. This is - * useful to isolate modules where local state might conflict between tests. - */ - resetModules(): JestObjectType, - /** - * Exhausts the micro-task queue (usually interfaced in node via - * process.nextTick). - */ - runAllTicks(): void, - /** - * Exhausts the macro-task queue (i.e., all tasks queued by setTimeout(), - * setInterval(), and setImmediate()). - */ - runAllTimers(): void, - /** - * Exhausts all tasks queued by setImmediate(). - */ - runAllImmediates(): void, - /** - * Executes only the macro task queue (i.e. all tasks queued by setTimeout() - * or setInterval() and setImmediate()). - */ - runTimersToTime(msToRun: number): void, - /** - * Executes only the macro-tasks that are currently pending (i.e., only the - * tasks that have been queued by setTimeout() or setInterval() up to this - * point) - */ - runOnlyPendingTimers(): void, - /** - * Explicitly supplies the mock object that the module system should return - * for the specified module. Note: It is recommended to use jest.mock() - * instead. - */ - setMock(moduleName: string, moduleExports: any): JestObjectType, - /** - * Indicates that the module system should never return a mocked version of - * the specified module from require() (e.g. that it should always return the - * real module). - */ - unmock(moduleName: string): JestObjectType, - /** - * Instructs Jest to use fake versions of the standard timer functions - * (setTimeout, setInterval, clearTimeout, clearInterval, nextTick, - * setImmediate and clearImmediate). - */ - useFakeTimers(): JestObjectType, - /** - * Instructs Jest to use the real versions of the standard timer functions. - */ - useRealTimers(): JestObjectType, - /** - * Creates a mock function similar to jest.fn but also tracks calls to - * object[methodName]. - */ - spyOn(object: Object, methodName: string): JestMockFn -}; - -type JestSpyType = { - calls: JestCallsType -}; - -/** Runs this function after every test inside this context */ -declare function afterEach(fn: Function): void; -/** Runs this function before every test inside this context */ -declare function beforeEach(fn: Function): void; -/** Runs this function after all tests have finished inside this context */ -declare function afterAll(fn: Function): void; -/** Runs this function before any tests have started inside this context */ -declare function beforeAll(fn: Function): void; -/** A context for grouping tests together */ -declare function describe(name: string, fn: Function): void; - -/** An individual test unit */ -declare var it: { - /** - * An individual test unit - * - * @param {string} Name of Test - * @param {Function} Test - */ - (name: string, fn?: Function): ?Promise, - /** - * Only run this test - * - * @param {string} Name of Test - * @param {Function} Test - */ - only(name: string, fn?: Function): ?Promise, - /** - * Skip running this test - * - * @param {string} Name of Test - * @param {Function} Test - */ - skip(name: string, fn?: Function): ?Promise, - /** - * Run the test concurrently - * - * @param {string} Name of Test - * @param {Function} Test - */ - concurrent(name: string, fn?: Function): ?Promise -}; -declare function fit(name: string, fn: Function): ?Promise; -/** An individual test unit */ -declare var test: typeof it; -/** A disabled group of tests */ -declare var xdescribe: typeof describe; -/** A focused group of tests */ -declare var fdescribe: typeof describe; -/** A disabled individual test */ -declare var xit: typeof it; -/** A disabled individual test */ -declare var xtest: typeof it; - -/** The expect function is used every time you want to test a value */ -declare var expect: { - /** The object that you want to make assertions against */ - (value: any): JestExpectType & JestPromiseType, - /** Add additional Jasmine matchers to Jest's roster */ - extend(matchers: { [name: string]: JestMatcher }): void, - /** Add a module that formats application-specific data structures. */ - addSnapshotSerializer(serializer: (input: Object) => string): void, - assertions(expectedAssertions: number): void, - hasAssertions(): void, - any(value: mixed): JestAsymmetricEqualityType, - anything(): void, - arrayContaining(value: Array): void, - objectContaining(value: Object): void, - /** Matches any received string that contains the exact expected string. */ - stringContaining(value: string): void, - stringMatching(value: string | RegExp): void -}; - -// TODO handle return type -// http://jasmine.github.io/2.4/introduction.html#section-Spies -declare function spyOn(value: mixed, method: string): Object; - -/** Holds all functions related to manipulating test runner */ -declare var jest: JestObjectType; - -/** - * The global Jamine object, this is generally not exposed as the public API, - * using features inside here could break in later versions of Jest. - */ -declare var jasmine: { - DEFAULT_TIMEOUT_INTERVAL: number, - any(value: mixed): JestAsymmetricEqualityType, - anything(): void, - arrayContaining(value: Array): void, - clock(): JestClockType, - createSpy(name: string): JestSpyType, - createSpyObj( - baseName: string, - methodNames: Array - ): { [methodName: string]: JestSpyType }, - objectContaining(value: Object): void, - stringMatching(value: string): void -}; diff --git a/flow-typed/npm/jest_v23.x.x.js b/flow-typed/npm/jest_v23.x.x.js new file mode 100644 index 000000000..dbfc9b687 --- /dev/null +++ b/flow-typed/npm/jest_v23.x.x.js @@ -0,0 +1,1146 @@ +// flow-typed signature: 691597c4a5aab83a3b2e6d9ccd01a97d +// flow-typed version: 71534a866d/jest_v23.x.x/flow_>=v0.39.x + +type JestMockFn, TReturn> = { + (...args: TArguments): TReturn, + /** + * An object for introspecting mock calls + */ + mock: { + /** + * An array that represents all calls that have been made into this mock + * function. Each call is represented by an array of arguments that were + * passed during the call. + */ + calls: Array, + /** + * An array that contains all the object instances that have been + * instantiated from this mock function. + */ + instances: Array, + /** + * An array that contains all the object results that have been + * returned by this mock function call + */ + results: Array<{ isThrow: boolean, value: TReturn }> + }, + /** + * Resets all information stored in the mockFn.mock.calls and + * mockFn.mock.instances arrays. Often this is useful when you want to clean + * up a mock's usage data between two assertions. + */ + mockClear(): void, + /** + * Resets all information stored in the mock. This is useful when you want to + * completely restore a mock back to its initial state. + */ + mockReset(): void, + /** + * Removes the mock and restores the initial implementation. This is useful + * when you want to mock functions in certain test cases and restore the + * original implementation in others. Beware that mockFn.mockRestore only + * works when mock was created with jest.spyOn. Thus you have to take care of + * restoration yourself when manually assigning jest.fn(). + */ + mockRestore(): void, + /** + * Accepts a function that should be used as the implementation of the mock. + * The mock itself will still record all calls that go into and instances + * that come from itself -- the only difference is that the implementation + * will also be executed when the mock is called. + */ + mockImplementation( + fn: (...args: TArguments) => TReturn + ): JestMockFn, + /** + * Accepts a function that will be used as an implementation of the mock for + * one call to the mocked function. Can be chained so that multiple function + * calls produce different results. + */ + mockImplementationOnce( + fn: (...args: TArguments) => TReturn + ): JestMockFn, + /** + * Accepts a string to use in test result output in place of "jest.fn()" to + * indicate which mock function is being referenced. + */ + mockName(name: string): JestMockFn, + /** + * Just a simple sugar function for returning `this` + */ + mockReturnThis(): void, + /** + * Accepts a value that will be returned whenever the mock function is called. + */ + mockReturnValue(value: TReturn): JestMockFn, + /** + * Sugar for only returning a value once inside your mock + */ + mockReturnValueOnce(value: TReturn): JestMockFn, + /** + * Sugar for jest.fn().mockImplementation(() => Promise.resolve(value)) + */ + mockResolvedValue(value: TReturn): JestMockFn>, + /** + * Sugar for jest.fn().mockImplementationOnce(() => Promise.resolve(value)) + */ + mockResolvedValueOnce(value: TReturn): JestMockFn>, + /** + * Sugar for jest.fn().mockImplementation(() => Promise.reject(value)) + */ + mockRejectedValue(value: TReturn): JestMockFn>, + /** + * Sugar for jest.fn().mockImplementationOnce(() => Promise.reject(value)) + */ + mockRejectedValueOnce(value: TReturn): JestMockFn> +}; + +type JestAsymmetricEqualityType = { + /** + * A custom Jasmine equality tester + */ + asymmetricMatch(value: mixed): boolean +}; + +type JestCallsType = { + allArgs(): mixed, + all(): mixed, + any(): boolean, + count(): number, + first(): mixed, + mostRecent(): mixed, + reset(): void +}; + +type JestClockType = { + install(): void, + mockDate(date: Date): void, + tick(milliseconds?: number): void, + uninstall(): void +}; + +type JestMatcherResult = { + message?: string | (() => string), + pass: boolean +}; + +type JestMatcher = (actual: any, expected: any) => + | JestMatcherResult + | Promise; + +type JestPromiseType = { + /** + * Use rejects to unwrap the reason of a rejected promise so any other + * matcher can be chained. If the promise is fulfilled the assertion fails. + */ + rejects: JestExpectType, + /** + * Use resolves to unwrap the value of a fulfilled promise so any other + * matcher can be chained. If the promise is rejected the assertion fails. + */ + resolves: JestExpectType +}; + +/** + * Jest allows functions and classes to be used as test names in test() and + * describe() + */ +type JestTestName = string | Function; + +/** + * Plugin: jest-styled-components + */ + +type JestStyledComponentsMatcherValue = + | string + | JestAsymmetricEqualityType + | RegExp + | typeof undefined; + +type JestStyledComponentsMatcherOptions = { + media?: string; + modifier?: string; + supports?: string; +} + +type JestStyledComponentsMatchersType = { + toHaveStyleRule( + property: string, + value: JestStyledComponentsMatcherValue, + options?: JestStyledComponentsMatcherOptions + ): void, +}; + +/** + * Plugin: jest-enzyme + */ +type EnzymeMatchersType = { + // 5.x + toBeEmpty(): void, + toBePresent(): void, + // 6.x + toBeChecked(): void, + toBeDisabled(): void, + toBeEmptyRender(): void, + toContainMatchingElement(selector: string): void; + toContainMatchingElements(n: number, selector: string): void; + toContainExactlyOneMatchingElement(selector: string): void; + toContainReact(element: React$Element): void, + toExist(): void, + toHaveClassName(className: string): void, + toHaveHTML(html: string): void, + toHaveProp: ((propKey: string, propValue?: any) => void) & ((props: Object) => void), + toHaveRef(refName: string): void, + toHaveState: ((stateKey: string, stateValue?: any) => void) & ((state: Object) => void), + toHaveStyle: ((styleKey: string, styleValue?: any) => void) & ((style: Object) => void), + toHaveTagName(tagName: string): void, + toHaveText(text: string): void, + toHaveValue(value: any): void, + toIncludeText(text: string): void, + toMatchElement( + element: React$Element, + options?: {| ignoreProps?: boolean |}, + ): void, + toMatchSelector(selector: string): void +}; + +// DOM testing library extensions https://github.com/kentcdodds/dom-testing-library#custom-jest-matchers +type DomTestingLibraryType = { + toBeInTheDOM(): void, + toHaveTextContent(content: string): void, + toHaveAttribute(name: string, expectedValue?: string): void +}; + +// Jest JQuery Matchers: https://github.com/unindented/custom-jquery-matchers +type JestJQueryMatchersType = { + toExist(): void, + toHaveLength(len: number): void, + toHaveId(id: string): void, + toHaveClass(className: string): void, + toHaveTag(tag: string): void, + toHaveAttr(key: string, val?: any): void, + toHaveProp(key: string, val?: any): void, + toHaveText(text: string | RegExp): void, + toHaveData(key: string, val?: any): void, + toHaveValue(val: any): void, + toHaveCss(css: {[key: string]: any}): void, + toBeChecked(): void, + toBeDisabled(): void, + toBeEmpty(): void, + toBeHidden(): void, + toBeSelected(): void, + toBeVisible(): void, + toBeFocused(): void, + toBeInDom(): void, + toBeMatchedBy(sel: string): void, + toHaveDescendant(sel: string): void, + toHaveDescendantWithText(sel: string, text: string | RegExp): void +}; + + +// Jest Extended Matchers: https://github.com/jest-community/jest-extended +type JestExtendedMatchersType = { + /** + * Note: Currently unimplemented + * Passing assertion + * + * @param {String} message + */ + // pass(message: string): void; + + /** + * Note: Currently unimplemented + * Failing assertion + * + * @param {String} message + */ + // fail(message: string): void; + + /** + * Use .toBeEmpty when checking if a String '', Array [] or Object {} is empty. + */ + toBeEmpty(): void; + + /** + * Use .toBeOneOf when checking if a value is a member of a given Array. + * @param {Array.<*>} members + */ + toBeOneOf(members: any[]): void; + + /** + * Use `.toBeNil` when checking a value is `null` or `undefined`. + */ + toBeNil(): void; + + /** + * Use `.toSatisfy` when you want to use a custom matcher by supplying a predicate function that returns a `Boolean`. + * @param {Function} predicate + */ + toSatisfy(predicate: (n: any) => boolean): void; + + /** + * Use `.toBeArray` when checking if a value is an `Array`. + */ + toBeArray(): void; + + /** + * Use `.toBeArrayOfSize` when checking if a value is an `Array` of size x. + * @param {Number} x + */ + toBeArrayOfSize(x: number): void; + + /** + * Use `.toIncludeAllMembers` when checking if an `Array` contains all of the same members of a given set. + * @param {Array.<*>} members + */ + toIncludeAllMembers(members: any[]): void; + + /** + * Use `.toIncludeAnyMembers` when checking if an `Array` contains any of the members of a given set. + * @param {Array.<*>} members + */ + toIncludeAnyMembers(members: any[]): void; + + /** + * Use `.toSatisfyAll` when you want to use a custom matcher by supplying a predicate function that returns a `Boolean` for all values in an array. + * @param {Function} predicate + */ + toSatisfyAll(predicate: (n: any) => boolean): void; + + /** + * Use `.toBeBoolean` when checking if a value is a `Boolean`. + */ + toBeBoolean(): void; + + /** + * Use `.toBeTrue` when checking a value is equal (===) to `true`. + */ + toBeTrue(): void; + + /** + * Use `.toBeFalse` when checking a value is equal (===) to `false`. + */ + toBeFalse(): void; + + /** + * Use .toBeDate when checking if a value is a Date. + */ + toBeDate(): void; + + /** + * Use `.toBeFunction` when checking if a value is a `Function`. + */ + toBeFunction(): void; + + /** + * Use `.toHaveBeenCalledBefore` when checking if a `Mock` was called before another `Mock`. + * + * Note: Required Jest version >22 + * Note: Your mock functions will have to be asynchronous to cause the timestamps inside of Jest to occur in a differentJS event loop, otherwise the mock timestamps will all be the same + * + * @param {Mock} mock + */ + toHaveBeenCalledBefore(mock: JestMockFn): void; + + /** + * Use `.toBeNumber` when checking if a value is a `Number`. + */ + toBeNumber(): void; + + /** + * Use `.toBeNaN` when checking a value is `NaN`. + */ + toBeNaN(): void; + + /** + * Use `.toBeFinite` when checking if a value is a `Number`, not `NaN` or `Infinity`. + */ + toBeFinite(): void; + + /** + * Use `.toBePositive` when checking if a value is a positive `Number`. + */ + toBePositive(): void; + + /** + * Use `.toBeNegative` when checking if a value is a negative `Number`. + */ + toBeNegative(): void; + + /** + * Use `.toBeEven` when checking if a value is an even `Number`. + */ + toBeEven(): void; + + /** + * Use `.toBeOdd` when checking if a value is an odd `Number`. + */ + toBeOdd(): void; + + /** + * Use `.toBeWithin` when checking if a number is in between the given bounds of: start (inclusive) and end (exclusive). + * + * @param {Number} start + * @param {Number} end + */ + toBeWithin(start: number, end: number): void; + + /** + * Use `.toBeObject` when checking if a value is an `Object`. + */ + toBeObject(): void; + + /** + * Use `.toContainKey` when checking if an object contains the provided key. + * + * @param {String} key + */ + toContainKey(key: string): void; + + /** + * Use `.toContainKeys` when checking if an object has all of the provided keys. + * + * @param {Array.} keys + */ + toContainKeys(keys: string[]): void; + + /** + * Use `.toContainAllKeys` when checking if an object only contains all of the provided keys. + * + * @param {Array.} keys + */ + toContainAllKeys(keys: string[]): void; + + /** + * Use `.toContainAnyKeys` when checking if an object contains at least one of the provided keys. + * + * @param {Array.} keys + */ + toContainAnyKeys(keys: string[]): void; + + /** + * Use `.toContainValue` when checking if an object contains the provided value. + * + * @param {*} value + */ + toContainValue(value: any): void; + + /** + * Use `.toContainValues` when checking if an object contains all of the provided values. + * + * @param {Array.<*>} values + */ + toContainValues(values: any[]): void; + + /** + * Use `.toContainAllValues` when checking if an object only contains all of the provided values. + * + * @param {Array.<*>} values + */ + toContainAllValues(values: any[]): void; + + /** + * Use `.toContainAnyValues` when checking if an object contains at least one of the provided values. + * + * @param {Array.<*>} values + */ + toContainAnyValues(values: any[]): void; + + /** + * Use `.toContainEntry` when checking if an object contains the provided entry. + * + * @param {Array.} entry + */ + toContainEntry(entry: [string, string]): void; + + /** + * Use `.toContainEntries` when checking if an object contains all of the provided entries. + * + * @param {Array.>} entries + */ + toContainEntries(entries: [string, string][]): void; + + /** + * Use `.toContainAllEntries` when checking if an object only contains all of the provided entries. + * + * @param {Array.>} entries + */ + toContainAllEntries(entries: [string, string][]): void; + + /** + * Use `.toContainAnyEntries` when checking if an object contains at least one of the provided entries. + * + * @param {Array.>} entries + */ + toContainAnyEntries(entries: [string, string][]): void; + + /** + * Use `.toBeExtensible` when checking if an object is extensible. + */ + toBeExtensible(): void; + + /** + * Use `.toBeFrozen` when checking if an object is frozen. + */ + toBeFrozen(): void; + + /** + * Use `.toBeSealed` when checking if an object is sealed. + */ + toBeSealed(): void; + + /** + * Use `.toBeString` when checking if a value is a `String`. + */ + toBeString(): void; + + /** + * Use `.toEqualCaseInsensitive` when checking if a string is equal (===) to another ignoring the casing of both strings. + * + * @param {String} string + */ + toEqualCaseInsensitive(string: string): void; + + /** + * Use `.toStartWith` when checking if a `String` starts with a given `String` prefix. + * + * @param {String} prefix + */ + toStartWith(prefix: string): void; + + /** + * Use `.toEndWith` when checking if a `String` ends with a given `String` suffix. + * + * @param {String} suffix + */ + toEndWith(suffix: string): void; + + /** + * Use `.toInclude` when checking if a `String` includes the given `String` substring. + * + * @param {String} substring + */ + toInclude(substring: string): void; + + /** + * Use `.toIncludeRepeated` when checking if a `String` includes the given `String` substring the correct number of times. + * + * @param {String} substring + * @param {Number} times + */ + toIncludeRepeated(substring: string, times: number): void; + + /** + * Use `.toIncludeMultiple` when checking if a `String` includes all of the given substrings. + * + * @param {Array.} substring + */ + toIncludeMultiple(substring: string[]): void; +}; + +interface JestExpectType { + not: + & JestExpectType + & EnzymeMatchersType + & DomTestingLibraryType + & JestJQueryMatchersType + & JestStyledComponentsMatchersType + & JestExtendedMatchersType, + /** + * If you have a mock function, you can use .lastCalledWith to test what + * arguments it was last called with. + */ + lastCalledWith(...args: Array): void, + /** + * toBe just checks that a value is what you expect. It uses === to check + * strict equality. + */ + toBe(value: any): void, + /** + * Use .toBeCalledWith to ensure that a mock function was called with + * specific arguments. + */ + toBeCalledWith(...args: Array): void, + /** + * Using exact equality with floating point numbers is a bad idea. Rounding + * means that intuitive things fail. + */ + toBeCloseTo(num: number, delta: any): void, + /** + * Use .toBeDefined to check that a variable is not undefined. + */ + toBeDefined(): void, + /** + * Use .toBeFalsy when you don't care what a value is, you just want to + * ensure a value is false in a boolean context. + */ + toBeFalsy(): void, + /** + * To compare floating point numbers, you can use toBeGreaterThan. + */ + toBeGreaterThan(number: number): void, + /** + * To compare floating point numbers, you can use toBeGreaterThanOrEqual. + */ + toBeGreaterThanOrEqual(number: number): void, + /** + * To compare floating point numbers, you can use toBeLessThan. + */ + toBeLessThan(number: number): void, + /** + * To compare floating point numbers, you can use toBeLessThanOrEqual. + */ + toBeLessThanOrEqual(number: number): void, + /** + * Use .toBeInstanceOf(Class) to check that an object is an instance of a + * class. + */ + toBeInstanceOf(cls: Class<*>): void, + /** + * .toBeNull() is the same as .toBe(null) but the error messages are a bit + * nicer. + */ + toBeNull(): void, + /** + * Use .toBeTruthy when you don't care what a value is, you just want to + * ensure a value is true in a boolean context. + */ + toBeTruthy(): void, + /** + * Use .toBeUndefined to check that a variable is undefined. + */ + toBeUndefined(): void, + /** + * Use .toContain when you want to check that an item is in a list. For + * testing the items in the list, this uses ===, a strict equality check. + */ + toContain(item: any): void, + /** + * Use .toContainEqual when you want to check that an item is in a list. For + * testing the items in the list, this matcher recursively checks the + * equality of all fields, rather than checking for object identity. + */ + toContainEqual(item: any): void, + /** + * Use .toEqual when you want to check that two objects have the same value. + * This matcher recursively checks the equality of all fields, rather than + * checking for object identity. + */ + toEqual(value: any): void, + /** + * Use .toHaveBeenCalled to ensure that a mock function got called. + */ + toHaveBeenCalled(): void, + toBeCalled(): void; + /** + * Use .toHaveBeenCalledTimes to ensure that a mock function got called exact + * number of times. + */ + toHaveBeenCalledTimes(number: number): void, + toBeCalledTimes(number: number): void; + /** + * + */ + toHaveBeenNthCalledWith(nthCall: number, ...args: Array): void; + nthCalledWith(nthCall: number, ...args: Array): void; + /** + * + */ + toHaveReturned(): void; + toReturn(): void; + /** + * + */ + toHaveReturnedTimes(number: number): void; + toReturnTimes(number: number): void; + /** + * + */ + toHaveReturnedWith(value: any): void; + toReturnWith(value: any): void; + /** + * + */ + toHaveLastReturnedWith(value: any): void; + lastReturnedWith(value: any): void; + /** + * + */ + toHaveNthReturnedWith(nthCall: number, value: any): void; + nthReturnedWith(nthCall: number, value: any): void; + /** + * Use .toHaveBeenCalledWith to ensure that a mock function was called with + * specific arguments. + */ + toHaveBeenCalledWith(...args: Array): void, + toBeCalledWith(...args: Array): void, + /** + * Use .toHaveBeenLastCalledWith to ensure that a mock function was last called + * with specific arguments. + */ + toHaveBeenLastCalledWith(...args: Array): void, + lastCalledWith(...args: Array): void, + /** + * Check that an object has a .length property and it is set to a certain + * numeric value. + */ + toHaveLength(number: number): void, + /** + * + */ + toHaveProperty(propPath: string, value?: any): void, + /** + * Use .toMatch to check that a string matches a regular expression or string. + */ + toMatch(regexpOrString: RegExp | string): void, + /** + * Use .toMatchObject to check that a javascript object matches a subset of the properties of an object. + */ + toMatchObject(object: Object | Array): void, + /** + * Use .toStrictEqual to check that a javascript object matches a subset of the properties of an object. + */ + toStrictEqual(value: any): void, + /** + * This ensures that an Object matches the most recent snapshot. + */ + toMatchSnapshot(propertyMatchers?: any, name?: string): void, + /** + * This ensures that an Object matches the most recent snapshot. + */ + toMatchSnapshot(name: string): void, + + toMatchInlineSnapshot(snapshot?: string): void, + toMatchInlineSnapshot(propertyMatchers?: any, snapshot?: string): void, + /** + * Use .toThrow to test that a function throws when it is called. + * If you want to test that a specific error gets thrown, you can provide an + * argument to toThrow. The argument can be a string for the error message, + * a class for the error, or a regex that should match the error. + * + * Alias: .toThrowError + */ + toThrow(message?: string | Error | Class | RegExp): void, + toThrowError(message?: string | Error | Class | RegExp): void, + /** + * Use .toThrowErrorMatchingSnapshot to test that a function throws a error + * matching the most recent snapshot when it is called. + */ + toThrowErrorMatchingSnapshot(): void, + toThrowErrorMatchingInlineSnapshot(snapshot?: string): void, +} + +type JestObjectType = { + /** + * Disables automatic mocking in the module loader. + * + * After this method is called, all `require()`s will return the real + * versions of each module (rather than a mocked version). + */ + disableAutomock(): JestObjectType, + /** + * An un-hoisted version of disableAutomock + */ + autoMockOff(): JestObjectType, + /** + * Enables automatic mocking in the module loader. + */ + enableAutomock(): JestObjectType, + /** + * An un-hoisted version of enableAutomock + */ + autoMockOn(): JestObjectType, + /** + * Clears the mock.calls and mock.instances properties of all mocks. + * Equivalent to calling .mockClear() on every mocked function. + */ + clearAllMocks(): JestObjectType, + /** + * Resets the state of all mocks. Equivalent to calling .mockReset() on every + * mocked function. + */ + resetAllMocks(): JestObjectType, + /** + * Restores all mocks back to their original value. + */ + restoreAllMocks(): JestObjectType, + /** + * Removes any pending timers from the timer system. + */ + clearAllTimers(): void, + /** + * The same as `mock` but not moved to the top of the expectation by + * babel-jest. + */ + doMock(moduleName: string, moduleFactory?: any): JestObjectType, + /** + * The same as `unmock` but not moved to the top of the expectation by + * babel-jest. + */ + dontMock(moduleName: string): JestObjectType, + /** + * Returns a new, unused mock function. Optionally takes a mock + * implementation. + */ + fn, TReturn>( + implementation?: (...args: TArguments) => TReturn + ): JestMockFn, + /** + * Determines if the given function is a mocked function. + */ + isMockFunction(fn: Function): boolean, + /** + * Given the name of a module, use the automatic mocking system to generate a + * mocked version of the module for you. + */ + genMockFromModule(moduleName: string): any, + /** + * Mocks a module with an auto-mocked version when it is being required. + * + * The second argument can be used to specify an explicit module factory that + * is being run instead of using Jest's automocking feature. + * + * The third argument can be used to create virtual mocks -- mocks of modules + * that don't exist anywhere in the system. + */ + mock( + moduleName: string, + moduleFactory?: any, + options?: Object + ): JestObjectType, + /** + * Returns the actual module instead of a mock, bypassing all checks on + * whether the module should receive a mock implementation or not. + */ + requireActual(moduleName: string): any, + /** + * Returns a mock module instead of the actual module, bypassing all checks + * on whether the module should be required normally or not. + */ + requireMock(moduleName: string): any, + /** + * Resets the module registry - the cache of all required modules. This is + * useful to isolate modules where local state might conflict between tests. + */ + resetModules(): JestObjectType, + /** + * Exhausts the micro-task queue (usually interfaced in node via + * process.nextTick). + */ + runAllTicks(): void, + /** + * Exhausts the macro-task queue (i.e., all tasks queued by setTimeout(), + * setInterval(), and setImmediate()). + */ + runAllTimers(): void, + /** + * Exhausts all tasks queued by setImmediate(). + */ + runAllImmediates(): void, + /** + * Executes only the macro task queue (i.e. all tasks queued by setTimeout() + * or setInterval() and setImmediate()). + */ + advanceTimersByTime(msToRun: number): void, + /** + * Executes only the macro task queue (i.e. all tasks queued by setTimeout() + * or setInterval() and setImmediate()). + * + * Renamed to `advanceTimersByTime`. + */ + runTimersToTime(msToRun: number): void, + /** + * Executes only the macro-tasks that are currently pending (i.e., only the + * tasks that have been queued by setTimeout() or setInterval() up to this + * point) + */ + runOnlyPendingTimers(): void, + /** + * Explicitly supplies the mock object that the module system should return + * for the specified module. Note: It is recommended to use jest.mock() + * instead. + */ + setMock(moduleName: string, moduleExports: any): JestObjectType, + /** + * Indicates that the module system should never return a mocked version of + * the specified module from require() (e.g. that it should always return the + * real module). + */ + unmock(moduleName: string): JestObjectType, + /** + * Instructs Jest to use fake versions of the standard timer functions + * (setTimeout, setInterval, clearTimeout, clearInterval, nextTick, + * setImmediate and clearImmediate). + */ + useFakeTimers(): JestObjectType, + /** + * Instructs Jest to use the real versions of the standard timer functions. + */ + useRealTimers(): JestObjectType, + /** + * Creates a mock function similar to jest.fn but also tracks calls to + * object[methodName]. + */ + spyOn(object: Object, methodName: string, accessType?: "get" | "set"): JestMockFn, + /** + * Set the default timeout interval for tests and before/after hooks in milliseconds. + * Note: The default timeout interval is 5 seconds if this method is not called. + */ + setTimeout(timeout: number): JestObjectType +}; + +type JestSpyType = { + calls: JestCallsType +}; + +/** Runs this function after every test inside this context */ +declare function afterEach( + fn: (done: () => void) => ?Promise, + timeout?: number +): void; +/** Runs this function before every test inside this context */ +declare function beforeEach( + fn: (done: () => void) => ?Promise, + timeout?: number +): void; +/** Runs this function after all tests have finished inside this context */ +declare function afterAll( + fn: (done: () => void) => ?Promise, + timeout?: number +): void; +/** Runs this function before any tests have started inside this context */ +declare function beforeAll( + fn: (done: () => void) => ?Promise, + timeout?: number +): void; + +/** A context for grouping tests together */ +declare var describe: { + /** + * Creates a block that groups together several related tests in one "test suite" + */ + (name: JestTestName, fn: () => void): void, + + /** + * Only run this describe block + */ + only(name: JestTestName, fn: () => void): void, + + /** + * Skip running this describe block + */ + skip(name: JestTestName, fn: () => void): void, + + /** + * each runs this test against array of argument arrays per each run + * + * @param {table} table of Test + */ + each( + table: Array | mixed> + ): ( + name: JestTestName, + fn?: (...args: Array) => ?Promise + ) => void, +}; + +/** An individual test unit */ +declare var it: { + /** + * An individual test unit + * + * @param {JestTestName} Name of Test + * @param {Function} Test + * @param {number} Timeout for the test, in milliseconds. + */ + ( + name: JestTestName, + fn?: (done: () => void) => ?Promise, + timeout?: number + ): void, + /** + * each runs this test against array of argument arrays per each run + * + * @param {table} table of Test + */ + each( + table: Array | mixed> + ): ( + name: JestTestName, + fn?: (...args: Array) => ?Promise + ) => void, + /** + * Only run this test + * + * @param {JestTestName} Name of Test + * @param {Function} Test + * @param {number} Timeout for the test, in milliseconds. + */ + only( + name: JestTestName, + fn?: (done: () => void) => ?Promise, + timeout?: number + ): { + each( + table: Array | mixed> + ): ( + name: JestTestName, + fn?: (...args: Array) => ?Promise + ) => void, + }, + /** + * Skip running this test + * + * @param {JestTestName} Name of Test + * @param {Function} Test + * @param {number} Timeout for the test, in milliseconds. + */ + skip( + name: JestTestName, + fn?: (done: () => void) => ?Promise, + timeout?: number + ): void, + /** + * Run the test concurrently + * + * @param {JestTestName} Name of Test + * @param {Function} Test + * @param {number} Timeout for the test, in milliseconds. + */ + concurrent( + name: JestTestName, + fn?: (done: () => void) => ?Promise, + timeout?: number + ): void, + /** + * each runs this test against array of argument arrays per each run + * + * @param {table} table of Test + */ + each( + table: Array | mixed> + ): ( + name: JestTestName, + fn?: (...args: Array) => ?Promise + ) => void, +}; +declare function fit( + name: JestTestName, + fn: (done: () => void) => ?Promise, + timeout?: number +): void; +/** An individual test unit */ +declare var test: typeof it; +/** A disabled group of tests */ +declare var xdescribe: typeof describe; +/** A focused group of tests */ +declare var fdescribe: typeof describe; +/** A disabled individual test */ +declare var xit: typeof it; +/** A disabled individual test */ +declare var xtest: typeof it; + +type JestPrettyFormatColors = { + comment: { close: string, open: string }, + content: { close: string, open: string }, + prop: { close: string, open: string }, + tag: { close: string, open: string }, + value: { close: string, open: string }, +}; + +type JestPrettyFormatIndent = string => string; +type JestPrettyFormatRefs = Array; +type JestPrettyFormatPrint = any => string; +type JestPrettyFormatStringOrNull = string | null; + +type JestPrettyFormatOptions = {| + callToJSON: boolean, + edgeSpacing: string, + escapeRegex: boolean, + highlight: boolean, + indent: number, + maxDepth: number, + min: boolean, + plugins: JestPrettyFormatPlugins, + printFunctionName: boolean, + spacing: string, + theme: {| + comment: string, + content: string, + prop: string, + tag: string, + value: string, + |}, +|}; + +type JestPrettyFormatPlugin = { + print: ( + val: any, + serialize: JestPrettyFormatPrint, + indent: JestPrettyFormatIndent, + opts: JestPrettyFormatOptions, + colors: JestPrettyFormatColors, + ) => string, + test: any => boolean, +}; + +type JestPrettyFormatPlugins = Array; + +/** The expect function is used every time you want to test a value */ +declare var expect: { + /** The object that you want to make assertions against */ + (value: any): + & JestExpectType + & JestPromiseType + & EnzymeMatchersType + & DomTestingLibraryType + & JestJQueryMatchersType + & JestStyledComponentsMatchersType + & JestExtendedMatchersType, + + /** Add additional Jasmine matchers to Jest's roster */ + extend(matchers: { [name: string]: JestMatcher }): void, + /** Add a module that formats application-specific data structures. */ + addSnapshotSerializer(pluginModule: JestPrettyFormatPlugin): void, + assertions(expectedAssertions: number): void, + hasAssertions(): void, + any(value: mixed): JestAsymmetricEqualityType, + anything(): any, + arrayContaining(value: Array): Array, + objectContaining(value: Object): Object, + /** Matches any received string that contains the exact expected string. */ + stringContaining(value: string): string, + stringMatching(value: string | RegExp): string, + not: { + arrayContaining: (value: $ReadOnlyArray) => Array, + objectContaining: (value: {}) => Object, + stringContaining: (value: string) => string, + stringMatching: (value: string | RegExp) => string, + }, +}; + +// TODO handle return type +// http://jasmine.github.io/2.4/introduction.html#section-Spies +declare function spyOn(value: mixed, method: string): Object; + +/** Holds all functions related to manipulating test runner */ +declare var jest: JestObjectType; + +/** + * The global Jasmine object, this is generally not exposed as the public API, + * using features inside here could break in later versions of Jest. + */ +declare var jasmine: { + DEFAULT_TIMEOUT_INTERVAL: number, + any(value: mixed): JestAsymmetricEqualityType, + anything(): any, + arrayContaining(value: Array): Array, + clock(): JestClockType, + createSpy(name: string): JestSpyType, + createSpyObj( + baseName: string, + methodNames: Array + ): { [methodName: string]: JestSpyType }, + objectContaining(value: Object): Object, + stringMatching(value: string): string +}; diff --git a/flow-typed/npm/mkdirp_v0.5.x.js b/flow-typed/npm/mkdirp_v0.5.x.js new file mode 100644 index 000000000..e26f9a4be --- /dev/null +++ b/flow-typed/npm/mkdirp_v0.5.x.js @@ -0,0 +1,13 @@ +// flow-typed signature: 82aa0feffc2bbd64dce3bec492f5d601 +// flow-typed version: 3315d89a00/mkdirp_v0.5.x/flow_>=v0.25.0 + +declare module 'mkdirp' { + declare type Options = number | { mode?: number; fs?: mixed }; + + declare type Callback = (err: ?Error, path: ?string) => void; + + declare module.exports: { + (path: string, options?: Options | Callback, callback?: Callback): void; + sync(path: string, options?: Options): void; + }; +} diff --git a/flow-typed/npm/npm-run-all_vx.x.x.js b/flow-typed/npm/npm-run-all_vx.x.x.js index cf64a2e79..8f2ac1e02 100644 --- a/flow-typed/npm/npm-run-all_vx.x.x.js +++ b/flow-typed/npm/npm-run-all_vx.x.x.js @@ -1,5 +1,5 @@ -// flow-typed signature: 7c4e18e05f6fdfb83bdd8f8f0a84bdd9 -// flow-typed version: <>/npm-run-all_v^4.0.1/flow_v0.47.0 +// flow-typed signature: f56668ade016b4cece81a1bd7dea5136 +// flow-typed version: <>/npm-run-all_v^4.1.3/flow_v0.80.0 /** * This is an autogenerated libdef stub for: diff --git a/flow-typed/npm/prettier_v1.x.x.js b/flow-typed/npm/prettier_v1.x.x.js new file mode 100644 index 000000000..0c2449152 --- /dev/null +++ b/flow-typed/npm/prettier_v1.x.x.js @@ -0,0 +1,178 @@ +// flow-typed signature: 4eed8da2dc730dc33e7710b465eaa44b +// flow-typed version: cc7a557b34/prettier_v1.x.x/flow_>=v0.56.x + +declare module "prettier" { + declare type AST = Object; + declare type Doc = Object; + declare type FastPath = Object; + + declare type PrettierParserName = + | "babylon" + | "flow" + | "typescript" + | "postcss" + | "css" + | "less" + | "scss" + | "json" + | "graphql" + | "markdown" + | "vue"; + + declare type PrettierParser = { + [name: PrettierParserName]: (text: string, options?: Object) => AST + }; + + declare type CustomParser = ( + text: string, + parsers: PrettierParser, + options: Options + ) => AST; + + declare type Options = {| + printWidth?: number, + tabWidth?: number, + useTabs?: boolean, + semi?: boolean, + singleQuote?: boolean, + trailingComma?: "none" | "es5" | "all", + bracketSpacing?: boolean, + jsxBracketSameLine?: boolean, + arrowParens?: "avoid" | "always", + rangeStart?: number, + rangeEnd?: number, + parser?: PrettierParserName | CustomParser, + filepath?: string, + requirePragma?: boolean, + insertPragma?: boolean, + proseWrap?: "always" | "never" | "preserve", + plugins?: Array + |}; + + declare type Plugin = { + languages: SupportLanguage, + parsers: { [parserName: string]: Parser }, + printers: { [astFormat: string]: Printer } + }; + + declare type Parser = { + parse: ( + text: string, + parsers: { [parserName: string]: Parser }, + options: Object + ) => AST, + astFormat: string + }; + + declare type Printer = { + print: ( + path: FastPath, + options: Object, + print: (path: FastPath) => Doc + ) => Doc, + embed: ( + path: FastPath, + print: (path: FastPath) => Doc, + textToDoc: (text: string, options: Object) => Doc, + options: Object + ) => ?Doc + }; + + declare type CursorOptions = {| + cursorOffset: number, + printWidth?: $PropertyType, + tabWidth?: $PropertyType, + useTabs?: $PropertyType, + semi?: $PropertyType, + singleQuote?: $PropertyType, + trailingComma?: $PropertyType, + bracketSpacing?: $PropertyType, + jsxBracketSameLine?: $PropertyType, + arrowParens?: $PropertyType, + parser?: $PropertyType, + filepath?: $PropertyType, + requirePragma?: $PropertyType, + insertPragma?: $PropertyType, + proseWrap?: $PropertyType, + plugins?: $PropertyType + |}; + + declare type CursorResult = {| + formatted: string, + cursorOffset: number + |}; + + declare type ResolveConfigOptions = {| + useCache?: boolean, + config?: string, + editorconfig?: boolean + |}; + + declare type SupportLanguage = { + name: string, + since: string, + parsers: Array, + group?: string, + tmScope: string, + aceMode: string, + codemirrorMode: string, + codemirrorMimeType: string, + aliases?: Array, + extensions: Array, + filenames?: Array, + linguistLanguageId: number, + vscodeLanguageIds: Array + }; + + declare type SupportOption = {| + since: string, + type: "int" | "boolean" | "choice" | "path", + deprecated?: string, + redirect?: SupportOptionRedirect, + description: string, + oppositeDescription?: string, + default: SupportOptionValue, + range?: SupportOptionRange, + choices?: SupportOptionChoice + |}; + + declare type SupportOptionRedirect = {| + options: string, + value: SupportOptionValue + |}; + + declare type SupportOptionRange = {| + start: number, + end: number, + step: number + |}; + + declare type SupportOptionChoice = {| + value: boolean | string, + description?: string, + since?: string, + deprecated?: string, + redirect?: SupportOptionValue + |}; + + declare type SupportOptionValue = number | boolean | string; + + declare type SupportInfo = {| + languages: Array, + options: Array + |}; + + declare type Prettier = {| + format: (source: string, options?: Options) => string, + check: (source: string, options?: Options) => boolean, + formatWithCursor: (source: string, options: CursorOptions) => CursorResult, + resolveConfig: { + (filePath: string, options?: ResolveConfigOptions): Promise, + sync(filePath: string, options?: ResolveConfigOptions): Promise + }, + clearConfigCache: () => void, + getSupportInfo: (version?: string) => SupportInfo + |}; + + declare export default Prettier; +} diff --git a/flow-typed/npm/prettier_vx.x.x.js b/flow-typed/npm/prettier_vx.x.x.js deleted file mode 100644 index a309587f3..000000000 --- a/flow-typed/npm/prettier_vx.x.x.js +++ /dev/null @@ -1,66 +0,0 @@ -// flow-typed signature: 8769bb658eae9016290c1e6921b94232 -// flow-typed version: <>/prettier_v^1.4.2/flow_v0.47.0 - -/** - * This is an autogenerated libdef stub for: - * - * 'prettier' - * - * Fill this stub out by replacing all the `any` types. - * - * Once filled out, we encourage you to share your work with the - * community by sending a pull request to: - * https://github.com/flowtype/flow-typed - */ - -declare module 'prettier' { - declare module.exports: any; -} - -/** - * We include stubs for each file inside this npm package in case you need to - * require those files directly. Feel free to delete any files that aren't - * needed. - */ -declare module 'prettier/bin/prettier' { - declare module.exports: any; -} - -declare module 'prettier/src/parser-babylon' { - declare module.exports: any; -} - -declare module 'prettier/src/parser-flow' { - declare module.exports: any; -} - -declare module 'prettier/src/parser-postcss' { - declare module.exports: any; -} - -declare module 'prettier/src/parser-typescript' { - declare module.exports: any; -} - -// Filename aliases -declare module 'prettier/bin/prettier.js' { - declare module.exports: $Exports<'prettier/bin/prettier'>; -} -declare module 'prettier/index' { - declare module.exports: $Exports<'prettier'>; -} -declare module 'prettier/index.js' { - declare module.exports: $Exports<'prettier'>; -} -declare module 'prettier/src/parser-babylon.js' { - declare module.exports: $Exports<'prettier/src/parser-babylon'>; -} -declare module 'prettier/src/parser-flow.js' { - declare module.exports: $Exports<'prettier/src/parser-flow'>; -} -declare module 'prettier/src/parser-postcss.js' { - declare module.exports: $Exports<'prettier/src/parser-postcss'>; -} -declare module 'prettier/src/parser-typescript.js' { - declare module.exports: $Exports<'prettier/src/parser-typescript'>; -} diff --git a/flow-typed/npm/rimraf_v2.x.x.js b/flow-typed/npm/rimraf_v2.x.x.js new file mode 100644 index 000000000..13b85249c --- /dev/null +++ b/flow-typed/npm/rimraf_v2.x.x.js @@ -0,0 +1,18 @@ +// flow-typed signature: 1dff23447d5e18f5ac2b05aaec7cfb74 +// flow-typed version: a453e98ea2/rimraf_v2.x.x/flow_>=v0.25.0 + +declare module 'rimraf' { + declare type Options = { + maxBusyTries?: number, + emfileWait?: number, + glob?: boolean, + disableGlob?: boolean + }; + + declare type Callback = (err: ?Error, path: ?string) => void; + + declare module.exports: { + (f: string, opts?: Options | Callback, callback?: Callback): void; + sync(path: string, opts?: Options): void; + }; +} diff --git a/flow-typed/npm/rimraf_vx.x.x.js b/flow-typed/npm/rimraf_vx.x.x.js deleted file mode 100644 index 56f50e0c7..000000000 --- a/flow-typed/npm/rimraf_vx.x.x.js +++ /dev/null @@ -1,39 +0,0 @@ -// flow-typed signature: 5b18a997bba2338d0958ada6f1db4d19 -// flow-typed version: <>/rimraf_v^2.5.4/flow_v0.47.0 - -/** - * This is an autogenerated libdef stub for: - * - * 'rimraf' - * - * Fill this stub out by replacing all the `any` types. - * - * Once filled out, we encourage you to share your work with the - * community by sending a pull request to: - * https://github.com/flowtype/flow-typed - */ - -declare module 'rimraf' { - declare module.exports: any; -} - -/** - * We include stubs for each file inside this npm package in case you need to - * require those files directly. Feel free to delete any files that aren't - * needed. - */ -declare module 'rimraf/bin' { - declare module.exports: any; -} - -declare module 'rimraf/rimraf' { - declare module.exports: any; -} - -// Filename aliases -declare module 'rimraf/bin.js' { - declare module.exports: $Exports<'rimraf/bin'>; -} -declare module 'rimraf/rimraf.js' { - declare module.exports: $Exports<'rimraf/rimraf'>; -} diff --git a/flow-typed/npm/semantic-release_vx.x.x.js b/flow-typed/npm/semantic-release_vx.x.x.js index e8132f907..766aed397 100644 --- a/flow-typed/npm/semantic-release_vx.x.x.js +++ b/flow-typed/npm/semantic-release_vx.x.x.js @@ -1,5 +1,5 @@ -// flow-typed signature: 4afebfe8b27973c18cd40ad5dc9324fb -// flow-typed version: <>/semantic-release_v^6.3.6/flow_v0.47.0 +// flow-typed signature: fd55a816a45d907ab90d2ceebffe1a37 +// flow-typed version: <>/semantic-release_v^15.9.15/flow_v0.80.0 /** * This is an autogenerated libdef stub for: @@ -26,35 +26,79 @@ declare module 'semantic-release/bin/semantic-release' { declare module.exports: any; } -declare module 'semantic-release/src/lib/commits' { +declare module 'semantic-release/cli' { declare module.exports: any; } -declare module 'semantic-release/src/lib/get-registry' { +declare module 'semantic-release/lib/definitions/constants' { declare module.exports: any; } -declare module 'semantic-release/src/lib/plugin-noop' { +declare module 'semantic-release/lib/definitions/errors' { declare module.exports: any; } -declare module 'semantic-release/src/lib/plugins' { +declare module 'semantic-release/lib/definitions/plugins' { declare module.exports: any; } -declare module 'semantic-release/src/lib/type' { +declare module 'semantic-release/lib/get-commits' { declare module.exports: any; } -declare module 'semantic-release/src/lib/verify' { +declare module 'semantic-release/lib/get-config' { declare module.exports: any; } -declare module 'semantic-release/src/post' { +declare module 'semantic-release/lib/get-error' { declare module.exports: any; } -declare module 'semantic-release/src/pre' { +declare module 'semantic-release/lib/get-git-auth-url' { + declare module.exports: any; +} + +declare module 'semantic-release/lib/get-last-release' { + declare module.exports: any; +} + +declare module 'semantic-release/lib/get-logger' { + declare module.exports: any; +} + +declare module 'semantic-release/lib/get-next-version' { + declare module.exports: any; +} + +declare module 'semantic-release/lib/git' { + declare module.exports: any; +} + +declare module 'semantic-release/lib/hide-sensitive' { + declare module.exports: any; +} + +declare module 'semantic-release/lib/plugins/index' { + declare module.exports: any; +} + +declare module 'semantic-release/lib/plugins/normalize' { + declare module.exports: any; +} + +declare module 'semantic-release/lib/plugins/pipeline' { + declare module.exports: any; +} + +declare module 'semantic-release/lib/plugins/utils' { + declare module.exports: any; +} + +declare module 'semantic-release/lib/utils' { + declare module.exports: any; +} + +declare module 'semantic-release/lib/verify' { declare module.exports: any; } @@ -62,27 +106,66 @@ declare module 'semantic-release/src/pre' { declare module 'semantic-release/bin/semantic-release.js' { declare module.exports: $Exports<'semantic-release/bin/semantic-release'>; } -declare module 'semantic-release/src/lib/commits.js' { - declare module.exports: $Exports<'semantic-release/src/lib/commits'>; +declare module 'semantic-release/cli.js' { + declare module.exports: $Exports<'semantic-release/cli'>; +} +declare module 'semantic-release/index' { + declare module.exports: $Exports<'semantic-release'>; +} +declare module 'semantic-release/index.js' { + declare module.exports: $Exports<'semantic-release'>; +} +declare module 'semantic-release/lib/definitions/constants.js' { + declare module.exports: $Exports<'semantic-release/lib/definitions/constants'>; +} +declare module 'semantic-release/lib/definitions/errors.js' { + declare module.exports: $Exports<'semantic-release/lib/definitions/errors'>; +} +declare module 'semantic-release/lib/definitions/plugins.js' { + declare module.exports: $Exports<'semantic-release/lib/definitions/plugins'>; +} +declare module 'semantic-release/lib/get-commits.js' { + declare module.exports: $Exports<'semantic-release/lib/get-commits'>; +} +declare module 'semantic-release/lib/get-config.js' { + declare module.exports: $Exports<'semantic-release/lib/get-config'>; +} +declare module 'semantic-release/lib/get-error.js' { + declare module.exports: $Exports<'semantic-release/lib/get-error'>; +} +declare module 'semantic-release/lib/get-git-auth-url.js' { + declare module.exports: $Exports<'semantic-release/lib/get-git-auth-url'>; +} +declare module 'semantic-release/lib/get-last-release.js' { + declare module.exports: $Exports<'semantic-release/lib/get-last-release'>; +} +declare module 'semantic-release/lib/get-logger.js' { + declare module.exports: $Exports<'semantic-release/lib/get-logger'>; +} +declare module 'semantic-release/lib/get-next-version.js' { + declare module.exports: $Exports<'semantic-release/lib/get-next-version'>; +} +declare module 'semantic-release/lib/git.js' { + declare module.exports: $Exports<'semantic-release/lib/git'>; } -declare module 'semantic-release/src/lib/get-registry.js' { - declare module.exports: $Exports<'semantic-release/src/lib/get-registry'>; +declare module 'semantic-release/lib/hide-sensitive.js' { + declare module.exports: $Exports<'semantic-release/lib/hide-sensitive'>; } -declare module 'semantic-release/src/lib/plugin-noop.js' { - declare module.exports: $Exports<'semantic-release/src/lib/plugin-noop'>; +declare module 'semantic-release/lib/plugins/index.js' { + declare module.exports: $Exports<'semantic-release/lib/plugins/index'>; } -declare module 'semantic-release/src/lib/plugins.js' { - declare module.exports: $Exports<'semantic-release/src/lib/plugins'>; +declare module 'semantic-release/lib/plugins/normalize.js' { + declare module.exports: $Exports<'semantic-release/lib/plugins/normalize'>; } -declare module 'semantic-release/src/lib/type.js' { - declare module.exports: $Exports<'semantic-release/src/lib/type'>; +declare module 'semantic-release/lib/plugins/pipeline.js' { + declare module.exports: $Exports<'semantic-release/lib/plugins/pipeline'>; } -declare module 'semantic-release/src/lib/verify.js' { - declare module.exports: $Exports<'semantic-release/src/lib/verify'>; +declare module 'semantic-release/lib/plugins/utils.js' { + declare module.exports: $Exports<'semantic-release/lib/plugins/utils'>; } -declare module 'semantic-release/src/post.js' { - declare module.exports: $Exports<'semantic-release/src/post'>; +declare module 'semantic-release/lib/utils.js' { + declare module.exports: $Exports<'semantic-release/lib/utils'>; } -declare module 'semantic-release/src/pre.js' { - declare module.exports: $Exports<'semantic-release/src/pre'>; +declare module 'semantic-release/lib/verify.js' { + declare module.exports: $Exports<'semantic-release/lib/verify'>; } diff --git a/flow-typed/npm/tmp_vx.x.x.js b/flow-typed/npm/tmp_vx.x.x.js index f70049aab..df87d9fa2 100644 --- a/flow-typed/npm/tmp_vx.x.x.js +++ b/flow-typed/npm/tmp_vx.x.x.js @@ -1,5 +1,5 @@ -// flow-typed signature: 6a7199b5b1fc83a3692ef2d6bc31a366 -// flow-typed version: <>/tmp_v^0.0.31/flow_v0.47.0 +// flow-typed signature: 1819da40df28179099d945a395127fdd +// flow-typed version: <>/tmp_v^0.0.33/flow_v0.80.0 /** * This is an autogenerated libdef stub for: diff --git a/flow-typed/npm/uuid_v3.x.x.js b/flow-typed/npm/uuid_v3.x.x.js index 0bf919501..bf8d507b3 100644 --- a/flow-typed/npm/uuid_v3.x.x.js +++ b/flow-typed/npm/uuid_v3.x.x.js @@ -1,15 +1,102 @@ -// flow-typed signature: c07f382c8238bb78e545b60dd4f097a6 -// flow-typed version: 27f92307d3/uuid_v3.x.x/flow_>=v0.33.x - -declare module 'uuid' { - declare function v1(options?: {| - node?: number[], - clockseq?: number, - msecs?: number | Date, - nsecs?: number, - |}, buffer?: number[] | Buffer, offset?: number): string; - declare function v4(options?: {| - random?: number[], - rng?: () => number[] | Buffer, - |}, buffer?: number[] | Buffer, offset?: number): string; +// flow-typed signature: 3cf668e64747095cab0bb360cf2fb34f +// flow-typed version: d659bd0cb8/uuid_v3.x.x/flow_>=v0.32.x + +declare module "uuid" { + declare class uuid { + static ( + options?: {| + random?: number[], + rng?: () => number[] | Buffer + |}, + buffer?: number[] | Buffer, + offset?: number + ): string, + + static v1( + options?: {| + node?: number[], + clockseq?: number, + msecs?: number | Date, + nsecs?: number + |}, + buffer?: number[] | Buffer, + offset?: number + ): string, + + static v4( + options?: {| + random?: number[], + rng?: () => number[] | Buffer + |}, + buffer?: number[] | Buffer, + offset?: number + ): string + } + declare module.exports: Class; +} + +declare module "uuid/v1" { + declare class v1 { + static ( + options?: {| + node?: number[], + clockseq?: number, + msecs?: number | Date, + nsecs?: number + |}, + buffer?: number[] | Buffer, + offset?: number + ): string + } + + declare module.exports: Class; +} + +declare module "uuid/v3" { + declare class v3 { + static ( + name?: string | number[], + namespace?: string | number[], + buffer?: number[] | Buffer, + offset?: number + ): string, + + static name: string, + static DNS: string, + static URL: string + } + + declare module.exports: Class; +} + +declare module "uuid/v4" { + declare class v4 { + static ( + options?: {| + random?: number[], + rng?: () => number[] | Buffer + |}, + buffer?: number[] | Buffer, + offset?: number + ): string + } + + declare module.exports: Class; +} + +declare module "uuid/v5" { + declare class v5 { + static ( + name?: string | number[], + namespace?: string | number[], + buffer?: number[] | Buffer, + offset?: number + ): string, + + static name: string, + static DNS: string, + static URL: string + } + + declare module.exports: Class; } From 8549c56f72eda3f8f3731e4b12690ada8b92f762 Mon Sep 17 00:00:00 2001 From: Jarom Loveridge Date: Thu, 27 Sep 2018 22:05:54 -0600 Subject: [PATCH 2/6] chore(types): Make flow and TypeScript types a bit more specific. --- src/MongoMemoryServer.d.ts | 24 ++++++++++------------ src/MongoMemoryServer.js | 22 +++++++++----------- src/types.d.ts | 19 ++++++++++++++++++ src/types.js | 30 ++++++++++++++++++++++++++++ src/util/MongoBinary.d.ts | 4 +++- src/util/MongoBinaryDownload.d.ts | 15 +++++--------- src/util/MongoBinaryDownload.js | 14 ++++--------- src/util/MongoBinaryDownloadUrl.d.ts | 27 +++++++++++++++---------- src/util/MongoBinaryDownloadUrl.js | 29 +++++++++++---------------- src/util/MongoInstance.d.ts | 26 +++++++++--------------- src/util/MongoInstance.js | 19 +++++------------- 11 files changed, 122 insertions(+), 107 deletions(-) create mode 100644 src/types.d.ts create mode 100644 src/types.js diff --git a/src/MongoMemoryServer.d.ts b/src/MongoMemoryServer.d.ts index 8d3bbda54..e42d75ada 100644 --- a/src/MongoMemoryServer.d.ts +++ b/src/MongoMemoryServer.d.ts @@ -1,28 +1,24 @@ /// -import { ChildProcess } from 'child_process'; +import { ChildProcess, SpawnOptions } from 'child_process'; import MongoInstance from './util/MongoInstance'; +import { MongoBinaryOpts } from './util/MongoBinary'; +import { CallbackFn, DebugFn, DebugPropT, StorageEngineT } from './types'; export interface MongoMemoryServerOptsT { instance: { port?: number; dbPath?: string; dbName?: string; - storageEngine?: string; - debug?: boolean | ((...args: any[]) => any); + storageEngine?: StorageEngineT; + debug?: DebugPropT; replSet?: string; auth?: boolean; args?: string[]; }; - binary: { - version?: string; - downloadDir?: string; - platform?: string; - arch?: string; - debug?: boolean | ((...args: any[]) => any); - }; + binary: MongoBinaryOpts; debug?: boolean; - spawn: any; + spawn: SpawnOptions; autoStart?: boolean; } @@ -31,12 +27,12 @@ export interface MongoInstanceDataT { dbPath: string; dbName: string; uri: string; - storageEngine: string; + storageEngine: StorageEngineT; instance: MongoInstance; childProcess: ChildProcess; tmpDir?: { name: string; - removeCallback: ((...args: any[]) => any); + removeCallback: CallbackFn; }; replSet?: string; } @@ -45,7 +41,7 @@ export default class MongoMemoryServer { isRunning: boolean; runningInstance: Promise | undefined; opts: MongoMemoryServerOptsT; - debug: ((...args: any[]) => any); + debug: DebugFn; constructor(opts?: Partial); diff --git a/src/MongoMemoryServer.js b/src/MongoMemoryServer.js index 6cda36e4a..8085db693 100644 --- a/src/MongoMemoryServer.js +++ b/src/MongoMemoryServer.js @@ -6,6 +6,8 @@ import tmp from 'tmp'; import getport from 'get-port'; import Debug from 'debug'; import MongoInstance from './util/MongoInstance'; +import type { MongoBinaryOpts } from './util/MongoBinary'; +import type { CallbackFn, DebugFn, DebugPropT, SpawnOptions, StorageEngineT } from './types'; tmp.setGracefulCleanup(); @@ -15,21 +17,15 @@ export type MongoMemoryServerOptsT = { ip?: string, // for binding to all IP addresses set it to `::,0.0.0.0`, by default '127.0.0.1' dbPath?: string, dbName?: string, - storageEngine?: string, - debug?: boolean | Function, + storageEngine?: StorageEngineT, + debug?: DebugPropT, replSet?: string, args?: string[], auth?: boolean, }, - binary: { - version?: string, - downloadDir?: string, - platform?: string, - arch?: string, - debug?: boolean | Function, - }, + binary: MongoBinaryOpts, debug?: boolean, - spawn: any, + spawn: SpawnOptions, autoStart?: boolean, }; @@ -38,12 +34,12 @@ export type MongoInstanceDataT = { dbPath: string, dbName: string, uri: string, - storageEngine: string, + storageEngine: StorageEngineT, instance: MongoInstance, childProcess: ChildProcess, tmpDir?: { name: string, - removeCallback: Function, + removeCallback: CallbackFn, }, replSet?: string, }; @@ -60,7 +56,7 @@ export default class MongoMemoryServer { isRunning: boolean = false; runningInstance: ?Promise; opts: MongoMemoryServerOptsT; - debug: Function; + debug: DebugFn; constructor(opts?: $Shape = {}) { this.opts = opts; diff --git a/src/types.d.ts b/src/types.d.ts new file mode 100644 index 000000000..95a6ec652 --- /dev/null +++ b/src/types.d.ts @@ -0,0 +1,19 @@ +/// + +// These types are used internally to the module. + +export type DebugFn = (...args: any[]) => any; +export type DebugPropT = boolean | DebugFn; + +export interface DownloadProgressT { + current: number; + length: number; + totalMb: number; + lastPrintedAt: number; +} + +export type CallbackFn = (...args: any[]) => any; + +export { SpawnOptions } from 'child_process'; + +export type StorageEngineT = 'devnull' | 'ephemeralForTest' | 'mmapv1' | 'wiredTiger'; diff --git a/src/types.js b/src/types.js new file mode 100644 index 000000000..a0ab2d1bd --- /dev/null +++ b/src/types.js @@ -0,0 +1,30 @@ +// @flow +export type DebugFn = (...args: any[]) => any; +export type DebugPropT = boolean | DebugFn; + +export type DownloadProgressT = { + current: number, + length: number, + totalMb: number, + lastPrintedAt: number, +}; + +export type CallbackFn = (...args: any[]) => any; + +/** + * Adapted from the TypeScript definition for node since flow doens't seem to know about these types. + */ +export interface SpawnOptions { + cwd?: string; + env?: {}; + argv0?: string; + stdio?: string | any[]; + detached?: boolean; + uid?: number; + gid?: number; + shell?: boolean | string; + windowsVerbatimArguments?: boolean; + windowsHide?: boolean; +} + +export type StorageEngineT = 'devnull' | 'ephemeralForTest' | 'mmapv1' | 'wiredTiger'; diff --git a/src/util/MongoBinary.d.ts b/src/util/MongoBinary.d.ts index d0dfc348e..814a19665 100644 --- a/src/util/MongoBinary.d.ts +++ b/src/util/MongoBinary.d.ts @@ -1,3 +1,5 @@ +import { DebugPropT } from '../types'; + export interface MongoBinaryCache { [version: string]: string; } @@ -7,7 +9,7 @@ export interface MongoBinaryOpts { downloadDir?: string; platform?: string; arch?: string; - debug?: boolean | ((...args: any[]) => any); + debug?: DebugPropT; } // disable error for a class with all static functions, diff --git a/src/util/MongoBinaryDownload.d.ts b/src/util/MongoBinaryDownload.d.ts index fa29ac8e2..649387374 100644 --- a/src/util/MongoBinaryDownload.d.ts +++ b/src/util/MongoBinaryDownload.d.ts @@ -1,21 +1,16 @@ +import { DebugPropT, DebugFn, DownloadProgressT } from '../types'; + export interface MongoBinaryDownloadOpts { version: string; downloadDir: string; platform: string; arch: string; - debug?: boolean | Function; -} - -interface dlProgress { // tslint:disable-line - current: number; - length: number; - totalMb: number; - lastPrintedAt: number; + debug?: DebugPropT; } export default class MongoBinaryDownload { - debug: Function; - dlProgress: dlProgress; + debug: DebugFn; + dlProgress: DownloadProgressT; downloadDir: string; arch: string; diff --git a/src/util/MongoBinaryDownload.js b/src/util/MongoBinaryDownload.js index fc9eda7e3..e042d5a7b 100644 --- a/src/util/MongoBinaryDownload.js +++ b/src/util/MongoBinaryDownload.js @@ -10,25 +10,19 @@ import https from 'https'; import HttpsProxyAgent from 'https-proxy-agent'; import decompress from 'decompress'; import MongoBinaryDownloadUrl from './MongoBinaryDownloadUrl'; +import type { DebugFn, DebugPropT, DownloadProgressT } from '../types'; export type MongoBinaryDownloadOpts = { version: string, downloadDir: string, platform: string, arch: string, - debug?: boolean | Function, -}; - -type dlProgress = { - current: number, - length: number, - totalMb: number, - lastPrintedAt: number, + debug?: DebugPropT, }; export default class MongoBinaryDownload { - debug: Function; - dlProgress: dlProgress; + debug: DebugFn; + dlProgress: DownloadProgressT; downloadDir: string; arch: string; diff --git a/src/util/MongoBinaryDownloadUrl.d.ts b/src/util/MongoBinaryDownloadUrl.d.ts index bc0987a77..278b8179d 100644 --- a/src/util/MongoBinaryDownloadUrl.d.ts +++ b/src/util/MongoBinaryDownloadUrl.d.ts @@ -1,30 +1,35 @@ /// -import {Os as OS} from 'getos'; +import * as getos from 'getos'; export interface MongoBinaryDownloadUrlOpts { version: string; platform: string; arch: string; - os?: OS; // getos() result + os?: getos.Os | null; // getos() result } export default class MongoBinaryDownloadUrl { + platform: string; + arch: string; + version: string; + os: getos.Os | null | undefined; + constructor(opts: MongoBinaryDownloadUrlOpts); getDownloadUrl(): Promise; getArchiveName(): Promise; getArchiveNameWin(): Promise; getArchiveNameOsx(): Promise; getArchiveNameLinux(): Promise; - getos(): Promise; - getLinuxOSVersionString(os: OS): string; - getDebianVersionString(os: OS): string; - getFedoraVersionString(os: OS): string; - getRhelVersionString(os: OS): string; - getElementaryOSVersionString(os: OS): string; - getLegacyVersionString(os: OS): string; - getSuseVersionString(os: any): string; - getUbuntuVersionString(os: OS): string; + getos(): Promise; + getLinuxOSVersionString(os: getos.Os): string; + getDebianVersionString(os: getos.Os): string; + getFedoraVersionString(os: getos.Os): string; + getRhelVersionString(os: getos.Os): string; + getElementaryOSVersionString(os: getos.Os): string; + getLegacyVersionString(os: getos.Os): string; + getSuseVersionString(os: getos.Os): string; + getUbuntuVersionString(os: getos.Os): string; translatePlatform(platform: string): string; translateArch(arch: string, mongoPlatform: string): string; } diff --git a/src/util/MongoBinaryDownloadUrl.js b/src/util/MongoBinaryDownloadUrl.js index b898c9cf3..970542afb 100644 --- a/src/util/MongoBinaryDownloadUrl.js +++ b/src/util/MongoBinaryDownloadUrl.js @@ -3,23 +3,18 @@ import getos from 'getos'; -type OS = { - dist: string, - release?: string, -}; - export type MongoBinaryDownloadUrlOpts = { version: string, platform: string, arch: string, - os?: ?OS, // getos() result + os?: ?getos.Os, }; export default class MongoBinaryDownloadUrl { platform: string; arch: string; version: string; - os: ?OS; + os: ?getos.Os; constructor({ platform, arch, version, os }: MongoBinaryDownloadUrlOpts) { this.platform = this.translatePlatform(platform); @@ -90,7 +85,7 @@ export default class MongoBinaryDownloadUrl { return name; } - async getos(): Promise { + async getos(): Promise { return new Promise((resolve, reject) => { getos((e: any, os: any) => { if (e) reject(e); @@ -99,7 +94,7 @@ export default class MongoBinaryDownloadUrl { }); } - getLinuxOSVersionString(os: OS): string { + getLinuxOSVersionString(os: getos.Os): string { if (/ubuntu/i.test(os.dist)) { return this.getUbuntuVersionString(os); } else if (/elementary OS/i.test(os.dist)) { @@ -119,7 +114,7 @@ export default class MongoBinaryDownloadUrl { return this.getLegacyVersionString(os); } - getDebianVersionString(os: OS): string { + getDebianVersionString(os: getos.Os): string { let name: string = 'debian'; const release: number = parseFloat(os.release); if (release >= 9) { @@ -132,7 +127,7 @@ export default class MongoBinaryDownloadUrl { return name; } - getFedoraVersionString(os: OS): string { + getFedoraVersionString(os: getos.Os): string { let name: string = 'rhel'; const fedoraVer: number = parseInt(os.release, 10); if (fedoraVer > 18) { @@ -145,7 +140,7 @@ export default class MongoBinaryDownloadUrl { return name; } - getRhelVersionString(os: OS): string { + getRhelVersionString(os: getos.Os): string { let name: string = 'rhel'; const { release } = os; if (release) { @@ -161,22 +156,22 @@ export default class MongoBinaryDownloadUrl { } // eslint-disable-next-line no-unused-vars - getElementaryOSVersionString(os: OS): string { + getElementaryOSVersionString(os: getos.Os): string { return 'ubuntu1404'; } // eslint-disable-next-line no-unused-vars - getMintVersionString(os: OS): string { + getMintVersionString(os: getos.Os): string { // unfortunately getos doesn't return version for Mint return 'ubuntu1404'; } // eslint-disable-next-line no-unused-vars - getLegacyVersionString(os: OS): string { + getLegacyVersionString(os: getos.Os): string { return ''; } - getSuseVersionString(os: any): string { + getSuseVersionString(os: getos.Os): string { const [release]: [string | null] = os.release.match(/(^11|^12)/) || [null]; if (release) { @@ -185,7 +180,7 @@ export default class MongoBinaryDownloadUrl { return ''; } - getUbuntuVersionString(os: OS): string { + getUbuntuVersionString(os: getos.Os): string { let name: string = 'ubuntu'; const ubuntuVer: string[] = os.release ? os.release.split('.') : []; const majorVer: number = parseInt(ubuntuVer[0], 10); diff --git a/src/util/MongoInstance.d.ts b/src/util/MongoInstance.d.ts index fbeb9314f..f8e3087b8 100644 --- a/src/util/MongoInstance.d.ts +++ b/src/util/MongoInstance.d.ts @@ -1,15 +1,16 @@ /// -import { ChildProcess } from 'child_process'; +import { ChildProcess, SpawnOptions } from 'child_process'; import { MongoBinaryOpts } from './MongoBinary'; +import { DebugFn, DebugPropT, CallbackFn, StorageEngineT } from '../types'; export interface MongodOps { // instance options instance: { port: number; - storageEngine?: string; + storageEngine?: StorageEngineT; dbPath: string; - debug?: boolean | ((...args: any[]) => any); + debug?: DebugPropT; replSet?: string; args?: string[]; auth?: boolean; @@ -19,29 +20,20 @@ export interface MongodOps { binary?: MongoBinaryOpts; // child process spawn options - spawn?: { - cwd?: string; - env?: object; - argv0?: string; - stdio?: string | any[]; - detached?: boolean; - uid?: number; - gid?: number; - shell?: boolean | string; - }; + spawn?: SpawnOptions; - debug?: boolean | ((...args: any[]) => any); + debug?: DebugPropT; } export default class MongodbInstance { static childProcessList: ChildProcess[]; opts: MongodOps; - debug: ((...args: any[]) => any); + debug: DebugFn; childProcess: ChildProcess; killerProcess: ChildProcess; - instanceReady: ((...args: any[]) => any); - instanceFailed: ((...args: any[]) => any); + instanceReady: CallbackFn; + instanceFailed: CallbackFn; constructor(opts: MongodOps); diff --git a/src/util/MongoInstance.js b/src/util/MongoInstance.js index b2f500ce9..10a4cbac3 100644 --- a/src/util/MongoInstance.js +++ b/src/util/MongoInstance.js @@ -5,15 +5,16 @@ import { ChildProcess, spawn as spawnChild } from 'child_process'; import path from 'path'; import MongoBinary from './MongoBinary'; import type { MongoBinaryOpts } from './MongoBinary'; +import type { DebugPropT, StorageEngineT, SpawnOptions } from '../types'; export type MongodOps = { // instance options instance: { port: number, ip?: string, // for binding to all IP addresses set it to `::,0.0.0.0`, by default '127.0.0.1' - storageEngine?: string, + storageEngine?: StorageEngineT, dbPath: string, - debug?: boolean | Function, + debug?: DebugPropT, replSet?: string, args?: string[], auth?: boolean, @@ -23,18 +24,8 @@ export type MongodOps = { binary?: MongoBinaryOpts, // child process spawn options - spawn?: { - cwd?: string, - env?: Object, - argv0?: string, - stdio?: string | Array, - detached?: boolean, - uid?: number, - gid?: number, - shell?: boolean | string, - }, - - debug?: boolean | Function, + spawn?: SpawnOptions, + debug?: DebugPropT, }; export default class MongodbInstance { From dfc89685b264dc6ce569796217e2d6555b79917d Mon Sep 17 00:00:00 2001 From: Jarom Loveridge Date: Thu, 27 Sep 2018 22:07:53 -0600 Subject: [PATCH 3/6] chore(editorconfig): add .editorconfig so compatible editors will honor code style by default. --- .editorconfig | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..bfdeac23f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +insert_final_newline = true +indent_size = 2 +indent_style = space +tab_width = 2 +trim_trailing_whitespace = true + +# Set default charset +[*.{js,ts}] +charset = utf-8 From 22569aff136d84a10b493afdd78649011c681a8a Mon Sep 17 00:00:00 2001 From: Jarom Loveridge Date: Thu, 27 Sep 2018 22:09:03 -0600 Subject: [PATCH 4/6] chore(vscode, flow): Prevent VSCode from complaining about flow types in `js` files. --- .vscode/settings.json | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..ab7667da3 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "javascript.validate.enable": false +} \ No newline at end of file From d3f36dcf2149693826c01cbe0a05b9be8390c1c9 Mon Sep 17 00:00:00 2001 From: Jarom Loveridge Date: Sun, 30 Sep 2018 01:04:19 -0600 Subject: [PATCH 5/6] chore(replset): Implement MongoMemoryReplSet --- package.json | 6 +- src/MongoMemoryReplSet.d.ts | 57 ++++++++ src/MongoMemoryReplSet.js | 251 ++++++++++++++++++++++++++++++++ src/MongoMemoryServer.d.ts | 15 +- src/MongoMemoryServer.js | 30 ++-- src/__tests__/replset-test.js | 66 +++++++++ src/index.js | 3 +- src/types.d.ts | 30 ++++ src/types.js | 30 ++++ src/util/MongoBinaryDownload.js | 2 +- src/util/MongoInstance.d.ts | 3 - src/util/db_util.d.ts | 20 +++ src/util/db_util.js | 29 ++++ 13 files changed, 503 insertions(+), 39 deletions(-) create mode 100644 src/MongoMemoryReplSet.d.ts create mode 100644 src/MongoMemoryReplSet.js create mode 100644 src/__tests__/replset-test.js create mode 100644 src/util/db_util.d.ts create mode 100644 src/util/db_util.js diff --git a/package.json b/package.json index 94b750cbc..9d5236b35 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "eslint-plugin-prettier": "^2.6.2", "flow-bin": "^0.80.0", "jest": "^23.6.0", - "mongodb": "3.1.4", + "mongodb": "^3.1.6", "npm-run-all": "^4.1.3", "prettier": "^1.14.2", "rimraf": "^2.6.2", @@ -68,7 +68,9 @@ "tmp": "^0.0.33", "uuid": "^3.2.1" }, - "peerDependencies": {}, + "peerDependencies": { + "mongodb": ">= 3.0" + }, "scripts": { "build": "npm-run-all build:*", "build:cjs": "rimraf lib && babel src --ignore __tests__,__mocks__ -d lib", diff --git a/src/MongoMemoryReplSet.d.ts b/src/MongoMemoryReplSet.d.ts new file mode 100644 index 000000000..75bbcf57f --- /dev/null +++ b/src/MongoMemoryReplSet.d.ts @@ -0,0 +1,57 @@ +/// +import { SpawnOptions } from 'child_process'; +import * as events from 'events'; +import { + DebugFn, + MongoMemoryInstancePropT, + MongoMemoryInstancePropBaseT, + StorageEngineT, +} from './types'; +import MongoMemoryServer from './MongoMemoryServer'; +import { MongoBinaryOpts } from './util/MongoBinary'; + +/** + * Replica set specific options. + * + * @property {boolean} auth enable auth; (default: false) + * @property {string[]} args additional command line args passed to `mongod` + * @property {number} count number of `mongod` servers to start (default: 1) + * @property {string} dbName database name used in connection string + * @property {string} ip bind to all IP addresses specify `::,0.0.0.0`; (default '127.0.0.1') + * @property {string} name replSet name (default: 'testset') + * @property {number} oplogSize oplog size (in MB); (default: 1) + * @property {StorageEngineT} storageEngine `mongod` storage engine type; (default: 'ephemeralForTest') + */ +export interface ReplSetOpts { + auth: boolean; + args: string[]; + count: number; + dbName: string; + ip: string; + name: string; + oplogSize: number; + spawn: SpawnOptions; + storageEngine: StorageEngineT; +} + +export interface MongoMemoryReplSetOptsT { + instanceOpts: MongoMemoryInstancePropBaseT[]; + binary: MongoBinaryOpts; + replSet: ReplSetOpts; + autoStart?: boolean; + debug?: boolean; +} + +export default class MongoMemoryReplSet extends events.EventEmitter { + servers: MongoMemoryServer[]; + opts: MongoMemoryReplSetOptsT; + debug: DebugFn; + _state: 'init' | 'running' | 'stopped'; + getConnectionString(otherDb?: string | boolean): Promise; + getDbName(): Promise; + getInstanceOpts(baseOpts: MongoMemoryInstancePropBaseT): MongoMemoryInstancePropT; + getUri(otherDb?: string | boolean): Promise; + start(): Promise; + stop(): Promise; + waitUntilRunning(): Promise; +} diff --git a/src/MongoMemoryReplSet.js b/src/MongoMemoryReplSet.js new file mode 100644 index 000000000..c7675419b --- /dev/null +++ b/src/MongoMemoryReplSet.js @@ -0,0 +1,251 @@ +// @flow +import events from 'events'; +import { MongoClient } from 'mongodb'; +import MongoMemoryServer from './MongoMemoryServer'; +import type { MongoMemoryServerOptsT } from './MongoMemoryServer'; +import { generateDbName, getHost, getReplStatus } from './util/db_util'; +import type { MongoBinaryOpts } from './util/MongoBinary'; +import type { + DebugFn, + MongoMemoryInstancePropT, + MongoMemoryInstancePropBaseT, + SpawnOptions, + StorageEngineT, +} from './types'; + +/** + * Replica set specific options. + * + * @property {boolean} auth enable auth; (default: false) + * @property {string[]} args additional command line args passed to `mongod` + * @property {number} count number of `mongod` servers to start (default: 1) + * @property {string} dbName database name used in connection string + * @property {string} ip bind to all IP addresses specify `::,0.0.0.0`; (default '127.0.0.1') + * @property {string} name replSet name (default: 'testset') + * @property {number} oplogSize oplog size (in MB); (default: 1) + * @property {StorageEngineT} storageEngine `mongod` storage engine type; (default: 'ephemeralForTest') + */ +export interface ReplSetOpts { + auth: boolean; + args: string[]; + count: number; + dbName: string; + ip: string; + name: string; + oplogSize: number; + spawn: SpawnOptions; + storageEngine: StorageEngineT; +} + +export interface MongoMemoryReplSetOptsT { + instanceOpts: MongoMemoryInstancePropBaseT[]; + binary: MongoBinaryOpts; + replSet: ReplSetOpts; + autoStart?: boolean; + debug?: boolean; +} + +export default class MongoMemoryReplSet extends events.EventEmitter { + servers: MongoMemoryServer[]; + opts: MongoMemoryReplSetOptsT; + debug: DebugFn; + _state: 'init' | 'running' | 'stopped'; + + constructor(opts?: $Shape = {}) { + super(); + const replSetDefaults: ReplSetOpts = { + auth: false, + args: [], + name: 'testset', + count: 1, + dbName: generateDbName(), + ip: '127.0.0.1', + oplogSize: 1, + spawn: {}, + storageEngine: 'ephemeralForTest', + }; + this._state = 'stopped'; + this.opts = { + binary: opts.binary || {}, + debug: !!opts.debug, + instanceOpts: opts.instanceOpts || [], + replSet: Object.assign(replSetDefaults, (opts.replSet: any)), + }; + this.opts.replSet.args.push('--oplogSize', `${this.opts.replSet.oplogSize}`); + this.debug = (...args: any[]) => { + if (!this.opts.debug) return; + console.log(...args); + }; + // auto start by default + if (opts.autoStart || !('autoStart' in opts)) { + this.debug('Autostarting MongoMemoryReplSet.'); + setTimeout(() => this.start(), 0); + } + process.on('beforeExit', () => this.stop()); + } + + async getConnectionString(otherDb?: string | boolean): Promise { + return this.getUri(otherDb); + } + + /** + * Returns database name. + */ + async getDbName(): Promise { + // this function is only async for consistency with MongoMemoryServer + // I don't see much point to either of them being async but don't + // care enough to change it and introduce a breaking change. + return this.opts.replSet.dbName; + } + + /** + * Returns instance options suitable for a MongoMemoryServer. + * @param {MongoMemoryInstancePropBaseT} baseOpts + */ + getInstanceOpts(baseOpts: MongoMemoryInstancePropBaseT = {}): MongoMemoryInstancePropT { + const rsOpts: ReplSetOpts = this.opts.replSet; + const opts: MongoMemoryInstancePropT = { + auth: !!rsOpts.auth, + args: rsOpts.args, + dbName: rsOpts.dbName, + ip: rsOpts.ip, + replSet: rsOpts.name, + }; + if (baseOpts.args) opts.args = rsOpts.args.concat(baseOpts.args); + if (baseOpts.port) opts.port = baseOpts.port; + if (baseOpts.dbPath) opts.dbPath = baseOpts.dbPath; + if (baseOpts.storageEngine) opts.storageEngine = baseOpts.storageEngine; + this.debug(' instance opts:', opts); + return opts; + } + + /** + * Returns a mongodb: URI to connect to a given database. + */ + async getUri(otherDb?: string | boolean): Promise { + if (this._state === 'init') { + await this._waitForPrimary(); + } + if (this._state !== 'running') { + throw new Error('Replica Set is not running. Use opts.debug for more info.'); + } + let dbName: string; + if (otherDb) { + dbName = typeof otherDb === 'string' ? otherDb : generateDbName(); + } else { + dbName = this.opts.replSet.dbName; + } + const ports = await Promise.all(this.servers.map(s => s.getPort())); + const hosts = ports.map(port => `127.0.0.1:${port}`).join(','); + return `mongodb://${hosts}/${dbName}`; + } + + /** + * Start underlying `mongod` instances. + */ + async start(): Promise { + this.debug('start'); + if (this._state !== 'stopped') { + throw new Error(`Already in 'init' or 'running' state. Use opts.debug = true for more info.`); + } + this._state = 'init'; + this.emit('state', 'init'); + this.debug('init'); + // Any servers defined within `opts.instanceOpts` should be started first as + // the user could have specified a `dbPath` in which case we would want to perform + // the `replSetInitiate` command against that server. + const servers = this.opts.instanceOpts.map(opts => { + this.debug(' starting server from instanceOpts:', opts, '...'); + return this._startServer(this.getInstanceOpts(opts)); + }); + while (servers.length < this.opts.replSet.count) { + this.debug(' starting a server due to count...'); + const server = this._startServer(this.getInstanceOpts({})); + servers.push(server); + } + this.servers = servers; + // Brief delay to wait for servers to start up. + await new Promise(resolve => setTimeout(resolve, 1000)); + await this._initReplSet(); + } + + /** + * Stop the underlying `mongod` instance(s). + */ + async stop(): Promise { + if (this._state === 'stopped') return false; + const servers = this.servers; + this.servers = []; + this._state = 'stopped'; + return Promise.all(servers.map(s => s.stop())) + .then(() => true) + .catch(err => { + this.debug(err); + return false; + }); + } + + async waitUntilRunning() { + if (this._state === 'running') return; + await new Promise(resolve => this.on('state', state => state === 'running' && resolve())); + } + + /** + * Connects to the first server from the list of servers and issues the `replSetInitiate` + * command passing in a new replica set configuration object. + */ + async _initReplSet(): Promise { + if (this._state !== 'init') { + throw new Error('Not in init phase.'); + } + this.debug('Initializing replica set.'); + if (!this.servers.length) { + throw new Error('One or more server is required.'); + } + const uris = await Promise.all(this.servers.map(server => server.getUri())); + const conn = await MongoClient.connect( + uris[0], + { useNewUrlParser: true } + ); + try { + const db = await conn.db(this.opts.replSet.dbName); + const admin = db.admin(); + const members = uris.map((uri, idx) => ({ _id: idx, host: getHost(uri) })); + const rsConfig = { + _id: this.opts.replSet.name, + members, + }; + await admin.command({ replSetInitiate: rsConfig }); + this.debug('Waiting for replica set to have a PRIMARY member.'); + await this._waitForPrimary(admin); + this._state = 'running'; + this.emit('state', 'running'); + this.debug('running'); + } finally { + await conn.close(); + } + } + + _startServer(instanceOpts: MongoMemoryInstancePropT): MongoMemoryServer { + const serverOpts: MongoMemoryServerOptsT = { + autoStart: true, + debug: this.opts.debug, + binary: this.opts.binary, + instance: instanceOpts, + spawn: (this.opts.replSet.spawn: any), + }; + const server = new MongoMemoryServer(serverOpts); + return server; + } + + async _waitForPrimary(db: any): Promise { + const replStatus = await getReplStatus(db); + this.debug(' replStatus:', replStatus); + const hasPrimary = replStatus.members.some(m => m.stateStr === 'PRIMARY'); + if (!hasPrimary) { + this.debug('No PRIMARY yet. Waiting...'); + return new Promise(resolve => setTimeout(() => resolve(this._waitForPrimary(db)), 1000)); + } + return true; + } +} diff --git a/src/MongoMemoryServer.d.ts b/src/MongoMemoryServer.d.ts index e42d75ada..98362c29b 100644 --- a/src/MongoMemoryServer.d.ts +++ b/src/MongoMemoryServer.d.ts @@ -3,19 +3,10 @@ import { ChildProcess, SpawnOptions } from 'child_process'; import MongoInstance from './util/MongoInstance'; import { MongoBinaryOpts } from './util/MongoBinary'; -import { CallbackFn, DebugFn, DebugPropT, StorageEngineT } from './types'; +import { CallbackFn, DebugFn, MongoMemoryInstancePropT, StorageEngineT } from './types'; export interface MongoMemoryServerOptsT { - instance: { - port?: number; - dbPath?: string; - dbName?: string; - storageEngine?: StorageEngineT; - debug?: DebugPropT; - replSet?: string; - auth?: boolean; - args?: string[]; - }; + instance: MongoMemoryInstancePropT; binary: MongoBinaryOpts; debug?: boolean; spawn: SpawnOptions; @@ -53,6 +44,4 @@ export default class MongoMemoryServer { getPort(): Promise; getDbPath(): Promise; getDbName(): Promise; - - protected _startUpInstance(): Promise; } diff --git a/src/MongoMemoryServer.js b/src/MongoMemoryServer.js index 8085db693..f050fd375 100644 --- a/src/MongoMemoryServer.js +++ b/src/MongoMemoryServer.js @@ -1,28 +1,24 @@ /* @flow */ import type { ChildProcess } from 'child_process'; -import uuid from 'uuid/v4'; import tmp from 'tmp'; import getport from 'get-port'; import Debug from 'debug'; +import { generateDbName } from './util/db_util'; import MongoInstance from './util/MongoInstance'; import type { MongoBinaryOpts } from './util/MongoBinary'; -import type { CallbackFn, DebugFn, DebugPropT, SpawnOptions, StorageEngineT } from './types'; +import type { + CallbackFn, + DebugFn, + MongoMemoryInstancePropT, + SpawnOptions, + StorageEngineT, +} from './types'; tmp.setGracefulCleanup(); export type MongoMemoryServerOptsT = { - instance: { - port?: ?number, - ip?: string, // for binding to all IP addresses set it to `::,0.0.0.0`, by default '127.0.0.1' - dbPath?: string, - dbName?: string, - storageEngine?: StorageEngineT, - debug?: DebugPropT, - replSet?: string, - args?: string[], - auth?: boolean, - }, + instance: MongoMemoryInstancePropT, binary: MongoBinaryOpts, debug?: boolean, spawn: SpawnOptions, @@ -44,10 +40,6 @@ export type MongoInstanceDataT = { replSet?: string, }; -async function generateDbName(dbName?: string): Promise { - return dbName || uuid(); -} - async function generateConnectionString(port: number, dbName: string): Promise { return `mongodb://127.0.0.1:${port}/${dbName}`; } @@ -113,7 +105,7 @@ export default class MongoMemoryServer { data.port = await getport({ port: instOpts.port }); this.debug = Debug(`Mongo[${data.port}]`); this.debug.enabled = !!this.opts.debug; - data.dbName = await generateDbName(instOpts.dbName); + data.dbName = generateDbName(instOpts.dbName); data.uri = await generateConnectionString(data.port, data.dbName); data.storageEngine = instOpts.storageEngine || 'ephemeralForTest'; data.replSet = instOpts.replSet; @@ -183,7 +175,7 @@ export default class MongoMemoryServer { return generateConnectionString(port, otherDbName); } // generate new random db name - return generateConnectionString(port, await generateDbName()); + return generateConnectionString(port, generateDbName()); } return uri; diff --git a/src/__tests__/replset-test.js b/src/__tests__/replset-test.js new file mode 100644 index 000000000..b46dad098 --- /dev/null +++ b/src/__tests__/replset-test.js @@ -0,0 +1,66 @@ +// @flow + +import MongoMemoryReplSet from '../MongoMemoryReplSet'; + +describe('single server replset', () => { + let replSet: MongoMemoryReplSet; + afterEach(async () => { + if (!(replSet && replSet._state === 'running')) return; + await replSet.stop(); + replSet = (null: any); + }); + + it('should enter running state', async () => { + replSet = new MongoMemoryReplSet(); + await replSet.waitUntilRunning(); + const uri = await replSet.getUri(); + expect(uri.split(',').length).toEqual(1); + }); + + it('should be able to get connection string to specific db', async () => { + replSet = new MongoMemoryReplSet(); + await replSet.waitUntilRunning(); + const uri = await replSet.getUri('other'); + const str = await replSet.getConnectionString('other'); + expect(uri.split(',').length).toEqual(1); + expect(uri.endsWith('/other')).toBeTruthy(); + expect(str).toEqual(uri); + }); + + it('should be able to get dbName', async () => { + const opts: any = { autoStart: false, replSet: { dbName: 'static' } }; + replSet = new MongoMemoryReplSet(opts); + const dbName = await replSet.getDbName(); + expect(dbName).toEqual('static'); + }); + + it('should not autostart if autostart: false', async () => { + replSet = new MongoMemoryReplSet({ autoStart: false }); + await new Promise((resolve, reject) => { + replSet.once('state', state => reject(new Error(`Invalid state: ${state}`))); + setTimeout(resolve, 500); + }); + }); +}); + +describe('multi-member replica set', () => { + let replSet: MongoMemoryReplSet; + afterEach(async () => { + if (!replSet) return; + await replSet.stop(); + replSet = (null: any); + }); + + it( + 'should enter running state', + async () => { + const opts: any = { replSet: { count: 3 } }; + replSet = new MongoMemoryReplSet(opts); + await replSet.waitUntilRunning(); + expect(replSet.servers.length).toEqual(3); + const uri = await replSet.getUri(); + expect(uri.split(',').length).toEqual(3); + }, + 40000 + ); +}); diff --git a/src/index.js b/src/index.js index 1cc4ce309..370abf502 100644 --- a/src/index.js +++ b/src/index.js @@ -1,8 +1,9 @@ /* @flow */ import MongoMemoryServer from './MongoMemoryServer'; +import MongoMemoryReplSet from './MongoMemoryReplSet'; import MongoInstance from './util/MongoInstance'; import MongoBinary from './util/MongoBinary'; export default MongoMemoryServer; -export { MongoMemoryServer, MongoInstance, MongoBinary }; +export { MongoMemoryServer, MongoMemoryReplSet, MongoInstance, MongoBinary }; diff --git a/src/types.d.ts b/src/types.d.ts index 95a6ec652..a00aea6d5 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -17,3 +17,33 @@ export type CallbackFn = (...args: any[]) => any; export { SpawnOptions } from 'child_process'; export type StorageEngineT = 'devnull' | 'ephemeralForTest' | 'mmapv1' | 'wiredTiger'; + +export interface MongoMemoryInstancePropBaseT { + args?: string[]; + port?: number | null; + dbPath?: string; + storageEngine?: StorageEngineT; +} + +export interface MongoMemoryInstancePropT extends MongoMemoryInstancePropBaseT { + auth?: boolean; + dbName?: string; + debug?: DebugPropT; + ip?: string; // for binding to all IP addresses set it to `::,0.0.0.0`, by default '127.0.0.1' + replSet?: string; + storageEngine?: StorageEngineT; +} + +export interface ReplStatusMemberT { + _id: number; + name: string; + health: number; + state: number; + stateStr: string; + uptime: number; +} + +export interface ReplStatusResultT { + set: string; + members: ReplStatusMemberT[]; +} diff --git a/src/types.js b/src/types.js index a0ab2d1bd..5bd4e0fae 100644 --- a/src/types.js +++ b/src/types.js @@ -28,3 +28,33 @@ export interface SpawnOptions { } export type StorageEngineT = 'devnull' | 'ephemeralForTest' | 'mmapv1' | 'wiredTiger'; + +export interface MongoMemoryInstancePropBaseT { + args?: string[]; + port?: ?number; + dbPath?: string; + storageEngine?: StorageEngineT; +} + +export interface MongoMemoryInstancePropT extends MongoMemoryInstancePropBaseT { + auth?: boolean; + dbName?: string; + debug?: DebugPropT; + ip?: string; // for binding to all IP addresses set it to `::,0.0.0.0`, by default '127.0.0.1' + replSet?: string; + storageEngine?: StorageEngineT; +} + +export interface ReplStatusMemberT { + _id: number; + name: string; + health: number; + state: number; + stateStr: string; + uptime: number; +} + +export interface ReplStatusResultT { + set: string; + members: ReplStatusMemberT[]; +} diff --git a/src/util/MongoBinaryDownload.js b/src/util/MongoBinaryDownload.js index e042d5a7b..dd44d8042 100644 --- a/src/util/MongoBinaryDownload.js +++ b/src/util/MongoBinaryDownload.js @@ -126,7 +126,7 @@ export default class MongoBinaryDownload { const downloadLocation = path.resolve(this.downloadDir, filename); const tempDownloadLocation = path.resolve(this.downloadDir, `${filename}.downloading`); - console.log(`Downloading${proxy ? ` via proxy ${proxy}` : ''}:`, downloadUrl); + this.debug(`Downloading${proxy ? ` via proxy ${proxy}` : ''}:`, downloadUrl); const downloadedFile = await this.httpDownload( downloadOptions, downloadLocation, diff --git a/src/util/MongoInstance.d.ts b/src/util/MongoInstance.d.ts index f8e3087b8..852d683a2 100644 --- a/src/util/MongoInstance.d.ts +++ b/src/util/MongoInstance.d.ts @@ -46,7 +46,4 @@ export default class MongodbInstance { closeHandler(code: number): void; stderrHandler(message: string | Buffer): void; stdoutHandler(message: string | Buffer): void; - - private _launchMongod(mongoBin: string): ChildProcess; - private _launchKiller(parentPid: number, childPid: number): ChildProcess; } diff --git a/src/util/db_util.d.ts b/src/util/db_util.d.ts new file mode 100644 index 000000000..5df43420b --- /dev/null +++ b/src/util/db_util.d.ts @@ -0,0 +1,20 @@ +import { ReplStatusResultT } from '../types'; +/** + * Returns a database name string. + * @param {string} dbName + */ +export function generateDbName(dbName?: string): string; + +/** + * Extracts the host and port information from a mongodb URI string. + * @param {string} uri mongodb URI + */ +export function getHost(uri: string): string; + +/** + * Returns replica set status result. + * @param {any} db db instance + */ +export function getReplStatus(db: any): Promise; + +export default generateDbName; diff --git a/src/util/db_util.js b/src/util/db_util.js new file mode 100644 index 000000000..ed5e3e65d --- /dev/null +++ b/src/util/db_util.js @@ -0,0 +1,29 @@ +// @flow +import uuid from 'uuid/v4'; +import type { ReplStatusResultT } from '../types'; +/** + * Returns a database name string. + * @param {string} dbName + */ +export function generateDbName(dbName?: string): string { + return dbName || uuid(); +} + +/** + * Extracts the host and port information from a mongodb URI string. + * @param {string} uri mongodb URI + */ +export function getHost(uri: string): string { + return uri.replace('mongodb://', '').replace(/\/.*/, ''); +} + +/** + * Returns replica set status result. + * @param {any} db db instance + */ +export async function getReplStatus(db: any): Promise { + const status = await db.command({ replSetGetStatus: 1 }); + return status; +} + +export default generateDbName; From 4937c86567a934714119b38a59fb724752d87e40 Mon Sep 17 00:00:00 2001 From: Jarom Loveridge Date: Sun, 30 Sep 2018 02:03:09 -0600 Subject: [PATCH 6/6] docs(replset): Add documentation on replica set usage. --- README.md | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c5c45c746..4967c402c 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ All options are optional. const mongod = new MongodbMemoryServer({ instance: { port?: ?number, // by default choose any free port - ip?: string, // by default '127.0.0.1', for binding to all IP addresses set it to `::,0.0.0.0`, + ip?: string, // by default '127.0.0.1', for binding to all IP addresses set it to `::,0.0.0.0`, dbName?: string, // by default generate random dbName dbPath?: string, // by default create in temp directory storageEngine?: string, // by default `ephemeralForTest`, available engines: [ 'devnull', 'ephemeralForTest', 'mmapv1', 'wiredTiger' ] @@ -76,6 +76,57 @@ MONGOMS_ARCH=x64 MONGOMS_VERSION=3 MONGOMS_DEBUG=1 # also available case-insensitive values: "on" "yes" "true" ``` + +### Replica Set start: +```js +import { MongoMemoryReplSet } from 'mongodb-memory-server'; + +const replSet = new MongoMemoryReplSet(); +await replSet.waitUntilRunning(); +const uri = await mongod.getConnectionString(); +const port = await mongod.getPort(); +const dbPath = await mongod.getDbPath(); +const dbName = await mongod.getDbName(); + +// some code + +// stop replica set manually +replSet.stop(); +// or it should be stopped automatically when you exit from script +``` + +### Available options +All options are optional. +```js +const replSet = new MongoMemoryReplSet({ + autoStart, // same as for MongoMemoryServer + binary: binaryOpts, // same as for MongoMemoryServer + debug, // same as for MongoMemoryServer + instanceOpts: [ + { + args, // any additional instance specific args + port, // port number for the instance + dbPath, // path to database files for this instance + storageEngine, // same storage engine options + }, + // each entry will result in a MongoMemoryServer + ], + // unless otherwise noted below these values will be in common with all instances spawned. + replSet: { + name, // replica set name (default: 'testset') + auth, // enable auth support? (default: false) + args, // any args specified here will be combined with any per instance args from `instanceOpts` + count, // number of `mongod` processes to start; (default: 1) + dbName, // default database for db URI strings. (default: uuid.v4()) + ip, // by default '127.0.0.1', for binding to all IP addresses set it to `::,0.0.0.0` + oplogSize, // size (in MB) for the oplog; (default: 1) + spawn, // spawn options when creating the child processes + storageEngine, // default storage engine for instance. (Can be overridden per instance) + } +}); +``` + + ### Simple test with MongoClient Take a look at this [test file](https://github.com/nodkz/mongodb-memory-server/blob/master/src/__tests__/singleDB-test.js).