From 249925e1765c51af0a9a26d688a7784cf7eb968c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Geonizeli?= Date: Sat, 14 Aug 2021 11:37:55 -0300 Subject: [PATCH] add relay eslint plugin --- .eslintrc | 8 +- .../src/pages/Orders/Exchange/Exchange.tsx | 6 - .../__generated__/ExchangeQuery.graphql.ts | 178 ++++++++---------- package.json | 1 + yarn.lock | 9 +- 5 files changed, 95 insertions(+), 107 deletions(-) diff --git a/.eslintrc b/.eslintrc index 7f775ba..bea5ba5 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,5 +1,5 @@ { - "extends": ["vtex"], + "extends": ["vtex", "plugin:relay/recommended"], "ignorePatterns": [ "__mocks__/", "__generated__/" @@ -9,5 +9,9 @@ "files": ["**/*.tsx"], "extends": ["vtex-react"] } - ] + ], + "rules": { + "relay/generated-flow-types": "false" + }, + "plugins": ["relay"] } diff --git a/app/javascript/src/pages/Orders/Exchange/Exchange.tsx b/app/javascript/src/pages/Orders/Exchange/Exchange.tsx index a607ad1..296128b 100644 --- a/app/javascript/src/pages/Orders/Exchange/Exchange.tsx +++ b/app/javascript/src/pages/Orders/Exchange/Exchange.tsx @@ -30,20 +30,14 @@ export const Exchange: FC = () => { fiatBalances { edges { node { - id amountCents - amountCurrency } } } balances { edges { node { - id amount - currency { - name - } } } } diff --git a/app/javascript/src/pages/Orders/Exchange/__generated__/ExchangeQuery.graphql.ts b/app/javascript/src/pages/Orders/Exchange/__generated__/ExchangeQuery.graphql.ts index becd5d9..bab9853 100644 --- a/app/javascript/src/pages/Orders/Exchange/__generated__/ExchangeQuery.graphql.ts +++ b/app/javascript/src/pages/Orders/Exchange/__generated__/ExchangeQuery.graphql.ts @@ -8,20 +8,14 @@ export type ExchangeQueryResponse = { readonly fiatBalances: { readonly edges: ReadonlyArray<{ readonly node: { - readonly id: string; readonly amountCents: number; - readonly amountCurrency: string; }; }>; }; readonly balances: { readonly edges: ReadonlyArray<{ readonly node: { - readonly id: string; readonly amount: string; - readonly currency: { - readonly name: string; - }; }; }>; }; @@ -38,21 +32,16 @@ query ExchangeQuery { fiatBalances { edges { node { - id amountCents - amountCurrency + id } } } balances { edges { node { - id amount - currency { - name - id - } + id } } } @@ -64,69 +53,21 @@ var v0 = { "alias": null, "args": null, "kind": "ScalarField", - "name": "id", + "name": "amountCents", "storageKey": null }, v1 = { - "alias": null, - "args": null, - "concreteType": "FiatBalanceConnection", - "kind": "LinkedField", - "name": "fiatBalances", - "plural": false, - "selections": [ - { - "alias": null, - "args": null, - "concreteType": "FiatBalanceEdge", - "kind": "LinkedField", - "name": "edges", - "plural": true, - "selections": [ - { - "alias": null, - "args": null, - "concreteType": "FiatBalance", - "kind": "LinkedField", - "name": "node", - "plural": false, - "selections": [ - (v0/*: any*/), - { - "alias": null, - "args": null, - "kind": "ScalarField", - "name": "amountCents", - "storageKey": null - }, - { - "alias": null, - "args": null, - "kind": "ScalarField", - "name": "amountCurrency", - "storageKey": null - } - ], - "storageKey": null - } - ], - "storageKey": null - } - ], - "storageKey": null -}, -v2 = { "alias": null, "args": null, "kind": "ScalarField", "name": "amount", "storageKey": null }, -v3 = { +v2 = { "alias": null, "args": null, "kind": "ScalarField", - "name": "name", + "name": "id", "storageKey": null }; return { @@ -136,7 +77,40 @@ return { "metadata": null, "name": "ExchangeQuery", "selections": [ - (v1/*: any*/), + { + "alias": null, + "args": null, + "concreteType": "FiatBalanceConnection", + "kind": "LinkedField", + "name": "fiatBalances", + "plural": false, + "selections": [ + { + "alias": null, + "args": null, + "concreteType": "FiatBalanceEdge", + "kind": "LinkedField", + "name": "edges", + "plural": true, + "selections": [ + { + "alias": null, + "args": null, + "concreteType": "FiatBalance", + "kind": "LinkedField", + "name": "node", + "plural": false, + "selections": [ + (v0/*: any*/) + ], + "storageKey": null + } + ], + "storageKey": null + } + ], + "storageKey": null + }, { "alias": null, "args": null, @@ -161,20 +135,7 @@ return { "name": "node", "plural": false, "selections": [ - (v0/*: any*/), - (v2/*: any*/), - { - "alias": null, - "args": null, - "concreteType": "Currency", - "kind": "LinkedField", - "name": "currency", - "plural": false, - "selections": [ - (v3/*: any*/) - ], - "storageKey": null - } + (v1/*: any*/) ], "storageKey": null } @@ -194,7 +155,41 @@ return { "kind": "Operation", "name": "ExchangeQuery", "selections": [ - (v1/*: any*/), + { + "alias": null, + "args": null, + "concreteType": "FiatBalanceConnection", + "kind": "LinkedField", + "name": "fiatBalances", + "plural": false, + "selections": [ + { + "alias": null, + "args": null, + "concreteType": "FiatBalanceEdge", + "kind": "LinkedField", + "name": "edges", + "plural": true, + "selections": [ + { + "alias": null, + "args": null, + "concreteType": "FiatBalance", + "kind": "LinkedField", + "name": "node", + "plural": false, + "selections": [ + (v0/*: any*/), + (v2/*: any*/) + ], + "storageKey": null + } + ], + "storageKey": null + } + ], + "storageKey": null + }, { "alias": null, "args": null, @@ -219,21 +214,8 @@ return { "name": "node", "plural": false, "selections": [ - (v0/*: any*/), - (v2/*: any*/), - { - "alias": null, - "args": null, - "concreteType": "Currency", - "kind": "LinkedField", - "name": "currency", - "plural": false, - "selections": [ - (v3/*: any*/), - (v0/*: any*/) - ], - "storageKey": null - } + (v1/*: any*/), + (v2/*: any*/) ], "storageKey": null } @@ -246,14 +228,14 @@ return { ] }, "params": { - "cacheID": "7a42b2fc93f97505aaaf21867de36321", + "cacheID": "bb1b8283beba2daf38bacec716816383", "id": null, "metadata": {}, "name": "ExchangeQuery", "operationKind": "query", - "text": "query ExchangeQuery {\n fiatBalances {\n edges {\n node {\n id\n amountCents\n amountCurrency\n }\n }\n }\n balances {\n edges {\n node {\n id\n amount\n currency {\n name\n id\n }\n }\n }\n }\n}\n" + "text": "query ExchangeQuery {\n fiatBalances {\n edges {\n node {\n amountCents\n id\n }\n }\n }\n balances {\n edges {\n node {\n amount\n id\n }\n }\n }\n}\n" } }; })(); -(node as any).hash = '80cac44f2e6288dfb573d0037b7d4148'; +(node as any).hash = '517d3bf7bc6330021f8eb615e78417f5'; export default node; diff --git a/package.json b/package.json index d2bb066..11db0f0 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "eslint": "^7.32.0", "eslint-config-vtex": "^14.1.0", "eslint-config-vtex-react": "^8.1.0", + "eslint-plugin-relay": "^1.8.2", "graphql": "^15.5.1", "prettier": "^2.3.2", "relay-compiler": "^11.0.2", diff --git a/yarn.lock b/yarn.lock index 0fb4192..f412efe 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3563,6 +3563,13 @@ eslint-plugin-react@^7.20.6: resolve "^2.0.0-next.3" string.prototype.matchall "^4.0.5" +eslint-plugin-relay@^1.8.2: + version "1.8.2" + resolved "https://registry.yarnpkg.com/eslint-plugin-relay/-/eslint-plugin-relay-1.8.2.tgz#925f59231e39dfc076b3cbb39ef793c13381579e" + integrity sha512-bqIfXJnPMd6iHPitONSi8JqxrWQWaX4Rqk1shusKDlUu5vswUgoqOEGgqE8nDu6SmejBUZMz0vY+ROvq5wqOsw== + dependencies: + graphql "^14.0.0 || ^15.0.0" + eslint-plugin-vtex@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/eslint-plugin-vtex/-/eslint-plugin-vtex-2.1.0.tgz#cb328b5d6f4bba400cf57d5dca679985ac768e2a" @@ -4256,7 +4263,7 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6 resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.6.tgz#ff040b2b0853b23c3d31027523706f1885d76bee" integrity sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ== -graphql@^15.5.1: +"graphql@^14.0.0 || ^15.0.0", graphql@^15.5.1: version "15.5.1" resolved "https://registry.yarnpkg.com/graphql/-/graphql-15.5.1.tgz#f2f84415d8985e7b84731e7f3536f8bb9d383aad" integrity sha512-FeTRX67T3LoE3LWAxxOlW2K3Bz+rMYAC18rRguK4wgXaTZMiJwSUwDmPFo3UadAKbzirKIg5Qy+sNJXbpPRnQw==