diff --git a/.travis.yml b/.travis.yml index 459e059..e56c63d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,3 +7,4 @@ script: - ./node_modules/.bin/lerna bootstrap --hoist - npm run build - npm run lint + - npm run flow diff --git a/examples/counter/package.json b/examples/counter/package.json index c3e3513..d5d1752 100644 --- a/examples/counter/package.json +++ b/examples/counter/package.json @@ -16,5 +16,8 @@ "build": "react-scripts build", "test": "react-scripts test --env=jsdom", "eject": "react-scripts eject" + }, + "devDependencies": { + "draft-js": "^0.10.5" } } diff --git a/examples/mentions-example/package.json b/examples/mentions-example/package.json index 71bf19a..913ccee 100644 --- a/examples/mentions-example/package.json +++ b/examples/mentions-example/package.json @@ -18,5 +18,8 @@ "build": "react-scripts build", "test": "react-scripts test --env=jsdom", "eject": "react-scripts eject" + }, + "devDependencies": { + "draft-js": "^0.10.5" } } diff --git a/lerna.json b/lerna.json index fad86ab..0a8fa7b 100644 --- a/lerna.json +++ b/lerna.json @@ -4,5 +4,6 @@ "examples/*", "packages/*" ], + "nohoist": ["**/draft-js"], "version": "0.1.5" } diff --git a/packages/atomic-block/package.json b/packages/atomic-block/package.json index 92995ed..218f663 100644 --- a/packages/atomic-block/package.json +++ b/packages/atomic-block/package.json @@ -14,7 +14,7 @@ "build": "./node_modules/.bin/rollup -c", "start": "./node_modules/.bin/rollup -c -w", "prepare": "yarn run build", - "flow": "./node_modules/.bin/flow", + "flow": "./node_modules/.bin/flow check", "predeploy": "cd example && yarn install && yarn run build", "deploy": "gh-pages -d example/build" }, diff --git a/packages/atomic-block/src/index.js b/packages/atomic-block/src/index.js index 3d48b8d..c2f5e43 100644 --- a/packages/atomic-block/src/index.js +++ b/packages/atomic-block/src/index.js @@ -1,6 +1,7 @@ // @flow import React, { Component } from 'react' +import type { Node } from 'react' import { withPluginContext, constants } from '@djsp/core' import type { PluginProps } from '@djsp/core' import { ContentBlock, EditorState, Modifier, SelectionState } from 'draft-js' @@ -13,7 +14,7 @@ const _BlockChildren = ({ editorState, setEditorState, ...props -}: Object) => { +}: Object): Node => { const blockKey = props.block.getKey() const { children, focusBlock } = props.blockProps const selection = editorState.getSelection() @@ -43,7 +44,7 @@ type Props = PluginProps & { // Set selection of editor to next/previous block const setSelection = ( editorState: EditorState, - setEditorState: EditorState, + setEditorState: (editorState: EditorState) => void, newActiveBlock: ContentBlock ): void => { // TODO verify that always a key-0-0 exists @@ -91,7 +92,10 @@ class AtomicBlockPlugin extends Component { this.unregister() } - handleKeyCommand = (command, editorState) => { + handleKeyCommand = ( + command: string, + editorState: EditorState + ): DraftHandleValue => { const { setEditorState } = this.props let contentState = editorState.getCurrentContent() @@ -189,7 +193,10 @@ class AtomicBlockPlugin extends Component { ) } - handleReturn = (event, editorState) => { + handleReturn = ( + event: SyntheticKeyboardEvent<*>, + editorState: EditorState + ): DraftHandleValue => { const { setEditorState } = this.props const selection = editorState.getSelection() @@ -205,7 +212,7 @@ class AtomicBlockPlugin extends Component { return constants.NOT_HANDLED } - blockRendererFn = block => { + blockRendererFn = (block: ContentBlock): ?Object => { const { type, children, editorState } = this.props const content = editorState.getCurrentContent() diff --git a/packages/autocomplete/package.json b/packages/autocomplete/package.json index 3b22b4b..6d5de59 100644 --- a/packages/autocomplete/package.json +++ b/packages/autocomplete/package.json @@ -12,7 +12,7 @@ "test": "cross-env CI=1 react-scripts test --env=jsdom", "test:watch": "react-scripts test --env=jsdom", "build": "./node_modules/.bin/rollup -c", - "flow": "./node_modules/.bin/flow", + "flow": "./node_modules/.bin/flow check", "start": "./node_modules/.bin/rollup -c -w", "prepare": "yarn run build", "predeploy": "cd example && yarn install && yarn run build", diff --git a/packages/block-type-toggle/package.json b/packages/block-type-toggle/package.json index 6035162..0761dc4 100644 --- a/packages/block-type-toggle/package.json +++ b/packages/block-type-toggle/package.json @@ -13,7 +13,7 @@ "test:watch": "react-scripts test --env=jsdom", "build": "./node_modules/.bin/rollup -c", "start": "./node_modules/.bin/rollup -c -w", - "flow": "./node_modules/.bin/flow", + "flow": "./node_modules/.bin/flow check", "prepare": "yarn run build", "predeploy": "cd example && yarn install && yarn run build", "deploy": "gh-pages -d example/build" diff --git a/packages/core/package.json b/packages/core/package.json index 35a579e..741eb39 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -14,7 +14,7 @@ "build": "rimraf dist && ./node_modules/.bin/rollup -c && yarn build:flow", "build:flow": "./node_modules/.bin/flow-copy-source -v -i '**/__tests__/**' src dist", "start": "./node_modules/.bin/rollup -c -w", - "flow": "./node_modules/.bin/flow", + "flow": "./node_modules/.bin/flow check", "prepare": "yarn run build && yarn build:flow", "predeploy": "cd example && yarn install && yarn run build", "deploy": "gh-pages -d example/build" diff --git a/packages/inline-style-toggle/package.json b/packages/inline-style-toggle/package.json index c8d32b2..18de847 100644 --- a/packages/inline-style-toggle/package.json +++ b/packages/inline-style-toggle/package.json @@ -10,7 +10,7 @@ "jsnext:main": "dist/index.es.js", "scripts": { "test": "cross-env CI=1 react-scripts test --env=jsdom", - "flow": "./node_modules/.bin/flow", + "flow": "./node_modules/.bin/flow check", "test:watch": "react-scripts test --env=jsdom", "build": "./node_modules/.bin/rollup -c", "start": "./node_modules/.bin/rollup -c -w", diff --git a/packages/utils/package.json b/packages/utils/package.json index fa051fe..517290c 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -11,7 +11,7 @@ "scripts": { "test": "cross-env CI=1 react-scripts test --env=jsdom", "test:watch": "react-scripts test --env=jsdom", - "flow": "./node_modules/.bin/flow", + "flow": "./node_modules/.bin/flow check", "build": "./node_modules/.bin/rollup -c", "start": "./node_modules/.bin/rollup -c -w", "prepare": "yarn run build",