├── .babelrc ├── .flowconfig ├── .gitignore ├── .prettierrc ├── .travis.yml ├── LICENSE ├── README.md ├── flow-typed └── npm │ ├── @babel │ ├── core_vx.x.x.js │ ├── preset-env_vx.x.x.js │ └── preset-flow_vx.x.x.js │ ├── flow-bin_v0.x.x.js │ ├── jest_v23.x.x.js │ ├── prettier_v1.x.x.js │ ├── rimraf_v2.x.x.js │ ├── rollup-plugin-babel_vx.x.x.js │ ├── rollup-plugin-replace_vx.x.x.js │ ├── rollup-plugin-uglify_vx.x.x.js │ └── rollup_vx.x.x.js ├── jest.config.js ├── package.json ├── rollup.config.js ├── src ├── index.d.ts └── index.js ├── test ├── bundle-size.spec.js └── index.spec.js └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "@babel/flow", 4 | [ 5 | "@babel/env", 6 | { 7 | "loose": true 8 | } 9 | ] 10 | ], 11 | "comments": false 12 | } 13 | -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | 3 | [include] 4 | 5 | [libs] 6 | 7 | [lints] 8 | 9 | [options] 10 | 11 | suppress_comment= \\(.\\|\n\\)*\\$ExpectError 12 | include_warnings=true 13 | 14 | [strict] 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # editors 2 | .idea 3 | .vscode 4 | 5 | # library 6 | node_modules/ 7 | 8 | # MacOS 9 | .DS_Store 10 | 11 | # generated files 12 | dist/ 13 | 14 | # logs 15 | yarn-error.log 16 | npm-debug.log 17 | npm-debug.log.* 18 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "trailingComma": "all", 3 | "semi": true, 4 | "tabWidth": 2, 5 | "useTabs": false, 6 | "singleQuote": true 7 | } 8 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | cache: yarn 3 | node_js: 4 | - '8.4' 5 | script: 6 | - yarn run validate 7 | - yarn run test 8 | # Required for lock file generation 9 | # https://github.com/greenkeeperio/greenkeeper-lockfile 10 | before_install: yarn global add greenkeeper-lockfile@1 11 | before_script: 12 | - greenkeeper-lockfile-update 13 | after_script: greenkeeper-lockfile-upload 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Alexander Reardon 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # tiny-warning 🔬⚠️ 2 | 3 | [![Build Status](https://travis-ci.org/alexreardon/tiny-warning.svg?branch=master)](https://travis-ci.org/alexreardon/tiny-warning) 4 | [![npm](https://img.shields.io/npm/v/tiny-warning.svg)](https://www.npmjs.com/package/tiny-warning) [![Downloads per month](https://img.shields.io/npm/dm/tiny-warning.svg)](https://www.npmjs.com/package/tiny-warning) [![dependencies](https://david-dm.org/alexreardon/tiny-warning.svg)](https://david-dm.org/alexreardon/tiny-warning) 5 | [![min](https://img.shields.io/bundlephobia/min/tiny-warning.svg)](https://www.npmjs.com/package/tiny-warning) 6 | [![minzip](https://img.shields.io/bundlephobia/minzip/tiny-warning.svg)](https://www.npmjs.com/package/tiny-warning) 7 | 8 | A tiny [`warning`](https://www.npmjs.com/package/warning) alternative. 9 | 10 | ```js 11 | import warning from 'tiny-warning'; 12 | 13 | warning(truthyValue, 'This should not log a warning'); 14 | 15 | warning(falsyValue, 'This should log a warning'); 16 | // console.warn('Warning: This should log a warning'); 17 | ``` 18 | 19 | ## API: `(condition: mixed, message: string) => void` 20 | 21 | - `condition` is required and can be anything 22 | - `message` is a required string that will be passed onto `console.warn` 23 | 24 | ## Why `tiny-warning`? 25 | 26 | The [`library: warning`](https://www.npmjs.com/package/warning) supports passing in arguments to the `warning` function in a sprintf style `(condition, format, a, b, c, d, e, f)`. It has internal logic to execute the sprintf substitutions. `tiny-warning` has dropped all of the sprintf logic. `tiny-warning` allows you to pass a single string message. With [template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals) there is really no need for a custom message formatter to be built into the library. If you need a multi part message you can just do this: `warning(condition, 'Hello, ${name} - how are you today?')` 27 | 28 | ## Dropping your `warning` for kb savings! 29 | 30 | We recommend using [`babel-plugin-dev-expression`](https://www.npmjs.com/package/babel-plugin-dev-expression) to remove `warning` calls from your production build. This saves you kb's as well as avoids logging warnings to the console for production. 31 | 32 | What it does it turn your code that looks like this: 33 | 34 | ```js 35 | warning(condition, 'My cool message that takes up a lot of kbs'); 36 | ``` 37 | 38 | Into this 39 | 40 | ```js 41 | if ('production' !== process.env.NODE_ENV) { 42 | warning(condition, 'My cool message that takes up a lot of kbs'); 43 | } 44 | ``` 45 | 46 | Your bundler can then drop the code in the `"production" !== process.env.NODE_ENV` block for your production builds 47 | 48 | Final result: 49 | 50 | ```js 51 | // nothing to see here! 👍 52 | ``` 53 | 54 | > For `rollup` use [rollup-plugin-replace](https://github.com/rollup/rollup-plugin-replace) and set `NODE_ENV` to `production` and then `rollup` will treeshake out the unused code 55 | > 56 | > [`Webpack` instructions](https://webpack.js.org/guides/production/#specify-the-mode) 57 | 58 | ## Builds 59 | 60 | - We have a `es` (EcmaScript module) build (because you _know_ you want to deduplicate this super heavy library) 61 | - We have a `cjs` (CommonJS) build 62 | - We have a `umd` (Universal module definition) build in case you needed it 63 | 64 | We expect `process.env.NODE_ENV` to be available at module compilation. We cache this value 65 | 66 | ## That's it! 67 | 68 | 🤘 69 | -------------------------------------------------------------------------------- /flow-typed/npm/@babel/core_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: afb3994794f3c2f840f54e3cb3826ce7 2 | // flow-typed version: <>/@babel/core_v^7.1.2/flow_v0.82.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * '@babel/core' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module '@babel/core' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module '@babel/core/lib/config/caching' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module '@babel/core/lib/config/config-chain' { 30 | declare module.exports: any; 31 | } 32 | 33 | declare module '@babel/core/lib/config/config-descriptors' { 34 | declare module.exports: any; 35 | } 36 | 37 | declare module '@babel/core/lib/config/files/configuration' { 38 | declare module.exports: any; 39 | } 40 | 41 | declare module '@babel/core/lib/config/files/index-browser' { 42 | declare module.exports: any; 43 | } 44 | 45 | declare module '@babel/core/lib/config/files/index' { 46 | declare module.exports: any; 47 | } 48 | 49 | declare module '@babel/core/lib/config/files/package' { 50 | declare module.exports: any; 51 | } 52 | 53 | declare module '@babel/core/lib/config/files/plugins' { 54 | declare module.exports: any; 55 | } 56 | 57 | declare module '@babel/core/lib/config/files/types' { 58 | declare module.exports: any; 59 | } 60 | 61 | declare module '@babel/core/lib/config/files/utils' { 62 | declare module.exports: any; 63 | } 64 | 65 | declare module '@babel/core/lib/config/full' { 66 | declare module.exports: any; 67 | } 68 | 69 | declare module '@babel/core/lib/config/helpers/config-api' { 70 | declare module.exports: any; 71 | } 72 | 73 | declare module '@babel/core/lib/config/helpers/environment' { 74 | declare module.exports: any; 75 | } 76 | 77 | declare module '@babel/core/lib/config/index' { 78 | declare module.exports: any; 79 | } 80 | 81 | declare module '@babel/core/lib/config/item' { 82 | declare module.exports: any; 83 | } 84 | 85 | declare module '@babel/core/lib/config/partial' { 86 | declare module.exports: any; 87 | } 88 | 89 | declare module '@babel/core/lib/config/pattern-to-regex' { 90 | declare module.exports: any; 91 | } 92 | 93 | declare module '@babel/core/lib/config/plugin' { 94 | declare module.exports: any; 95 | } 96 | 97 | declare module '@babel/core/lib/config/util' { 98 | declare module.exports: any; 99 | } 100 | 101 | declare module '@babel/core/lib/config/validation/option-assertions' { 102 | declare module.exports: any; 103 | } 104 | 105 | declare module '@babel/core/lib/config/validation/options' { 106 | declare module.exports: any; 107 | } 108 | 109 | declare module '@babel/core/lib/config/validation/plugins' { 110 | declare module.exports: any; 111 | } 112 | 113 | declare module '@babel/core/lib/config/validation/removed' { 114 | declare module.exports: any; 115 | } 116 | 117 | declare module '@babel/core/lib/index' { 118 | declare module.exports: any; 119 | } 120 | 121 | declare module '@babel/core/lib/parse' { 122 | declare module.exports: any; 123 | } 124 | 125 | declare module '@babel/core/lib/tools/build-external-helpers' { 126 | declare module.exports: any; 127 | } 128 | 129 | declare module '@babel/core/lib/transform-ast' { 130 | declare module.exports: any; 131 | } 132 | 133 | declare module '@babel/core/lib/transform-file-browser' { 134 | declare module.exports: any; 135 | } 136 | 137 | declare module '@babel/core/lib/transform-file-sync-browser' { 138 | declare module.exports: any; 139 | } 140 | 141 | declare module '@babel/core/lib/transform-file' { 142 | declare module.exports: any; 143 | } 144 | 145 | declare module '@babel/core/lib/transform' { 146 | declare module.exports: any; 147 | } 148 | 149 | declare module '@babel/core/lib/transformation/block-hoist-plugin' { 150 | declare module.exports: any; 151 | } 152 | 153 | declare module '@babel/core/lib/transformation/file/file' { 154 | declare module.exports: any; 155 | } 156 | 157 | declare module '@babel/core/lib/transformation/file/generate' { 158 | declare module.exports: any; 159 | } 160 | 161 | declare module '@babel/core/lib/transformation/file/merge-map' { 162 | declare module.exports: any; 163 | } 164 | 165 | declare module '@babel/core/lib/transformation/index' { 166 | declare module.exports: any; 167 | } 168 | 169 | declare module '@babel/core/lib/transformation/normalize-file' { 170 | declare module.exports: any; 171 | } 172 | 173 | declare module '@babel/core/lib/transformation/normalize-opts' { 174 | declare module.exports: any; 175 | } 176 | 177 | declare module '@babel/core/lib/transformation/plugin-pass' { 178 | declare module.exports: any; 179 | } 180 | 181 | declare module '@babel/core/lib/transformation/util/missing-plugin-helper' { 182 | declare module.exports: any; 183 | } 184 | 185 | // Filename aliases 186 | declare module '@babel/core/lib/config/caching.js' { 187 | declare module.exports: $Exports<'@babel/core/lib/config/caching'>; 188 | } 189 | declare module '@babel/core/lib/config/config-chain.js' { 190 | declare module.exports: $Exports<'@babel/core/lib/config/config-chain'>; 191 | } 192 | declare module '@babel/core/lib/config/config-descriptors.js' { 193 | declare module.exports: $Exports<'@babel/core/lib/config/config-descriptors'>; 194 | } 195 | declare module '@babel/core/lib/config/files/configuration.js' { 196 | declare module.exports: $Exports<'@babel/core/lib/config/files/configuration'>; 197 | } 198 | declare module '@babel/core/lib/config/files/index-browser.js' { 199 | declare module.exports: $Exports<'@babel/core/lib/config/files/index-browser'>; 200 | } 201 | declare module '@babel/core/lib/config/files/index.js' { 202 | declare module.exports: $Exports<'@babel/core/lib/config/files/index'>; 203 | } 204 | declare module '@babel/core/lib/config/files/package.js' { 205 | declare module.exports: $Exports<'@babel/core/lib/config/files/package'>; 206 | } 207 | declare module '@babel/core/lib/config/files/plugins.js' { 208 | declare module.exports: $Exports<'@babel/core/lib/config/files/plugins'>; 209 | } 210 | declare module '@babel/core/lib/config/files/types.js' { 211 | declare module.exports: $Exports<'@babel/core/lib/config/files/types'>; 212 | } 213 | declare module '@babel/core/lib/config/files/utils.js' { 214 | declare module.exports: $Exports<'@babel/core/lib/config/files/utils'>; 215 | } 216 | declare module '@babel/core/lib/config/full.js' { 217 | declare module.exports: $Exports<'@babel/core/lib/config/full'>; 218 | } 219 | declare module '@babel/core/lib/config/helpers/config-api.js' { 220 | declare module.exports: $Exports<'@babel/core/lib/config/helpers/config-api'>; 221 | } 222 | declare module '@babel/core/lib/config/helpers/environment.js' { 223 | declare module.exports: $Exports<'@babel/core/lib/config/helpers/environment'>; 224 | } 225 | declare module '@babel/core/lib/config/index.js' { 226 | declare module.exports: $Exports<'@babel/core/lib/config/index'>; 227 | } 228 | declare module '@babel/core/lib/config/item.js' { 229 | declare module.exports: $Exports<'@babel/core/lib/config/item'>; 230 | } 231 | declare module '@babel/core/lib/config/partial.js' { 232 | declare module.exports: $Exports<'@babel/core/lib/config/partial'>; 233 | } 234 | declare module '@babel/core/lib/config/pattern-to-regex.js' { 235 | declare module.exports: $Exports<'@babel/core/lib/config/pattern-to-regex'>; 236 | } 237 | declare module '@babel/core/lib/config/plugin.js' { 238 | declare module.exports: $Exports<'@babel/core/lib/config/plugin'>; 239 | } 240 | declare module '@babel/core/lib/config/util.js' { 241 | declare module.exports: $Exports<'@babel/core/lib/config/util'>; 242 | } 243 | declare module '@babel/core/lib/config/validation/option-assertions.js' { 244 | declare module.exports: $Exports<'@babel/core/lib/config/validation/option-assertions'>; 245 | } 246 | declare module '@babel/core/lib/config/validation/options.js' { 247 | declare module.exports: $Exports<'@babel/core/lib/config/validation/options'>; 248 | } 249 | declare module '@babel/core/lib/config/validation/plugins.js' { 250 | declare module.exports: $Exports<'@babel/core/lib/config/validation/plugins'>; 251 | } 252 | declare module '@babel/core/lib/config/validation/removed.js' { 253 | declare module.exports: $Exports<'@babel/core/lib/config/validation/removed'>; 254 | } 255 | declare module '@babel/core/lib/index.js' { 256 | declare module.exports: $Exports<'@babel/core/lib/index'>; 257 | } 258 | declare module '@babel/core/lib/parse.js' { 259 | declare module.exports: $Exports<'@babel/core/lib/parse'>; 260 | } 261 | declare module '@babel/core/lib/tools/build-external-helpers.js' { 262 | declare module.exports: $Exports<'@babel/core/lib/tools/build-external-helpers'>; 263 | } 264 | declare module '@babel/core/lib/transform-ast.js' { 265 | declare module.exports: $Exports<'@babel/core/lib/transform-ast'>; 266 | } 267 | declare module '@babel/core/lib/transform-file-browser.js' { 268 | declare module.exports: $Exports<'@babel/core/lib/transform-file-browser'>; 269 | } 270 | declare module '@babel/core/lib/transform-file-sync-browser.js' { 271 | declare module.exports: $Exports<'@babel/core/lib/transform-file-sync-browser'>; 272 | } 273 | declare module '@babel/core/lib/transform-file.js' { 274 | declare module.exports: $Exports<'@babel/core/lib/transform-file'>; 275 | } 276 | declare module '@babel/core/lib/transform.js' { 277 | declare module.exports: $Exports<'@babel/core/lib/transform'>; 278 | } 279 | declare module '@babel/core/lib/transformation/block-hoist-plugin.js' { 280 | declare module.exports: $Exports<'@babel/core/lib/transformation/block-hoist-plugin'>; 281 | } 282 | declare module '@babel/core/lib/transformation/file/file.js' { 283 | declare module.exports: $Exports<'@babel/core/lib/transformation/file/file'>; 284 | } 285 | declare module '@babel/core/lib/transformation/file/generate.js' { 286 | declare module.exports: $Exports<'@babel/core/lib/transformation/file/generate'>; 287 | } 288 | declare module '@babel/core/lib/transformation/file/merge-map.js' { 289 | declare module.exports: $Exports<'@babel/core/lib/transformation/file/merge-map'>; 290 | } 291 | declare module '@babel/core/lib/transformation/index.js' { 292 | declare module.exports: $Exports<'@babel/core/lib/transformation/index'>; 293 | } 294 | declare module '@babel/core/lib/transformation/normalize-file.js' { 295 | declare module.exports: $Exports<'@babel/core/lib/transformation/normalize-file'>; 296 | } 297 | declare module '@babel/core/lib/transformation/normalize-opts.js' { 298 | declare module.exports: $Exports<'@babel/core/lib/transformation/normalize-opts'>; 299 | } 300 | declare module '@babel/core/lib/transformation/plugin-pass.js' { 301 | declare module.exports: $Exports<'@babel/core/lib/transformation/plugin-pass'>; 302 | } 303 | declare module '@babel/core/lib/transformation/util/missing-plugin-helper.js' { 304 | declare module.exports: $Exports<'@babel/core/lib/transformation/util/missing-plugin-helper'>; 305 | } 306 | -------------------------------------------------------------------------------- /flow-typed/npm/@babel/preset-env_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 343a2e6303af4218fd9eaaabea788b8b 2 | // flow-typed version: <>/@babel/preset-env_v^7.1.0/flow_v0.82.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * '@babel/preset-env' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module '@babel/preset-env' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module '@babel/preset-env/data/built-in-features' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module '@babel/preset-env/data/plugin-features' { 30 | declare module.exports: any; 31 | } 32 | 33 | declare module '@babel/preset-env/data/shipped-proposals' { 34 | declare module.exports: any; 35 | } 36 | 37 | declare module '@babel/preset-env/data/unreleased-labels' { 38 | declare module.exports: any; 39 | } 40 | 41 | declare module '@babel/preset-env/lib/available-plugins' { 42 | declare module.exports: any; 43 | } 44 | 45 | declare module '@babel/preset-env/lib/built-in-definitions' { 46 | declare module.exports: any; 47 | } 48 | 49 | declare module '@babel/preset-env/lib/debug' { 50 | declare module.exports: any; 51 | } 52 | 53 | declare module '@babel/preset-env/lib/default-includes' { 54 | declare module.exports: any; 55 | } 56 | 57 | declare module '@babel/preset-env/lib/defaults' { 58 | declare module.exports: any; 59 | } 60 | 61 | declare module '@babel/preset-env/lib/index' { 62 | declare module.exports: any; 63 | } 64 | 65 | declare module '@babel/preset-env/lib/module-transformations' { 66 | declare module.exports: any; 67 | } 68 | 69 | declare module '@babel/preset-env/lib/normalize-options' { 70 | declare module.exports: any; 71 | } 72 | 73 | declare module '@babel/preset-env/lib/options' { 74 | declare module.exports: any; 75 | } 76 | 77 | declare module '@babel/preset-env/lib/targets-parser' { 78 | declare module.exports: any; 79 | } 80 | 81 | declare module '@babel/preset-env/lib/use-built-ins-entry-plugin' { 82 | declare module.exports: any; 83 | } 84 | 85 | declare module '@babel/preset-env/lib/use-built-ins-plugin' { 86 | declare module.exports: any; 87 | } 88 | 89 | declare module '@babel/preset-env/lib/utils' { 90 | declare module.exports: any; 91 | } 92 | 93 | // Filename aliases 94 | declare module '@babel/preset-env/data/built-in-features.js' { 95 | declare module.exports: $Exports<'@babel/preset-env/data/built-in-features'>; 96 | } 97 | declare module '@babel/preset-env/data/plugin-features.js' { 98 | declare module.exports: $Exports<'@babel/preset-env/data/plugin-features'>; 99 | } 100 | declare module '@babel/preset-env/data/shipped-proposals.js' { 101 | declare module.exports: $Exports<'@babel/preset-env/data/shipped-proposals'>; 102 | } 103 | declare module '@babel/preset-env/data/unreleased-labels.js' { 104 | declare module.exports: $Exports<'@babel/preset-env/data/unreleased-labels'>; 105 | } 106 | declare module '@babel/preset-env/lib/available-plugins.js' { 107 | declare module.exports: $Exports<'@babel/preset-env/lib/available-plugins'>; 108 | } 109 | declare module '@babel/preset-env/lib/built-in-definitions.js' { 110 | declare module.exports: $Exports<'@babel/preset-env/lib/built-in-definitions'>; 111 | } 112 | declare module '@babel/preset-env/lib/debug.js' { 113 | declare module.exports: $Exports<'@babel/preset-env/lib/debug'>; 114 | } 115 | declare module '@babel/preset-env/lib/default-includes.js' { 116 | declare module.exports: $Exports<'@babel/preset-env/lib/default-includes'>; 117 | } 118 | declare module '@babel/preset-env/lib/defaults.js' { 119 | declare module.exports: $Exports<'@babel/preset-env/lib/defaults'>; 120 | } 121 | declare module '@babel/preset-env/lib/index.js' { 122 | declare module.exports: $Exports<'@babel/preset-env/lib/index'>; 123 | } 124 | declare module '@babel/preset-env/lib/module-transformations.js' { 125 | declare module.exports: $Exports<'@babel/preset-env/lib/module-transformations'>; 126 | } 127 | declare module '@babel/preset-env/lib/normalize-options.js' { 128 | declare module.exports: $Exports<'@babel/preset-env/lib/normalize-options'>; 129 | } 130 | declare module '@babel/preset-env/lib/options.js' { 131 | declare module.exports: $Exports<'@babel/preset-env/lib/options'>; 132 | } 133 | declare module '@babel/preset-env/lib/targets-parser.js' { 134 | declare module.exports: $Exports<'@babel/preset-env/lib/targets-parser'>; 135 | } 136 | declare module '@babel/preset-env/lib/use-built-ins-entry-plugin.js' { 137 | declare module.exports: $Exports<'@babel/preset-env/lib/use-built-ins-entry-plugin'>; 138 | } 139 | declare module '@babel/preset-env/lib/use-built-ins-plugin.js' { 140 | declare module.exports: $Exports<'@babel/preset-env/lib/use-built-ins-plugin'>; 141 | } 142 | declare module '@babel/preset-env/lib/utils.js' { 143 | declare module.exports: $Exports<'@babel/preset-env/lib/utils'>; 144 | } 145 | -------------------------------------------------------------------------------- /flow-typed/npm/@babel/preset-flow_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 11744c4d4bc0cb7b5a5c5272f94dc84b 2 | // flow-typed version: <>/@babel/preset-flow_v^7.0.0/flow_v0.82.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * '@babel/preset-flow' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module '@babel/preset-flow' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module '@babel/preset-flow/lib/index' { 26 | declare module.exports: any; 27 | } 28 | 29 | // Filename aliases 30 | declare module '@babel/preset-flow/lib/index.js' { 31 | declare module.exports: $Exports<'@babel/preset-flow/lib/index'>; 32 | } 33 | -------------------------------------------------------------------------------- /flow-typed/npm/flow-bin_v0.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 6a5610678d4b01e13bbfbbc62bdaf583 2 | // flow-typed version: 3817bc6980/flow-bin_v0.x.x/flow_>=v0.25.x 3 | 4 | declare module "flow-bin" { 5 | declare module.exports: string; 6 | } 7 | -------------------------------------------------------------------------------- /flow-typed/npm/jest_v23.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 691597c4a5aab83a3b2e6d9ccd01a97d 2 | // flow-typed version: 71534a866d/jest_v23.x.x/flow_>=v0.39.x 3 | 4 | type JestMockFn, TReturn> = { 5 | (...args: TArguments): TReturn, 6 | /** 7 | * An object for introspecting mock calls 8 | */ 9 | mock: { 10 | /** 11 | * An array that represents all calls that have been made into this mock 12 | * function. Each call is represented by an array of arguments that were 13 | * passed during the call. 14 | */ 15 | calls: Array, 16 | /** 17 | * An array that contains all the object instances that have been 18 | * instantiated from this mock function. 19 | */ 20 | instances: Array, 21 | /** 22 | * An array that contains all the object results that have been 23 | * returned by this mock function call 24 | */ 25 | results: Array<{ isThrow: boolean, value: TReturn }> 26 | }, 27 | /** 28 | * Resets all information stored in the mockFn.mock.calls and 29 | * mockFn.mock.instances arrays. Often this is useful when you want to clean 30 | * up a mock's usage data between two assertions. 31 | */ 32 | mockClear(): void, 33 | /** 34 | * Resets all information stored in the mock. This is useful when you want to 35 | * completely restore a mock back to its initial state. 36 | */ 37 | mockReset(): void, 38 | /** 39 | * Removes the mock and restores the initial implementation. This is useful 40 | * when you want to mock functions in certain test cases and restore the 41 | * original implementation in others. Beware that mockFn.mockRestore only 42 | * works when mock was created with jest.spyOn. Thus you have to take care of 43 | * restoration yourself when manually assigning jest.fn(). 44 | */ 45 | mockRestore(): void, 46 | /** 47 | * Accepts a function that should be used as the implementation of the mock. 48 | * The mock itself will still record all calls that go into and instances 49 | * that come from itself -- the only difference is that the implementation 50 | * will also be executed when the mock is called. 51 | */ 52 | mockImplementation( 53 | fn: (...args: TArguments) => TReturn 54 | ): JestMockFn, 55 | /** 56 | * Accepts a function that will be used as an implementation of the mock for 57 | * one call to the mocked function. Can be chained so that multiple function 58 | * calls produce different results. 59 | */ 60 | mockImplementationOnce( 61 | fn: (...args: TArguments) => TReturn 62 | ): JestMockFn, 63 | /** 64 | * Accepts a string to use in test result output in place of "jest.fn()" to 65 | * indicate which mock function is being referenced. 66 | */ 67 | mockName(name: string): JestMockFn, 68 | /** 69 | * Just a simple sugar function for returning `this` 70 | */ 71 | mockReturnThis(): void, 72 | /** 73 | * Accepts a value that will be returned whenever the mock function is called. 74 | */ 75 | mockReturnValue(value: TReturn): JestMockFn, 76 | /** 77 | * Sugar for only returning a value once inside your mock 78 | */ 79 | mockReturnValueOnce(value: TReturn): JestMockFn, 80 | /** 81 | * Sugar for jest.fn().mockImplementation(() => Promise.resolve(value)) 82 | */ 83 | mockResolvedValue(value: TReturn): JestMockFn>, 84 | /** 85 | * Sugar for jest.fn().mockImplementationOnce(() => Promise.resolve(value)) 86 | */ 87 | mockResolvedValueOnce(value: TReturn): JestMockFn>, 88 | /** 89 | * Sugar for jest.fn().mockImplementation(() => Promise.reject(value)) 90 | */ 91 | mockRejectedValue(value: TReturn): JestMockFn>, 92 | /** 93 | * Sugar for jest.fn().mockImplementationOnce(() => Promise.reject(value)) 94 | */ 95 | mockRejectedValueOnce(value: TReturn): JestMockFn> 96 | }; 97 | 98 | type JestAsymmetricEqualityType = { 99 | /** 100 | * A custom Jasmine equality tester 101 | */ 102 | asymmetricMatch(value: mixed): boolean 103 | }; 104 | 105 | type JestCallsType = { 106 | allArgs(): mixed, 107 | all(): mixed, 108 | any(): boolean, 109 | count(): number, 110 | first(): mixed, 111 | mostRecent(): mixed, 112 | reset(): void 113 | }; 114 | 115 | type JestClockType = { 116 | install(): void, 117 | mockDate(date: Date): void, 118 | tick(milliseconds?: number): void, 119 | uninstall(): void 120 | }; 121 | 122 | type JestMatcherResult = { 123 | message?: string | (() => string), 124 | pass: boolean 125 | }; 126 | 127 | type JestMatcher = (actual: any, expected: any) => 128 | | JestMatcherResult 129 | | Promise; 130 | 131 | type JestPromiseType = { 132 | /** 133 | * Use rejects to unwrap the reason of a rejected promise so any other 134 | * matcher can be chained. If the promise is fulfilled the assertion fails. 135 | */ 136 | rejects: JestExpectType, 137 | /** 138 | * Use resolves to unwrap the value of a fulfilled promise so any other 139 | * matcher can be chained. If the promise is rejected the assertion fails. 140 | */ 141 | resolves: JestExpectType 142 | }; 143 | 144 | /** 145 | * Jest allows functions and classes to be used as test names in test() and 146 | * describe() 147 | */ 148 | type JestTestName = string | Function; 149 | 150 | /** 151 | * Plugin: jest-styled-components 152 | */ 153 | 154 | type JestStyledComponentsMatcherValue = 155 | | string 156 | | JestAsymmetricEqualityType 157 | | RegExp 158 | | typeof undefined; 159 | 160 | type JestStyledComponentsMatcherOptions = { 161 | media?: string; 162 | modifier?: string; 163 | supports?: string; 164 | } 165 | 166 | type JestStyledComponentsMatchersType = { 167 | toHaveStyleRule( 168 | property: string, 169 | value: JestStyledComponentsMatcherValue, 170 | options?: JestStyledComponentsMatcherOptions 171 | ): void, 172 | }; 173 | 174 | /** 175 | * Plugin: jest-enzyme 176 | */ 177 | type EnzymeMatchersType = { 178 | // 5.x 179 | toBeEmpty(): void, 180 | toBePresent(): void, 181 | // 6.x 182 | toBeChecked(): void, 183 | toBeDisabled(): void, 184 | toBeEmptyRender(): void, 185 | toContainMatchingElement(selector: string): void; 186 | toContainMatchingElements(n: number, selector: string): void; 187 | toContainExactlyOneMatchingElement(selector: string): void; 188 | toContainReact(element: React$Element): void, 189 | toExist(): void, 190 | toHaveClassName(className: string): void, 191 | toHaveHTML(html: string): void, 192 | toHaveProp: ((propKey: string, propValue?: any) => void) & ((props: Object) => void), 193 | toHaveRef(refName: string): void, 194 | toHaveState: ((stateKey: string, stateValue?: any) => void) & ((state: Object) => void), 195 | toHaveStyle: ((styleKey: string, styleValue?: any) => void) & ((style: Object) => void), 196 | toHaveTagName(tagName: string): void, 197 | toHaveText(text: string): void, 198 | toHaveValue(value: any): void, 199 | toIncludeText(text: string): void, 200 | toMatchElement( 201 | element: React$Element, 202 | options?: {| ignoreProps?: boolean |}, 203 | ): void, 204 | toMatchSelector(selector: string): void 205 | }; 206 | 207 | // DOM testing library extensions https://github.com/kentcdodds/dom-testing-library#custom-jest-matchers 208 | type DomTestingLibraryType = { 209 | toBeInTheDOM(): void, 210 | toHaveTextContent(content: string): void, 211 | toHaveAttribute(name: string, expectedValue?: string): void 212 | }; 213 | 214 | // Jest JQuery Matchers: https://github.com/unindented/custom-jquery-matchers 215 | type JestJQueryMatchersType = { 216 | toExist(): void, 217 | toHaveLength(len: number): void, 218 | toHaveId(id: string): void, 219 | toHaveClass(className: string): void, 220 | toHaveTag(tag: string): void, 221 | toHaveAttr(key: string, val?: any): void, 222 | toHaveProp(key: string, val?: any): void, 223 | toHaveText(text: string | RegExp): void, 224 | toHaveData(key: string, val?: any): void, 225 | toHaveValue(val: any): void, 226 | toHaveCss(css: {[key: string]: any}): void, 227 | toBeChecked(): void, 228 | toBeDisabled(): void, 229 | toBeEmpty(): void, 230 | toBeHidden(): void, 231 | toBeSelected(): void, 232 | toBeVisible(): void, 233 | toBeFocused(): void, 234 | toBeInDom(): void, 235 | toBeMatchedBy(sel: string): void, 236 | toHaveDescendant(sel: string): void, 237 | toHaveDescendantWithText(sel: string, text: string | RegExp): void 238 | }; 239 | 240 | 241 | // Jest Extended Matchers: https://github.com/jest-community/jest-extended 242 | type JestExtendedMatchersType = { 243 | /** 244 | * Note: Currently unimplemented 245 | * Passing assertion 246 | * 247 | * @param {String} message 248 | */ 249 | // pass(message: string): void; 250 | 251 | /** 252 | * Note: Currently unimplemented 253 | * Failing assertion 254 | * 255 | * @param {String} message 256 | */ 257 | // fail(message: string): void; 258 | 259 | /** 260 | * Use .toBeEmpty when checking if a String '', Array [] or Object {} is empty. 261 | */ 262 | toBeEmpty(): void; 263 | 264 | /** 265 | * Use .toBeOneOf when checking if a value is a member of a given Array. 266 | * @param {Array.<*>} members 267 | */ 268 | toBeOneOf(members: any[]): void; 269 | 270 | /** 271 | * Use `.toBeNil` when checking a value is `null` or `undefined`. 272 | */ 273 | toBeNil(): void; 274 | 275 | /** 276 | * Use `.toSatisfy` when you want to use a custom matcher by supplying a predicate function that returns a `Boolean`. 277 | * @param {Function} predicate 278 | */ 279 | toSatisfy(predicate: (n: any) => boolean): void; 280 | 281 | /** 282 | * Use `.toBeArray` when checking if a value is an `Array`. 283 | */ 284 | toBeArray(): void; 285 | 286 | /** 287 | * Use `.toBeArrayOfSize` when checking if a value is an `Array` of size x. 288 | * @param {Number} x 289 | */ 290 | toBeArrayOfSize(x: number): void; 291 | 292 | /** 293 | * Use `.toIncludeAllMembers` when checking if an `Array` contains all of the same members of a given set. 294 | * @param {Array.<*>} members 295 | */ 296 | toIncludeAllMembers(members: any[]): void; 297 | 298 | /** 299 | * Use `.toIncludeAnyMembers` when checking if an `Array` contains any of the members of a given set. 300 | * @param {Array.<*>} members 301 | */ 302 | toIncludeAnyMembers(members: any[]): void; 303 | 304 | /** 305 | * 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. 306 | * @param {Function} predicate 307 | */ 308 | toSatisfyAll(predicate: (n: any) => boolean): void; 309 | 310 | /** 311 | * Use `.toBeBoolean` when checking if a value is a `Boolean`. 312 | */ 313 | toBeBoolean(): void; 314 | 315 | /** 316 | * Use `.toBeTrue` when checking a value is equal (===) to `true`. 317 | */ 318 | toBeTrue(): void; 319 | 320 | /** 321 | * Use `.toBeFalse` when checking a value is equal (===) to `false`. 322 | */ 323 | toBeFalse(): void; 324 | 325 | /** 326 | * Use .toBeDate when checking if a value is a Date. 327 | */ 328 | toBeDate(): void; 329 | 330 | /** 331 | * Use `.toBeFunction` when checking if a value is a `Function`. 332 | */ 333 | toBeFunction(): void; 334 | 335 | /** 336 | * Use `.toHaveBeenCalledBefore` when checking if a `Mock` was called before another `Mock`. 337 | * 338 | * Note: Required Jest version >22 339 | * 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 340 | * 341 | * @param {Mock} mock 342 | */ 343 | toHaveBeenCalledBefore(mock: JestMockFn): void; 344 | 345 | /** 346 | * Use `.toBeNumber` when checking if a value is a `Number`. 347 | */ 348 | toBeNumber(): void; 349 | 350 | /** 351 | * Use `.toBeNaN` when checking a value is `NaN`. 352 | */ 353 | toBeNaN(): void; 354 | 355 | /** 356 | * Use `.toBeFinite` when checking if a value is a `Number`, not `NaN` or `Infinity`. 357 | */ 358 | toBeFinite(): void; 359 | 360 | /** 361 | * Use `.toBePositive` when checking if a value is a positive `Number`. 362 | */ 363 | toBePositive(): void; 364 | 365 | /** 366 | * Use `.toBeNegative` when checking if a value is a negative `Number`. 367 | */ 368 | toBeNegative(): void; 369 | 370 | /** 371 | * Use `.toBeEven` when checking if a value is an even `Number`. 372 | */ 373 | toBeEven(): void; 374 | 375 | /** 376 | * Use `.toBeOdd` when checking if a value is an odd `Number`. 377 | */ 378 | toBeOdd(): void; 379 | 380 | /** 381 | * Use `.toBeWithin` when checking if a number is in between the given bounds of: start (inclusive) and end (exclusive). 382 | * 383 | * @param {Number} start 384 | * @param {Number} end 385 | */ 386 | toBeWithin(start: number, end: number): void; 387 | 388 | /** 389 | * Use `.toBeObject` when checking if a value is an `Object`. 390 | */ 391 | toBeObject(): void; 392 | 393 | /** 394 | * Use `.toContainKey` when checking if an object contains the provided key. 395 | * 396 | * @param {String} key 397 | */ 398 | toContainKey(key: string): void; 399 | 400 | /** 401 | * Use `.toContainKeys` when checking if an object has all of the provided keys. 402 | * 403 | * @param {Array.} keys 404 | */ 405 | toContainKeys(keys: string[]): void; 406 | 407 | /** 408 | * Use `.toContainAllKeys` when checking if an object only contains all of the provided keys. 409 | * 410 | * @param {Array.} keys 411 | */ 412 | toContainAllKeys(keys: string[]): void; 413 | 414 | /** 415 | * Use `.toContainAnyKeys` when checking if an object contains at least one of the provided keys. 416 | * 417 | * @param {Array.} keys 418 | */ 419 | toContainAnyKeys(keys: string[]): void; 420 | 421 | /** 422 | * Use `.toContainValue` when checking if an object contains the provided value. 423 | * 424 | * @param {*} value 425 | */ 426 | toContainValue(value: any): void; 427 | 428 | /** 429 | * Use `.toContainValues` when checking if an object contains all of the provided values. 430 | * 431 | * @param {Array.<*>} values 432 | */ 433 | toContainValues(values: any[]): void; 434 | 435 | /** 436 | * Use `.toContainAllValues` when checking if an object only contains all of the provided values. 437 | * 438 | * @param {Array.<*>} values 439 | */ 440 | toContainAllValues(values: any[]): void; 441 | 442 | /** 443 | * Use `.toContainAnyValues` when checking if an object contains at least one of the provided values. 444 | * 445 | * @param {Array.<*>} values 446 | */ 447 | toContainAnyValues(values: any[]): void; 448 | 449 | /** 450 | * Use `.toContainEntry` when checking if an object contains the provided entry. 451 | * 452 | * @param {Array.} entry 453 | */ 454 | toContainEntry(entry: [string, string]): void; 455 | 456 | /** 457 | * Use `.toContainEntries` when checking if an object contains all of the provided entries. 458 | * 459 | * @param {Array.>} entries 460 | */ 461 | toContainEntries(entries: [string, string][]): void; 462 | 463 | /** 464 | * Use `.toContainAllEntries` when checking if an object only contains all of the provided entries. 465 | * 466 | * @param {Array.>} entries 467 | */ 468 | toContainAllEntries(entries: [string, string][]): void; 469 | 470 | /** 471 | * Use `.toContainAnyEntries` when checking if an object contains at least one of the provided entries. 472 | * 473 | * @param {Array.>} entries 474 | */ 475 | toContainAnyEntries(entries: [string, string][]): void; 476 | 477 | /** 478 | * Use `.toBeExtensible` when checking if an object is extensible. 479 | */ 480 | toBeExtensible(): void; 481 | 482 | /** 483 | * Use `.toBeFrozen` when checking if an object is frozen. 484 | */ 485 | toBeFrozen(): void; 486 | 487 | /** 488 | * Use `.toBeSealed` when checking if an object is sealed. 489 | */ 490 | toBeSealed(): void; 491 | 492 | /** 493 | * Use `.toBeString` when checking if a value is a `String`. 494 | */ 495 | toBeString(): void; 496 | 497 | /** 498 | * Use `.toEqualCaseInsensitive` when checking if a string is equal (===) to another ignoring the casing of both strings. 499 | * 500 | * @param {String} string 501 | */ 502 | toEqualCaseInsensitive(string: string): void; 503 | 504 | /** 505 | * Use `.toStartWith` when checking if a `String` starts with a given `String` prefix. 506 | * 507 | * @param {String} prefix 508 | */ 509 | toStartWith(prefix: string): void; 510 | 511 | /** 512 | * Use `.toEndWith` when checking if a `String` ends with a given `String` suffix. 513 | * 514 | * @param {String} suffix 515 | */ 516 | toEndWith(suffix: string): void; 517 | 518 | /** 519 | * Use `.toInclude` when checking if a `String` includes the given `String` substring. 520 | * 521 | * @param {String} substring 522 | */ 523 | toInclude(substring: string): void; 524 | 525 | /** 526 | * Use `.toIncludeRepeated` when checking if a `String` includes the given `String` substring the correct number of times. 527 | * 528 | * @param {String} substring 529 | * @param {Number} times 530 | */ 531 | toIncludeRepeated(substring: string, times: number): void; 532 | 533 | /** 534 | * Use `.toIncludeMultiple` when checking if a `String` includes all of the given substrings. 535 | * 536 | * @param {Array.} substring 537 | */ 538 | toIncludeMultiple(substring: string[]): void; 539 | }; 540 | 541 | interface JestExpectType { 542 | not: 543 | & JestExpectType 544 | & EnzymeMatchersType 545 | & DomTestingLibraryType 546 | & JestJQueryMatchersType 547 | & JestStyledComponentsMatchersType 548 | & JestExtendedMatchersType, 549 | /** 550 | * If you have a mock function, you can use .lastCalledWith to test what 551 | * arguments it was last called with. 552 | */ 553 | lastCalledWith(...args: Array): void, 554 | /** 555 | * toBe just checks that a value is what you expect. It uses === to check 556 | * strict equality. 557 | */ 558 | toBe(value: any): void, 559 | /** 560 | * Use .toBeCalledWith to ensure that a mock function was called with 561 | * specific arguments. 562 | */ 563 | toBeCalledWith(...args: Array): void, 564 | /** 565 | * Using exact equality with floating point numbers is a bad idea. Rounding 566 | * means that intuitive things fail. 567 | */ 568 | toBeCloseTo(num: number, delta: any): void, 569 | /** 570 | * Use .toBeDefined to check that a variable is not undefined. 571 | */ 572 | toBeDefined(): void, 573 | /** 574 | * Use .toBeFalsy when you don't care what a value is, you just want to 575 | * ensure a value is false in a boolean context. 576 | */ 577 | toBeFalsy(): void, 578 | /** 579 | * To compare floating point numbers, you can use toBeGreaterThan. 580 | */ 581 | toBeGreaterThan(number: number): void, 582 | /** 583 | * To compare floating point numbers, you can use toBeGreaterThanOrEqual. 584 | */ 585 | toBeGreaterThanOrEqual(number: number): void, 586 | /** 587 | * To compare floating point numbers, you can use toBeLessThan. 588 | */ 589 | toBeLessThan(number: number): void, 590 | /** 591 | * To compare floating point numbers, you can use toBeLessThanOrEqual. 592 | */ 593 | toBeLessThanOrEqual(number: number): void, 594 | /** 595 | * Use .toBeInstanceOf(Class) to check that an object is an instance of a 596 | * class. 597 | */ 598 | toBeInstanceOf(cls: Class<*>): void, 599 | /** 600 | * .toBeNull() is the same as .toBe(null) but the error messages are a bit 601 | * nicer. 602 | */ 603 | toBeNull(): void, 604 | /** 605 | * Use .toBeTruthy when you don't care what a value is, you just want to 606 | * ensure a value is true in a boolean context. 607 | */ 608 | toBeTruthy(): void, 609 | /** 610 | * Use .toBeUndefined to check that a variable is undefined. 611 | */ 612 | toBeUndefined(): void, 613 | /** 614 | * Use .toContain when you want to check that an item is in a list. For 615 | * testing the items in the list, this uses ===, a strict equality check. 616 | */ 617 | toContain(item: any): void, 618 | /** 619 | * Use .toContainEqual when you want to check that an item is in a list. For 620 | * testing the items in the list, this matcher recursively checks the 621 | * equality of all fields, rather than checking for object identity. 622 | */ 623 | toContainEqual(item: any): void, 624 | /** 625 | * Use .toEqual when you want to check that two objects have the same value. 626 | * This matcher recursively checks the equality of all fields, rather than 627 | * checking for object identity. 628 | */ 629 | toEqual(value: any): void, 630 | /** 631 | * Use .toHaveBeenCalled to ensure that a mock function got called. 632 | */ 633 | toHaveBeenCalled(): void, 634 | toBeCalled(): void; 635 | /** 636 | * Use .toHaveBeenCalledTimes to ensure that a mock function got called exact 637 | * number of times. 638 | */ 639 | toHaveBeenCalledTimes(number: number): void, 640 | toBeCalledTimes(number: number): void; 641 | /** 642 | * 643 | */ 644 | toHaveBeenNthCalledWith(nthCall: number, ...args: Array): void; 645 | nthCalledWith(nthCall: number, ...args: Array): void; 646 | /** 647 | * 648 | */ 649 | toHaveReturned(): void; 650 | toReturn(): void; 651 | /** 652 | * 653 | */ 654 | toHaveReturnedTimes(number: number): void; 655 | toReturnTimes(number: number): void; 656 | /** 657 | * 658 | */ 659 | toHaveReturnedWith(value: any): void; 660 | toReturnWith(value: any): void; 661 | /** 662 | * 663 | */ 664 | toHaveLastReturnedWith(value: any): void; 665 | lastReturnedWith(value: any): void; 666 | /** 667 | * 668 | */ 669 | toHaveNthReturnedWith(nthCall: number, value: any): void; 670 | nthReturnedWith(nthCall: number, value: any): void; 671 | /** 672 | * Use .toHaveBeenCalledWith to ensure that a mock function was called with 673 | * specific arguments. 674 | */ 675 | toHaveBeenCalledWith(...args: Array): void, 676 | toBeCalledWith(...args: Array): void, 677 | /** 678 | * Use .toHaveBeenLastCalledWith to ensure that a mock function was last called 679 | * with specific arguments. 680 | */ 681 | toHaveBeenLastCalledWith(...args: Array): void, 682 | lastCalledWith(...args: Array): void, 683 | /** 684 | * Check that an object has a .length property and it is set to a certain 685 | * numeric value. 686 | */ 687 | toHaveLength(number: number): void, 688 | /** 689 | * 690 | */ 691 | toHaveProperty(propPath: string, value?: any): void, 692 | /** 693 | * Use .toMatch to check that a string matches a regular expression or string. 694 | */ 695 | toMatch(regexpOrString: RegExp | string): void, 696 | /** 697 | * Use .toMatchObject to check that a javascript object matches a subset of the properties of an object. 698 | */ 699 | toMatchObject(object: Object | Array): void, 700 | /** 701 | * Use .toStrictEqual to check that a javascript object matches a subset of the properties of an object. 702 | */ 703 | toStrictEqual(value: any): void, 704 | /** 705 | * This ensures that an Object matches the most recent snapshot. 706 | */ 707 | toMatchSnapshot(propertyMatchers?: any, name?: string): void, 708 | /** 709 | * This ensures that an Object matches the most recent snapshot. 710 | */ 711 | toMatchSnapshot(name: string): void, 712 | 713 | toMatchInlineSnapshot(snapshot?: string): void, 714 | toMatchInlineSnapshot(propertyMatchers?: any, snapshot?: string): void, 715 | /** 716 | * Use .toThrow to test that a function throws when it is called. 717 | * If you want to test that a specific error gets thrown, you can provide an 718 | * argument to toThrow. The argument can be a string for the error message, 719 | * a class for the error, or a regex that should match the error. 720 | * 721 | * Alias: .toThrowError 722 | */ 723 | toThrow(message?: string | Error | Class | RegExp): void, 724 | toThrowError(message?: string | Error | Class | RegExp): void, 725 | /** 726 | * Use .toThrowErrorMatchingSnapshot to test that a function throws a error 727 | * matching the most recent snapshot when it is called. 728 | */ 729 | toThrowErrorMatchingSnapshot(): void, 730 | toThrowErrorMatchingInlineSnapshot(snapshot?: string): void, 731 | } 732 | 733 | type JestObjectType = { 734 | /** 735 | * Disables automatic mocking in the module loader. 736 | * 737 | * After this method is called, all `require()`s will return the real 738 | * versions of each module (rather than a mocked version). 739 | */ 740 | disableAutomock(): JestObjectType, 741 | /** 742 | * An un-hoisted version of disableAutomock 743 | */ 744 | autoMockOff(): JestObjectType, 745 | /** 746 | * Enables automatic mocking in the module loader. 747 | */ 748 | enableAutomock(): JestObjectType, 749 | /** 750 | * An un-hoisted version of enableAutomock 751 | */ 752 | autoMockOn(): JestObjectType, 753 | /** 754 | * Clears the mock.calls and mock.instances properties of all mocks. 755 | * Equivalent to calling .mockClear() on every mocked function. 756 | */ 757 | clearAllMocks(): JestObjectType, 758 | /** 759 | * Resets the state of all mocks. Equivalent to calling .mockReset() on every 760 | * mocked function. 761 | */ 762 | resetAllMocks(): JestObjectType, 763 | /** 764 | * Restores all mocks back to their original value. 765 | */ 766 | restoreAllMocks(): JestObjectType, 767 | /** 768 | * Removes any pending timers from the timer system. 769 | */ 770 | clearAllTimers(): void, 771 | /** 772 | * The same as `mock` but not moved to the top of the expectation by 773 | * babel-jest. 774 | */ 775 | doMock(moduleName: string, moduleFactory?: any): JestObjectType, 776 | /** 777 | * The same as `unmock` but not moved to the top of the expectation by 778 | * babel-jest. 779 | */ 780 | dontMock(moduleName: string): JestObjectType, 781 | /** 782 | * Returns a new, unused mock function. Optionally takes a mock 783 | * implementation. 784 | */ 785 | fn, TReturn>( 786 | implementation?: (...args: TArguments) => TReturn 787 | ): JestMockFn, 788 | /** 789 | * Determines if the given function is a mocked function. 790 | */ 791 | isMockFunction(fn: Function): boolean, 792 | /** 793 | * Given the name of a module, use the automatic mocking system to generate a 794 | * mocked version of the module for you. 795 | */ 796 | genMockFromModule(moduleName: string): any, 797 | /** 798 | * Mocks a module with an auto-mocked version when it is being required. 799 | * 800 | * The second argument can be used to specify an explicit module factory that 801 | * is being run instead of using Jest's automocking feature. 802 | * 803 | * The third argument can be used to create virtual mocks -- mocks of modules 804 | * that don't exist anywhere in the system. 805 | */ 806 | mock( 807 | moduleName: string, 808 | moduleFactory?: any, 809 | options?: Object 810 | ): JestObjectType, 811 | /** 812 | * Returns the actual module instead of a mock, bypassing all checks on 813 | * whether the module should receive a mock implementation or not. 814 | */ 815 | requireActual(moduleName: string): any, 816 | /** 817 | * Returns a mock module instead of the actual module, bypassing all checks 818 | * on whether the module should be required normally or not. 819 | */ 820 | requireMock(moduleName: string): any, 821 | /** 822 | * Resets the module registry - the cache of all required modules. This is 823 | * useful to isolate modules where local state might conflict between tests. 824 | */ 825 | resetModules(): JestObjectType, 826 | /** 827 | * Exhausts the micro-task queue (usually interfaced in node via 828 | * process.nextTick). 829 | */ 830 | runAllTicks(): void, 831 | /** 832 | * Exhausts the macro-task queue (i.e., all tasks queued by setTimeout(), 833 | * setInterval(), and setImmediate()). 834 | */ 835 | runAllTimers(): void, 836 | /** 837 | * Exhausts all tasks queued by setImmediate(). 838 | */ 839 | runAllImmediates(): void, 840 | /** 841 | * Executes only the macro task queue (i.e. all tasks queued by setTimeout() 842 | * or setInterval() and setImmediate()). 843 | */ 844 | advanceTimersByTime(msToRun: number): void, 845 | /** 846 | * Executes only the macro task queue (i.e. all tasks queued by setTimeout() 847 | * or setInterval() and setImmediate()). 848 | * 849 | * Renamed to `advanceTimersByTime`. 850 | */ 851 | runTimersToTime(msToRun: number): void, 852 | /** 853 | * Executes only the macro-tasks that are currently pending (i.e., only the 854 | * tasks that have been queued by setTimeout() or setInterval() up to this 855 | * point) 856 | */ 857 | runOnlyPendingTimers(): void, 858 | /** 859 | * Explicitly supplies the mock object that the module system should return 860 | * for the specified module. Note: It is recommended to use jest.mock() 861 | * instead. 862 | */ 863 | setMock(moduleName: string, moduleExports: any): JestObjectType, 864 | /** 865 | * Indicates that the module system should never return a mocked version of 866 | * the specified module from require() (e.g. that it should always return the 867 | * real module). 868 | */ 869 | unmock(moduleName: string): JestObjectType, 870 | /** 871 | * Instructs Jest to use fake versions of the standard timer functions 872 | * (setTimeout, setInterval, clearTimeout, clearInterval, nextTick, 873 | * setImmediate and clearImmediate). 874 | */ 875 | useFakeTimers(): JestObjectType, 876 | /** 877 | * Instructs Jest to use the real versions of the standard timer functions. 878 | */ 879 | useRealTimers(): JestObjectType, 880 | /** 881 | * Creates a mock function similar to jest.fn but also tracks calls to 882 | * object[methodName]. 883 | */ 884 | spyOn(object: Object, methodName: string, accessType?: "get" | "set"): JestMockFn, 885 | /** 886 | * Set the default timeout interval for tests and before/after hooks in milliseconds. 887 | * Note: The default timeout interval is 5 seconds if this method is not called. 888 | */ 889 | setTimeout(timeout: number): JestObjectType 890 | }; 891 | 892 | type JestSpyType = { 893 | calls: JestCallsType 894 | }; 895 | 896 | /** Runs this function after every test inside this context */ 897 | declare function afterEach( 898 | fn: (done: () => void) => ?Promise, 899 | timeout?: number 900 | ): void; 901 | /** Runs this function before every test inside this context */ 902 | declare function beforeEach( 903 | fn: (done: () => void) => ?Promise, 904 | timeout?: number 905 | ): void; 906 | /** Runs this function after all tests have finished inside this context */ 907 | declare function afterAll( 908 | fn: (done: () => void) => ?Promise, 909 | timeout?: number 910 | ): void; 911 | /** Runs this function before any tests have started inside this context */ 912 | declare function beforeAll( 913 | fn: (done: () => void) => ?Promise, 914 | timeout?: number 915 | ): void; 916 | 917 | /** A context for grouping tests together */ 918 | declare var describe: { 919 | /** 920 | * Creates a block that groups together several related tests in one "test suite" 921 | */ 922 | (name: JestTestName, fn: () => void): void, 923 | 924 | /** 925 | * Only run this describe block 926 | */ 927 | only(name: JestTestName, fn: () => void): void, 928 | 929 | /** 930 | * Skip running this describe block 931 | */ 932 | skip(name: JestTestName, fn: () => void): void, 933 | 934 | /** 935 | * each runs this test against array of argument arrays per each run 936 | * 937 | * @param {table} table of Test 938 | */ 939 | each( 940 | table: Array | mixed> 941 | ): ( 942 | name: JestTestName, 943 | fn?: (...args: Array) => ?Promise 944 | ) => void, 945 | }; 946 | 947 | /** An individual test unit */ 948 | declare var it: { 949 | /** 950 | * An individual test unit 951 | * 952 | * @param {JestTestName} Name of Test 953 | * @param {Function} Test 954 | * @param {number} Timeout for the test, in milliseconds. 955 | */ 956 | ( 957 | name: JestTestName, 958 | fn?: (done: () => void) => ?Promise, 959 | timeout?: number 960 | ): void, 961 | /** 962 | * each runs this test against array of argument arrays per each run 963 | * 964 | * @param {table} table of Test 965 | */ 966 | each( 967 | table: Array | mixed> 968 | ): ( 969 | name: JestTestName, 970 | fn?: (...args: Array) => ?Promise 971 | ) => void, 972 | /** 973 | * Only run this test 974 | * 975 | * @param {JestTestName} Name of Test 976 | * @param {Function} Test 977 | * @param {number} Timeout for the test, in milliseconds. 978 | */ 979 | only( 980 | name: JestTestName, 981 | fn?: (done: () => void) => ?Promise, 982 | timeout?: number 983 | ): { 984 | each( 985 | table: Array | mixed> 986 | ): ( 987 | name: JestTestName, 988 | fn?: (...args: Array) => ?Promise 989 | ) => void, 990 | }, 991 | /** 992 | * Skip running this test 993 | * 994 | * @param {JestTestName} Name of Test 995 | * @param {Function} Test 996 | * @param {number} Timeout for the test, in milliseconds. 997 | */ 998 | skip( 999 | name: JestTestName, 1000 | fn?: (done: () => void) => ?Promise, 1001 | timeout?: number 1002 | ): void, 1003 | /** 1004 | * Run the test concurrently 1005 | * 1006 | * @param {JestTestName} Name of Test 1007 | * @param {Function} Test 1008 | * @param {number} Timeout for the test, in milliseconds. 1009 | */ 1010 | concurrent( 1011 | name: JestTestName, 1012 | fn?: (done: () => void) => ?Promise, 1013 | timeout?: number 1014 | ): void, 1015 | /** 1016 | * each runs this test against array of argument arrays per each run 1017 | * 1018 | * @param {table} table of Test 1019 | */ 1020 | each( 1021 | table: Array | mixed> 1022 | ): ( 1023 | name: JestTestName, 1024 | fn?: (...args: Array) => ?Promise 1025 | ) => void, 1026 | }; 1027 | declare function fit( 1028 | name: JestTestName, 1029 | fn: (done: () => void) => ?Promise, 1030 | timeout?: number 1031 | ): void; 1032 | /** An individual test unit */ 1033 | declare var test: typeof it; 1034 | /** A disabled group of tests */ 1035 | declare var xdescribe: typeof describe; 1036 | /** A focused group of tests */ 1037 | declare var fdescribe: typeof describe; 1038 | /** A disabled individual test */ 1039 | declare var xit: typeof it; 1040 | /** A disabled individual test */ 1041 | declare var xtest: typeof it; 1042 | 1043 | type JestPrettyFormatColors = { 1044 | comment: { close: string, open: string }, 1045 | content: { close: string, open: string }, 1046 | prop: { close: string, open: string }, 1047 | tag: { close: string, open: string }, 1048 | value: { close: string, open: string }, 1049 | }; 1050 | 1051 | type JestPrettyFormatIndent = string => string; 1052 | type JestPrettyFormatRefs = Array; 1053 | type JestPrettyFormatPrint = any => string; 1054 | type JestPrettyFormatStringOrNull = string | null; 1055 | 1056 | type JestPrettyFormatOptions = {| 1057 | callToJSON: boolean, 1058 | edgeSpacing: string, 1059 | escapeRegex: boolean, 1060 | highlight: boolean, 1061 | indent: number, 1062 | maxDepth: number, 1063 | min: boolean, 1064 | plugins: JestPrettyFormatPlugins, 1065 | printFunctionName: boolean, 1066 | spacing: string, 1067 | theme: {| 1068 | comment: string, 1069 | content: string, 1070 | prop: string, 1071 | tag: string, 1072 | value: string, 1073 | |}, 1074 | |}; 1075 | 1076 | type JestPrettyFormatPlugin = { 1077 | print: ( 1078 | val: any, 1079 | serialize: JestPrettyFormatPrint, 1080 | indent: JestPrettyFormatIndent, 1081 | opts: JestPrettyFormatOptions, 1082 | colors: JestPrettyFormatColors, 1083 | ) => string, 1084 | test: any => boolean, 1085 | }; 1086 | 1087 | type JestPrettyFormatPlugins = Array; 1088 | 1089 | /** The expect function is used every time you want to test a value */ 1090 | declare var expect: { 1091 | /** The object that you want to make assertions against */ 1092 | (value: any): 1093 | & JestExpectType 1094 | & JestPromiseType 1095 | & EnzymeMatchersType 1096 | & DomTestingLibraryType 1097 | & JestJQueryMatchersType 1098 | & JestStyledComponentsMatchersType 1099 | & JestExtendedMatchersType, 1100 | 1101 | /** Add additional Jasmine matchers to Jest's roster */ 1102 | extend(matchers: { [name: string]: JestMatcher }): void, 1103 | /** Add a module that formats application-specific data structures. */ 1104 | addSnapshotSerializer(pluginModule: JestPrettyFormatPlugin): void, 1105 | assertions(expectedAssertions: number): void, 1106 | hasAssertions(): void, 1107 | any(value: mixed): JestAsymmetricEqualityType, 1108 | anything(): any, 1109 | arrayContaining(value: Array): Array, 1110 | objectContaining(value: Object): Object, 1111 | /** Matches any received string that contains the exact expected string. */ 1112 | stringContaining(value: string): string, 1113 | stringMatching(value: string | RegExp): string, 1114 | not: { 1115 | arrayContaining: (value: $ReadOnlyArray) => Array, 1116 | objectContaining: (value: {}) => Object, 1117 | stringContaining: (value: string) => string, 1118 | stringMatching: (value: string | RegExp) => string, 1119 | }, 1120 | }; 1121 | 1122 | // TODO handle return type 1123 | // http://jasmine.github.io/2.4/introduction.html#section-Spies 1124 | declare function spyOn(value: mixed, method: string): Object; 1125 | 1126 | /** Holds all functions related to manipulating test runner */ 1127 | declare var jest: JestObjectType; 1128 | 1129 | /** 1130 | * The global Jasmine object, this is generally not exposed as the public API, 1131 | * using features inside here could break in later versions of Jest. 1132 | */ 1133 | declare var jasmine: { 1134 | DEFAULT_TIMEOUT_INTERVAL: number, 1135 | any(value: mixed): JestAsymmetricEqualityType, 1136 | anything(): any, 1137 | arrayContaining(value: Array): Array, 1138 | clock(): JestClockType, 1139 | createSpy(name: string): JestSpyType, 1140 | createSpyObj( 1141 | baseName: string, 1142 | methodNames: Array 1143 | ): { [methodName: string]: JestSpyType }, 1144 | objectContaining(value: Object): Object, 1145 | stringMatching(value: string): string 1146 | }; 1147 | -------------------------------------------------------------------------------- /flow-typed/npm/prettier_v1.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 4eed8da2dc730dc33e7710b465eaa44b 2 | // flow-typed version: cc7a557b34/prettier_v1.x.x/flow_>=v0.56.x 3 | 4 | declare module "prettier" { 5 | declare type AST = Object; 6 | declare type Doc = Object; 7 | declare type FastPath = Object; 8 | 9 | declare type PrettierParserName = 10 | | "babylon" 11 | | "flow" 12 | | "typescript" 13 | | "postcss" 14 | | "css" 15 | | "less" 16 | | "scss" 17 | | "json" 18 | | "graphql" 19 | | "markdown" 20 | | "vue"; 21 | 22 | declare type PrettierParser = { 23 | [name: PrettierParserName]: (text: string, options?: Object) => AST 24 | }; 25 | 26 | declare type CustomParser = ( 27 | text: string, 28 | parsers: PrettierParser, 29 | options: Options 30 | ) => AST; 31 | 32 | declare type Options = {| 33 | printWidth?: number, 34 | tabWidth?: number, 35 | useTabs?: boolean, 36 | semi?: boolean, 37 | singleQuote?: boolean, 38 | trailingComma?: "none" | "es5" | "all", 39 | bracketSpacing?: boolean, 40 | jsxBracketSameLine?: boolean, 41 | arrowParens?: "avoid" | "always", 42 | rangeStart?: number, 43 | rangeEnd?: number, 44 | parser?: PrettierParserName | CustomParser, 45 | filepath?: string, 46 | requirePragma?: boolean, 47 | insertPragma?: boolean, 48 | proseWrap?: "always" | "never" | "preserve", 49 | plugins?: Array 50 | |}; 51 | 52 | declare type Plugin = { 53 | languages: SupportLanguage, 54 | parsers: { [parserName: string]: Parser }, 55 | printers: { [astFormat: string]: Printer } 56 | }; 57 | 58 | declare type Parser = { 59 | parse: ( 60 | text: string, 61 | parsers: { [parserName: string]: Parser }, 62 | options: Object 63 | ) => AST, 64 | astFormat: string 65 | }; 66 | 67 | declare type Printer = { 68 | print: ( 69 | path: FastPath, 70 | options: Object, 71 | print: (path: FastPath) => Doc 72 | ) => Doc, 73 | embed: ( 74 | path: FastPath, 75 | print: (path: FastPath) => Doc, 76 | textToDoc: (text: string, options: Object) => Doc, 77 | options: Object 78 | ) => ?Doc 79 | }; 80 | 81 | declare type CursorOptions = {| 82 | cursorOffset: number, 83 | printWidth?: $PropertyType, 84 | tabWidth?: $PropertyType, 85 | useTabs?: $PropertyType, 86 | semi?: $PropertyType, 87 | singleQuote?: $PropertyType, 88 | trailingComma?: $PropertyType, 89 | bracketSpacing?: $PropertyType, 90 | jsxBracketSameLine?: $PropertyType, 91 | arrowParens?: $PropertyType, 92 | parser?: $PropertyType, 93 | filepath?: $PropertyType, 94 | requirePragma?: $PropertyType, 95 | insertPragma?: $PropertyType, 96 | proseWrap?: $PropertyType, 97 | plugins?: $PropertyType 98 | |}; 99 | 100 | declare type CursorResult = {| 101 | formatted: string, 102 | cursorOffset: number 103 | |}; 104 | 105 | declare type ResolveConfigOptions = {| 106 | useCache?: boolean, 107 | config?: string, 108 | editorconfig?: boolean 109 | |}; 110 | 111 | declare type SupportLanguage = { 112 | name: string, 113 | since: string, 114 | parsers: Array, 115 | group?: string, 116 | tmScope: string, 117 | aceMode: string, 118 | codemirrorMode: string, 119 | codemirrorMimeType: string, 120 | aliases?: Array, 121 | extensions: Array, 122 | filenames?: Array, 123 | linguistLanguageId: number, 124 | vscodeLanguageIds: Array 125 | }; 126 | 127 | declare type SupportOption = {| 128 | since: string, 129 | type: "int" | "boolean" | "choice" | "path", 130 | deprecated?: string, 131 | redirect?: SupportOptionRedirect, 132 | description: string, 133 | oppositeDescription?: string, 134 | default: SupportOptionValue, 135 | range?: SupportOptionRange, 136 | choices?: SupportOptionChoice 137 | |}; 138 | 139 | declare type SupportOptionRedirect = {| 140 | options: string, 141 | value: SupportOptionValue 142 | |}; 143 | 144 | declare type SupportOptionRange = {| 145 | start: number, 146 | end: number, 147 | step: number 148 | |}; 149 | 150 | declare type SupportOptionChoice = {| 151 | value: boolean | string, 152 | description?: string, 153 | since?: string, 154 | deprecated?: string, 155 | redirect?: SupportOptionValue 156 | |}; 157 | 158 | declare type SupportOptionValue = number | boolean | string; 159 | 160 | declare type SupportInfo = {| 161 | languages: Array, 162 | options: Array 163 | |}; 164 | 165 | declare type Prettier = {| 166 | format: (source: string, options?: Options) => string, 167 | check: (source: string, options?: Options) => boolean, 168 | formatWithCursor: (source: string, options: CursorOptions) => CursorResult, 169 | resolveConfig: { 170 | (filePath: string, options?: ResolveConfigOptions): Promise, 171 | sync(filePath: string, options?: ResolveConfigOptions): Promise 172 | }, 173 | clearConfigCache: () => void, 174 | getSupportInfo: (version?: string) => SupportInfo 175 | |}; 176 | 177 | declare export default Prettier; 178 | } 179 | -------------------------------------------------------------------------------- /flow-typed/npm/rimraf_v2.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 1dff23447d5e18f5ac2b05aaec7cfb74 2 | // flow-typed version: a453e98ea2/rimraf_v2.x.x/flow_>=v0.25.0 3 | 4 | declare module 'rimraf' { 5 | declare type Options = { 6 | maxBusyTries?: number, 7 | emfileWait?: number, 8 | glob?: boolean, 9 | disableGlob?: boolean 10 | }; 11 | 12 | declare type Callback = (err: ?Error, path: ?string) => void; 13 | 14 | declare module.exports: { 15 | (f: string, opts?: Options | Callback, callback?: Callback): void; 16 | sync(path: string, opts?: Options): void; 17 | }; 18 | } 19 | -------------------------------------------------------------------------------- /flow-typed/npm/rollup-plugin-babel_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 973c9500e4cab50d99a36b48129481e3 2 | // flow-typed version: <>/rollup-plugin-babel_v^4.0.3/flow_v0.82.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'rollup-plugin-babel' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'rollup-plugin-babel' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'rollup-plugin-babel/dist/rollup-plugin-babel.cjs' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'rollup-plugin-babel/dist/rollup-plugin-babel.esm' { 30 | declare module.exports: any; 31 | } 32 | 33 | declare module 'rollup-plugin-babel/src/constants' { 34 | declare module.exports: any; 35 | } 36 | 37 | declare module 'rollup-plugin-babel/src/helperPlugin' { 38 | declare module.exports: any; 39 | } 40 | 41 | declare module 'rollup-plugin-babel/src/index' { 42 | declare module.exports: any; 43 | } 44 | 45 | declare module 'rollup-plugin-babel/src/preflightCheck' { 46 | declare module.exports: any; 47 | } 48 | 49 | declare module 'rollup-plugin-babel/src/utils' { 50 | declare module.exports: any; 51 | } 52 | 53 | // Filename aliases 54 | declare module 'rollup-plugin-babel/dist/rollup-plugin-babel.cjs.js' { 55 | declare module.exports: $Exports<'rollup-plugin-babel/dist/rollup-plugin-babel.cjs'>; 56 | } 57 | declare module 'rollup-plugin-babel/dist/rollup-plugin-babel.esm.js' { 58 | declare module.exports: $Exports<'rollup-plugin-babel/dist/rollup-plugin-babel.esm'>; 59 | } 60 | declare module 'rollup-plugin-babel/src/constants.js' { 61 | declare module.exports: $Exports<'rollup-plugin-babel/src/constants'>; 62 | } 63 | declare module 'rollup-plugin-babel/src/helperPlugin.js' { 64 | declare module.exports: $Exports<'rollup-plugin-babel/src/helperPlugin'>; 65 | } 66 | declare module 'rollup-plugin-babel/src/index.js' { 67 | declare module.exports: $Exports<'rollup-plugin-babel/src/index'>; 68 | } 69 | declare module 'rollup-plugin-babel/src/preflightCheck.js' { 70 | declare module.exports: $Exports<'rollup-plugin-babel/src/preflightCheck'>; 71 | } 72 | declare module 'rollup-plugin-babel/src/utils.js' { 73 | declare module.exports: $Exports<'rollup-plugin-babel/src/utils'>; 74 | } 75 | -------------------------------------------------------------------------------- /flow-typed/npm/rollup-plugin-replace_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: db087c0f8735aace9843e6ebf0fc6db2 2 | // flow-typed version: <>/rollup-plugin-replace_v^2.0.0/flow_v0.82.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'rollup-plugin-replace' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'rollup-plugin-replace' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'rollup-plugin-replace/dist/rollup-plugin-replace.cjs' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'rollup-plugin-replace/dist/rollup-plugin-replace.es' { 30 | declare module.exports: any; 31 | } 32 | 33 | declare module 'rollup-plugin-replace/src/index' { 34 | declare module.exports: any; 35 | } 36 | 37 | // Filename aliases 38 | declare module 'rollup-plugin-replace/dist/rollup-plugin-replace.cjs.js' { 39 | declare module.exports: $Exports<'rollup-plugin-replace/dist/rollup-plugin-replace.cjs'>; 40 | } 41 | declare module 'rollup-plugin-replace/dist/rollup-plugin-replace.es.js' { 42 | declare module.exports: $Exports<'rollup-plugin-replace/dist/rollup-plugin-replace.es'>; 43 | } 44 | declare module 'rollup-plugin-replace/src/index.js' { 45 | declare module.exports: $Exports<'rollup-plugin-replace/src/index'>; 46 | } 47 | -------------------------------------------------------------------------------- /flow-typed/npm/rollup-plugin-uglify_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 7d8521b06a61516b9b178233496d21bd 2 | // flow-typed version: <>/rollup-plugin-uglify_v^6.0.0/flow_v0.82.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'rollup-plugin-uglify' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'rollup-plugin-uglify' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'rollup-plugin-uglify/transform' { 26 | declare module.exports: any; 27 | } 28 | 29 | // Filename aliases 30 | declare module 'rollup-plugin-uglify/index' { 31 | declare module.exports: $Exports<'rollup-plugin-uglify'>; 32 | } 33 | declare module 'rollup-plugin-uglify/index.js' { 34 | declare module.exports: $Exports<'rollup-plugin-uglify'>; 35 | } 36 | declare module 'rollup-plugin-uglify/transform.js' { 37 | declare module.exports: $Exports<'rollup-plugin-uglify/transform'>; 38 | } 39 | -------------------------------------------------------------------------------- /flow-typed/npm/rollup_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 74b987f228ae8ecd554f7ca28416e775 2 | // flow-typed version: <>/rollup_v^0.66.2/flow_v0.82.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'rollup' 8 | * 9 | * Fill this stub out by replacing all the `any` types. 10 | * 11 | * Once filled out, we encourage you to share your work with the 12 | * community by sending a pull request to: 13 | * https://github.com/flowtype/flow-typed 14 | */ 15 | 16 | declare module 'rollup' { 17 | declare module.exports: any; 18 | } 19 | 20 | /** 21 | * We include stubs for each file inside this npm package in case you need to 22 | * require those files directly. Feel free to delete any files that aren't 23 | * needed. 24 | */ 25 | declare module 'rollup/dist/rollup.browser' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'rollup/dist/rollup.es' { 30 | declare module.exports: any; 31 | } 32 | 33 | declare module 'rollup/dist/rollup' { 34 | declare module.exports: any; 35 | } 36 | 37 | // Filename aliases 38 | declare module 'rollup/dist/rollup.browser.js' { 39 | declare module.exports: $Exports<'rollup/dist/rollup.browser'>; 40 | } 41 | declare module 'rollup/dist/rollup.es.js' { 42 | declare module.exports: $Exports<'rollup/dist/rollup.es'>; 43 | } 44 | declare module 'rollup/dist/rollup.js' { 45 | declare module.exports: $Exports<'rollup/dist/rollup'>; 46 | } 47 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable flowtype/require-valid-file-annotation */ 2 | 3 | module.exports = { 4 | setupFiles: [ 5 | // for some painful reason this is needed for our 'async' usage 6 | // in drop-dev-warnings-for-prod.spec.js 7 | require.resolve('regenerator-runtime/runtime'), 8 | ], 9 | }; 10 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tiny-warning", 3 | "version": "1.0.3", 4 | "keywords": [ 5 | "warning", 6 | "warn" 7 | ], 8 | "description": "A tiny warning function", 9 | "main": "dist/tiny-warning.cjs.js", 10 | "module": "dist/tiny-warning.esm.js", 11 | "types": "src/index.d.ts", 12 | "sideEffects": false, 13 | "files": [ 14 | "/dist", 15 | "/src" 16 | ], 17 | "author": "Alex Reardon ", 18 | "repository": { 19 | "type": "git", 20 | "url": "https://github.com/alexreardon/tiny-warning.git" 21 | }, 22 | "bugs": { 23 | "url": "https://github.com/alexreardon/tiny-warning/issues" 24 | }, 25 | "license": "MIT", 26 | "scripts": { 27 | "test": "yarn jest", 28 | "lint": "yarn prettier --debug-check src/** test/**", 29 | "typecheck": "yarn flow", 30 | "validate": "yarn lint && yarn flow", 31 | "build:clean": "rimraf dist", 32 | "build:flow": "echo \"// @flow\n\nexport * from '../src';\" > dist/tiny-warning.cjs.js.flow", 33 | "build:dist": "yarn rollup --config rollup.config.js", 34 | "build": "yarn build:clean && yarn build:dist && yarn build:flow", 35 | "prepublishOnly": "yarn build" 36 | }, 37 | "devDependencies": { 38 | "@babel/core": "^7.5.0", 39 | "@babel/preset-env": "^7.5.0", 40 | "@babel/preset-flow": "^7.0.0", 41 | "babel-core": "7.0.0-bridge.0", 42 | "babel-jest": "^24.8.0", 43 | "flow-bin": "0.102.0", 44 | "jest": "^24.8.0", 45 | "prettier": "1.18.2", 46 | "regenerator-runtime": "^0.13.2", 47 | "rimraf": "^2.6.3", 48 | "rollup": "^1.16.6", 49 | "rollup-plugin-babel": "^4.3.3", 50 | "rollup-plugin-replace": "^2.2.0", 51 | "rollup-plugin-uglify": "^6.0.2" 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | import babel from 'rollup-plugin-babel'; 2 | import replace from 'rollup-plugin-replace'; 3 | import { uglify } from 'rollup-plugin-uglify'; 4 | import pkg from './package.json'; 5 | 6 | const input = 'src/index.js'; 7 | 8 | export default [ 9 | // ESM build 10 | { 11 | input, 12 | output: { 13 | file: pkg.module, 14 | format: 'esm', 15 | }, 16 | plugins: [babel()], 17 | }, 18 | // CommonJS build 19 | { 20 | input, 21 | output: { 22 | file: pkg.main, 23 | format: 'cjs', 24 | }, 25 | plugins: [babel()], 26 | }, 27 | // UMD: Production build 28 | { 29 | input, 30 | output: { 31 | file: 'dist/tiny-warning.js', 32 | format: 'umd', 33 | name: 'warning', 34 | }, 35 | plugins: [ 36 | // Setting development env before running babel etc 37 | replace({ 'process.env.NODE_ENV': JSON.stringify('development') }), 38 | babel(), 39 | ], 40 | }, 41 | { 42 | input, 43 | output: { 44 | file: 'dist/tiny-warning.min.js', 45 | format: 'umd', 46 | name: 'warning', 47 | }, 48 | plugins: [ 49 | // Setting development env before running babel etc 50 | replace({ 'process.env.NODE_ENV': JSON.stringify('production') }), 51 | babel(), 52 | uglify(), 53 | ], 54 | }, 55 | ]; 56 | -------------------------------------------------------------------------------- /src/index.d.ts: -------------------------------------------------------------------------------- 1 | export default function warning(condition: any, message: string): void 2 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | const isProduction: boolean = process.env.NODE_ENV === 'production'; 3 | 4 | export default function warning(condition: mixed, message: string): void { 5 | // don't do anything in production 6 | // wrapping in production check for better dead code elimination 7 | if (!isProduction) { 8 | // condition passed: do not log 9 | if (condition) { 10 | return; 11 | } 12 | 13 | // Condition not passed 14 | const text: string = `Warning: ${message}`; 15 | 16 | // check console for IE9 support which provides console 17 | // only with open devtools 18 | if (typeof console !== 'undefined') { 19 | console.warn(text); 20 | } 21 | 22 | // Throwing an error and catching it immediately 23 | // to improve debugging 24 | // A consumer can use 'pause on caught exceptions' 25 | // https://github.com/facebook/react/issues/4216 26 | try { 27 | throw Error(text); 28 | } catch (x) {} 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /test/bundle-size.spec.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | import { rollup } from 'rollup'; 3 | import babel from 'rollup-plugin-babel'; 4 | import replace from 'rollup-plugin-replace'; 5 | 6 | const DEV_SIZE = 284; 7 | const PROD_SIZE = 66; 8 | 9 | type GetCodeArgs = {| 10 | mode: string, 11 | |}; 12 | const getCode = async ({ mode }: GetCodeArgs): Promise => { 13 | const bundle = await rollup({ 14 | input: 'src/index.js', 15 | output: { 16 | format: 'esm', 17 | }, 18 | plugins: [ 19 | replace({ 'process.env.NODE_ENV': JSON.stringify(mode) }), 20 | babel(), 21 | ], 22 | }); 23 | const result = await bundle.generate({ format: 'esm' }); 24 | return result.output[0].code; 25 | }; 26 | 27 | it(`development mode size should be ${DEV_SIZE}`, async () => { 28 | const code: string = await getCode({ mode: 'development' }); 29 | expect(code.length).toBe(DEV_SIZE); 30 | }); 31 | 32 | it(`production mode size should be ${PROD_SIZE}`, async () => { 33 | const code: string = await getCode({ mode: 'production' }); 34 | expect(code.length).toBe(PROD_SIZE); 35 | }); 36 | 37 | it('should not strip console.warn from dev builds', async () => { 38 | const code: string = await getCode({ mode: 'development' }); 39 | expect(code.includes('console.warn')).toBe(true); 40 | }); 41 | 42 | it('should strip console.warn from production builds', async () => { 43 | const code: string = await getCode({ mode: 'production' }); 44 | expect(code.includes('console.warn')).toBe(false); 45 | }); 46 | -------------------------------------------------------------------------------- /test/index.spec.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | import warning from '../src'; 3 | 4 | beforeEach(() => { 5 | jest.spyOn(console, 'warn').mockImplementation(() => {}); 6 | }); 7 | 8 | afterEach(() => { 9 | // $ExpectError - mocked 10 | console.warn.mockRestore(); 11 | }); 12 | 13 | it('should not log a warning if the condition is truthy', () => { 14 | const truthy: mixed[] = [1, -1, true, {}, [], Symbol(), 'hi']; 15 | truthy.forEach((value: mixed) => { 16 | warning(value, 'message'); 17 | expect(console.warn).not.toHaveBeenCalled(); 18 | }); 19 | }); 20 | 21 | it('should log a warning if the condition is falsy', () => { 22 | // https://github.com/getify/You-Dont-Know-JS/blob/master/types%20%26%20grammar/ch4.md#falsy-values 23 | const falsy: mixed[] = [undefined, null, false, +0, -0, NaN, '']; 24 | falsy.forEach((value: mixed) => { 25 | const message: string = `hey ${String(value)}`; 26 | warning(value, message); 27 | 28 | expect(console.warn).toHaveBeenCalledWith('Warning: ' + message); 29 | // $ExpectError - mocking console.warn 30 | console.warn.mockClear(); 31 | }); 32 | }); 33 | --------------------------------------------------------------------------------