diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-08-14 05:01:11 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-08-14 05:02:09 +0200 |
commit | 363723fc84f7b8477592e0105aeb331ec9a017af (patch) | |
tree | 29f92724f34131bac64d6a318dd7e30612e631c7 /node_modules/jest-validate | |
parent | 5634e77ad96bfe1818f6b6ee70b7379652e5487f (diff) |
node_modules
Diffstat (limited to 'node_modules/jest-validate')
-rw-r--r-- | node_modules/jest-validate/.npmignore | 3 | ||||
-rw-r--r-- | node_modules/jest-validate/README.md | 143 | ||||
-rw-r--r-- | node_modules/jest-validate/build/condition.js | 26 | ||||
-rw-r--r-- | node_modules/jest-validate/build/defaultConfig.js | 34 | ||||
-rw-r--r-- | node_modules/jest-validate/build/deprecated.js | 40 | ||||
-rw-r--r-- | node_modules/jest-validate/build/errors.js | 44 | ||||
-rw-r--r-- | node_modules/jest-validate/build/exampleConfig.js | 32 | ||||
-rw-r--r-- | node_modules/jest-validate/build/index.js | 18 | ||||
-rw-r--r-- | node_modules/jest-validate/build/types.js | 11 | ||||
-rw-r--r-- | node_modules/jest-validate/build/utils.js | 68 | ||||
-rw-r--r-- | node_modules/jest-validate/build/validate.js | 69 | ||||
-rw-r--r-- | node_modules/jest-validate/build/warnings.js | 45 | ||||
-rw-r--r-- | node_modules/jest-validate/package.json | 16 |
13 files changed, 0 insertions, 549 deletions
diff --git a/node_modules/jest-validate/.npmignore b/node_modules/jest-validate/.npmignore deleted file mode 100644 index 85e48fe7b..000000000 --- a/node_modules/jest-validate/.npmignore +++ /dev/null @@ -1,3 +0,0 @@ -**/__mocks__/** -**/__tests__/** -src diff --git a/node_modules/jest-validate/README.md b/node_modules/jest-validate/README.md deleted file mode 100644 index 3e130b38c..000000000 --- a/node_modules/jest-validate/README.md +++ /dev/null @@ -1,143 +0,0 @@ -# jest-validate - -Generic configuration validation tool that helps you with warnings, errors and deprecation messages as well as showing users examples of correct configuration. - -``` -npm install --save jest-validate -``` - -## Usage - -```js -import {validate} from 'jest-validate'; - -validate( - config: Object, - options: ValidationOptions, -); // => {hasDeprecationWarnings: boolean, isValid: boolean} -``` - -Where `ValidationOptions` are: -```js -type ValidationOptions = { - comment?: string, - condition?: (option: any, validOption: any) => boolean, - deprecate?: ( - config: Object, - option: string, - deprecatedOptions: Object, - options: ValidationOptions - ) => true, - deprecatedConfig?: {[key: string]: Function}, - error?: ( - option: string, - received: any, - defaultValue: any, - options: ValidationOptions, - ) => void, - exampleConfig: Object, - title?: Title, - unknown?: ( - config: Object, - exampleConfig: Object, - option: string, - options: ValidationOptions - ) => void, -} - -type Title = {| - deprecation?: string, - error?: string, - warning?: string, -|} -``` - -`exampleConfig` is the only option required. - -## API - -By default `jest-validate` will print generic warning and error messages. You can however customize this behavior by providing `options: ValidationOptions` object as a second argument: - -Almost anything can be overwritten to suite your needs. - -### Options - -* `comment` – optional string to be rendered bellow error/warning message. -* `condition` – an optional function with validation condition. -* `deprecate`, `error`, `unknown` – optional functions responsible for displaying warning and error messages. -* `deprecatedConfig` – optional object with deprecated config keys. -* `exampleConfig` – the only **required** option with configuration against which you'd like to test. -* `title` – optional object of titles for errors and messages. - -You will find examples of `condition`, `deprecate`, `error`, `unknown`, and `deprecatedConfig` inside source of this repository, named respectively. - -## Examples - -Minimal example: - -```js -validate(config, {exampleConfig}); -``` - -Example with slight modifications: - -```js -validate(config, { - comment: ' Documentation: http://custom-docs.com', - exampleConfig, - deprecatedConfig, - title: { - deprecation: 'Custom Deprecation', - // leaving 'error' and 'warning' as default - } -}); -``` - -This will output: - -#### Warning: - -``` -● Validation Warning: - - Unknown option transformx with value "<rootDir>/node_modules/babel-jest" was found. - This is either a typing error or a user mistake. Fixing it will remove this message. - - Documentation: http://custom-docs.com -``` - -#### Error: - -``` -● Validation Error: - - Option transform must be of type: - object - but instead received: - string - - Example: - { - "transform": {"^.+\\.js$": "<rootDir>/preprocessor.js"} - } - - Documentation: http://custom-docs.com -``` - -#### Deprecation -Based on `deprecatedConfig` object with proper deprecation messages. Note custom title: - -``` -Custom Deprecation: - - Option scriptPreprocessor was replaced by transform, which support multiple preprocessors. - - Jest now treats your current configuration as: - { - "transform": {".*": "xxx"} - } - - Please update your configuration. - - Documentation: http://custom-docs.com -``` diff --git a/node_modules/jest-validate/build/condition.js b/node_modules/jest-validate/build/condition.js deleted file mode 100644 index 05b49b15f..000000000 --- a/node_modules/jest-validate/build/condition.js +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * - */ - -'use strict'; - -const toString = Object.prototype.toString; - -const validationCondition = ( -option, -validOption) => -{ - return ( - option === null || - option === undefined || - toString.call(option) === toString.call(validOption)); - -}; - -module.exports = validationCondition;
\ No newline at end of file diff --git a/node_modules/jest-validate/build/defaultConfig.js b/node_modules/jest-validate/build/defaultConfig.js deleted file mode 100644 index 6c78233df..000000000 --- a/node_modules/jest-validate/build/defaultConfig.js +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * - */ - -'use strict';var _require = - - - -require('./deprecated');const deprecationWarning = _require.deprecationWarning;var _require2 = -require('./warnings');const unknownOptionWarning = _require2.unknownOptionWarning;var _require3 = -require('./errors');const errorMessage = _require3.errorMessage; -const exampleConfig = require('./exampleConfig'); -const validationCondition = require('./condition');var _require4 = -require('./utils');const ERROR = _require4.ERROR,DEPRECATION = _require4.DEPRECATION,WARNING = _require4.WARNING; - -module.exports = { - comment: '', - condition: validationCondition, - deprecate: deprecationWarning, - deprecatedConfig: {}, - error: errorMessage, - exampleConfig, - title: { - deprecation: DEPRECATION, - error: ERROR, - warning: WARNING }, - - unknown: unknownOptionWarning };
\ No newline at end of file diff --git a/node_modules/jest-validate/build/deprecated.js b/node_modules/jest-validate/build/deprecated.js deleted file mode 100644 index 5de6db0c4..000000000 --- a/node_modules/jest-validate/build/deprecated.js +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * - */ - -'use strict';var _require = - - - -require('./utils');const logValidationWarning = _require.logValidationWarning,DEPRECATION = _require.DEPRECATION; - -const deprecationMessage = (message, options) => { - const comment = options.comment; - const name = options.title && options.title.deprecation || DEPRECATION; - - logValidationWarning(name, message, comment); -}; - -const deprecationWarning = ( -config, -option, -deprecatedOptions, -options) => -{ - if (option in deprecatedOptions) { - deprecationMessage(deprecatedOptions[option](config), options); - - return true; - } - - return false; -}; - -module.exports = { - deprecationWarning };
\ No newline at end of file diff --git a/node_modules/jest-validate/build/errors.js b/node_modules/jest-validate/build/errors.js deleted file mode 100644 index 670512349..000000000 --- a/node_modules/jest-validate/build/errors.js +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * - */ - -'use strict'; - - - -const chalk = require('chalk');var _require = -require('./utils');const format = _require.format,ValidationError = _require.ValidationError,ERROR = _require.ERROR;var _require2 = -require('jest-matcher-utils');const getType = _require2.getType; - -const errorMessage = ( -option, -received, -defaultValue, -options) => -{ - const message = - ` Option ${chalk.bold(`"${option}"`)} must be of type: - ${chalk.bold.green(getType(defaultValue))} - but instead received: - ${chalk.bold.red(getType(received))} - - Example: - { - ${chalk.bold(`"${option}"`)}: ${chalk.bold(format(defaultValue))} - }`; - - const comment = options.comment; - const name = options.title && options.title.error || ERROR; - - throw new ValidationError(name, message, comment); -}; - -module.exports = { - ValidationError, - errorMessage };
\ No newline at end of file diff --git a/node_modules/jest-validate/build/exampleConfig.js b/node_modules/jest-validate/build/exampleConfig.js deleted file mode 100644 index 2e26dc341..000000000 --- a/node_modules/jest-validate/build/exampleConfig.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * - */ - -'use strict'; - - - -const config = { - comment: ' A comment', - condition: (option, validOption) => true, - deprecate: (config, option, deprecatedOptions, options) => false, - deprecatedConfig: { - key: config => {} }, - - error: (option, received, defaultValue, options) => {}, - exampleConfig: { key: 'value', test: 'case' }, - title: { - deprecation: 'Deprecation Warning', - error: 'Validation Error', - warning: 'Validation Warning' }, - - unknown: (config, option, options) => {} }; - - -module.exports = config;
\ No newline at end of file diff --git a/node_modules/jest-validate/build/index.js b/node_modules/jest-validate/build/index.js deleted file mode 100644 index cbc8b0666..000000000 --- a/node_modules/jest-validate/build/index.js +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * - */ - -'use strict'; - -module.exports = { - ValidationError: require('./errors').ValidationError, - createDidYouMeanMessage: require('./utils').createDidYouMeanMessage, - format: require('./utils').format, - logValidationWarning: require('./utils').logValidationWarning, - validate: require('./validate') };
\ No newline at end of file diff --git a/node_modules/jest-validate/build/types.js b/node_modules/jest-validate/build/types.js deleted file mode 100644 index 01523b94f..000000000 --- a/node_modules/jest-validate/build/types.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * - */ - -'use strict';
\ No newline at end of file diff --git a/node_modules/jest-validate/build/utils.js b/node_modules/jest-validate/build/utils.js deleted file mode 100644 index f89d53b61..000000000 --- a/node_modules/jest-validate/build/utils.js +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * - */ - -'use strict'; - -const chalk = require('chalk'); -const BULLET = chalk.bold('\u25cf'); -const DEPRECATION = `${BULLET} Deprecation Warning`; -const ERROR = `${BULLET} Validation Error`; -const WARNING = `${BULLET} Validation Warning`; - -const format = value => -typeof value === 'function' ? -value.toString() : -require('pretty-format')(value, { min: true }); - -class ValidationError extends Error { - - - - constructor(name, message, comment) { - super(); - comment = comment ? '\n\n' + comment : '\n'; - this.name = ''; - this.message = chalk.red(chalk.bold(name) + ':\n\n' + message + comment); - Error.captureStackTrace(this, () => {}); - }} - - -const logValidationWarning = ( -name, -message, -comment) => -{ - comment = comment ? '\n\n' + comment : '\n'; - console.warn(chalk.yellow(chalk.bold(name) + ':\n\n' + message + comment)); -}; - -const createDidYouMeanMessage = ( -unrecognized, -allowedOptions) => -{ - const leven = require('leven'); - const suggestion = allowedOptions.find(option => { - const steps = leven(option, unrecognized); - return steps < 3; - }); - - return suggestion ? - `Did you mean ${chalk.bold(format(suggestion))}?` : - ''; -}; - -module.exports = { - DEPRECATION, - ERROR, - ValidationError, - WARNING, - createDidYouMeanMessage, - format, - logValidationWarning };
\ No newline at end of file diff --git a/node_modules/jest-validate/build/validate.js b/node_modules/jest-validate/build/validate.js deleted file mode 100644 index 870a3ece4..000000000 --- a/node_modules/jest-validate/build/validate.js +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * - */ - -'use strict'; - - - -const defaultConfig = require('./defaultConfig'); - -const _validate = (config, options) => { - let hasDeprecationWarnings = false; - - for (const key in config) { - if ( - options.deprecatedConfig && - key in options.deprecatedConfig && - typeof options.deprecate === 'function') - { - const isDeprecatedKey = options.deprecate( - config, - key, - options.deprecatedConfig, - options); - - - hasDeprecationWarnings = hasDeprecationWarnings || isDeprecatedKey; - } else if (hasOwnProperty.call(options.exampleConfig, key)) { - if ( - typeof options.condition === 'function' && - typeof options.error === 'function' && - !options.condition(config[key], options.exampleConfig[key])) - { - options.error(key, config[key], options.exampleConfig[key], options); - } - } else { - options.unknown && - options.unknown(config, options.exampleConfig, key, options); - } - } - - return { hasDeprecationWarnings }; -}; - -const validate = (config, options) => { - _validate(options, defaultConfig); // validate against jest-validate config - - const defaultedOptions = Object.assign( - {}, - defaultConfig, - options, - { title: Object.assign({}, defaultConfig.title, options.title) });var _validate2 = - - - _validate(config, defaultedOptions);const hasDeprecationWarnings = _validate2.hasDeprecationWarnings; - - return { - hasDeprecationWarnings, - isValid: true }; - -}; - -module.exports = validate;
\ No newline at end of file diff --git a/node_modules/jest-validate/build/warnings.js b/node_modules/jest-validate/build/warnings.js deleted file mode 100644 index 8c4b57e89..000000000 --- a/node_modules/jest-validate/build/warnings.js +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * - */ - -'use strict'; - - - -const chalk = require('chalk');var _require = - - - - - -require('./utils');const format = _require.format,logValidationWarning = _require.logValidationWarning,createDidYouMeanMessage = _require.createDidYouMeanMessage,WARNING = _require.WARNING; - -const unknownOptionWarning = ( -config, -exampleConfig, -option, -options) => -{ - const didYouMean = - createDidYouMeanMessage(option, Object.keys(exampleConfig)); - /* eslint-disable max-len */ - const message = - ` Unknown option ${chalk.bold(`"${option}"`)} with value ${chalk.bold(format(config[option]))} was found.` + ( - didYouMean && ` ${didYouMean}`) + - `\n This is probably a typing mistake. Fixing it will remove this message.`; - /* eslint-enable max-len */ - - const comment = options.comment; - const name = options.title && options.title.warning || WARNING; - - logValidationWarning(name, message, comment); -}; - -module.exports = { - unknownOptionWarning };
\ No newline at end of file diff --git a/node_modules/jest-validate/package.json b/node_modules/jest-validate/package.json deleted file mode 100644 index 2b636cd9a..000000000 --- a/node_modules/jest-validate/package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "name": "jest-validate", - "version": "19.0.2", - "repository": { - "type": "git", - "url": "https://github.com/facebook/jest.git" - }, - "license": "BSD-3-Clause", - "main": "build/index.js", - "dependencies": { - "chalk": "^1.1.1", - "jest-matcher-utils": "^19.0.0", - "leven": "^2.0.0", - "pretty-format": "^19.0.0" - } -} |