From 4e5c3944d88626cd53bc6769b87375ea5241cfdd Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Thu, 27 Apr 2017 22:10:43 -0700 Subject: [PATCH] Add flow, example implementation and types --- .flowconfig | 12 +++ frontend/components/Document/Document.js | 14 +-- package.json | 3 +- types.js | 32 +++++++ webpack.config.js | 4 +- yarn.lock | 107 +++++++++++++++++++++-- 6 files changed, 156 insertions(+), 16 deletions(-) create mode 100644 .flowconfig create mode 100644 types.js diff --git a/.flowconfig b/.flowconfig new file mode 100644 index 00000000..bec59bf6 --- /dev/null +++ b/.flowconfig @@ -0,0 +1,12 @@ +[ignore] +/node_modules/.* + +[libs] + +[options] +esproposal.decorators=ignore +esproposal.class_static_fields=enable +esproposal.class_instance_fields=enable +unsafe.enable_getters_and_setters=true +module.name_mapper='^\(.*\)\.s?css$' -> 'empty/object' +module.file_ext=.scss diff --git a/frontend/components/Document/Document.js b/frontend/components/Document/Document.js index af53363d..13649a39 100644 --- a/frontend/components/Document/Document.js +++ b/frontend/components/Document/Document.js @@ -1,15 +1,15 @@ -import React, { PropTypes } from 'react'; +// @flow +import React from 'react'; import { toJS } from 'mobx'; import { observer } from 'mobx-react'; - -import PublishingInfo from 'components/PublishingInfo'; +import type { Document as DocumentType } from '../../../types'; +import PublishingInfo from '../PublishingInfo'; +import styles from './Document.scss'; import DocumentHtml from './components/DocumentHtml'; -import styles from './Document.scss'; - @observer class Document extends React.Component { - static propTypes = { - document: PropTypes.object.isRequired, + props: { + document: DocumentType, }; render() { diff --git a/package.json b/package.json index 57150020..c8820942 100644 --- a/package.json +++ b/package.json @@ -118,7 +118,7 @@ "mobx-react-devtools": "^4.2.11", "moment": "2.13.0", "node-dev": "3.1.0", - "node-sass": "3.8.0", + "node-sass": "^4.5.2", "normalize.css": "4.1.1", "normalizr": "2.0.1", "pg": "^6.1.5", @@ -157,6 +157,7 @@ "babel-jest": "^15.0.0", "enzyme": "^2.4.1", "fetch-test-server": "^1.1.0", + "flow-bin": "^0.45.0", "identity-obj-proxy": "^3.0.0", "ignore-loader": "0.1.1", "jest-cli": "^15.1.1", diff --git a/types.js b/types.js new file mode 100644 index 00000000..7fea471e --- /dev/null +++ b/types.js @@ -0,0 +1,32 @@ +export type User = { + avatarUrl: string, + id: string, + name: string, + username: string, +}; + +export type Collection = { + createdAt: string, + description: string, + id: string, + name: string, + type: string, + updatedAt: string, + url: string, +}; + +export type Document = { + collaborators: Array, + collection: Collection, + createdAt: string, + createdBy: string, + html: string, + id: string, + private: boolean, + team: string, + text: string, + title: string, + updatedAt: string, + updatedBy: string, + url: string, +}; diff --git a/webpack.config.js b/webpack.config.js index ab0e258d..3e161f23 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -5,7 +5,9 @@ require('dotenv').config({ silent: true }); const definePlugin = new webpack.DefinePlugin({ __DEV__: JSON.stringify(JSON.parse(process.env.NODE_ENV !== 'production')), - __PRERELEASE__: JSON.stringify(JSON.parse(process.env.BUILD_PRERELEASE || 'false')), + __PRERELEASE__: JSON.stringify( + JSON.parse(process.env.BUILD_PRERELEASE || 'false') + ), SLACK_REDIRECT_URI: JSON.stringify(process.env.SLACK_REDIRECT_URI), SLACK_KEY: JSON.stringify(process.env.SLACK_KEY), URL: JSON.stringify(process.env.URL), diff --git a/yarn.lock b/yarn.lock index d93cace7..c06c1793 100644 --- a/yarn.lock +++ b/yarn.lock @@ -63,6 +63,13 @@ ajv@^4.7.0: co "^4.6.0" json-stable-stringify "^1.0.1" +ajv@^4.9.1: + version "4.11.7" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.11.7.tgz#8655a5d86d0824985cc471a1d913fb6729a0ec48" + dependencies: + co "^4.6.0" + json-stable-stringify "^1.0.1" + align-text@^0.1.1, align-text@^0.1.3: version "0.1.4" resolved "https://registry.yarnpkg.com/align-text/-/align-text-0.1.4.tgz#0cd90a561093f35d0a99256c22b7069433fad117" @@ -1398,6 +1405,10 @@ caseless@~0.11.0: version "0.11.0" resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.11.0.tgz#715b96ea9841593cc33067923f5ec60ebda4f7d7" +caseless@~0.12.0: + version "0.12.0" + resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc" + center-align@^0.1.1: version "0.1.3" resolved "https://registry.yarnpkg.com/center-align/-/center-align-0.1.3.tgz#aa0d32629b6ee972200411cbd4461c907bc2b7ad" @@ -3086,6 +3097,10 @@ flatten@1.0.2, flatten@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782" +flow-bin@^0.45.0: + version "0.45.0" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.45.0.tgz#009dd0f577a3f665c74ca8be827ae8c2dd8fd6b5" + flow-parser@0.43.0: version "0.43.0" resolved "https://registry.yarnpkg.com/flow-parser/-/flow-parser-0.43.0.tgz#e2b8eb1ac83dd53f7b6b04a7c35b6a52c33479b7" @@ -3116,6 +3131,14 @@ form-data@~2.0.0: combined-stream "^1.0.5" mime-types "^2.1.11" +form-data@~2.1.1: + version "2.1.4" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.1.4.tgz#33c183acf193276ecaa98143a69e94bfee1750d1" + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.5" + mime-types "^2.1.12" + frameguard@1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/frameguard/-/frameguard-1.1.0.tgz#e5de5e3ecb17ff84b697300b0e0d748a7d09047b" @@ -3488,6 +3511,10 @@ handlebars@^4.0.1, handlebars@^4.0.3: optionalDependencies: uglify-js "^2.6" +har-schema@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-1.0.5.tgz#d263135f43307c02c602afc8fe95970c0151369e" + har-validator@~2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-2.0.6.tgz#cdcbc08188265ad119b6a5a7c8ab70eecfb5d27d" @@ -3497,6 +3524,13 @@ har-validator@~2.0.6: is-my-json-valid "^2.12.4" pinkie-promise "^2.0.0" +har-validator@~4.2.1: + version "4.2.1" + resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-4.2.1.tgz#33481d0f1bbff600dd203d75812a6a5fba002e2a" + dependencies: + ajv "^4.9.1" + har-schema "^1.0.5" + harmony-reflect@^1.4.6: version "1.5.0" resolved "https://registry.yarnpkg.com/harmony-reflect/-/harmony-reflect-1.5.0.tgz#fbcc7c6ba2ddb5ea94da23934d677bb020a4187c" @@ -5172,6 +5206,10 @@ lodash.merge@^4.4.0: version "4.6.0" resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.0.tgz#69884ba144ac33fe699737a6086deffadd0f89c5" +lodash.mergewith@^4.6.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash.mergewith/-/lodash.mergewith-4.6.0.tgz#150cf0a16791f5903b8891eab154609274bdea55" + lodash.once@^4.0.0: version "4.1.1" resolved "https://registry.yarnpkg.com/lodash.once/-/lodash.once-4.1.1.tgz#0dd3971213c7c56df880977d504c88fb471a97ac" @@ -5490,7 +5528,7 @@ miller-rabin@^4.0.0: version "1.24.0" resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.24.0.tgz#e2d13f939f0016c6e4e9ad25a8652f126c467f0c" -mime-types@^2.0.7, mime-types@^2.1.11, mime-types@~2.1.11, mime-types@~2.1.6, mime-types@~2.1.7, mime-types@~2.1.9: +mime-types@^2.0.7, mime-types@^2.1.11, mime-types@^2.1.12, mime-types@~2.1.11, mime-types@~2.1.6, mime-types@~2.1.7, mime-types@~2.1.9: version "2.1.12" resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.12.tgz#152ba256777020dd4663f54c2e7bc26381e71729" dependencies: @@ -5798,9 +5836,9 @@ node-pre-gyp@^0.6.29: tar "~2.2.0" tar-pack "~3.1.0" -node-sass@3.8.0: - version "3.8.0" - resolved "https://registry.yarnpkg.com/node-sass/-/node-sass-3.8.0.tgz#ec0f89ae6625e1d990dc7ff713b275ea15dfee05" +node-sass@^4.5.2: + version "4.5.2" + resolved "https://registry.yarnpkg.com/node-sass/-/node-sass-4.5.2.tgz#4012fa2bd129b1d6365117e88d9da0500d99da64" dependencies: async-foreach "^0.1.3" chalk "^1.1.1" @@ -5809,13 +5847,17 @@ node-sass@3.8.0: get-stdin "^4.0.1" glob "^7.0.3" in-publish "^2.0.0" + lodash.assign "^4.2.0" lodash.clonedeep "^4.3.2" + lodash.mergewith "^4.6.0" meow "^3.7.0" mkdirp "^0.5.1" nan "^2.3.2" node-gyp "^3.3.1" - request "^2.61.0" + npmlog "^4.0.0" + request "^2.79.0" sass-graph "^2.1.1" + stdout-stream "^1.4.0" node-uuid@~1.4.4, node-uuid@~1.4.7: version "1.4.7" @@ -5917,7 +5959,7 @@ npm-which@^3.0.1: gauge "~2.6.0" set-blocking "~2.0.0" -npmlog@4.x: +npmlog@4.x, npmlog@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.0.0.tgz#e094503961c70c1774eb76692080e8d578a9f88f" dependencies: @@ -6261,6 +6303,10 @@ pbkdf2@^3.0.3: dependencies: create-hmac "^1.1.2" +performance-now@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-0.2.0.tgz#33ef30c5c77d4ea21c5a53869d91b56d8f2555e5" + pg-connection-string@0.1.3: version "0.1.3" resolved "https://registry.yarnpkg.com/pg-connection-string/-/pg-connection-string-0.1.3.tgz#da1847b20940e42ee1492beaf65d49d91b245df7" @@ -6713,6 +6759,10 @@ qs@~6.2.0: version "6.2.1" resolved "https://registry.yarnpkg.com/qs/-/qs-6.2.1.tgz#ce03c5ff0935bc1d9d69a9f14cbd18e568d67625" +qs@~6.4.0: + version "6.4.0" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.4.0.tgz#13e26d28ad6b0ffaa91312cd3bf708ed351e7233" + query-string@^3.0.0: version "3.0.3" resolved "https://registry.yarnpkg.com/query-string/-/query-string-3.0.3.tgz#ae2e14b4d05071d4e9b9eb4873c35b0dcd42e638" @@ -7153,7 +7203,7 @@ replace-ext@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/replace-ext/-/replace-ext-0.0.1.tgz#29bbd92078a739f0bcce2b4ee41e837953522924" -request@2, request@2.x, request@^2.55.0, request@^2.61.0: +request@2, request@2.x, request@^2.55.0: version "2.75.0" resolved "https://registry.yarnpkg.com/request/-/request-2.75.0.tgz#d2b8268a286da13eaa5d01adf5d18cc90f657d93" dependencies: @@ -7179,6 +7229,33 @@ request@2, request@2.x, request@^2.55.0, request@^2.61.0: tough-cookie "~2.3.0" tunnel-agent "~0.4.1" +request@^2.79.0: + version "2.81.0" + resolved "https://registry.yarnpkg.com/request/-/request-2.81.0.tgz#c6928946a0e06c5f8d6f8a9333469ffda46298a0" + dependencies: + aws-sign2 "~0.6.0" + aws4 "^1.2.1" + caseless "~0.12.0" + combined-stream "~1.0.5" + extend "~3.0.0" + forever-agent "~0.6.1" + form-data "~2.1.1" + har-validator "~4.2.1" + hawk "~3.1.3" + http-signature "~1.1.0" + is-typedarray "~1.0.0" + isstream "~0.1.2" + json-stringify-safe "~5.0.1" + mime-types "~2.1.7" + oauth-sign "~0.8.1" + performance-now "^0.2.0" + qs "~6.4.0" + safe-buffer "^5.0.1" + stringstream "~0.0.4" + tough-cookie "~2.3.0" + tunnel-agent "^0.6.0" + uuid "^3.0.0" + require-directory@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" @@ -7650,6 +7727,12 @@ statuses@~1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.2.1.tgz#dded45cc18256d51ed40aec142489d5c61026d28" +stdout-stream@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/stdout-stream/-/stdout-stream-1.4.0.tgz#a2c7c8587e54d9427ea9edb3ac3f2cd522df378b" + dependencies: + readable-stream "^2.0.1" + stream-browserify@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/stream-browserify/-/stream-browserify-1.0.0.tgz#bf9b4abfb42b274d751479e44e0ff2656b6f1193" @@ -8002,6 +8085,12 @@ tty-browserify@0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6" +tunnel-agent@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" + dependencies: + safe-buffer "^5.0.1" + tunnel-agent@~0.4.1: version "0.4.3" resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.4.3.tgz#6373db76909fe570e08d73583365ed828a74eeeb" @@ -8196,6 +8285,10 @@ uuid@2.0.2, uuid@^2.0.1: version "2.0.2" resolved "https://registry.yarnpkg.com/uuid/-/uuid-2.0.2.tgz#48bd5698f0677e3c7901a1c46ef15b1643794726" +uuid@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.0.1.tgz#6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1" + v8flags@^2.0.2: version "2.0.11" resolved "https://registry.yarnpkg.com/v8flags/-/v8flags-2.0.11.tgz#bca8f30f0d6d60612cc2c00641e6962d42ae6881"