Skip to content

Commit

Permalink
fix: flow 0.101 errors
Browse files Browse the repository at this point in the history
* fix: fix flow error

* fix(utils): fix flow error

* chore: update dependencies

* test: add flow def test files

* test(add new test example):

* chore(test): remove example

* fix(package.json): replace import

* Revert "fix(package.json): replace import"

This reverts commit 087e4f5.

* chore: update dependencies

* build: reassemble yarn lock for fixing travis ci checks

* ci: change node 9 -> 10
  • Loading branch information
HsuTing authored and nodkz committed Jun 25, 2019
1 parent 7cfb022 commit b3233e7
Show file tree
Hide file tree
Showing 9 changed files with 5,235 additions and 3,120 deletions.
44 changes: 24 additions & 20 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
{
"extends": [
"airbnb-base",
"prettier"
],
"plugins": [
"prettier"
],
"extends": ["airbnb-base", "prettier"],
"plugins": ["prettier"],
"parser": "babel-eslint",
"rules": {
"no-underscore-dangle": 0,
Expand All @@ -14,22 +9,31 @@
"prefer-template": 0,
"no-use-before-define": 0,
"no-else-return": 0,
"comma-dangle": ["error", {
"arrays": "always-multiline",
"objects": "always-multiline",
"imports": "always-multiline",
"exports": "always-multiline",
"functions": "ignore",
}],
"prettier/prettier": ["error", {
"printWidth": 100,
"singleQuote": true,
"trailingComma": "es5",
}],
"comma-dangle": [
"error",
{
"arrays": "always-multiline",
"objects": "always-multiline",
"imports": "always-multiline",
"exports": "always-multiline",
"functions": "ignore"
}
],
"prettier/prettier": [
"error",
{
"printWidth": 100,
"singleQuote": true,
"trailingComma": "es5"
}
],
"no-plusplus": 0,
"prefer-destructuring": 0,
"no-prototype-builtins": 0,
"class-methods-use-this": 0
"class-methods-use-this": 0,
"lines-between-class-members": 0,
"no-console": "off",
"import/prefer-default-export": 0
},
"env": {
"jest": true
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ cache:
notifications:
email: true
node_js:
- "9"
- "8"
- '10'
- '8'
script:
- yarn run test
- yarn run build
Expand Down
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"javascript.validate.enable": false,
"editor.formatOnSave": true,
"eslint.validate": [
{ "language": "javascript", "autoFix": true },
{ "language": "javascriptreact", "autoFix": true }
]
}
54 changes: 27 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,37 +30,37 @@
"dependencies": {},
"peerDependencies": {
"graphql": ">=0.11.0",
"react-relay-network-modern": ">=2.1.0",
"react-relay": ">=1.4.0"
"react-relay": ">=1.4.0",
"react-relay-network-modern": ">=2.1.0"
},
"devDependencies": {
"@babel/cli": "^7.0.0-beta.51",
"@babel/core": "^7.0.0-beta.51",
"@babel/plugin-proposal-class-properties": "^7.0.0-beta.51",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0-beta.51",
"@babel/plugin-transform-flow-strip-types": "^7.0.0-beta.51",
"@babel/preset-env": "^7.0.0-beta.51",
"babel-eslint": "^8.2.3",
"babel-jest": "^23.0.1",
"@babel/cli": "^7.4.4",
"@babel/core": "^7.4.5",
"@babel/plugin-proposal-class-properties": "^7.4.4",
"@babel/plugin-proposal-object-rest-spread": "^7.4.4",
"@babel/plugin-transform-flow-strip-types": "^7.4.4",
"@babel/preset-env": "^7.4.5",
"babel-eslint": "^10.0.2",
"babel-jest": "^24.8.0",
"babel-plugin-replace-imports": "^1.0.2",
"babel-polyfill": "^6.26.0",
"cz-conventional-changelog": "^2.1.0",
"eslint": "^4.19.1",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-config-prettier": "^2.9.0",
"eslint-module-utils": "^2.2.0",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-prettier": "^2.6.0",
"fetch-mock": "^6.4.4",
"flow-bin": "^0.74.0",
"form-data": "^2.3.2",
"graphql": "^0.13.2",
"jest": "^23.1.0",
"prettier": "^1.13.5",
"react-relay-network-modern": "^2.3.3",
"relay-runtime": "^1.6.0",
"rimraf": "^2.6.2",
"semantic-release": "^15.5.2"
"eslint": "^6.0.1",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-config-prettier": "^5.1.0",
"eslint-module-utils": "^2.4.0",
"eslint-plugin-import": "^2.18.0",
"eslint-plugin-prettier": "^3.1.0",
"fetch-mock": "^7.3.3",
"flow-bin": "^0.101.1",
"form-data": "^2.4.0",
"graphql": "^14.3.1",
"jest": "^24.8.0",
"prettier": "^1.18.2",
"react-relay-network-modern": "^4.0.1",
"relay-runtime": "^5.0.0",
"rimraf": "^2.6.3",
"semantic-release": "^15.13.16"
},
"config": {
"commitizen": {
Expand All @@ -79,7 +79,7 @@
"build-mjs-rename": "find ./mjs -name \"*.js\" -exec bash -c 'mv \"$1\" \"${1%.js}\".mjs' - '{}' \\;",
"build-node8": "rimraf node8 && BABEL_ENV=node8 babel src --ignore __tests__,__mocks__ -d node8 && COPY_TO_FOLDER=node8 npm run build-flow",
"build-flow": "echo `$1` && find ./src -name '*.js' -not -path '*/__*' | while read filepath; do cp $filepath `echo ./${COPY_TO_FOLDER:-lib}$filepath | sed 's/.\\/src\\//\\//g'`.flow; done",
"lint": "eslint src test *.js",
"lint": "eslint 'src/**/*.js'",
"coverage": "jest --coverage --maxWorkers 2",
"watch": "jest --watch",
"flow": "flow",
Expand Down
2 changes: 1 addition & 1 deletion src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default class RelayServerSSR {
this.cache = new Map();
}

getMiddleware(args: SSRGraphQLArgs | (() => Promise<SSRGraphQLArgs>)): Middleware {
getMiddleware(args?: SSRGraphQLArgs | (() => Promise<SSRGraphQLArgs>)): Middleware {
return next => async (r: any) => {
const req: RelayRequest = r;
const cacheKey = getCacheKey(req.operation.name, req.variables);
Expand Down
4 changes: 3 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
/* @flow */
/* eslint-disable */

type valueType = string | Object | valueType[];

export function isFunction(obj: any): boolean %checks {
return !!(obj && obj.constructor && obj.call && obj.apply);
}

export function stableCopy(value: mixed): mixed {
export function stableCopy(value: valueType): valueType {
if (!value || typeof value !== 'object') {
return value;
}
Expand Down
17 changes: 17 additions & 0 deletions test/flow-defs-client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* @flow */

import { RelayNetworkLayer, cacheMiddleware, urlMiddleware } from 'react-relay-network-modern';
import RelaySSR from '../src/client';

export const network = new RelayNetworkLayer([
cacheMiddleware({
size: 100,
ttl: 60 * 1000,
}),
new RelaySSR().getMiddleware({
lookup: false,
}),
urlMiddleware({
url: () => 'http://localhost:8000/graphql',
}),
]);
15 changes: 15 additions & 0 deletions test/flow-defs-server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* @flow */

import { RelayNetworkLayer, urlMiddleware } from 'react-relay-network-modern';
import RelayServerSSR from '../src/server';

const relayServerSSR = new RelayServerSSR();

export const network = new RelayNetworkLayer([
urlMiddleware({
url: () => 'http://localhost:8000/graphql',
}),
relayServerSSR.getMiddleware(),
]);

console.log(network);
Loading

0 comments on commit b3233e7

Please sign in to comment.