├── .babelrc ├── .flowconfig ├── .gitignore ├── .nvmrc ├── .prettierignore ├── .prettierrc ├── .storybook └── config.js ├── .travis.yml ├── Readme.md ├── examples ├── chat.js ├── images.js └── index.js ├── flow-typed └── npm │ ├── @storybook │ └── react_v3.x.x.js │ ├── babel-cli_vx.x.x.js │ ├── babel-plugin-transform-class-properties_vx.x.x.js │ ├── babel-plugin-transform-flow-strip-types_vx.x.x.js │ ├── babel-plugin-transform-object-rest-spread_vx.x.x.js │ ├── babel-preset-env_vx.x.x.js │ ├── babel-preset-react_vx.x.x.js │ ├── casual-browserify_vx.x.x.js │ ├── flow-bin_v0.x.x.js │ ├── flow-copy-source_vx.x.x.js │ ├── husky_vx.x.x.js │ ├── jest_v23.x.x.js │ ├── lodash_v4.x.x.js │ ├── prettier_v1.x.x.js │ └── pretty-quick_vx.x.x.js ├── package-lock.json ├── package.json └── src ├── __test__ └── index.test.js └── index.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [["env"], "react"], 3 | "plugins": ["transform-class-properties", "transform-object-rest-spread"] 4 | } 5 | -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/skrivle/react-inverted-scrollview/e0e44c544b1c481077560e5662b8036ad2e57850/.flowconfig -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | *.log 4 | lib/ 5 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | v10.3.0 2 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | /flow-typed -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "tabWidth": 4, 3 | "singleQuote": true, 4 | "printWidth": 100 5 | } 6 | -------------------------------------------------------------------------------- /.storybook/config.js: -------------------------------------------------------------------------------- 1 | import { configure } from '@storybook/react'; 2 | 3 | function loadStories() { 4 | require('../examples'); 5 | } 6 | 7 | configure(loadStories, module); 8 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: "node_js" 2 | node_js: 3 | - "10" 4 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/vejersele/react-inverted-scrollview.svg?branch=master)](https://travis-ci.org/vejersele/react-inverted-scrollview) 2 | 3 | # React Inverted ScrollView 4 | 5 | Easily support inverted scrolling in for example chat apps. Maintains a correct scroll position when new content is added. 6 | 7 | ## Installation: 8 | 9 | ``` 10 | npm install react-inverted-scrollview --save 11 | ``` 12 | 13 | ## Example: 14 | 15 | ```javascript 16 | import _ from 'lodash'; 17 | import React, { Component } from 'react'; 18 | import ScrollView from 'react-inverted-scrollview'; 19 | 20 | class MyComponent extends Component { 21 | state = { 22 | messages: _.range(30).map(index => ({ 23 | id: index, 24 | text: `message-${index}` 25 | })) 26 | }; 27 | 28 | scrollToBottom() { 29 | if (!this.scrollView) return; 30 | this.scrollView.scrollToBottom(); 31 | } 32 | 33 | scrollToTop() { 34 | if (!this.scrollView) return; 35 | this.scrollView.scrollToTop(); 36 | } 37 | 38 | handleScroll = ({ scrollTop, scrollBottom }) => { 39 | console.log('scrollTop', scrollTop); 40 | console.log('scrollBottom', scrollBottom); 41 | }; 42 | 43 | render() { 44 | const { messages } = this.state; 45 | return ( 46 | (this.scrollView = ref)} 50 | onScroll={this.handleScroll} 51 | > 52 | {messages.map(message =>
{message.text}
)} 53 |
54 | ); 55 | } 56 | } 57 | ``` 58 | 59 | ## API 60 | 61 | ### Props 62 | 63 | | Prop | Type | Default | 64 | | ----------------------------- | ---------------------------------------------------------- | -------- | 65 | | width | number | 100 | 66 | | height | number | 100 | 67 | | onScroll | (info: { scrollBottom: number, scrollTop: number }) => any | () => {} | 68 | | style | Object {} | {} | 69 | | restoreScrollPositionOnUpdate | boolean | true | 70 | | children | React.Node or ({restoreScrollPosition}) => Node | Node | 71 | 72 | ### Instance methods 73 | 74 | ```javascript 75 | instance.scrollToBottom(); 76 | instance.scrollToTop(); 77 | instance.setScrollBottom(value); 78 | instance.setScrollTop(value); 79 | instance.restoreScrollPosition(); 80 | ``` 81 | 82 | ## Check out the examples: 83 | 84 | ``` 85 | git clone https://github.com/vejersele/react-inverted-scrollview.git 86 | cd react-inverted-scrollview 87 | npm install 88 | npm run storybook 89 | ``` 90 | -------------------------------------------------------------------------------- /examples/chat.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import React, { Component } from 'react'; 4 | import { storiesOf } from '@storybook/react'; 5 | import ScrollView from '../src/'; 6 | import casual from 'casual-browserify'; 7 | import _ from 'lodash'; 8 | 9 | const generateMessages = amount => 10 | _.range(amount).map(() => ({ 11 | id: casual.uuid, 12 | text: casual.description, 13 | user: casual.name 14 | })); 15 | 16 | const fetchOlderMessages = () => 17 | new Promise(resolve => { 18 | setTimeout(() => { 19 | resolve(generateMessages(10)); 20 | }, Math.max(500, Math.round(Math.random() * 2000))); 21 | }); 22 | 23 | const Message = ({ message }) => ( 24 |
25 | {message.user} : {message.text} 26 |
27 | ); 28 | 29 | type State = { 30 | input: string, 31 | messages: Array<{ text: string, id: string, user: string }>, 32 | isLoading: boolean 33 | }; 34 | 35 | class Chat extends Component<{}, State> { 36 | input: ?HTMLElement; 37 | scrollView: ?ScrollView; 38 | 39 | state = { 40 | input: '', 41 | messages: generateMessages(10), 42 | isLoading: false 43 | }; 44 | 45 | componentDidMount() { 46 | if (!this.input) return; 47 | this.input.focus(); 48 | } 49 | 50 | handleSubmit = e => { 51 | e.preventDefault(); 52 | 53 | if (this.state.input === '') return; 54 | 55 | this.setState( 56 | state => ({ 57 | messages: [...state.messages, { text: state.input, id: casual.uuid, user: 'me' }], 58 | input: '' 59 | }), 60 | () => { 61 | this.scrollToBottom(); 62 | } 63 | ); 64 | }; 65 | 66 | scrollToBottom() { 67 | if (!this.scrollView) return; 68 | this.scrollView.scrollToBottom(); 69 | } 70 | 71 | handleScroll = ({ scrollTop, scrollBottom }) => { 72 | const { isLoading } = this.state; 73 | 74 | if (isLoading || scrollTop > 100) return; 75 | 76 | this.setState({ isLoading: true }); 77 | 78 | fetchOlderMessages().then(olderMessages => { 79 | this.setState(({ messages }) => ({ 80 | isLoading: false, 81 | messages: [...olderMessages, ...messages] 82 | })); 83 | }); 84 | }; 85 | 86 | render() { 87 | const { messages, input, isLoading } = this.state; 88 | 89 | return ( 90 |
91 | (this.scrollView = ref)} 94 | height={300} 95 | width={300} 96 | > 97 | {isLoading ? ( 98 |
99 | Loading ... 100 |
101 | ) : null} 102 |
103 | {messages.map(message => )} 104 |
105 |
106 |
107 |
108 | this.setState({ input: e.target.value })} 111 | ref={ref => (this.input = ref)} 112 | style={{ width: '100%', boxSizing: 'border-box', padding: 5 }} 113 | /> 114 |
115 |
116 |
117 | ); 118 | } 119 | } 120 | 121 | storiesOf('Chat', module).add('Chat', () => ( 122 |
123 | 124 |
125 | )); 126 | -------------------------------------------------------------------------------- /examples/images.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import _ from 'lodash'; 4 | import { storiesOf } from '@storybook/react'; 5 | import React, { Component } from 'react'; 6 | import ScrollView from '../src/index'; 7 | 8 | const ImageList = () => ( 9 | { 11 | console.log('scrollTop', scrollTop); 12 | console.log('scrollBottom', scrollBottom); 13 | }} 14 | height={500} 15 | width={300} 16 | > 17 | {({ restoreScrollPosition }) => 18 | _.range(10).map(i => ( 19 |
20 | restoreScrollPosition()} 24 | /> 25 |
26 | )) 27 | } 28 |
29 | ); 30 | 31 | storiesOf('ImageList', module).add('ImageList', () => ( 32 |
33 | 34 |
35 | )); 36 | -------------------------------------------------------------------------------- /examples/index.js: -------------------------------------------------------------------------------- 1 | import './chat'; 2 | import './images'; 3 | -------------------------------------------------------------------------------- /flow-typed/npm/@storybook/react_v3.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 1aeadf523ef2d96985697463dd71c89d 2 | // flow-typed version: 35108faf5b/@storybook/react_v3.x.x/flow_>=v0.72.x 3 | 4 | type NodeModule = typeof module; 5 | 6 | declare module '@storybook/react' { 7 | declare type Context = { kind: string, story: string }; 8 | declare type Renderable = React$Element<*>; 9 | declare type RenderCallback = (context: Context) => Renderable | Array; 10 | declare type RenderFunction = () => Renderable | Array; 11 | 12 | declare type StoryDecorator = (story: RenderFunction, context: Context) => Renderable | null; 13 | 14 | declare interface Story { 15 | +kind: string; 16 | add(storyName: string, callback: RenderCallback): Story; 17 | addDecorator(decorator: StoryDecorator): Story; 18 | } 19 | 20 | declare interface StoryObject { 21 | name: string; 22 | render: RenderFunction; 23 | } 24 | 25 | declare interface StoryBucket { 26 | kind: string; 27 | filename: string; 28 | stories: Array; 29 | } 30 | 31 | declare function addDecorator(decorator: StoryDecorator): void; 32 | declare function configure(fn: () => void, module: NodeModule): void; 33 | declare function setAddon(addon: Object): void; 34 | declare function storiesOf(name: string, module: NodeModule): Story; 35 | declare function storiesOf(name: string, module: NodeModule): Story & T; 36 | declare function forceReRender(): void; 37 | 38 | declare function getStorybook(): Array; 39 | } 40 | -------------------------------------------------------------------------------- /flow-typed/npm/babel-cli_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 89ccd8f6b78c4893189f4d37a1275ff7 2 | // flow-typed version: <>/babel-cli_v^6.26.0/flow_v0.103.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'babel-cli' 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-cli' { 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-cli/bin/babel-doctor' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'babel-cli/bin/babel-external-helpers' { 30 | declare module.exports: any; 31 | } 32 | 33 | declare module 'babel-cli/bin/babel-node' { 34 | declare module.exports: any; 35 | } 36 | 37 | declare module 'babel-cli/bin/babel' { 38 | declare module.exports: any; 39 | } 40 | 41 | declare module 'babel-cli/lib/_babel-node' { 42 | declare module.exports: any; 43 | } 44 | 45 | declare module 'babel-cli/lib/babel-external-helpers' { 46 | declare module.exports: any; 47 | } 48 | 49 | declare module 'babel-cli/lib/babel-node' { 50 | declare module.exports: any; 51 | } 52 | 53 | declare module 'babel-cli/lib/babel/dir' { 54 | declare module.exports: any; 55 | } 56 | 57 | declare module 'babel-cli/lib/babel/file' { 58 | declare module.exports: any; 59 | } 60 | 61 | declare module 'babel-cli/lib/babel' { 62 | declare module.exports: any; 63 | } 64 | 65 | declare module 'babel-cli/lib/babel/util' { 66 | declare module.exports: any; 67 | } 68 | 69 | // Filename aliases 70 | declare module 'babel-cli/bin/babel-doctor.js' { 71 | declare module.exports: $Exports<'babel-cli/bin/babel-doctor'>; 72 | } 73 | declare module 'babel-cli/bin/babel-external-helpers.js' { 74 | declare module.exports: $Exports<'babel-cli/bin/babel-external-helpers'>; 75 | } 76 | declare module 'babel-cli/bin/babel-node.js' { 77 | declare module.exports: $Exports<'babel-cli/bin/babel-node'>; 78 | } 79 | declare module 'babel-cli/bin/babel.js' { 80 | declare module.exports: $Exports<'babel-cli/bin/babel'>; 81 | } 82 | declare module 'babel-cli/index' { 83 | declare module.exports: $Exports<'babel-cli'>; 84 | } 85 | declare module 'babel-cli/index.js' { 86 | declare module.exports: $Exports<'babel-cli'>; 87 | } 88 | declare module 'babel-cli/lib/_babel-node.js' { 89 | declare module.exports: $Exports<'babel-cli/lib/_babel-node'>; 90 | } 91 | declare module 'babel-cli/lib/babel-external-helpers.js' { 92 | declare module.exports: $Exports<'babel-cli/lib/babel-external-helpers'>; 93 | } 94 | declare module 'babel-cli/lib/babel-node.js' { 95 | declare module.exports: $Exports<'babel-cli/lib/babel-node'>; 96 | } 97 | declare module 'babel-cli/lib/babel/dir.js' { 98 | declare module.exports: $Exports<'babel-cli/lib/babel/dir'>; 99 | } 100 | declare module 'babel-cli/lib/babel/file.js' { 101 | declare module.exports: $Exports<'babel-cli/lib/babel/file'>; 102 | } 103 | declare module 'babel-cli/lib/babel/index' { 104 | declare module.exports: $Exports<'babel-cli/lib/babel'>; 105 | } 106 | declare module 'babel-cli/lib/babel/index.js' { 107 | declare module.exports: $Exports<'babel-cli/lib/babel'>; 108 | } 109 | declare module 'babel-cli/lib/babel/util.js' { 110 | declare module.exports: $Exports<'babel-cli/lib/babel/util'>; 111 | } 112 | -------------------------------------------------------------------------------- /flow-typed/npm/babel-plugin-transform-class-properties_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: ba19ceb3d1c9382a157deae682c377a8 2 | // flow-typed version: <>/babel-plugin-transform-class-properties_v^6.24.1/flow_v0.103.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'babel-plugin-transform-class-properties' 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-plugin-transform-class-properties' { 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-plugin-transform-class-properties/lib' { 26 | declare module.exports: any; 27 | } 28 | 29 | // Filename aliases 30 | declare module 'babel-plugin-transform-class-properties/lib/index' { 31 | declare module.exports: $Exports<'babel-plugin-transform-class-properties/lib'>; 32 | } 33 | declare module 'babel-plugin-transform-class-properties/lib/index.js' { 34 | declare module.exports: $Exports<'babel-plugin-transform-class-properties/lib'>; 35 | } 36 | -------------------------------------------------------------------------------- /flow-typed/npm/babel-plugin-transform-flow-strip-types_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 6703bae7be440cfc0432158d1df1f402 2 | // flow-typed version: <>/babel-plugin-transform-flow-strip-types_v^6.22.0/flow_v0.103.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'babel-plugin-transform-flow-strip-types' 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-plugin-transform-flow-strip-types' { 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-plugin-transform-flow-strip-types/lib' { 26 | declare module.exports: any; 27 | } 28 | 29 | // Filename aliases 30 | declare module 'babel-plugin-transform-flow-strip-types/lib/index' { 31 | declare module.exports: $Exports<'babel-plugin-transform-flow-strip-types/lib'>; 32 | } 33 | declare module 'babel-plugin-transform-flow-strip-types/lib/index.js' { 34 | declare module.exports: $Exports<'babel-plugin-transform-flow-strip-types/lib'>; 35 | } 36 | -------------------------------------------------------------------------------- /flow-typed/npm/babel-plugin-transform-object-rest-spread_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 8a2a98aafa2a9bab25d30c40a81386ad 2 | // flow-typed version: <>/babel-plugin-transform-object-rest-spread_v^6.26.0/flow_v0.103.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'babel-plugin-transform-object-rest-spread' 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-plugin-transform-object-rest-spread' { 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-plugin-transform-object-rest-spread/lib' { 26 | declare module.exports: any; 27 | } 28 | 29 | // Filename aliases 30 | declare module 'babel-plugin-transform-object-rest-spread/lib/index' { 31 | declare module.exports: $Exports<'babel-plugin-transform-object-rest-spread/lib'>; 32 | } 33 | declare module 'babel-plugin-transform-object-rest-spread/lib/index.js' { 34 | declare module.exports: $Exports<'babel-plugin-transform-object-rest-spread/lib'>; 35 | } 36 | -------------------------------------------------------------------------------- /flow-typed/npm/babel-preset-env_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 18b0ad2257916e44eca45b1b1997dd55 2 | // flow-typed version: <>/babel-preset-env_v^1.7.0/flow_v0.103.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/lib/default-includes' { 34 | declare module.exports: any; 35 | } 36 | 37 | declare module 'babel-preset-env/lib' { 38 | declare module.exports: any; 39 | } 40 | 41 | declare module 'babel-preset-env/lib/module-transformations' { 42 | declare module.exports: any; 43 | } 44 | 45 | declare module 'babel-preset-env/lib/normalize-options' { 46 | declare module.exports: any; 47 | } 48 | 49 | declare module 'babel-preset-env/lib/targets-parser' { 50 | declare module.exports: any; 51 | } 52 | 53 | declare module 'babel-preset-env/lib/transform-polyfill-require-plugin' { 54 | declare module.exports: any; 55 | } 56 | 57 | declare module 'babel-preset-env/lib/utils' { 58 | declare module.exports: any; 59 | } 60 | 61 | // Filename aliases 62 | declare module 'babel-preset-env/data/built-in-features.js' { 63 | declare module.exports: $Exports<'babel-preset-env/data/built-in-features'>; 64 | } 65 | declare module 'babel-preset-env/data/plugin-features.js' { 66 | declare module.exports: $Exports<'babel-preset-env/data/plugin-features'>; 67 | } 68 | declare module 'babel-preset-env/lib/default-includes.js' { 69 | declare module.exports: $Exports<'babel-preset-env/lib/default-includes'>; 70 | } 71 | declare module 'babel-preset-env/lib/index' { 72 | declare module.exports: $Exports<'babel-preset-env/lib'>; 73 | } 74 | declare module 'babel-preset-env/lib/index.js' { 75 | declare module.exports: $Exports<'babel-preset-env/lib'>; 76 | } 77 | declare module 'babel-preset-env/lib/module-transformations.js' { 78 | declare module.exports: $Exports<'babel-preset-env/lib/module-transformations'>; 79 | } 80 | declare module 'babel-preset-env/lib/normalize-options.js' { 81 | declare module.exports: $Exports<'babel-preset-env/lib/normalize-options'>; 82 | } 83 | declare module 'babel-preset-env/lib/targets-parser.js' { 84 | declare module.exports: $Exports<'babel-preset-env/lib/targets-parser'>; 85 | } 86 | declare module 'babel-preset-env/lib/transform-polyfill-require-plugin.js' { 87 | declare module.exports: $Exports<'babel-preset-env/lib/transform-polyfill-require-plugin'>; 88 | } 89 | declare module 'babel-preset-env/lib/utils.js' { 90 | declare module.exports: $Exports<'babel-preset-env/lib/utils'>; 91 | } 92 | -------------------------------------------------------------------------------- /flow-typed/npm/babel-preset-react_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: f5d51cf2f5fef48636d23680801eed45 2 | // flow-typed version: <>/babel-preset-react_v^6.24.1/flow_v0.103.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'babel-preset-react' 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-react' { 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-react/lib' { 26 | declare module.exports: any; 27 | } 28 | 29 | // Filename aliases 30 | declare module 'babel-preset-react/lib/index' { 31 | declare module.exports: $Exports<'babel-preset-react/lib'>; 32 | } 33 | declare module 'babel-preset-react/lib/index.js' { 34 | declare module.exports: $Exports<'babel-preset-react/lib'>; 35 | } 36 | -------------------------------------------------------------------------------- /flow-typed/npm/casual-browserify_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: a23340c2b1554d9c832ccdfa6de0a1f4 2 | // flow-typed version: <>/casual-browserify_v^1.5.19-2/flow_v0.103.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'casual-browserify' 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 'casual-browserify' { 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 'casual-browserify/scripts/generate' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'casual-browserify/src/casual_browserify' { 30 | declare module.exports: any; 31 | } 32 | 33 | declare module 'casual-browserify/src/casual' { 34 | declare module.exports: any; 35 | } 36 | 37 | declare module 'casual-browserify/src/helpers' { 38 | declare module.exports: any; 39 | } 40 | 41 | declare module 'casual-browserify/src/providers/address' { 42 | declare module.exports: any; 43 | } 44 | 45 | declare module 'casual-browserify/src/providers/ar_SY/address' { 46 | declare module.exports: any; 47 | } 48 | 49 | declare module 'casual-browserify/src/providers/ar_SY/color' { 50 | declare module.exports: any; 51 | } 52 | 53 | declare module 'casual-browserify/src/providers/ar_SY/date' { 54 | declare module.exports: any; 55 | } 56 | 57 | declare module 'casual-browserify/src/providers/ar_SY/person' { 58 | declare module.exports: any; 59 | } 60 | 61 | declare module 'casual-browserify/src/providers/ar_SY/text' { 62 | declare module.exports: any; 63 | } 64 | 65 | declare module 'casual-browserify/src/providers/color' { 66 | declare module.exports: any; 67 | } 68 | 69 | declare module 'casual-browserify/src/providers/date' { 70 | declare module.exports: any; 71 | } 72 | 73 | declare module 'casual-browserify/src/providers/de_DE/address' { 74 | declare module.exports: any; 75 | } 76 | 77 | declare module 'casual-browserify/src/providers/de_DE/date' { 78 | declare module.exports: any; 79 | } 80 | 81 | declare module 'casual-browserify/src/providers/de_DE/person' { 82 | declare module.exports: any; 83 | } 84 | 85 | declare module 'casual-browserify/src/providers/de_DE/text' { 86 | declare module.exports: any; 87 | } 88 | 89 | declare module 'casual-browserify/src/providers/en_CA/address' { 90 | declare module.exports: any; 91 | } 92 | 93 | declare module 'casual-browserify/src/providers/en_US/address' { 94 | declare module.exports: any; 95 | } 96 | 97 | declare module 'casual-browserify/src/providers/fr_FR/address' { 98 | declare module.exports: any; 99 | } 100 | 101 | declare module 'casual-browserify/src/providers/fr_FR/person' { 102 | declare module.exports: any; 103 | } 104 | 105 | declare module 'casual-browserify/src/providers/id_ID/address' { 106 | declare module.exports: any; 107 | } 108 | 109 | declare module 'casual-browserify/src/providers/internet' { 110 | declare module.exports: any; 111 | } 112 | 113 | declare module 'casual-browserify/src/providers/it_CH/address' { 114 | declare module.exports: any; 115 | } 116 | 117 | declare module 'casual-browserify/src/providers/it_CH/date' { 118 | declare module.exports: any; 119 | } 120 | 121 | declare module 'casual-browserify/src/providers/it_CH/person' { 122 | declare module.exports: any; 123 | } 124 | 125 | declare module 'casual-browserify/src/providers/it_IT/address' { 126 | declare module.exports: any; 127 | } 128 | 129 | declare module 'casual-browserify/src/providers/it_IT/date' { 130 | declare module.exports: any; 131 | } 132 | 133 | declare module 'casual-browserify/src/providers/it_IT/person' { 134 | declare module.exports: any; 135 | } 136 | 137 | declare module 'casual-browserify/src/providers/misc' { 138 | declare module.exports: any; 139 | } 140 | 141 | declare module 'casual-browserify/src/providers/nb_NO/address' { 142 | declare module.exports: any; 143 | } 144 | 145 | declare module 'casual-browserify/src/providers/nb_NO/color' { 146 | declare module.exports: any; 147 | } 148 | 149 | declare module 'casual-browserify/src/providers/nb_NO/date' { 150 | declare module.exports: any; 151 | } 152 | 153 | declare module 'casual-browserify/src/providers/nb_NO/person' { 154 | declare module.exports: any; 155 | } 156 | 157 | declare module 'casual-browserify/src/providers/nl_NL/address' { 158 | declare module.exports: any; 159 | } 160 | 161 | declare module 'casual-browserify/src/providers/nl_NL/person' { 162 | declare module.exports: any; 163 | } 164 | 165 | declare module 'casual-browserify/src/providers/number' { 166 | declare module.exports: any; 167 | } 168 | 169 | declare module 'casual-browserify/src/providers/payment' { 170 | declare module.exports: any; 171 | } 172 | 173 | declare module 'casual-browserify/src/providers/person' { 174 | declare module.exports: any; 175 | } 176 | 177 | declare module 'casual-browserify/src/providers/pt_BR/address' { 178 | declare module.exports: any; 179 | } 180 | 181 | declare module 'casual-browserify/src/providers/pt_BR/color' { 182 | declare module.exports: any; 183 | } 184 | 185 | declare module 'casual-browserify/src/providers/pt_BR/person' { 186 | declare module.exports: any; 187 | } 188 | 189 | declare module 'casual-browserify/src/providers/ro_RO/address' { 190 | declare module.exports: any; 191 | } 192 | 193 | declare module 'casual-browserify/src/providers/ro_RO/date' { 194 | declare module.exports: any; 195 | } 196 | 197 | declare module 'casual-browserify/src/providers/ro_RO/person' { 198 | declare module.exports: any; 199 | } 200 | 201 | declare module 'casual-browserify/src/providers/ru_RU/address' { 202 | declare module.exports: any; 203 | } 204 | 205 | declare module 'casual-browserify/src/providers/ru_RU/color' { 206 | declare module.exports: any; 207 | } 208 | 209 | declare module 'casual-browserify/src/providers/ru_RU/internet' { 210 | declare module.exports: any; 211 | } 212 | 213 | declare module 'casual-browserify/src/providers/ru_RU/person' { 214 | declare module.exports: any; 215 | } 216 | 217 | declare module 'casual-browserify/src/providers/ru_RU/text' { 218 | declare module.exports: any; 219 | } 220 | 221 | declare module 'casual-browserify/src/providers/sv_SE/address' { 222 | declare module.exports: any; 223 | } 224 | 225 | declare module 'casual-browserify/src/providers/sv_SE/person' { 226 | declare module.exports: any; 227 | } 228 | 229 | declare module 'casual-browserify/src/providers/sv_SE/text' { 230 | declare module.exports: any; 231 | } 232 | 233 | declare module 'casual-browserify/src/providers/text' { 234 | declare module.exports: any; 235 | } 236 | 237 | declare module 'casual-browserify/src/providers/uk_UA/address' { 238 | declare module.exports: any; 239 | } 240 | 241 | declare module 'casual-browserify/src/providers/uk_UA/color' { 242 | declare module.exports: any; 243 | } 244 | 245 | declare module 'casual-browserify/src/providers/uk_UA/text' { 246 | declare module.exports: any; 247 | } 248 | 249 | declare module 'casual-browserify/src/require_provider_browserify' { 250 | declare module.exports: any; 251 | } 252 | 253 | declare module 'casual-browserify/src/safe_require_browserify' { 254 | declare module.exports: any; 255 | } 256 | 257 | declare module 'casual-browserify/test/casual' { 258 | declare module.exports: any; 259 | } 260 | 261 | declare module 'casual-browserify/utils/show' { 262 | declare module.exports: any; 263 | } 264 | 265 | // Filename aliases 266 | declare module 'casual-browserify/scripts/generate.js' { 267 | declare module.exports: $Exports<'casual-browserify/scripts/generate'>; 268 | } 269 | declare module 'casual-browserify/src/casual_browserify.js' { 270 | declare module.exports: $Exports<'casual-browserify/src/casual_browserify'>; 271 | } 272 | declare module 'casual-browserify/src/casual.js' { 273 | declare module.exports: $Exports<'casual-browserify/src/casual'>; 274 | } 275 | declare module 'casual-browserify/src/helpers.js' { 276 | declare module.exports: $Exports<'casual-browserify/src/helpers'>; 277 | } 278 | declare module 'casual-browserify/src/providers/address.js' { 279 | declare module.exports: $Exports<'casual-browserify/src/providers/address'>; 280 | } 281 | declare module 'casual-browserify/src/providers/ar_SY/address.js' { 282 | declare module.exports: $Exports<'casual-browserify/src/providers/ar_SY/address'>; 283 | } 284 | declare module 'casual-browserify/src/providers/ar_SY/color.js' { 285 | declare module.exports: $Exports<'casual-browserify/src/providers/ar_SY/color'>; 286 | } 287 | declare module 'casual-browserify/src/providers/ar_SY/date.js' { 288 | declare module.exports: $Exports<'casual-browserify/src/providers/ar_SY/date'>; 289 | } 290 | declare module 'casual-browserify/src/providers/ar_SY/person.js' { 291 | declare module.exports: $Exports<'casual-browserify/src/providers/ar_SY/person'>; 292 | } 293 | declare module 'casual-browserify/src/providers/ar_SY/text.js' { 294 | declare module.exports: $Exports<'casual-browserify/src/providers/ar_SY/text'>; 295 | } 296 | declare module 'casual-browserify/src/providers/color.js' { 297 | declare module.exports: $Exports<'casual-browserify/src/providers/color'>; 298 | } 299 | declare module 'casual-browserify/src/providers/date.js' { 300 | declare module.exports: $Exports<'casual-browserify/src/providers/date'>; 301 | } 302 | declare module 'casual-browserify/src/providers/de_DE/address.js' { 303 | declare module.exports: $Exports<'casual-browserify/src/providers/de_DE/address'>; 304 | } 305 | declare module 'casual-browserify/src/providers/de_DE/date.js' { 306 | declare module.exports: $Exports<'casual-browserify/src/providers/de_DE/date'>; 307 | } 308 | declare module 'casual-browserify/src/providers/de_DE/person.js' { 309 | declare module.exports: $Exports<'casual-browserify/src/providers/de_DE/person'>; 310 | } 311 | declare module 'casual-browserify/src/providers/de_DE/text.js' { 312 | declare module.exports: $Exports<'casual-browserify/src/providers/de_DE/text'>; 313 | } 314 | declare module 'casual-browserify/src/providers/en_CA/address.js' { 315 | declare module.exports: $Exports<'casual-browserify/src/providers/en_CA/address'>; 316 | } 317 | declare module 'casual-browserify/src/providers/en_US/address.js' { 318 | declare module.exports: $Exports<'casual-browserify/src/providers/en_US/address'>; 319 | } 320 | declare module 'casual-browserify/src/providers/fr_FR/address.js' { 321 | declare module.exports: $Exports<'casual-browserify/src/providers/fr_FR/address'>; 322 | } 323 | declare module 'casual-browserify/src/providers/fr_FR/person.js' { 324 | declare module.exports: $Exports<'casual-browserify/src/providers/fr_FR/person'>; 325 | } 326 | declare module 'casual-browserify/src/providers/id_ID/address.js' { 327 | declare module.exports: $Exports<'casual-browserify/src/providers/id_ID/address'>; 328 | } 329 | declare module 'casual-browserify/src/providers/internet.js' { 330 | declare module.exports: $Exports<'casual-browserify/src/providers/internet'>; 331 | } 332 | declare module 'casual-browserify/src/providers/it_CH/address.js' { 333 | declare module.exports: $Exports<'casual-browserify/src/providers/it_CH/address'>; 334 | } 335 | declare module 'casual-browserify/src/providers/it_CH/date.js' { 336 | declare module.exports: $Exports<'casual-browserify/src/providers/it_CH/date'>; 337 | } 338 | declare module 'casual-browserify/src/providers/it_CH/person.js' { 339 | declare module.exports: $Exports<'casual-browserify/src/providers/it_CH/person'>; 340 | } 341 | declare module 'casual-browserify/src/providers/it_IT/address.js' { 342 | declare module.exports: $Exports<'casual-browserify/src/providers/it_IT/address'>; 343 | } 344 | declare module 'casual-browserify/src/providers/it_IT/date.js' { 345 | declare module.exports: $Exports<'casual-browserify/src/providers/it_IT/date'>; 346 | } 347 | declare module 'casual-browserify/src/providers/it_IT/person.js' { 348 | declare module.exports: $Exports<'casual-browserify/src/providers/it_IT/person'>; 349 | } 350 | declare module 'casual-browserify/src/providers/misc.js' { 351 | declare module.exports: $Exports<'casual-browserify/src/providers/misc'>; 352 | } 353 | declare module 'casual-browserify/src/providers/nb_NO/address.js' { 354 | declare module.exports: $Exports<'casual-browserify/src/providers/nb_NO/address'>; 355 | } 356 | declare module 'casual-browserify/src/providers/nb_NO/color.js' { 357 | declare module.exports: $Exports<'casual-browserify/src/providers/nb_NO/color'>; 358 | } 359 | declare module 'casual-browserify/src/providers/nb_NO/date.js' { 360 | declare module.exports: $Exports<'casual-browserify/src/providers/nb_NO/date'>; 361 | } 362 | declare module 'casual-browserify/src/providers/nb_NO/person.js' { 363 | declare module.exports: $Exports<'casual-browserify/src/providers/nb_NO/person'>; 364 | } 365 | declare module 'casual-browserify/src/providers/nl_NL/address.js' { 366 | declare module.exports: $Exports<'casual-browserify/src/providers/nl_NL/address'>; 367 | } 368 | declare module 'casual-browserify/src/providers/nl_NL/person.js' { 369 | declare module.exports: $Exports<'casual-browserify/src/providers/nl_NL/person'>; 370 | } 371 | declare module 'casual-browserify/src/providers/number.js' { 372 | declare module.exports: $Exports<'casual-browserify/src/providers/number'>; 373 | } 374 | declare module 'casual-browserify/src/providers/payment.js' { 375 | declare module.exports: $Exports<'casual-browserify/src/providers/payment'>; 376 | } 377 | declare module 'casual-browserify/src/providers/person.js' { 378 | declare module.exports: $Exports<'casual-browserify/src/providers/person'>; 379 | } 380 | declare module 'casual-browserify/src/providers/pt_BR/address.js' { 381 | declare module.exports: $Exports<'casual-browserify/src/providers/pt_BR/address'>; 382 | } 383 | declare module 'casual-browserify/src/providers/pt_BR/color.js' { 384 | declare module.exports: $Exports<'casual-browserify/src/providers/pt_BR/color'>; 385 | } 386 | declare module 'casual-browserify/src/providers/pt_BR/person.js' { 387 | declare module.exports: $Exports<'casual-browserify/src/providers/pt_BR/person'>; 388 | } 389 | declare module 'casual-browserify/src/providers/ro_RO/address.js' { 390 | declare module.exports: $Exports<'casual-browserify/src/providers/ro_RO/address'>; 391 | } 392 | declare module 'casual-browserify/src/providers/ro_RO/date.js' { 393 | declare module.exports: $Exports<'casual-browserify/src/providers/ro_RO/date'>; 394 | } 395 | declare module 'casual-browserify/src/providers/ro_RO/person.js' { 396 | declare module.exports: $Exports<'casual-browserify/src/providers/ro_RO/person'>; 397 | } 398 | declare module 'casual-browserify/src/providers/ru_RU/address.js' { 399 | declare module.exports: $Exports<'casual-browserify/src/providers/ru_RU/address'>; 400 | } 401 | declare module 'casual-browserify/src/providers/ru_RU/color.js' { 402 | declare module.exports: $Exports<'casual-browserify/src/providers/ru_RU/color'>; 403 | } 404 | declare module 'casual-browserify/src/providers/ru_RU/internet.js' { 405 | declare module.exports: $Exports<'casual-browserify/src/providers/ru_RU/internet'>; 406 | } 407 | declare module 'casual-browserify/src/providers/ru_RU/person.js' { 408 | declare module.exports: $Exports<'casual-browserify/src/providers/ru_RU/person'>; 409 | } 410 | declare module 'casual-browserify/src/providers/ru_RU/text.js' { 411 | declare module.exports: $Exports<'casual-browserify/src/providers/ru_RU/text'>; 412 | } 413 | declare module 'casual-browserify/src/providers/sv_SE/address.js' { 414 | declare module.exports: $Exports<'casual-browserify/src/providers/sv_SE/address'>; 415 | } 416 | declare module 'casual-browserify/src/providers/sv_SE/person.js' { 417 | declare module.exports: $Exports<'casual-browserify/src/providers/sv_SE/person'>; 418 | } 419 | declare module 'casual-browserify/src/providers/sv_SE/text.js' { 420 | declare module.exports: $Exports<'casual-browserify/src/providers/sv_SE/text'>; 421 | } 422 | declare module 'casual-browserify/src/providers/text.js' { 423 | declare module.exports: $Exports<'casual-browserify/src/providers/text'>; 424 | } 425 | declare module 'casual-browserify/src/providers/uk_UA/address.js' { 426 | declare module.exports: $Exports<'casual-browserify/src/providers/uk_UA/address'>; 427 | } 428 | declare module 'casual-browserify/src/providers/uk_UA/color.js' { 429 | declare module.exports: $Exports<'casual-browserify/src/providers/uk_UA/color'>; 430 | } 431 | declare module 'casual-browserify/src/providers/uk_UA/text.js' { 432 | declare module.exports: $Exports<'casual-browserify/src/providers/uk_UA/text'>; 433 | } 434 | declare module 'casual-browserify/src/require_provider_browserify.js' { 435 | declare module.exports: $Exports<'casual-browserify/src/require_provider_browserify'>; 436 | } 437 | declare module 'casual-browserify/src/safe_require_browserify.js' { 438 | declare module.exports: $Exports<'casual-browserify/src/safe_require_browserify'>; 439 | } 440 | declare module 'casual-browserify/test/casual.js' { 441 | declare module.exports: $Exports<'casual-browserify/test/casual'>; 442 | } 443 | declare module 'casual-browserify/utils/show.js' { 444 | declare module.exports: $Exports<'casual-browserify/utils/show'>; 445 | } 446 | -------------------------------------------------------------------------------- /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/flow-copy-source_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: bd40082a025a56d7d74fe667291d28d9 2 | // flow-typed version: <>/flow-copy-source_v^2.0.0/flow_v0.103.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'flow-copy-source' 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 'flow-copy-source' { 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 'flow-copy-source/bin/flow-copy-source' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'flow-copy-source/src' { 30 | declare module.exports: any; 31 | } 32 | 33 | declare module 'flow-copy-source/src/kefir-copy-file' { 34 | declare module.exports: any; 35 | } 36 | 37 | declare module 'flow-copy-source/src/kefir-glob' { 38 | declare module.exports: any; 39 | } 40 | 41 | // Filename aliases 42 | declare module 'flow-copy-source/bin/flow-copy-source.js' { 43 | declare module.exports: $Exports<'flow-copy-source/bin/flow-copy-source'>; 44 | } 45 | declare module 'flow-copy-source/src/index' { 46 | declare module.exports: $Exports<'flow-copy-source/src'>; 47 | } 48 | declare module 'flow-copy-source/src/index.js' { 49 | declare module.exports: $Exports<'flow-copy-source/src'>; 50 | } 51 | declare module 'flow-copy-source/src/kefir-copy-file.js' { 52 | declare module.exports: $Exports<'flow-copy-source/src/kefir-copy-file'>; 53 | } 54 | declare module 'flow-copy-source/src/kefir-glob.js' { 55 | declare module.exports: $Exports<'flow-copy-source/src/kefir-glob'>; 56 | } 57 | -------------------------------------------------------------------------------- /flow-typed/npm/husky_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 81a310dfeb5819074ab95b16021bcb64 2 | // flow-typed version: <>/husky_v^0.14.3/flow_v0.103.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'husky' 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 'husky' { 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 'husky/__tests__' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'husky/bin/install' { 30 | declare module.exports: any; 31 | } 32 | 33 | declare module 'husky/bin/uninstall' { 34 | declare module.exports: any; 35 | } 36 | 37 | declare module 'husky/src/install' { 38 | declare module.exports: any; 39 | } 40 | 41 | declare module 'husky/src/uninstall' { 42 | declare module.exports: any; 43 | } 44 | 45 | declare module 'husky/src/utils/find-hooks-dir' { 46 | declare module.exports: any; 47 | } 48 | 49 | declare module 'husky/src/utils/find-parent' { 50 | declare module.exports: any; 51 | } 52 | 53 | declare module 'husky/src/utils/get-hook-script' { 54 | declare module.exports: any; 55 | } 56 | 57 | declare module 'husky/src/utils/is-husky' { 58 | declare module.exports: any; 59 | } 60 | 61 | // Filename aliases 62 | declare module 'husky/__tests__/index' { 63 | declare module.exports: $Exports<'husky/__tests__'>; 64 | } 65 | declare module 'husky/__tests__/index.js' { 66 | declare module.exports: $Exports<'husky/__tests__'>; 67 | } 68 | declare module 'husky/bin/install.js' { 69 | declare module.exports: $Exports<'husky/bin/install'>; 70 | } 71 | declare module 'husky/bin/uninstall.js' { 72 | declare module.exports: $Exports<'husky/bin/uninstall'>; 73 | } 74 | declare module 'husky/src/install.js' { 75 | declare module.exports: $Exports<'husky/src/install'>; 76 | } 77 | declare module 'husky/src/uninstall.js' { 78 | declare module.exports: $Exports<'husky/src/uninstall'>; 79 | } 80 | declare module 'husky/src/utils/find-hooks-dir.js' { 81 | declare module.exports: $Exports<'husky/src/utils/find-hooks-dir'>; 82 | } 83 | declare module 'husky/src/utils/find-parent.js' { 84 | declare module.exports: $Exports<'husky/src/utils/find-parent'>; 85 | } 86 | declare module 'husky/src/utils/get-hook-script.js' { 87 | declare module.exports: $Exports<'husky/src/utils/get-hook-script'>; 88 | } 89 | declare module 'husky/src/utils/is-husky.js' { 90 | declare module.exports: $Exports<'husky/src/utils/is-husky'>; 91 | } 92 | -------------------------------------------------------------------------------- /flow-typed/npm/jest_v23.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 78c200acffbcc16bba9478f5396c3a00 2 | // flow-typed version: b2980740dd/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(fn: (...args: TArguments) => TReturn): JestMockFn, 53 | /** 54 | * Accepts a function that will be used as an implementation of the mock for 55 | * one call to the mocked function. Can be chained so that multiple function 56 | * calls produce different results. 57 | */ 58 | mockImplementationOnce(fn: (...args: TArguments) => TReturn): JestMockFn, 59 | /** 60 | * Accepts a string to use in test result output in place of "jest.fn()" to 61 | * indicate which mock function is being referenced. 62 | */ 63 | mockName(name: string): JestMockFn, 64 | /** 65 | * Just a simple sugar function for returning `this` 66 | */ 67 | mockReturnThis(): void, 68 | /** 69 | * Accepts a value that will be returned whenever the mock function is called. 70 | */ 71 | mockReturnValue(value: TReturn): JestMockFn, 72 | /** 73 | * Sugar for only returning a value once inside your mock 74 | */ 75 | mockReturnValueOnce(value: TReturn): JestMockFn, 76 | /** 77 | * Sugar for jest.fn().mockImplementation(() => Promise.resolve(value)) 78 | */ 79 | mockResolvedValue(value: TReturn): JestMockFn>, 80 | /** 81 | * Sugar for jest.fn().mockImplementationOnce(() => Promise.resolve(value)) 82 | */ 83 | mockResolvedValueOnce(value: TReturn): JestMockFn>, 84 | /** 85 | * Sugar for jest.fn().mockImplementation(() => Promise.reject(value)) 86 | */ 87 | mockRejectedValue(value: TReturn): JestMockFn>, 88 | /** 89 | * Sugar for jest.fn().mockImplementationOnce(() => Promise.reject(value)) 90 | */ 91 | mockRejectedValueOnce(value: TReturn): JestMockFn> 92 | }; 93 | 94 | type JestAsymmetricEqualityType = { 95 | /** 96 | * A custom Jasmine equality tester 97 | */ 98 | asymmetricMatch(value: mixed): boolean 99 | }; 100 | 101 | type JestCallsType = { 102 | allArgs(): mixed, 103 | all(): mixed, 104 | any(): boolean, 105 | count(): number, 106 | first(): mixed, 107 | mostRecent(): mixed, 108 | reset(): void 109 | }; 110 | 111 | type JestClockType = { 112 | install(): void, 113 | mockDate(date: Date): void, 114 | tick(milliseconds?: number): void, 115 | uninstall(): void 116 | }; 117 | 118 | type JestMatcherResult = { 119 | message?: string | (() => string), 120 | pass: boolean 121 | }; 122 | 123 | type JestMatcher = (actual: any, expected: any) => JestMatcherResult | Promise; 124 | 125 | type JestPromiseType = { 126 | /** 127 | * Use rejects to unwrap the reason of a rejected promise so any other 128 | * matcher can be chained. If the promise is fulfilled the assertion fails. 129 | */ 130 | rejects: JestExpectType, 131 | /** 132 | * Use resolves to unwrap the value of a fulfilled promise so any other 133 | * matcher can be chained. If the promise is rejected the assertion fails. 134 | */ 135 | resolves: JestExpectType 136 | }; 137 | 138 | /** 139 | * Jest allows functions and classes to be used as test names in test() and 140 | * describe() 141 | */ 142 | type JestTestName = string | Function; 143 | 144 | /** 145 | * Plugin: jest-styled-components 146 | */ 147 | 148 | type JestStyledComponentsMatcherValue = 149 | | string 150 | | JestAsymmetricEqualityType 151 | | RegExp 152 | | typeof undefined; 153 | 154 | type JestStyledComponentsMatcherOptions = { 155 | media?: string, 156 | modifier?: string, 157 | supports?: string 158 | }; 159 | 160 | type JestStyledComponentsMatchersType = { 161 | toHaveStyleRule( 162 | property: string, 163 | value: JestStyledComponentsMatcherValue, 164 | options?: JestStyledComponentsMatcherOptions 165 | ): void 166 | }; 167 | 168 | /** 169 | * Plugin: jest-enzyme 170 | */ 171 | type EnzymeMatchersType = { 172 | // 5.x 173 | toBeEmpty(): void, 174 | toBePresent(): void, 175 | // 6.x 176 | toBeChecked(): void, 177 | toBeDisabled(): void, 178 | toBeEmptyRender(): void, 179 | toContainMatchingElement(selector: string): void, 180 | toContainMatchingElements(n: number, selector: string): void, 181 | toContainExactlyOneMatchingElement(selector: string): void, 182 | toContainReact(element: React$Element): void, 183 | toExist(): void, 184 | toHaveClassName(className: string): void, 185 | toHaveHTML(html: string): void, 186 | toHaveProp: ((propKey: string, propValue?: any) => void) & ((props: Object) => void), 187 | toHaveRef(refName: string): void, 188 | toHaveState: ((stateKey: string, stateValue?: any) => void) & ((state: Object) => void), 189 | toHaveStyle: ((styleKey: string, styleValue?: any) => void) & ((style: Object) => void), 190 | toHaveTagName(tagName: string): void, 191 | toHaveText(text: string): void, 192 | toHaveValue(value: any): void, 193 | toIncludeText(text: string): void, 194 | toMatchElement( 195 | element: React$Element, 196 | options?: {| ignoreProps?: boolean, verbose?: boolean |} 197 | ): void, 198 | toMatchSelector(selector: string): void, 199 | // 7.x 200 | toHaveDisplayName(name: string): void 201 | }; 202 | 203 | // DOM testing library extensions https://github.com/kentcdodds/dom-testing-library#custom-jest-matchers 204 | type DomTestingLibraryType = { 205 | toBeDisabled(): void, 206 | toBeEmpty(): void, 207 | toBeInTheDocument(): void, 208 | toBeVisible(): void, 209 | toContainElement(element: HTMLElement | null): void, 210 | toContainHTML(htmlText: string): void, 211 | toHaveAttribute(name: string, expectedValue?: string): void, 212 | toHaveClass(...classNames: string[]): void, 213 | toHaveFocus(): void, 214 | toHaveFormValues(expectedValues: { [name: string]: any }): void, 215 | toHaveStyle(css: string): void, 216 | toHaveTextContent(content: string | RegExp, options?: { normalizeWhitespace: boolean }): void, 217 | toBeInTheDOM(): void 218 | }; 219 | 220 | // Jest JQuery Matchers: https://github.com/unindented/custom-jquery-matchers 221 | type JestJQueryMatchersType = { 222 | toExist(): void, 223 | toHaveLength(len: number): void, 224 | toHaveId(id: string): void, 225 | toHaveClass(className: string): void, 226 | toHaveTag(tag: string): void, 227 | toHaveAttr(key: string, val?: any): void, 228 | toHaveProp(key: string, val?: any): void, 229 | toHaveText(text: string | RegExp): void, 230 | toHaveData(key: string, val?: any): void, 231 | toHaveValue(val: any): void, 232 | toHaveCss(css: { [key: string]: any }): void, 233 | toBeChecked(): void, 234 | toBeDisabled(): void, 235 | toBeEmpty(): void, 236 | toBeHidden(): void, 237 | toBeSelected(): void, 238 | toBeVisible(): void, 239 | toBeFocused(): void, 240 | toBeInDom(): void, 241 | toBeMatchedBy(sel: string): void, 242 | toHaveDescendant(sel: string): void, 243 | toHaveDescendantWithText(sel: string, text: string | RegExp): void 244 | }; 245 | 246 | // Jest Extended Matchers: https://github.com/jest-community/jest-extended 247 | type JestExtendedMatchersType = { 248 | /** 249 | * Note: Currently unimplemented 250 | * Passing assertion 251 | * 252 | * @param {String} message 253 | */ 254 | // pass(message: string): void; 255 | 256 | /** 257 | * Note: Currently unimplemented 258 | * Failing assertion 259 | * 260 | * @param {String} message 261 | */ 262 | // fail(message: string): void; 263 | 264 | /** 265 | * Use .toBeEmpty when checking if a String '', Array [] or Object {} is empty. 266 | */ 267 | toBeEmpty(): void, 268 | 269 | /** 270 | * Use .toBeOneOf when checking if a value is a member of a given Array. 271 | * @param {Array.<*>} members 272 | */ 273 | toBeOneOf(members: any[]): void, 274 | 275 | /** 276 | * Use `.toBeNil` when checking a value is `null` or `undefined`. 277 | */ 278 | toBeNil(): void, 279 | 280 | /** 281 | * Use `.toSatisfy` when you want to use a custom matcher by supplying a predicate function that returns a `Boolean`. 282 | * @param {Function} predicate 283 | */ 284 | toSatisfy(predicate: (n: any) => boolean): void, 285 | 286 | /** 287 | * Use `.toBeArray` when checking if a value is an `Array`. 288 | */ 289 | toBeArray(): void, 290 | 291 | /** 292 | * Use `.toBeArrayOfSize` when checking if a value is an `Array` of size x. 293 | * @param {Number} x 294 | */ 295 | toBeArrayOfSize(x: number): void, 296 | 297 | /** 298 | * Use `.toIncludeAllMembers` when checking if an `Array` contains all of the same members of a given set. 299 | * @param {Array.<*>} members 300 | */ 301 | toIncludeAllMembers(members: any[]): void, 302 | 303 | /** 304 | * Use `.toIncludeAnyMembers` when checking if an `Array` contains any of the members of a given set. 305 | * @param {Array.<*>} members 306 | */ 307 | toIncludeAnyMembers(members: any[]): void, 308 | 309 | /** 310 | * 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. 311 | * @param {Function} predicate 312 | */ 313 | toSatisfyAll(predicate: (n: any) => boolean): void, 314 | 315 | /** 316 | * Use `.toBeBoolean` when checking if a value is a `Boolean`. 317 | */ 318 | toBeBoolean(): void, 319 | 320 | /** 321 | * Use `.toBeTrue` when checking a value is equal (===) to `true`. 322 | */ 323 | toBeTrue(): void, 324 | 325 | /** 326 | * Use `.toBeFalse` when checking a value is equal (===) to `false`. 327 | */ 328 | toBeFalse(): void, 329 | 330 | /** 331 | * Use .toBeDate when checking if a value is a Date. 332 | */ 333 | toBeDate(): void, 334 | 335 | /** 336 | * Use `.toBeFunction` when checking if a value is a `Function`. 337 | */ 338 | toBeFunction(): void, 339 | 340 | /** 341 | * Use `.toHaveBeenCalledBefore` when checking if a `Mock` was called before another `Mock`. 342 | * 343 | * Note: Required Jest version >22 344 | * 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 345 | * 346 | * @param {Mock} mock 347 | */ 348 | toHaveBeenCalledBefore(mock: JestMockFn): void, 349 | 350 | /** 351 | * Use `.toBeNumber` when checking if a value is a `Number`. 352 | */ 353 | toBeNumber(): void, 354 | 355 | /** 356 | * Use `.toBeNaN` when checking a value is `NaN`. 357 | */ 358 | toBeNaN(): void, 359 | 360 | /** 361 | * Use `.toBeFinite` when checking if a value is a `Number`, not `NaN` or `Infinity`. 362 | */ 363 | toBeFinite(): void, 364 | 365 | /** 366 | * Use `.toBePositive` when checking if a value is a positive `Number`. 367 | */ 368 | toBePositive(): void, 369 | 370 | /** 371 | * Use `.toBeNegative` when checking if a value is a negative `Number`. 372 | */ 373 | toBeNegative(): void, 374 | 375 | /** 376 | * Use `.toBeEven` when checking if a value is an even `Number`. 377 | */ 378 | toBeEven(): void, 379 | 380 | /** 381 | * Use `.toBeOdd` when checking if a value is an odd `Number`. 382 | */ 383 | toBeOdd(): void, 384 | 385 | /** 386 | * Use `.toBeWithin` when checking if a number is in between the given bounds of: start (inclusive) and end (exclusive). 387 | * 388 | * @param {Number} start 389 | * @param {Number} end 390 | */ 391 | toBeWithin(start: number, end: number): void, 392 | 393 | /** 394 | * Use `.toBeObject` when checking if a value is an `Object`. 395 | */ 396 | toBeObject(): void, 397 | 398 | /** 399 | * Use `.toContainKey` when checking if an object contains the provided key. 400 | * 401 | * @param {String} key 402 | */ 403 | toContainKey(key: string): void, 404 | 405 | /** 406 | * Use `.toContainKeys` when checking if an object has all of the provided keys. 407 | * 408 | * @param {Array.} keys 409 | */ 410 | toContainKeys(keys: string[]): void, 411 | 412 | /** 413 | * Use `.toContainAllKeys` when checking if an object only contains all of the provided keys. 414 | * 415 | * @param {Array.} keys 416 | */ 417 | toContainAllKeys(keys: string[]): void, 418 | 419 | /** 420 | * Use `.toContainAnyKeys` when checking if an object contains at least one of the provided keys. 421 | * 422 | * @param {Array.} keys 423 | */ 424 | toContainAnyKeys(keys: string[]): void, 425 | 426 | /** 427 | * Use `.toContainValue` when checking if an object contains the provided value. 428 | * 429 | * @param {*} value 430 | */ 431 | toContainValue(value: any): void, 432 | 433 | /** 434 | * Use `.toContainValues` when checking if an object contains all of the provided values. 435 | * 436 | * @param {Array.<*>} values 437 | */ 438 | toContainValues(values: any[]): void, 439 | 440 | /** 441 | * Use `.toContainAllValues` when checking if an object only contains all of the provided values. 442 | * 443 | * @param {Array.<*>} values 444 | */ 445 | toContainAllValues(values: any[]): void, 446 | 447 | /** 448 | * Use `.toContainAnyValues` when checking if an object contains at least one of the provided values. 449 | * 450 | * @param {Array.<*>} values 451 | */ 452 | toContainAnyValues(values: any[]): void, 453 | 454 | /** 455 | * Use `.toContainEntry` when checking if an object contains the provided entry. 456 | * 457 | * @param {Array.} entry 458 | */ 459 | toContainEntry(entry: [string, string]): void, 460 | 461 | /** 462 | * Use `.toContainEntries` when checking if an object contains all of the provided entries. 463 | * 464 | * @param {Array.>} entries 465 | */ 466 | toContainEntries(entries: [string, string][]): void, 467 | 468 | /** 469 | * Use `.toContainAllEntries` when checking if an object only contains all of the provided entries. 470 | * 471 | * @param {Array.>} entries 472 | */ 473 | toContainAllEntries(entries: [string, string][]): void, 474 | 475 | /** 476 | * Use `.toContainAnyEntries` when checking if an object contains at least one of the provided entries. 477 | * 478 | * @param {Array.>} entries 479 | */ 480 | toContainAnyEntries(entries: [string, string][]): void, 481 | 482 | /** 483 | * Use `.toBeExtensible` when checking if an object is extensible. 484 | */ 485 | toBeExtensible(): void, 486 | 487 | /** 488 | * Use `.toBeFrozen` when checking if an object is frozen. 489 | */ 490 | toBeFrozen(): void, 491 | 492 | /** 493 | * Use `.toBeSealed` when checking if an object is sealed. 494 | */ 495 | toBeSealed(): void, 496 | 497 | /** 498 | * Use `.toBeString` when checking if a value is a `String`. 499 | */ 500 | toBeString(): void, 501 | 502 | /** 503 | * Use `.toEqualCaseInsensitive` when checking if a string is equal (===) to another ignoring the casing of both strings. 504 | * 505 | * @param {String} string 506 | */ 507 | toEqualCaseInsensitive(string: string): void, 508 | 509 | /** 510 | * Use `.toStartWith` when checking if a `String` starts with a given `String` prefix. 511 | * 512 | * @param {String} prefix 513 | */ 514 | toStartWith(prefix: string): void, 515 | 516 | /** 517 | * Use `.toEndWith` when checking if a `String` ends with a given `String` suffix. 518 | * 519 | * @param {String} suffix 520 | */ 521 | toEndWith(suffix: string): void, 522 | 523 | /** 524 | * Use `.toInclude` when checking if a `String` includes the given `String` substring. 525 | * 526 | * @param {String} substring 527 | */ 528 | toInclude(substring: string): void, 529 | 530 | /** 531 | * Use `.toIncludeRepeated` when checking if a `String` includes the given `String` substring the correct number of times. 532 | * 533 | * @param {String} substring 534 | * @param {Number} times 535 | */ 536 | toIncludeRepeated(substring: string, times: number): void, 537 | 538 | /** 539 | * Use `.toIncludeMultiple` when checking if a `String` includes all of the given substrings. 540 | * 541 | * @param {Array.} substring 542 | */ 543 | toIncludeMultiple(substring: string[]): void 544 | }; 545 | 546 | interface JestExpectType { 547 | not: JestExpectType & 548 | EnzymeMatchersType & 549 | DomTestingLibraryType & 550 | JestJQueryMatchersType & 551 | JestStyledComponentsMatchersType & 552 | JestExtendedMatchersType; 553 | /** 554 | * If you have a mock function, you can use .lastCalledWith to test what 555 | * arguments it was last called with. 556 | */ 557 | lastCalledWith(...args: Array): void; 558 | /** 559 | * toBe just checks that a value is what you expect. It uses === to check 560 | * strict equality. 561 | */ 562 | toBe(value: any): void; 563 | /** 564 | * Use .toBeCalledWith to ensure that a mock function was called with 565 | * specific arguments. 566 | */ 567 | toBeCalledWith(...args: Array): void; 568 | /** 569 | * Using exact equality with floating point numbers is a bad idea. Rounding 570 | * means that intuitive things fail. 571 | */ 572 | toBeCloseTo(num: number, delta: any): void; 573 | /** 574 | * Use .toBeDefined to check that a variable is not undefined. 575 | */ 576 | toBeDefined(): void; 577 | /** 578 | * Use .toBeFalsy when you don't care what a value is, you just want to 579 | * ensure a value is false in a boolean context. 580 | */ 581 | toBeFalsy(): void; 582 | /** 583 | * To compare floating point numbers, you can use toBeGreaterThan. 584 | */ 585 | toBeGreaterThan(number: number): void; 586 | /** 587 | * To compare floating point numbers, you can use toBeGreaterThanOrEqual. 588 | */ 589 | toBeGreaterThanOrEqual(number: number): void; 590 | /** 591 | * To compare floating point numbers, you can use toBeLessThan. 592 | */ 593 | toBeLessThan(number: number): void; 594 | /** 595 | * To compare floating point numbers, you can use toBeLessThanOrEqual. 596 | */ 597 | toBeLessThanOrEqual(number: number): void; 598 | /** 599 | * Use .toBeInstanceOf(Class) to check that an object is an instance of a 600 | * class. 601 | */ 602 | toBeInstanceOf(cls: Class<*>): void; 603 | /** 604 | * .toBeNull() is the same as .toBe(null) but the error messages are a bit 605 | * nicer. 606 | */ 607 | toBeNull(): void; 608 | /** 609 | * Use .toBeTruthy when you don't care what a value is, you just want to 610 | * ensure a value is true in a boolean context. 611 | */ 612 | toBeTruthy(): void; 613 | /** 614 | * Use .toBeUndefined to check that a variable is undefined. 615 | */ 616 | toBeUndefined(): void; 617 | /** 618 | * Use .toContain when you want to check that an item is in a list. For 619 | * testing the items in the list, this uses ===, a strict equality check. 620 | */ 621 | toContain(item: any): void; 622 | /** 623 | * Use .toContainEqual when you want to check that an item is in a list. For 624 | * testing the items in the list, this matcher recursively checks the 625 | * equality of all fields, rather than checking for object identity. 626 | */ 627 | toContainEqual(item: any): void; 628 | /** 629 | * Use .toEqual when you want to check that two objects have the same value. 630 | * This matcher recursively checks the equality of all fields, rather than 631 | * checking for object identity. 632 | */ 633 | toEqual(value: any): void; 634 | /** 635 | * Use .toHaveBeenCalled to ensure that a mock function got called. 636 | */ 637 | toHaveBeenCalled(): void; 638 | toBeCalled(): void; 639 | /** 640 | * Use .toHaveBeenCalledTimes to ensure that a mock function got called exact 641 | * number of times. 642 | */ 643 | toHaveBeenCalledTimes(number: number): void; 644 | toBeCalledTimes(number: number): void; 645 | /** 646 | * 647 | */ 648 | toHaveBeenNthCalledWith(nthCall: number, ...args: Array): void; 649 | nthCalledWith(nthCall: number, ...args: Array): void; 650 | /** 651 | * 652 | */ 653 | toHaveReturned(): void; 654 | toReturn(): void; 655 | /** 656 | * 657 | */ 658 | toHaveReturnedTimes(number: number): void; 659 | toReturnTimes(number: number): void; 660 | /** 661 | * 662 | */ 663 | toHaveReturnedWith(value: any): void; 664 | toReturnWith(value: any): void; 665 | /** 666 | * 667 | */ 668 | toHaveLastReturnedWith(value: any): void; 669 | lastReturnedWith(value: any): void; 670 | /** 671 | * 672 | */ 673 | toHaveNthReturnedWith(nthCall: number, value: any): void; 674 | nthReturnedWith(nthCall: number, value: any): void; 675 | /** 676 | * Use .toHaveBeenCalledWith to ensure that a mock function was called with 677 | * specific arguments. 678 | */ 679 | toHaveBeenCalledWith(...args: Array): void; 680 | toBeCalledWith(...args: Array): void; 681 | /** 682 | * Use .toHaveBeenLastCalledWith to ensure that a mock function was last called 683 | * with specific arguments. 684 | */ 685 | toHaveBeenLastCalledWith(...args: Array): void; 686 | lastCalledWith(...args: Array): void; 687 | /** 688 | * Check that an object has a .length property and it is set to a certain 689 | * numeric value. 690 | */ 691 | toHaveLength(number: number): void; 692 | /** 693 | * 694 | */ 695 | toHaveProperty(propPath: string, value?: any): void; 696 | /** 697 | * Use .toMatch to check that a string matches a regular expression or string. 698 | */ 699 | toMatch(regexpOrString: RegExp | string): void; 700 | /** 701 | * Use .toMatchObject to check that a javascript object matches a subset of the properties of an object. 702 | */ 703 | toMatchObject(object: Object | Array): void; 704 | /** 705 | * Use .toStrictEqual to check that a javascript object matches a subset of the properties of an object. 706 | */ 707 | toStrictEqual(value: any): void; 708 | /** 709 | * This ensures that an Object matches the most recent snapshot. 710 | */ 711 | toMatchSnapshot(propertyMatchers?: any, name?: string): void; 712 | /** 713 | * This ensures that an Object matches the most recent snapshot. 714 | */ 715 | toMatchSnapshot(name: string): void; 716 | 717 | toMatchInlineSnapshot(snapshot?: string): void; 718 | toMatchInlineSnapshot(propertyMatchers?: any, snapshot?: string): void; 719 | /** 720 | * Use .toThrow to test that a function throws when it is called. 721 | * If you want to test that a specific error gets thrown, you can provide an 722 | * argument to toThrow. The argument can be a string for the error message, 723 | * a class for the error, or a regex that should match the error. 724 | * 725 | * Alias: .toThrowError 726 | */ 727 | toThrow(message?: string | Error | Class | RegExp): void; 728 | toThrowError(message?: string | Error | Class | RegExp): void; 729 | /** 730 | * Use .toThrowErrorMatchingSnapshot to test that a function throws a error 731 | * matching the most recent snapshot when it is called. 732 | */ 733 | toThrowErrorMatchingSnapshot(): void; 734 | toThrowErrorMatchingInlineSnapshot(snapshot?: string): void; 735 | } 736 | 737 | type JestObjectType = { 738 | /** 739 | * Disables automatic mocking in the module loader. 740 | * 741 | * After this method is called, all `require()`s will return the real 742 | * versions of each module (rather than a mocked version). 743 | */ 744 | disableAutomock(): JestObjectType, 745 | /** 746 | * An un-hoisted version of disableAutomock 747 | */ 748 | autoMockOff(): JestObjectType, 749 | /** 750 | * Enables automatic mocking in the module loader. 751 | */ 752 | enableAutomock(): JestObjectType, 753 | /** 754 | * An un-hoisted version of enableAutomock 755 | */ 756 | autoMockOn(): JestObjectType, 757 | /** 758 | * Clears the mock.calls and mock.instances properties of all mocks. 759 | * Equivalent to calling .mockClear() on every mocked function. 760 | */ 761 | clearAllMocks(): JestObjectType, 762 | /** 763 | * Resets the state of all mocks. Equivalent to calling .mockReset() on every 764 | * mocked function. 765 | */ 766 | resetAllMocks(): JestObjectType, 767 | /** 768 | * Restores all mocks back to their original value. 769 | */ 770 | restoreAllMocks(): JestObjectType, 771 | /** 772 | * Removes any pending timers from the timer system. 773 | */ 774 | clearAllTimers(): void, 775 | /** 776 | * The same as `mock` but not moved to the top of the expectation by 777 | * babel-jest. 778 | */ 779 | doMock(moduleName: string, moduleFactory?: any): JestObjectType, 780 | /** 781 | * The same as `unmock` but not moved to the top of the expectation by 782 | * babel-jest. 783 | */ 784 | dontMock(moduleName: string): JestObjectType, 785 | /** 786 | * Returns a new, unused mock function. Optionally takes a mock 787 | * implementation. 788 | */ 789 | fn, TReturn>( 790 | implementation?: (...args: TArguments) => TReturn 791 | ): JestMockFn, 792 | /** 793 | * Determines if the given function is a mocked function. 794 | */ 795 | isMockFunction(fn: Function): boolean, 796 | /** 797 | * Given the name of a module, use the automatic mocking system to generate a 798 | * mocked version of the module for you. 799 | */ 800 | genMockFromModule(moduleName: string): any, 801 | /** 802 | * Mocks a module with an auto-mocked version when it is being required. 803 | * 804 | * The second argument can be used to specify an explicit module factory that 805 | * is being run instead of using Jest's automocking feature. 806 | * 807 | * The third argument can be used to create virtual mocks -- mocks of modules 808 | * that don't exist anywhere in the system. 809 | */ 810 | mock(moduleName: string, moduleFactory?: any, options?: Object): 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(fn: (done: () => void) => ?Promise, timeout?: number): void; 898 | /** Runs this function before every test inside this context */ 899 | declare function beforeEach(fn: (done: () => void) => ?Promise, timeout?: number): void; 900 | /** Runs this function after all tests have finished inside this context */ 901 | declare function afterAll(fn: (done: () => void) => ?Promise, timeout?: number): void; 902 | /** Runs this function before any tests have started inside this context */ 903 | declare function beforeAll(fn: (done: () => void) => ?Promise, timeout?: number): void; 904 | 905 | /** A context for grouping tests together */ 906 | declare var describe: { 907 | /** 908 | * Creates a block that groups together several related tests in one "test suite" 909 | */ 910 | (name: JestTestName, fn: () => void): void, 911 | 912 | /** 913 | * Only run this describe block 914 | */ 915 | only(name: JestTestName, fn: () => void): void, 916 | 917 | /** 918 | * Skip running this describe block 919 | */ 920 | skip(name: JestTestName, fn: () => void): void, 921 | 922 | /** 923 | * each runs this test against array of argument arrays per each run 924 | * 925 | * @param {table} table of Test 926 | */ 927 | each( 928 | ...table: Array | mixed> | [Array, string] 929 | ): (name: JestTestName, fn?: (...args: Array) => ?Promise, timeout?: number) => void 930 | }; 931 | 932 | /** An individual test unit */ 933 | declare var it: { 934 | /** 935 | * An individual test unit 936 | * 937 | * @param {JestTestName} Name of Test 938 | * @param {Function} Test 939 | * @param {number} Timeout for the test, in milliseconds. 940 | */ 941 | (name: JestTestName, fn?: (done: () => void) => ?Promise, timeout?: number): void, 942 | 943 | /** 944 | * Only run this test 945 | * 946 | * @param {JestTestName} Name of Test 947 | * @param {Function} Test 948 | * @param {number} Timeout for the test, in milliseconds. 949 | */ 950 | only( 951 | name: JestTestName, 952 | fn?: (done: () => void) => ?Promise, 953 | timeout?: number 954 | ): { 955 | each( 956 | ...table: Array | mixed> | [Array, string] 957 | ): ( 958 | name: JestTestName, 959 | fn?: (...args: Array) => ?Promise, 960 | timeout?: number 961 | ) => void 962 | }, 963 | 964 | /** 965 | * Skip running this test 966 | * 967 | * @param {JestTestName} Name of Test 968 | * @param {Function} Test 969 | * @param {number} Timeout for the test, in milliseconds. 970 | */ 971 | skip(name: JestTestName, fn?: (done: () => void) => ?Promise, timeout?: number): void, 972 | 973 | /** 974 | * Run the test concurrently 975 | * 976 | * @param {JestTestName} Name of Test 977 | * @param {Function} Test 978 | * @param {number} Timeout for the test, in milliseconds. 979 | */ 980 | concurrent( 981 | name: JestTestName, 982 | fn?: (done: () => void) => ?Promise, 983 | timeout?: number 984 | ): void, 985 | 986 | /** 987 | * each runs this test against array of argument arrays per each run 988 | * 989 | * @param {table} table of Test 990 | */ 991 | each( 992 | ...table: Array | mixed> | [Array, string] 993 | ): (name: JestTestName, fn?: (...args: Array) => ?Promise, timeout?: number) => void 994 | }; 995 | 996 | declare function fit( 997 | name: JestTestName, 998 | fn: (done: () => void) => ?Promise, 999 | timeout?: number 1000 | ): void; 1001 | /** An individual test unit */ 1002 | declare var test: typeof it; 1003 | /** A disabled group of tests */ 1004 | declare var xdescribe: typeof describe; 1005 | /** A focused group of tests */ 1006 | declare var fdescribe: typeof describe; 1007 | /** A disabled individual test */ 1008 | declare var xit: typeof it; 1009 | /** A disabled individual test */ 1010 | declare var xtest: typeof it; 1011 | 1012 | type JestPrettyFormatColors = { 1013 | comment: { close: string, open: string }, 1014 | content: { close: string, open: string }, 1015 | prop: { close: string, open: string }, 1016 | tag: { close: string, open: string }, 1017 | value: { close: string, open: string } 1018 | }; 1019 | 1020 | type JestPrettyFormatIndent = string => string; 1021 | type JestPrettyFormatRefs = Array; 1022 | type JestPrettyFormatPrint = any => string; 1023 | type JestPrettyFormatStringOrNull = string | null; 1024 | 1025 | type JestPrettyFormatOptions = {| 1026 | callToJSON: boolean, 1027 | edgeSpacing: string, 1028 | escapeRegex: boolean, 1029 | highlight: boolean, 1030 | indent: number, 1031 | maxDepth: number, 1032 | min: boolean, 1033 | plugins: JestPrettyFormatPlugins, 1034 | printFunctionName: boolean, 1035 | spacing: string, 1036 | theme: {| 1037 | comment: string, 1038 | content: string, 1039 | prop: string, 1040 | tag: string, 1041 | value: string 1042 | |} 1043 | |}; 1044 | 1045 | type JestPrettyFormatPlugin = { 1046 | print: ( 1047 | val: any, 1048 | serialize: JestPrettyFormatPrint, 1049 | indent: JestPrettyFormatIndent, 1050 | opts: JestPrettyFormatOptions, 1051 | colors: JestPrettyFormatColors 1052 | ) => string, 1053 | test: any => boolean 1054 | }; 1055 | 1056 | type JestPrettyFormatPlugins = Array; 1057 | 1058 | /** The expect function is used every time you want to test a value */ 1059 | declare var expect: { 1060 | /** The object that you want to make assertions against */ 1061 | ( 1062 | value: any 1063 | ): JestExpectType & 1064 | JestPromiseType & 1065 | EnzymeMatchersType & 1066 | DomTestingLibraryType & 1067 | JestJQueryMatchersType & 1068 | JestStyledComponentsMatchersType & 1069 | JestExtendedMatchersType, 1070 | 1071 | /** Add additional Jasmine matchers to Jest's roster */ 1072 | extend(matchers: { [name: string]: JestMatcher }): void, 1073 | /** Add a module that formats application-specific data structures. */ 1074 | addSnapshotSerializer(pluginModule: JestPrettyFormatPlugin): void, 1075 | assertions(expectedAssertions: number): void, 1076 | hasAssertions(): void, 1077 | any(value: mixed): JestAsymmetricEqualityType, 1078 | anything(): any, 1079 | arrayContaining(value: Array): Array, 1080 | objectContaining(value: Object): Object, 1081 | /** Matches any received string that contains the exact expected string. */ 1082 | stringContaining(value: string): string, 1083 | stringMatching(value: string | RegExp): string, 1084 | not: { 1085 | arrayContaining: (value: $ReadOnlyArray) => Array, 1086 | objectContaining: (value: {}) => Object, 1087 | stringContaining: (value: string) => string, 1088 | stringMatching: (value: string | RegExp) => string 1089 | } 1090 | }; 1091 | 1092 | // TODO handle return type 1093 | // http://jasmine.github.io/2.4/introduction.html#section-Spies 1094 | declare function spyOn(value: mixed, method: string): Object; 1095 | 1096 | /** Holds all functions related to manipulating test runner */ 1097 | declare var jest: JestObjectType; 1098 | 1099 | /** 1100 | * The global Jasmine object, this is generally not exposed as the public API, 1101 | * using features inside here could break in later versions of Jest. 1102 | */ 1103 | declare var jasmine: { 1104 | DEFAULT_TIMEOUT_INTERVAL: number, 1105 | any(value: mixed): JestAsymmetricEqualityType, 1106 | anything(): any, 1107 | arrayContaining(value: Array): Array, 1108 | clock(): JestClockType, 1109 | createSpy(name: string): JestSpyType, 1110 | createSpyObj( 1111 | baseName: string, 1112 | methodNames: Array 1113 | ): { [methodName: string]: JestSpyType }, 1114 | objectContaining(value: Object): Object, 1115 | stringMatching(value: string): string 1116 | }; 1117 | -------------------------------------------------------------------------------- /flow-typed/npm/prettier_v1.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: 5d9f7564186b12849222d06b0c689452 2 | // flow-typed version: a3dbb68519/prettier_v1.x.x/flow_>=v0.84.x 3 | 4 | declare module "prettier" { 5 | declare export type AST = { [key: string]: any, ... }; 6 | declare export type Doc = { 7 | [key: string]: any, 8 | ... 9 | }; 10 | declare export type FastPath = { 11 | stack: any[], 12 | getName(): null | string | number | Symbol, 13 | getValue(): T, 14 | getNode(count?: number): null | T, 15 | getParentNode(count?: number): null | T, 16 | call(callback: (path: FastPath) => U, ...names: Array): U, 17 | each(callback: (path: FastPath) => void, ...names: Array): void, 18 | map(callback: (path: FastPath, index: number) => U, ...names: Array): U[], 19 | ... 20 | }; 21 | 22 | declare export type PrettierParserName = 23 | | "babylon" // deprecated 24 | | "babel" 25 | | "babel-flow" 26 | | "flow" 27 | | "typescript" 28 | | "postcss" // deprecated 29 | | "css" 30 | | "less" 31 | | "scss" 32 | | "json" 33 | | "json5" 34 | | "json-stringify" 35 | | "graphql" 36 | | "markdown" 37 | | "vue" 38 | | "html" 39 | | "angular" 40 | | "mdx" 41 | | "yaml"; 42 | 43 | declare export type PrettierParser = { 44 | [name: PrettierParserName]: (text: string, options?: { [key: string]: any, ... }) => AST, 45 | ... 46 | }; 47 | 48 | declare export type CustomParser = ( 49 | text: string, 50 | parsers: PrettierParser, 51 | options: Options 52 | ) => AST; 53 | 54 | declare export type Options = {| 55 | printWidth?: number, 56 | tabWidth?: number, 57 | useTabs?: boolean, 58 | semi?: boolean, 59 | singleQuote?: boolean, 60 | trailingComma?: "none" | "es5" | "all", 61 | bracketSpacing?: boolean, 62 | jsxBracketSameLine?: boolean, 63 | arrowParens?: "avoid" | "always", 64 | rangeStart?: number, 65 | rangeEnd?: number, 66 | parser?: PrettierParserName | CustomParser, 67 | filepath?: string, 68 | requirePragma?: boolean, 69 | insertPragma?: boolean, 70 | proseWrap?: "always" | "never" | "preserve", 71 | plugins?: Array 72 | |}; 73 | 74 | declare export type Plugin = { 75 | languages: SupportLanguage, 76 | parsers: { [parserName: string]: Parser, ... }, 77 | printers: { [astFormat: string]: Printer, ... }, 78 | options?: SupportOption[], 79 | ... 80 | }; 81 | 82 | declare export type Parser = { 83 | parse: ( 84 | text: string, 85 | parsers: { [parserName: string]: Parser, ... }, 86 | options: { [key: string]: any, ... } 87 | ) => AST, 88 | astFormat: string, 89 | hasPragma?: (text: string) => boolean, 90 | locStart: (node: any) => number, 91 | locEnd: (node: any) => number, 92 | preprocess?: (text: string, options: { [key: string]: any, ... }) => string, 93 | ... 94 | }; 95 | 96 | declare export type Printer = { 97 | print: ( 98 | path: FastPath<>, 99 | options: { [key: string]: any, ... }, 100 | print: (path: FastPath<>) => Doc 101 | ) => Doc, 102 | embed: ( 103 | path: FastPath<>, 104 | print: (path: FastPath<>) => Doc, 105 | textToDoc: (text: string, options: { [key: string]: any, ... }) => Doc, 106 | options: { [key: string]: any, ... } 107 | ) => ?Doc, 108 | insertPragma?: (text: string) => string, 109 | massageAstNode?: (node: any, newNode: any, parent: any) => any, 110 | hasPrettierIgnore?: (path: FastPath<>) => boolean, 111 | canAttachComment?: (node: any) => boolean, 112 | willPrintOwnComments?: (path: FastPath<>) => boolean, 113 | printComments?: (path: FastPath<>, print: (path: FastPath<>) => Doc, options: { [key: string]: any, ... }, needsSemi: boolean) => Doc, 114 | handleComments?: { 115 | ownLine?: (commentNode: any, text: string, options: { [key: string]: any, ... }, ast: any, isLastComment: boolean) => boolean, 116 | endOfLine?: (commentNode: any, text: string, options: { [key: string]: any, ... }, ast: any, isLastComment: boolean) => boolean, 117 | remaining?: (commentNode: any, text: string, options: { [key: string]: any, ... }, ast: any, isLastComment: boolean) => boolean, 118 | ... 119 | }, 120 | ... 121 | }; 122 | 123 | declare export type CursorOptions = {| 124 | cursorOffset: number, 125 | printWidth?: $PropertyType, 126 | tabWidth?: $PropertyType, 127 | useTabs?: $PropertyType, 128 | semi?: $PropertyType, 129 | singleQuote?: $PropertyType, 130 | trailingComma?: $PropertyType, 131 | bracketSpacing?: $PropertyType, 132 | jsxBracketSameLine?: $PropertyType, 133 | arrowParens?: $PropertyType, 134 | parser?: $PropertyType, 135 | filepath?: $PropertyType, 136 | requirePragma?: $PropertyType, 137 | insertPragma?: $PropertyType, 138 | proseWrap?: $PropertyType, 139 | plugins?: $PropertyType 140 | |}; 141 | 142 | declare export type CursorResult = {| 143 | formatted: string, 144 | cursorOffset: number 145 | |}; 146 | 147 | declare export type ResolveConfigOptions = {| 148 | useCache?: boolean, 149 | config?: string, 150 | editorconfig?: boolean 151 | |}; 152 | 153 | declare export type SupportLanguage = { 154 | name: string, 155 | since: string, 156 | parsers: Array, 157 | group?: string, 158 | tmScope: string, 159 | aceMode: string, 160 | codemirrorMode: string, 161 | codemirrorMimeType: string, 162 | aliases?: Array, 163 | extensions: Array, 164 | filenames?: Array, 165 | linguistLanguageId: number, 166 | vscodeLanguageIds: Array, 167 | ... 168 | }; 169 | 170 | declare export type SupportOption = {| 171 | since: string, 172 | type: "int" | "boolean" | "choice" | "path", 173 | deprecated?: string, 174 | redirect?: SupportOptionRedirect, 175 | description: string, 176 | oppositeDescription?: string, 177 | default: SupportOptionValue, 178 | range?: SupportOptionRange, 179 | choices?: SupportOptionChoice 180 | |}; 181 | 182 | declare export type SupportOptionRedirect = {| 183 | options: string, 184 | value: SupportOptionValue 185 | |}; 186 | 187 | declare export type SupportOptionRange = {| 188 | start: number, 189 | end: number, 190 | step: number 191 | |}; 192 | 193 | declare export type SupportOptionChoice = {| 194 | value: boolean | string, 195 | description?: string, 196 | since?: string, 197 | deprecated?: string, 198 | redirect?: SupportOptionValue 199 | |}; 200 | 201 | declare export type SupportOptionValue = number | boolean | string; 202 | 203 | declare export type SupportInfo = {| 204 | languages: Array, 205 | options: Array 206 | |}; 207 | 208 | declare export type Prettier = {| 209 | format: (source: string, options?: Options) => string, 210 | check: (source: string, options?: Options) => boolean, 211 | formatWithCursor: (source: string, options: CursorOptions) => CursorResult, 212 | resolveConfig: { 213 | (filePath: string, options?: ResolveConfigOptions): Promise, 214 | sync(filePath: string, options?: ResolveConfigOptions): ?Options 215 | }, 216 | clearConfigCache: () => void, 217 | getSupportInfo: (version?: string) => SupportInfo 218 | |}; 219 | 220 | declare export default Prettier; 221 | } 222 | -------------------------------------------------------------------------------- /flow-typed/npm/pretty-quick_vx.x.x.js: -------------------------------------------------------------------------------- 1 | // flow-typed signature: d91dcaecbedb50ab1245519b205571ca 2 | // flow-typed version: <>/pretty-quick_v^1.6.0/flow_v0.103.0 3 | 4 | /** 5 | * This is an autogenerated libdef stub for: 6 | * 7 | * 'pretty-quick' 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 'pretty-quick' { 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 'pretty-quick/bin/pretty-quick' { 26 | declare module.exports: any; 27 | } 28 | 29 | declare module 'pretty-quick/dist/createIgnorer' { 30 | declare module.exports: any; 31 | } 32 | 33 | declare module 'pretty-quick/dist/formatFiles' { 34 | declare module.exports: any; 35 | } 36 | 37 | declare module 'pretty-quick/dist' { 38 | declare module.exports: any; 39 | } 40 | 41 | declare module 'pretty-quick/dist/isSupportedExtension' { 42 | declare module.exports: any; 43 | } 44 | 45 | declare module 'pretty-quick/dist/scms/git' { 46 | declare module.exports: any; 47 | } 48 | 49 | declare module 'pretty-quick/dist/scms/hg' { 50 | declare module.exports: any; 51 | } 52 | 53 | declare module 'pretty-quick/dist/scms' { 54 | declare module.exports: any; 55 | } 56 | 57 | // Filename aliases 58 | declare module 'pretty-quick/bin/pretty-quick.js' { 59 | declare module.exports: $Exports<'pretty-quick/bin/pretty-quick'>; 60 | } 61 | declare module 'pretty-quick/dist/createIgnorer.js' { 62 | declare module.exports: $Exports<'pretty-quick/dist/createIgnorer'>; 63 | } 64 | declare module 'pretty-quick/dist/formatFiles.js' { 65 | declare module.exports: $Exports<'pretty-quick/dist/formatFiles'>; 66 | } 67 | declare module 'pretty-quick/dist/index' { 68 | declare module.exports: $Exports<'pretty-quick/dist'>; 69 | } 70 | declare module 'pretty-quick/dist/index.js' { 71 | declare module.exports: $Exports<'pretty-quick/dist'>; 72 | } 73 | declare module 'pretty-quick/dist/isSupportedExtension.js' { 74 | declare module.exports: $Exports<'pretty-quick/dist/isSupportedExtension'>; 75 | } 76 | declare module 'pretty-quick/dist/scms/git.js' { 77 | declare module.exports: $Exports<'pretty-quick/dist/scms/git'>; 78 | } 79 | declare module 'pretty-quick/dist/scms/hg.js' { 80 | declare module.exports: $Exports<'pretty-quick/dist/scms/hg'>; 81 | } 82 | declare module 'pretty-quick/dist/scms/index' { 83 | declare module.exports: $Exports<'pretty-quick/dist/scms'>; 84 | } 85 | declare module 'pretty-quick/dist/scms/index.js' { 86 | declare module.exports: $Exports<'pretty-quick/dist/scms'>; 87 | } 88 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-inverted-scrollview", 3 | "version": "1.0.7", 4 | "description": "Easily support inverted scrolling. Maintains a correct scroll position when new content is added.", 5 | "main": "lib/index.js", 6 | "files": [ 7 | "lib" 8 | ], 9 | "keywords": [ 10 | "inverted", 11 | "scroll", 12 | "ui", 13 | "infinite loading", 14 | "scrollTop", 15 | "scrollBottom", 16 | "react" 17 | ], 18 | "repository": { 19 | "type": "git", 20 | "url": "git+https://github.com/vejersele/react-inverted-scrollview.git" 21 | }, 22 | "scripts": { 23 | "clean": "rm -rf lib", 24 | "build:flow": "flow-copy-source src/ lib/ --ignore __test__/**/*", 25 | "build:babel": "babel src/ --out-dir lib/ --ignore __test__", 26 | "build": "npm run clean && npm run build:babel && npm run build:flow", 27 | "storybook": "start-storybook -p 6006", 28 | "test": "flow check && jest src/", 29 | "prepublish": "npm test && npm run build", 30 | "precommit": "pretty-quick --staged" 31 | }, 32 | "author": "Jelle Versele", 33 | "license": "MIT", 34 | "peerDependencies": { 35 | "react": "^15.0.0-0 || ^16.0.0-0" 36 | }, 37 | "devDependencies": { 38 | "@storybook/react": "^3.4.7", 39 | "babel-cli": "^6.26.0", 40 | "babel-plugin-transform-class-properties": "^6.24.1", 41 | "babel-plugin-transform-flow-strip-types": "^6.22.0", 42 | "babel-plugin-transform-object-rest-spread": "^6.26.0", 43 | "babel-preset-env": "^1.7.0", 44 | "babel-preset-react": "^6.24.1", 45 | "casual-browserify": "^1.5.19-2", 46 | "flow-bin": "^0.103.0", 47 | "flow-copy-source": "^2.0.0", 48 | "husky": "^0.14.3", 49 | "jest": "^23.1.0", 50 | "lodash": "^4.17.10", 51 | "prettier": "^1.13.5", 52 | "pretty-quick": "^1.6.0", 53 | "react": "^16.4.1", 54 | "react-dom": "^16.4.1" 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/__test__/index.test.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import React from 'react'; 4 | import ReactDOM from 'react-dom'; 5 | import ScrollView from '../index'; 6 | 7 | describe('ScrollView', () => { 8 | test('should render without errors', () => { 9 | const div = document.createElement('div'); 10 | ReactDOM.render({() =>
content
}
, div); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | // @flow 2 | 3 | import React, { Component, type Node } from 'react'; 4 | 5 | type RenderFuncArgs = { restoreScrollPosition: () => void }; 6 | type RenderFunc = RenderFuncArgs => Node; 7 | type OnScrollArgs = { scrollBottom: number, scrollTop: number }; 8 | 9 | export type Props = { 10 | onScroll: OnScrollArgs => any, 11 | width: number, 12 | height: number, 13 | style: {}, 14 | className?: string, 15 | children: Node | RenderFunc, 16 | restoreScrollPositionOnUpdate: boolean 17 | }; 18 | 19 | const getHeight = (container: HTMLElement) => container.getBoundingClientRect().height; 20 | 21 | export default class ScrollView extends Component { 22 | _currentScrollBottom: number; 23 | _scrollContainer: ?HTMLElement; 24 | 25 | _currentScrollBottom = 0; 26 | 27 | static defaultProps = { 28 | onScroll: () => {}, 29 | width: 100, 30 | height: 100, 31 | style: {}, 32 | restoreScrollPositionOnUpdate: true 33 | }; 34 | 35 | componentDidMount() { 36 | this.scrollToBottom(); 37 | } 38 | 39 | componentDidUpdate() { 40 | if (this.props.restoreScrollPositionOnUpdate) { 41 | this.restoreScrollPosition(); 42 | } 43 | } 44 | 45 | restoreScrollPosition() { 46 | this.setScrollBottom(this._currentScrollBottom); 47 | } 48 | 49 | scrollToTop() { 50 | this.setScrollTop(0); 51 | } 52 | 53 | scrollToBottom() { 54 | this.setScrollBottom(0); 55 | } 56 | 57 | setScrollBottom(value: number) { 58 | const container = this._scrollContainer; 59 | if (!container) return; 60 | const height = getHeight(container); 61 | container.scrollTop = container.scrollHeight - height - value; 62 | } 63 | 64 | setScrollTop(value: number) { 65 | if (!this._scrollContainer) return; 66 | this._scrollContainer.scrollTop = value; 67 | } 68 | 69 | _handleScroll = () => { 70 | const container = this._scrollContainer; 71 | 72 | if (!container) return; 73 | 74 | requestAnimationFrame(() => { 75 | const height = getHeight(container); 76 | const scrollTop = container.scrollTop; 77 | const scrollBottom = container.scrollHeight - height - scrollTop; 78 | 79 | this._currentScrollBottom = scrollBottom; 80 | 81 | this.props.onScroll({ scrollBottom, scrollTop }); 82 | }); 83 | }; 84 | 85 | _renderContent() { 86 | const { children } = this.props; 87 | if (typeof children === 'function') { 88 | return children({ restoreScrollPosition: () => this.restoreScrollPosition() }); 89 | } 90 | return children; 91 | } 92 | 93 | render() { 94 | const { height, width, style, children, className } = this.props; 95 | 96 | return ( 97 |
(this._scrollContainer = ref)} 108 | > 109 |
117 | {this._renderContent()} 118 |
119 |
120 | ); 121 | } 122 | } 123 | --------------------------------------------------------------------------------