From 5071524af2d74318085c8f6c1390f96421da1f75 Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU <20847995+ardatan@users.noreply.github.com> Date: Mon, 27 Jan 2020 15:25:38 +0200 Subject: [PATCH] Make all dependencies explicit (#439) * Fix deps * Explicit dependencies * Update package.json --- package.json | 3 +- packages/common/package.json | 1 + packages/common/src/debug-log.ts | 1 + packages/common/src/helpers.ts | 13 +- .../print-schema-with-directives.spec.ts | 2 +- packages/core/package.json | 3 + packages/core/src/load-typedefs.ts | 7 +- .../documents/documents-from-glob.spec.ts | 12 +- .../documents/import-documents.spec.ts | 14 +- .../loaders/schema/import-schema.spec.ts | 356 +++++++++--------- .../tests/loaders/schema/test-files/error.ts | 11 +- packages/file-loading/package.json | 1 + packages/graphql-tag-pluck/package.json | 4 + packages/graphql-tag-pluck/src/index.ts | 4 +- .../graphql-tag-pluck/src/libs/extname.ts | 2 +- packages/graphql-tag-pluck/src/visitor.ts | 34 +- .../tests/graphql-tag-pluck.test.ts | 174 ++++----- packages/loaders/apollo-engine/package.json | 1 + packages/loaders/code-file/package.json | 1 + .../tests/load-from-code-file.spec.ts | 4 +- packages/loaders/git/package.json | 3 +- packages/loaders/github/package.json | 3 +- packages/loaders/graphql-file/package.json | 3 +- packages/loaders/graphql-file/src/index.ts | 1 - packages/loaders/json-file/package.json | 3 +- packages/loaders/json-file/src/index.ts | 2 - packages/loaders/module/package.json | 1 + packages/loaders/prisma/package.json | 1 + packages/loaders/prisma/src/index.ts | 7 +- packages/loaders/url/package.json | 3 +- packages/loaders/url/src/index.ts | 2 +- packages/loaders/url/tests/url-loader.spec.ts | 24 +- .../relay-operation-optimizer/package.json | 1 + packages/schema-merging/package.json | 3 +- .../src/typedefs-mergers/fields.ts | 4 +- .../src/typedefs-mergers/merge-typedefs.ts | 1 + .../tests/merge-schemas.spec.ts | 54 ++- .../tests/merge-typedefs.spec.ts | 6 +- tslint.json | 78 ++++ yarn.lock | 15 +- 40 files changed, 487 insertions(+), 376 deletions(-) create mode 100644 tslint.json diff --git a/package.json b/package.json index e65046fe..58cfcbc4 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "node": ">=10" }, "lint-staged": { - "packages/**/*.{ts,tsx}": [ + "packages/**/src/**/*.{ts,tsx}": [ "tslint --fix", "git add" ], @@ -36,6 +36,7 @@ "lerna": "3.20.2", "lint-staged": "10.0.2", "prettier": "1.19.1", + "typescript": "3.7.5", "tslint": "5.20.1" }, "workspaces": [ diff --git a/packages/common/package.json b/packages/common/package.json index 30532f62..47e64395 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -6,6 +6,7 @@ "author": "Dotan Simha ", "license": "MIT", "scripts": { + "lint": "tslint src/**/*.ts", "clean": "rimraf dist", "prebuild": "yarn clean", "build": "bob", diff --git a/packages/common/src/debug-log.ts b/packages/common/src/debug-log.ts index a4a40aa9..e4d9468c 100644 --- a/packages/common/src/debug-log.ts +++ b/packages/common/src/debug-log.ts @@ -1,5 +1,6 @@ export function debugLog(...args: any[]): void { if (process && process.env && process.env.DEBUG && !process.env.GQL_TOOLKIT_NODEBUG) { + // tslint:disable-next-line: no-console console.log(...args); } } diff --git a/packages/common/src/helpers.ts b/packages/common/src/helpers.ts index 457d5de6..6569d5b7 100644 --- a/packages/common/src/helpers.ts +++ b/packages/common/src/helpers.ts @@ -11,7 +11,9 @@ export function chainFunctions(funcs: any[]) { export function isEqual(a: T, b: T): boolean { if (Array.isArray(a) && Array.isArray(b)) { - if (a.length !== b.length) return false; + if (a.length !== b.length) { + return false; + } for (var index = 0; index < a.length; index++) { if (a[index] !== b[index]) { @@ -64,6 +66,7 @@ export async function resolveBuiltinModule(moduleName: string, option?: return await import(moduleName); } } catch (e) { + // tslint:disable-next-line: no-console console.warn(` ${option || moduleName} module couldn't be found for built-in ${moduleName}. Please provide a working module in your loader options! @@ -74,8 +77,12 @@ export async function resolveBuiltinModule(moduleName: string, option?: } export function compareStrings(a: A, b: B) { - if (a.toString() < b.toString()) return -1; - if (a.toString() > b.toString()) return 1; + if (a.toString() < b.toString()) { + return -1; + } + if (a.toString() > b.toString()) { + return 1; + } return 0; } diff --git a/packages/common/tests/print-schema-with-directives.spec.ts b/packages/common/tests/print-schema-with-directives.spec.ts index 7fda7a68..50f2d0ea 100644 --- a/packages/common/tests/print-schema-with-directives.spec.ts +++ b/packages/common/tests/print-schema-with-directives.spec.ts @@ -85,5 +85,5 @@ describe('printSchemaWithDirectives', () => { expect(output).toContain('Test Query Comment'); expect(output).toContain('Test Field Comment'); - }) + }); }); diff --git a/packages/core/package.json b/packages/core/package.json index b5f33451..750eeaf7 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -6,6 +6,7 @@ "author": "Dotan Simha ", "license": "MIT", "scripts": { + "lint": "tslint src/**/*.ts", "clean": "rimraf dist", "prebuild": "yarn clean", "build": "bob", @@ -28,6 +29,7 @@ "devDependencies": { "@ardatan/bob": "0.2.7", "@types/is-glob": "4.0.1", + "@types/lodash": "4.14.149", "@types/jest": "24.9.1", "@types/valid-url": "1.0.2", "graphql": "14.5.8", @@ -46,6 +48,7 @@ "globby": "11.0.0", "import-from": "^3.0.0", "is-glob": "4.0.1", + "lodash": "4.17.15", "resolve-from": "5.0.0", "tslib": "1.10.0", "unixify": "1.0.0", diff --git a/packages/core/src/load-typedefs.ts b/packages/core/src/load-typedefs.ts index 8f6eb66f..4924a95a 100644 --- a/packages/core/src/load-typedefs.ts +++ b/packages/core/src/load-typedefs.ts @@ -58,12 +58,17 @@ async function getCustomLoaderByPath(path: string, cwd: string): Promise { function stringToHash(str: string) { let hash = 0; - if (str.length == 0) return hash; + // tslint:disable-next-line: triple-equals + if (str.length == 0) { + return hash; + } let char; for (let i = 0; i < str.length; i++) { char = str.charCodeAt(i); + // tslint:disable-next-line: no-bitwise hash = (hash << 5) - hash + char; + // tslint:disable-next-line: no-bitwise hash = hash & hash; } diff --git a/packages/core/tests/loaders/documents/documents-from-glob.spec.ts b/packages/core/tests/loaders/documents/documents-from-glob.spec.ts index 6bee5fdc..a4331908 100644 --- a/packages/core/tests/loaders/documents/documents-from-glob.spec.ts +++ b/packages/core/tests/loaders/documents/documents-from-glob.spec.ts @@ -79,7 +79,7 @@ describe('documentsFromGlob', () => { } catch (e) { expect(e).toBeDefined(); } - }) + }); it('Should ignore schema definitions', async () => { const glob = join(__dirname, './test-files/', '*.graphql'); @@ -92,9 +92,9 @@ describe('documentsFromGlob', () => { it('Should ignore files that is added to ignore glob (using options.ignore)', async () => { const glob = join(__dirname, './test-files/', '*.graphql'); const ignoreGlob = join(__dirname, './test-files/', '*.query.graphql'); - const result = await loadDocuments([glob], { - ignore: ignoreGlob, - loaders: [new GraphQLFileLoader()] + const result = await loadDocuments([glob], { + ignore: ignoreGlob, + loaders: [new GraphQLFileLoader()] }); expect(result.length).toBe(1); }); @@ -103,7 +103,7 @@ describe('documentsFromGlob', () => { const glob = join(__dirname, './test-files/', '*.graphql'); const ignoreGlob = `!(${join(__dirname, './test-files/', '*.query.graphql')})`; const result = await loadDocuments([glob, ignoreGlob], { - loaders: [new GraphQLFileLoader()] + loaders: [new GraphQLFileLoader()] }); expect(result.length).toBe(1); }); @@ -112,7 +112,7 @@ describe('documentsFromGlob', () => { const glob = join(__dirname, './test-with-brackets/', '**/*.ts'); const result = await loadDocuments(glob, { loaders: [new CodeFileLoader()], - }) + }); expect(result.length).toBe(1); }); }); diff --git a/packages/core/tests/loaders/documents/import-documents.spec.ts b/packages/core/tests/loaders/documents/import-documents.spec.ts index 4a89b56d..b732685b 100644 --- a/packages/core/tests/loaders/documents/import-documents.spec.ts +++ b/packages/core/tests/loaders/documents/import-documents.spec.ts @@ -1,7 +1,7 @@ -import { loadDocuments } from "@graphql-toolkit/core" -import { join } from "path" -import { GraphQLFileLoader } from "@graphql-toolkit/graphql-file-loader" -import { parse, print } from "graphql"; +import { loadDocuments } from '@graphql-toolkit/core'; +import { join } from 'path'; +import { GraphQLFileLoader } from '@graphql-toolkit/graphql-file-loader'; +import { parse, print } from 'graphql'; import '../../../../testing/to-be-similar-gql-doc'; describe('import in documents', () => { @@ -28,7 +28,7 @@ describe('import in documents', () => { baz } `); - }) + }); it('should get documents with specific imports properly', async () => { const [{ document }] = await loadDocuments(join(__dirname, './import-test/specific/a.graphql'), { loaders: [new GraphQLFileLoader()] @@ -50,5 +50,5 @@ describe('import in documents', () => { baz } `); - }) -}) \ No newline at end of file + }); +}); diff --git a/packages/core/tests/loaders/schema/import-schema.spec.ts b/packages/core/tests/loaders/schema/import-schema.spec.ts index cc165288..dc02d815 100644 --- a/packages/core/tests/loaders/schema/import-schema.spec.ts +++ b/packages/core/tests/loaders/schema/import-schema.spec.ts @@ -1,5 +1,5 @@ import { parseImportLine, parseSDL, loadTypedefs, LoadTypedefsOptions, OPERATION_KINDS } from '@graphql-toolkit/core'; -import * as fs from 'fs' +import * as fs from 'fs'; import { print, DocumentNode, DefinitionNode, ASTNode } from 'graphql'; import { UrlLoader } from '@graphql-toolkit/url-loader'; import { GraphQLFileLoader } from '@graphql-toolkit/graphql-file-loader'; @@ -35,90 +35,90 @@ test('parseImportLine: parse single import', () => { expect(parseImportLine(`import A from "schema.graphql"`)).toEqual({ imports: ['A'], from: 'schema.graphql', - }) -}) + }); +}); test('parseImportLine: optional semicolon', () => { expect(parseImportLine(`import A from "schema.graphql";`)).toEqual({ imports: ['A'], from: 'schema.graphql', }); -}) +}); test('parseImportLine: invalid', async () => { expect(() => parseImportLine(`import from "schema.graphql"`)).toThrow(); -}) +}); test('parseImportLine: invalid 2', async () => { expect(() => parseImportLine(`import A from ""`)).toThrow(); -}) +}); test('parseImportLine: invalid 3', async () => { expect(() => parseImportLine(`import A. from ""`)).toThrow(); -}) +}); test('parseImportLine: invalid 4', async () => { expect(() => parseImportLine(`import A.* from ""`)).toThrow(); -}) +}); test('parseImportLine: parse multi import', async () => { expect(parseImportLine(`import A, B from "schema.graphql"`)).toEqual({ imports: ['A', 'B'], from: 'schema.graphql', - }) -}) + }); +}); test('parseImportLine: parse multi import (weird spacing)', async () => { expect(parseImportLine(`import A ,B from "schema.graphql"`)).toEqual({ imports: ['A', 'B'], from: 'schema.graphql', - }) -}) + }); +}); test('parseImportLine: different path', async () => { expect(parseImportLine(`import A from "../new/schema.graphql"`)).toEqual({ imports: ['A'], from: '../new/schema.graphql', - }) -}) + }); +}); test('parseImportLine: module in node_modules', async () => { expect(parseImportLine(`import A from "module-name"`)).toEqual({ imports: ['A'], from: 'module-name', - }) -}) + }); +}); test('parseImportLine: specific field', async () => { expect(parseImportLine(`import A.b from "module-name"`)).toEqual({ imports: ['A.b'], from: 'module-name', - }) -}) + }); +}); test('parseImportLine: multiple specific fields', async () => { expect(parseImportLine(`import A.b, G.q from "module-name"`)).toEqual({ imports: ['A.b', 'G.q'], from: 'module-name', - }) -}) + }); +}); test('parseImportLine: default import', async () => { expect(parseImportLine(`import "module-name"`)).toEqual({ imports: ['*'], from: 'module-name', - }) + }); }); test('parseSDL: non-import comment', async () => { expect(parseSDL(`#importent: comment`)).toEqual([]); -}) +}); test('parse: multi line import', async () => { const sdl = `\ # import A from "a.graphql" # import * from "b.graphql" - ` + `; expect(parseSDL(sdl)).toEqual([ { imports: ['A'], @@ -128,8 +128,8 @@ test('parse: multi line import', async () => { imports: ['*'], from: 'b.graphql', }, - ]) -}) + ]); +}); test('Module in node_modules', async () => { const b = `\ @@ -138,10 +138,10 @@ test('Module in node_modules', async () => { id: ID! nickname: String! @lower } - ` + `; const lower = `\ directive @lower on FIELD_DEFINITION - ` + `; const expectedSDL = /* GraphQL */`\ type A { id: ID! @@ -154,16 +154,16 @@ test('Module in node_modules', async () => { } directive @lower on FIELD_DEFINITION - ` - const moduleDir = 'node_modules/graphql-import-test' + `; + const moduleDir = 'node_modules/graphql-import-test'; if (!fs.existsSync(moduleDir)) { - fs.mkdirSync(moduleDir) + fs.mkdirSync(moduleDir); } - fs.writeFileSync(moduleDir + '/b.graphql', b) - fs.writeFileSync(moduleDir + '/lower.graphql', lower) - expect(await importSchema('./fixtures/import-module/a.graphql')).toBeSimilarGqlDoc(expectedSDL) -}) + fs.writeFileSync(moduleDir + '/b.graphql', b); + fs.writeFileSync(moduleDir + '/lower.graphql', lower); + expect(await importSchema('./fixtures/import-module/a.graphql')).toBeSimilarGqlDoc(expectedSDL); +}); test('importSchema: imports only', async () => { const expectedSDL = /* GraphQL */`\ @@ -172,18 +172,18 @@ test('importSchema: imports only', async () => { second: Float third: String } - ` + `; expect(await importSchema('./fixtures/imports-only/all.graphql')).toBeSimilarGqlDoc(expectedSDL); -}) +}); test('importSchema: import .gql extension', async () => { const expectedSDL = /* GraphQL */`\ type A { id: ID! } - ` - expect(await importSchema('./fixtures/import-gql/a.gql')).toBeSimilarGqlDoc(expectedSDL) -}) + `; + expect(await importSchema('./fixtures/import-gql/a.gql')).toBeSimilarGqlDoc(expectedSDL); +}); test('importSchema: import duplicate', async () => { const expectedSDL = /* GraphQL */`\ @@ -192,9 +192,9 @@ test('importSchema: import duplicate', async () => { second: Float third: String } - ` - expect(await importSchema('./fixtures/import-duplicate/all.graphql')).toBeSimilarGqlDoc(expectedSDL) -}) + `; + expect(await importSchema('./fixtures/import-duplicate/all.graphql')).toBeSimilarGqlDoc(expectedSDL); +}); test('importSchema: import nested', async () => { const expectedSDL = /* GraphQL */`\ @@ -203,9 +203,9 @@ test('importSchema: import nested', async () => { second: Float third: String } - ` - expect(await importSchema('./fixtures/import-nested/all.graphql')).toBeSimilarGqlDoc(expectedSDL) -}) + `; + expect(await importSchema('./fixtures/import-nested/all.graphql')).toBeSimilarGqlDoc(expectedSDL); +}); test('importSchema: field types', async () => { const expectedSDL = /* GraphQL */`\ @@ -223,9 +223,9 @@ test('importSchema: field types', async () => { type C { id: ID! } - ` - expect(await importSchema('./fixtures/field-types/a.graphql')).toBeSimilarGqlDoc(expectedSDL) -}) + `; + expect(await importSchema('./fixtures/field-types/a.graphql')).toBeSimilarGqlDoc(expectedSDL); +}); test('importSchema: enums', async () => { const expectedSDL = /* GraphQL */`\ @@ -240,9 +240,9 @@ test('importSchema: enums', async () => { B2 B3 } - ` - expect(await importSchema('./fixtures/enums/a.graphql')).toBeSimilarGqlDoc(expectedSDL) -}) + `; + expect(await importSchema('./fixtures/enums/a.graphql')).toBeSimilarGqlDoc(expectedSDL); +}); test('importSchema: import all', async () => { const expectedSDL = /* GraphQL */`\ @@ -265,9 +265,9 @@ test('importSchema: import all', async () => { type C2 { id: ID! } - ` - expect(await importSchema('./fixtures/import-all/a.graphql')).toBeSimilarGqlDoc(expectedSDL) -}) + `; + expect(await importSchema('./fixtures/import-all/a.graphql')).toBeSimilarGqlDoc(expectedSDL); +}); test('importSchema: import all from objects', async () => { const schemaC = ` @@ -282,7 +282,7 @@ test('importSchema: import all from objects', async () => { type C3 { id: ID! } - ` + `; const schemaB = ` # import * from 'schemaC' @@ -291,7 +291,7 @@ test('importSchema: import all from objects', async () => { c1: C1 c2: C2 } - ` + `; const schemaA = ` # import B from 'schemaB' @@ -301,13 +301,13 @@ test('importSchema: import all from objects', async () => { second: Float b: B } - ` + `; const schemas = { schemaA, schemaB, schemaC, - } + }; const expectedSDL = /* GraphQL */`\ type A { @@ -329,25 +329,25 @@ test('importSchema: import all from objects', async () => { type C2 { id: ID! } - ` - expect(await importSchema(schemaA, schemas)).toBeSimilarGqlDoc(expectedSDL) -}) + `; + expect(await importSchema(schemaA, schemas)).toBeSimilarGqlDoc(expectedSDL); +}); test(`importSchema: single object schema`, async () => { const schemaA = ` type A { field: String } - ` + `; const expectedSDL = /* GraphQL */`\ type A { field: String } - ` + `; - expect(await importSchema(schemaA)).toBeSimilarGqlDoc(expectedSDL) -}) + expect(await importSchema(schemaA)).toBeSimilarGqlDoc(expectedSDL); +}); test(`importSchema: import all mix 'n match`, async () => { const schemaB = ` @@ -357,7 +357,7 @@ test(`importSchema: import all mix 'n match`, async () => { c1: C1 c2: C2 } - ` + `; const schemaA = ` # import * from "schemaB" @@ -367,11 +367,11 @@ test(`importSchema: import all mix 'n match`, async () => { second: Float b: B } - ` + `; const schemas = { schemaB, - } + }; const expectedSDL = /* GraphQL */`\ type A { @@ -393,10 +393,10 @@ test(`importSchema: import all mix 'n match`, async () => { c1: C1 c2: C2 } - ` + `; - expect(await importSchema(schemaA, schemas)).toBeSimilarGqlDoc(expectedSDL) -}) + expect(await importSchema(schemaA, schemas)).toBeSimilarGqlDoc(expectedSDL); +}); test(`importSchema: import all mix 'n match 2`, async () => { const schemaA = ` @@ -407,7 +407,7 @@ test(`importSchema: import all mix 'n match 2`, async () => { second: Float b: B } - ` + `; const expectedSDL = /* GraphQL */`\ type A { @@ -429,9 +429,9 @@ test(`importSchema: import all mix 'n match 2`, async () => { type C2 { id: ID! } - ` - expect(await importSchema(schemaA)).toBeSimilarGqlDoc(expectedSDL) -}) + `; + expect(await importSchema(schemaA)).toBeSimilarGqlDoc(expectedSDL); +}); test(`importSchema: import all - exclude Query/Mutation/Subscription type`, async () => { const schemaC = ` @@ -459,7 +459,7 @@ test(`importSchema: import all - exclude Query/Mutation/Subscription type`, asyn hello: String! } - ` + `; const schemaB = ` # import * from 'schemaC' @@ -468,7 +468,7 @@ test(`importSchema: import all - exclude Query/Mutation/Subscription type`, asyn c1: C1 c2: C2 } - ` + `; const schemaA = ` # import B from 'schemaB' @@ -482,13 +482,13 @@ test(`importSchema: import all - exclude Query/Mutation/Subscription type`, asyn second: Float b: B } - ` + `; const schemas = { schemaA, schemaB, schemaC, - } + }; const expectedSDL = /* GraphQL */`\ type Query { @@ -514,9 +514,9 @@ test(`importSchema: import all - exclude Query/Mutation/Subscription type`, asyn type C2 { id: ID! } - ` - expect(await importSchema(schemaA, schemas)).toBeSimilarGqlDoc(expectedSDL) -}) + `; + expect(await importSchema(schemaA, schemas)).toBeSimilarGqlDoc(expectedSDL); +}); test('importSchema: scalar', async () => { const expectedSDL = /* GraphQL */`\ @@ -525,9 +525,9 @@ test('importSchema: scalar', async () => { } scalar B - ` - expect(await importSchema('./fixtures/scalar/a.graphql')).toBeSimilarGqlDoc(expectedSDL) -}) + `; + expect(await importSchema('./fixtures/scalar/a.graphql')).toBeSimilarGqlDoc(expectedSDL); +}); test('importSchema: directive', async () => { const expectedSDL = /* GraphQL */`\ @@ -541,9 +541,9 @@ test('importSchema: directive', async () => { directive @upper on FIELD_DEFINITION directive @withB(argB: B) on FIELD_DEFINITION - ` - expect(await importSchema('./fixtures/directive/a.graphql')).toBeSimilarGqlDoc(expectedSDL) -}) + `; + expect(await importSchema('./fixtures/directive/a.graphql')).toBeSimilarGqlDoc(expectedSDL); +}); test('importSchema: key directive', async () => { const expectedSDL = /* GraphQL */`\ @@ -553,9 +553,9 @@ test('importSchema: key directive', async () => { upc: UPC! name: String } - ` - expect(await importSchema('./fixtures/directive/c.graphql')).toBeSimilarGqlDoc(expectedSDL) -}) + `; + expect(await importSchema('./fixtures/directive/c.graphql')).toBeSimilarGqlDoc(expectedSDL); +}); test('importSchema: multiple key directive', async () => { const expectedSDL = /* GraphQL */`\ @@ -568,9 +568,9 @@ test('importSchema: multiple key directive', async () => { sku: SKU! name: String } - ` - expect(await importSchema('./fixtures/directive/e.graphql')).toBeSimilarGqlDoc(expectedSDL) -}) + `; + expect(await importSchema('./fixtures/directive/e.graphql')).toBeSimilarGqlDoc(expectedSDL); +}); test('importSchema: external directive', async () => { const expectedSDL = /* GraphQL */`\ @@ -582,9 +582,9 @@ test('importSchema: external directive', async () => { upc: String @external name: String @external } - ` - expect(await importSchema('./fixtures/directive/f.graphql')).toBeSimilarGqlDoc(expectedSDL) -}) + `; + expect(await importSchema('./fixtures/directive/f.graphql')).toBeSimilarGqlDoc(expectedSDL); +}); test('importSchema: requires directive', async () => { const expectedSDL = /* GraphQL */`\ @@ -597,9 +597,9 @@ test('importSchema: requires directive', async () => { email: String @external reviews: [Review] @requires(fields: "email") } - ` - expect(await importSchema('./fixtures/directive/g.graphql')).toBeSimilarGqlDoc(expectedSDL) -}) + `; + expect(await importSchema('./fixtures/directive/g.graphql')).toBeSimilarGqlDoc(expectedSDL); +}); test('importSchema: interfaces', async () => { const expectedSDL = /* GraphQL */`\ @@ -616,9 +616,9 @@ test('importSchema: interfaces', async () => { type C { c: ID! } - ` - expect(await importSchema('./fixtures/interfaces/a.graphql')).toBeSimilarGqlDoc(expectedSDL) -}) + `; + expect(await importSchema('./fixtures/interfaces/a.graphql')).toBeSimilarGqlDoc(expectedSDL); +}); test('importSchema: interfaces-many', async () => { const expectedSDL = /* GraphQL */`\ @@ -643,9 +643,9 @@ test('importSchema: interfaces-many', async () => { interface D2 { d2: ID! } - ` - expect(await importSchema('./fixtures/interfaces-many/a.graphql')).toBeSimilarGqlDoc(expectedSDL) -}) + `; + expect(await importSchema('./fixtures/interfaces-many/a.graphql')).toBeSimilarGqlDoc(expectedSDL); +}); test('importSchema: interfaces-implements', async () => { const expectedSDL = /* GraphQL */`\ @@ -660,9 +660,9 @@ test('importSchema: interfaces-implements', async () => { type B1 implements B { id: ID! } - ` - expect(await importSchema('./fixtures/interfaces-implements/a.graphql')).toBeSimilarGqlDoc(expectedSDL) -}) + `; + expect(await importSchema('./fixtures/interfaces-implements/a.graphql')).toBeSimilarGqlDoc(expectedSDL); +}); test('importSchema: interfaces-implements-many', async () => { const expectedSDL = /* GraphQL */`\ @@ -681,9 +681,9 @@ test('importSchema: interfaces-implements-many', async () => { type B2 implements B { id: ID! } - ` - expect(await importSchema('./fixtures/interfaces-implements-many/a.graphql')).toBeSimilarGqlDoc(expectedSDL) -}) + `; + expect(await importSchema('./fixtures/interfaces-implements-many/a.graphql')).toBeSimilarGqlDoc(expectedSDL); +}); test('importSchema: input types', async () => { const expectedSDL = /* GraphQL */`\ @@ -699,18 +699,18 @@ test('importSchema: input types', async () => { input C { id: ID! } - ` - expect(await importSchema('./fixtures/input-types/a.graphql')).toBeSimilarGqlDoc(expectedSDL) -}) + `; + expect(await importSchema('./fixtures/input-types/a.graphql')).toBeSimilarGqlDoc(expectedSDL); +}); test('importSchema: complex test', async () => { try { - const a = await importSchema('./fixtures/complex/a.graphql') + const a = await importSchema('./fixtures/complex/a.graphql'); expect(a).toBeTruthy(); } catch (e) { expect(e).toBeFalsy(); } -}) +}); test('circular imports', async () => { const expectedSDL = /* GraphQL */`\ @@ -734,10 +734,10 @@ test('circular imports', async () => { c2: C2 a: A } - ` - const actualSDL = await importSchema('./fixtures/circular/a.graphql') - expect(actualSDL).toBeSimilarGqlDoc(expectedSDL) -}) + `; + const actualSDL = await importSchema('./fixtures/circular/a.graphql'); + expect(actualSDL).toBeSimilarGqlDoc(expectedSDL); +}); test('related types', async () => { const expectedSDL = /* GraphQL */`\ @@ -755,10 +755,10 @@ test('related types', async () => { type C { field: String } - ` - const actualSDL = await importSchema('./fixtures/related-types/a.graphql') - expect(actualSDL).toBeSimilarGqlDoc(expectedSDL) -}) + `; + const actualSDL = await importSchema('./fixtures/related-types/a.graphql'); + expect(actualSDL).toBeSimilarGqlDoc(expectedSDL); +}); test('relative paths', async () => { const expectedSDL = /* GraphQL */`\ @@ -781,10 +781,10 @@ test('relative paths', async () => { interface Node { id: ID! } - ` - const actualSDL = await importSchema('./fixtures/relative-paths/src/schema.graphql') - expect(actualSDL).toBeSimilarGqlDoc(expectedSDL) -}) + `; + const actualSDL = await importSchema('./fixtures/relative-paths/src/schema.graphql'); + expect(actualSDL).toBeSimilarGqlDoc(expectedSDL); +}); test('root field imports', async () => { const expectedSDL = /* GraphQL */`\ @@ -803,10 +803,10 @@ test('root field imports', async () => { input PostFilter { field3: Int } - ` - const actualSDL = await importSchema('./fixtures/root-fields/a.graphql') - expect(actualSDL).toBeSimilarGqlDoc(expectedSDL) -}) + `; + const actualSDL = await importSchema('./fixtures/root-fields/a.graphql'); + expect(actualSDL).toBeSimilarGqlDoc(expectedSDL); +}); test('extend root field', async () => { const expectedSDL = /* GraphQL */`\ @@ -818,10 +818,10 @@ test('extend root field', async () => { id: ID! name: String } - ` - const actualSDL = await importSchema('./fixtures/root-fields/c.graphql') - expect(actualSDL).toBeSimilarGqlDoc(expectedSDL) -}) + `; + const actualSDL = await importSchema('./fixtures/root-fields/c.graphql'); + expect(actualSDL).toBeSimilarGqlDoc(expectedSDL); +}); test('extend root field imports', async () => { const expectedSDL = /* GraphQL */`\ @@ -838,10 +838,10 @@ test('extend root field imports', async () => { id: ID! name: String } - ` - const actualSDL = await importSchema('./fixtures/root-fields/d.graphql') - expect(actualSDL).toBeSimilarGqlDoc(expectedSDL) -}) + `; + const actualSDL = await importSchema('./fixtures/root-fields/d.graphql'); + expect(actualSDL).toBeSimilarGqlDoc(expectedSDL); +}); test('merged root field imports', async () => { const expectedSDL = /* GraphQL */`\ @@ -863,10 +863,10 @@ test('merged root field imports', async () => { input PostFilter { field3: Int } - ` - const actualSDL = await importSchema('./fixtures/merged-root-fields/a.graphql') - expect(actualSDL).toBeSimilarGqlDoc(expectedSDL) -}) + `; + const actualSDL = await importSchema('./fixtures/merged-root-fields/a.graphql'); + expect(actualSDL).toBeSimilarGqlDoc(expectedSDL); +}); test('global schema modules', async () => { const shared = ` @@ -874,7 +874,7 @@ test('global schema modules', async () => { first: String } - ` + `; const expectedSDL = /* GraphQL */`\ type A { first: String @@ -884,9 +884,9 @@ test('global schema modules', async () => { type Shared { first: String } - ` - expect(await importSchema('./fixtures/global/a.graphql', { shared })).toBeSimilarGqlDoc(expectedSDL) -}) + `; + expect(await importSchema('./fixtures/global/a.graphql', { shared })).toBeSimilarGqlDoc(expectedSDL); +}); test('missing type on type', async () => { try { @@ -896,27 +896,27 @@ test('missing type on type', async () => { expect(e.message).toBe(`Field test: Couldn't find type Post in any of the schemas.`); } -}) +}); test('missing type on interface', async () => { try { await importSchema('./fixtures/type-not-found/b.graphql'); throw new Error(); } catch (e) { - expect(e.message).toBe(`Field test: Couldn't find type Post in any of the schemas.`) + expect(e.message).toBe(`Field test: Couldn't find type Post in any of the schemas.`); } -}) +}); test('missing type on input type', async () => { try { await importSchema('./fixtures/type-not-found/c.graphql'); throw new Error(); } catch (e) { - expect(e.message).toBe(`Field post: Couldn't find type Post in any of the schemas.`) + expect(e.message).toBe(`Field post: Couldn't find type Post in any of the schemas.`); } -}) +}); test('missing interface type', async () => { @@ -924,21 +924,21 @@ test('missing interface type', async () => { await importSchema('./fixtures/type-not-found/d.graphql'); throw new Error(); } catch (e) { - expect(e.message).toBe(`Couldn't find interface MyInterface in any of the schemas.`) + expect(e.message).toBe(`Couldn't find interface MyInterface in any of the schemas.`); } -}) +}); test('missing union type', async () => { try { - await importSchema('./fixtures/type-not-found/e.graphql') + await importSchema('./fixtures/type-not-found/e.graphql'); throw new Error(); } catch (e) { - expect(e.message).toBe(`Couldn't find type C in any of the schemas.`) + expect(e.message).toBe(`Couldn't find type C in any of the schemas.`); } -}) +}); test('missing type on input type', async () => { @@ -946,10 +946,10 @@ test('missing type on input type', async () => { await importSchema('./fixtures/type-not-found/f.graphql'); throw new Error(); } catch (e) { - expect(e.message).toBe(`Field myfield: Couldn't find type Post in any of the schemas.`) + expect(e.message).toBe(`Field myfield: Couldn't find type Post in any of the schemas.`); } -}) +}); test('missing type on directive', async () => { @@ -957,10 +957,10 @@ test('missing type on directive', async () => { await importSchema('./fixtures/type-not-found/g.graphql'); throw new Error(); } catch (e) { - expect(e.message).toBe(`Directive first: Couldn't find type first in any of the schemas.`) + expect(e.message).toBe(`Directive first: Couldn't find type first in any of the schemas.`); } -}) +}); test('import with collision', async () => { // Local type gets preference over imported type @@ -970,9 +970,9 @@ test('import with collision', async () => { name: String! intro: String } - ` - expect(await importSchema('./fixtures/collision/a.graphql')).toBeSimilarGqlDoc(expectedSDL) -}) + `; + expect(await importSchema('./fixtures/collision/a.graphql')).toBeSimilarGqlDoc(expectedSDL); +}); test('merged custom root fields imports', async () => { const expectedSDL = /* GraphQL */`\ @@ -992,9 +992,9 @@ test('merged custom root fields imports', async () => { field3: Int } `; - const actualSDL = await importSchema('./fixtures/merged-root-fields/a.graphql') - expect(actualSDL).toBeSimilarGqlDoc(expectedSDL) -}) + const actualSDL = await importSchema('./fixtures/merged-root-fields/a.graphql'); + expect(actualSDL).toBeSimilarGqlDoc(expectedSDL); +}); test('respect schema definition', async () => { const expectedSDL = /* GraphQL */`\ @@ -1011,7 +1011,7 @@ test('respect schema definition', async () => { c: String } `; - const actualSDL = await importSchema('./fixtures/schema-definition/a.graphql') + const actualSDL = await importSchema('./fixtures/schema-definition/a.graphql'); expect(actualSDL).toBeSimilarGqlDoc(expectedSDL); }); @@ -1024,9 +1024,9 @@ test('import schema with shadowed type', async () => { x: X } scalar X -` - expect(await importSchema('./fixtures/import-shadowed/a.graphql')).toBeSimilarGqlDoc(expectedSDL) -}) +`; + expect(await importSchema('./fixtures/import-shadowed/a.graphql')).toBeSimilarGqlDoc(expectedSDL); +}); test('import specific types', async () => { const expectedSDL = /* GraphQL */`\ @@ -1040,9 +1040,9 @@ interface B { type C { c: String } -` - expect(await importSchema('./fixtures/specific/a.graphql')).toBeSimilarGqlDoc(expectedSDL) -}) +`; + expect(await importSchema('./fixtures/specific/a.graphql')).toBeSimilarGqlDoc(expectedSDL); +}); test('imports missing named imports for file imported multiple time without duplicates', async () => { const expectedSDL = /* GraphQL */`\ @@ -1059,6 +1059,6 @@ type Mutation { type B { x: String } -` +`; expect(await importSchema('fixtures/multiple-imports/schema.graphql')).toBeSimilarGqlDoc(expectedSDL); -}) \ No newline at end of file +}); diff --git a/packages/core/tests/loaders/schema/test-files/error.ts b/packages/core/tests/loaders/schema/test-files/error.ts index cd98bad5..90d0f307 100644 --- a/packages/core/tests/loaders/schema/test-files/error.ts +++ b/packages/core/tests/loaders/schema/test-files/error.ts @@ -1,10 +1,11 @@ import gql from 'graphql-tag'; -export const myQuery = gql - query myQuery { - data { - field1 - field2 +export const myQuery = gql; + query; myQuery; { + data; { + field1; + field2; } } `; +; \ No newline at end of file diff --git a/packages/file-loading/package.json b/packages/file-loading/package.json index 533b5238..101f4908 100644 --- a/packages/file-loading/package.json +++ b/packages/file-loading/package.json @@ -6,6 +6,7 @@ "author": "Dotan Simha ", "license": "MIT", "scripts": { + "lint": "tslint src/**/*.ts", "clean": "rimraf dist", "prebuild": "yarn clean", "build": "bob", diff --git a/packages/graphql-tag-pluck/package.json b/packages/graphql-tag-pluck/package.json index 248e8c44..8934d287 100644 --- a/packages/graphql-tag-pluck/package.json +++ b/packages/graphql-tag-pluck/package.json @@ -5,6 +5,7 @@ "license": "MIT", "repository": "git@github.com:ardatan/graphql-toolkit.git", "scripts": { + "lint": "tslint src/**/*.ts", "clean": "rimraf dist", "prebuild": "yarn clean", "build": "bob", @@ -30,6 +31,9 @@ "@babel/types": "7.8.3", "@graphql-toolkit/common": "0.9.4" }, + "optionalDependencies": { + "vue-template-compiler": "^2.6.11" + }, "devDependencies": { "@ardatan/bob": "0.2.7", "@types/babel__traverse": "7.0.8", diff --git a/packages/graphql-tag-pluck/src/index.ts b/packages/graphql-tag-pluck/src/index.ts index b3f7462b..0555bbb0 100644 --- a/packages/graphql-tag-pluck/src/index.ts +++ b/packages/graphql-tag-pluck/src/index.ts @@ -14,8 +14,10 @@ export interface GraphQLTagPluckOptions { const supportedExtensions = ['.js', '.jsx', '.ts', '.tsx', '.flow', '.flow.js', '.flow.jsx', '.vue']; async function pluckVueFileScript(fileData: string) { + // tslint:disable-next-line: no-implicit-dependencies let vueTemplateCompiler: typeof import('vue-template-compiler'); try { + // tslint:disable-next-line: no-implicit-dependencies vueTemplateCompiler = await import('vue-template-compiler'); } catch (e) { throw Error( @@ -38,7 +40,7 @@ async function pluckVueFileScript(fileData: string) { } export const gqlPluckFromCodeString = async (filePath: string, code: string, options: GraphQLTagPluckOptions = {}): Promise => { - if (typeof code != 'string') { + if (typeof code !== 'string') { throw TypeError('Provided code must be a string'); } diff --git a/packages/graphql-tag-pluck/src/libs/extname.ts b/packages/graphql-tag-pluck/src/libs/extname.ts index 5a516e9c..f5c0f95c 100644 --- a/packages/graphql-tag-pluck/src/libs/extname.ts +++ b/packages/graphql-tag-pluck/src/libs/extname.ts @@ -2,7 +2,7 @@ export const getExtNameFromFilePath = (filePath: string): string => { const partials = filePath.split('.'); let ext = '.' + partials.pop(); - if (partials.length > 1 && partials[partials.length - 1] == 'flow') { + if (partials.length > 1 && partials[partials.length - 1] === 'flow') { ext = '.' + partials.pop() + ext; } diff --git a/packages/graphql-tag-pluck/src/visitor.ts b/packages/graphql-tag-pluck/src/visitor.ts index f3c611e8..14f96eef 100644 --- a/packages/graphql-tag-pluck/src/visitor.ts +++ b/packages/graphql-tag-pluck/src/visitor.ts @@ -131,13 +131,19 @@ export default (code: string, out, options: GraphQLTagPluckOptions = {}) => { const pluckMagicTemplateLiteral = (node, takeExpression = false) => { const leadingComments = node.leadingComments; - if (!leadingComments) return; - if (!leadingComments.length) return; + if (!leadingComments) { + return; + } + if (!leadingComments.length) { + return; + } const leadingComment = leadingComments[leadingComments.length - 1]; const leadingCommentValue = leadingComment.value.trim().toLowerCase(); - if (leadingCommentValue != gqlMagicComment) return; + if (leadingCommentValue !== gqlMagicComment) { + return; + } const gqlTemplateLiteral = pluckStringFromFile(takeExpression ? node.expression : node); @@ -151,9 +157,13 @@ export default (code: string, out, options: GraphQLTagPluckOptions = {}) => { enter(path) { // Find the identifier name used from graphql-tag, commonJS // e.g. import gql from 'graphql-tag' -> gql - if (path.node.callee.name == 'require' && isValidPackage(path.node.arguments[0].value)) { - if (!isVariableDeclarator(path.parent)) return; - if (!isIdentifier(path.parent.id)) return; + if (path.node.callee.name === 'require' && isValidPackage(path.node.arguments[0].value)) { + if (!isVariableDeclarator(path.parent)) { + return; + } + if (!isIdentifier(path.parent.id)) { + return; + } definedIdentifierNames.push(path.parent.id.name); @@ -180,7 +190,9 @@ export default (code: string, out, options: GraphQLTagPluckOptions = {}) => { enter(path) { // Find the identifier name used from graphql-tag, es6 // e.g. import gql from 'graphql-tag' -> gql - if (!isValidPackage(path.node.source.value)) return; + if (!isValidPackage(path.node.source.value)) { + return; + } const moduleNode = modules.find(pkg => pkg.name.toLowerCase() === path.node.source.value.toLowerCase()); @@ -198,7 +210,9 @@ export default (code: string, out, options: GraphQLTagPluckOptions = {}) => { return false; }); - if (!gqlImportSpecifier) return; + if (!gqlImportSpecifier) { + return; + } definedIdentifierNames.push(gqlImportSpecifier.local.name); }, @@ -209,7 +223,9 @@ export default (code: string, out, options: GraphQLTagPluckOptions = {}) => { // Push all template literals leaded by graphql magic comment // e.g. /* GraphQL */ `query myQuery {}` -> query myQuery {} - if (!isTemplateLiteral(path.node.expression)) return; + if (!isTemplateLiteral(path.node.expression)) { + return; + } pluckMagicTemplateLiteral(path.node, true); }, diff --git a/packages/graphql-tag-pluck/tests/graphql-tag-pluck.test.ts b/packages/graphql-tag-pluck/tests/graphql-tag-pluck.test.ts index 52348b46..f2084e84 100644 --- a/packages/graphql-tag-pluck/tests/graphql-tag-pluck.test.ts +++ b/packages/graphql-tag-pluck/tests/graphql-tag-pluck.test.ts @@ -1,5 +1,5 @@ import { gqlPluckFromCodeString } from '../src'; -import { freeText } from '../src/utils' +import { freeText } from '../src/utils'; describe('graphql-tag-pluck', () => { it('should pluck graphql-tag template literals from .js file', async () => { @@ -34,8 +34,8 @@ describe('graphql-tag-pluck', () => { ...Foo } } - `)) - }) + `)); + }); it('should pluck graphql-tag template literals from .js file and remove replacements', async () => { @@ -64,7 +64,7 @@ describe('graphql-tag-pluck', () => { \${fragment} \${fragment2} \` - `)) + `)); expect(gqlString).toEqual(freeText(` fragment Foo on FooType { @@ -81,8 +81,8 @@ describe('graphql-tag-pluck', () => { ...Foo2 } } - `)) - }) + `)); + }); it('should pluck graphql-tag template literals from .ts file', async () => { @@ -111,7 +111,7 @@ describe('graphql-tag-pluck', () => { \${fragment} \` } - `)) + `)); expect(gqlString).toEqual(freeText(` fragment Foo on FooType { @@ -123,8 +123,8 @@ describe('graphql-tag-pluck', () => { ...Foo } } - `)) - }) + `)); + }); it('should pluck graphql-tag template literals from .tsx file', async () => { @@ -157,7 +157,7 @@ describe('graphql-tag-pluck', () => { // } // } // \`; - `)) + `)); expect(gqlString).toEqual(freeText(` query IndexQuery { @@ -167,8 +167,8 @@ describe('graphql-tag-pluck', () => { } } } - `)) - }) + `)); + }); it('should pluck graphql-tag template literals from .vue JavaScript file', async () => { const gqlString = await gqlPluckFromCodeString('tmp-XXXXXX.vue', freeText(` @@ -208,7 +208,7 @@ describe('graphql-tag-pluck', () => { - `)) + `)); expect(gqlString).toEqual(freeText(` query IndexQuery { @@ -218,8 +218,8 @@ describe('graphql-tag-pluck', () => { } } } - `)) - }) + `)); + }); it('should pluck graphql-tag template literals from .vue TS/Pug/SCSS file', async () => { const gqlString = await gqlPluckFromCodeString('tmp-XXXXXX.vue', freeText(` @@ -259,7 +259,7 @@ describe('graphql-tag-pluck', () => { - `)) + `)); expect(gqlString).toEqual(freeText(` query IndexQuery { @@ -269,8 +269,8 @@ describe('graphql-tag-pluck', () => { } } } - `)) - }) + `)); + }); it('should pluck graphql-tag template literals from .tsx file with generic jsx elements', async () => { const gqlString = await gqlPluckFromCodeString('tmp-XXXXXX.tsx', freeText(` @@ -299,7 +299,7 @@ describe('graphql-tag-pluck', () => { } } \`; - `)) + `)); expect(gqlString).toEqual(freeText(` query IndexQuery { @@ -309,8 +309,8 @@ describe('graphql-tag-pluck', () => { } } } - `)) - }) + `)); + }); it('should pluck graphql-tag template literals from .ts file with the same const inside namespace and outside namespace', async () => { const gqlString = await gqlPluckFromCodeString('tmp-XXXXXX.ts', freeText(` @@ -344,7 +344,7 @@ describe('graphql-tag-pluck', () => { fieldA } \`; - `)) + `)); expect(gqlString).toEqual(freeText(` query myQueryInNamespace { @@ -354,8 +354,8 @@ describe('graphql-tag-pluck', () => { query myQuery { fieldA } - `)) - }) + `)); + }); it('should pluck graphql-tag template literals from .flow file', async () => { const gqlString = await gqlPluckFromCodeString('tmp-XXXXXX.flow', freeText(` @@ -377,7 +377,7 @@ describe('graphql-tag-pluck', () => { \${fragment} \` - `)) + `)); expect(gqlString).toEqual(freeText(` fragment Foo on FooType { @@ -389,8 +389,8 @@ describe('graphql-tag-pluck', () => { ...Foo } } - `)) - }) + `)); + }); it('should pluck graphql-tag template literals from .js file with @flow header', async () => { const gqlString = await gqlPluckFromCodeString('tmp-XXXXXX.js', freeText(` @@ -414,7 +414,7 @@ describe('graphql-tag-pluck', () => { \${fragment} \` - `)) + `)); expect(gqlString).toEqual(freeText(` fragment Foo on FooType { @@ -426,12 +426,12 @@ describe('graphql-tag-pluck', () => { ...Foo } } - `)) - }) + `)); + }); it('should NOT pluck graphql-tag template literals from .js file without a @flow header', async () => { - const fail = Error('Function did not throw') + const fail = Error('Function did not throw'); try { await gqlPluckFromCodeString('tmp-XXXXXX.js', freeText(` @@ -453,14 +453,14 @@ describe('graphql-tag-pluck', () => { \${fragment} \` - `)) + `)); - throw fail + throw fail; } catch (e) { - expect(e).not.toEqual(fail) + expect(e).not.toEqual(fail); } - }) + }); it('should pluck graphql-tag template literals from .flow.jsx file', async () => { const gqlString = await gqlPluckFromCodeString('tmp-XXXXXX.flow.jsx', freeText(` @@ -482,7 +482,7 @@ describe('graphql-tag-pluck', () => { \${fragment} \` - `)) + `)); expect(gqlString).toEqual(freeText(` fragment Foo on FooType { @@ -494,8 +494,8 @@ describe('graphql-tag-pluck', () => { ...Foo } } - `)) - }) + `)); + }); it('should pluck graphql-tag template literals from .*.jsx file', async () => { const gqlString = await gqlPluckFromCodeString('tmp-XXXXXX.mutation.jsx', freeText(` @@ -516,7 +516,7 @@ describe('graphql-tag-pluck', () => { \${fragment} \` - `)) + `)); expect(gqlString).toEqual(freeText(` fragment Foo on FooType { @@ -528,8 +528,8 @@ describe('graphql-tag-pluck', () => { ...Foo } } - `)) - }) + `)); + }); it('should pluck graphql-tag template literals leaded by a magic comment from .js file', async () => { const gqlString = await gqlPluckFromCodeString('tmp-XXXXXX.js', freeText(` @@ -539,7 +539,7 @@ describe('graphql-tag-pluck', () => { media draftjs }\` - `)) + `)); expect(gqlString).toEqual(freeText(` enum MessageTypes { @@ -547,8 +547,8 @@ describe('graphql-tag-pluck', () => { media draftjs } - `)) - }) + `)); + }); it('should pluck graphql-tag expression statements leaded by a magic comment from .js file', async () => { const gqlString = await gqlPluckFromCodeString('tmp-XXXXXX.js', freeText(` @@ -558,7 +558,7 @@ describe('graphql-tag-pluck', () => { media draftjs }\` - `)) + `)); expect(gqlString).toEqual(freeText(` enum MessageTypes { @@ -566,8 +566,8 @@ describe('graphql-tag-pluck', () => { media draftjs } - `)) - }) + `)); + }); it(`should NOT pluck other template literals from a .js file`, async () => { const gqlString = await gqlPluckFromCodeString(`tmp-XXXXXX.js`, freeText(` @@ -583,10 +583,10 @@ describe('graphql-tag-pluck', () => { test.test\` test4 \` - `)) + `)); - expect(gqlString).toEqual('') - }) + expect(gqlString).toEqual(''); + }); it('should pluck template literals when graphql-tag is imported differently', async () => { const gqlString = await gqlPluckFromCodeString('tmp-XXXXXX.js', freeText(` @@ -607,7 +607,7 @@ describe('graphql-tag-pluck', () => { \${fragment} \` - `)) + `)); expect(gqlString).toEqual(freeText(` fragment Foo on FooType { @@ -619,8 +619,8 @@ describe('graphql-tag-pluck', () => { ...Foo } } - `)) - }) + `)); + }); it('should pluck template literals from gql by default even if not imported from graphql-tag', async () => { const gqlString = await gqlPluckFromCodeString('tmp-XXXXXX.js', freeText(` @@ -639,7 +639,7 @@ describe('graphql-tag-pluck', () => { \${fragment} \` - `)) + `)); expect(gqlString).toEqual(freeText(` fragment Foo on FooType { @@ -651,8 +651,8 @@ describe('graphql-tag-pluck', () => { ...Foo } } - `)) - }) + `)); + }); it('should pluck graphql-tag template literals from code string', async () => { const gqlString = await gqlPluckFromCodeString('test.js', freeText(` @@ -673,7 +673,7 @@ describe('graphql-tag-pluck', () => { \${fragment} \` - `)) + `)); expect(gqlString).toEqual(freeText(` fragment Foo on FooType { @@ -685,8 +685,8 @@ describe('graphql-tag-pluck', () => { ...Foo } } - `)) - }) + `)); + }); it('should pluck graphql-tag template literals from a .js file', async () => { const gqlString = await gqlPluckFromCodeString('tmp-XXXXXX.js', freeText(` @@ -707,7 +707,7 @@ describe('graphql-tag-pluck', () => { \${fragment} \` - `)) + `)); expect(gqlString).toEqual(freeText(` fragment Foo on FooType { @@ -719,8 +719,8 @@ describe('graphql-tag-pluck', () => { ...Foo } } - `)) - }) + `)); + }); it('should be able to specify the global GraphQL identifier name', async () => { const gqlString = await gqlPluckFromCodeString('tmp-XXXXXX.js', freeText(` @@ -741,7 +741,7 @@ describe('graphql-tag-pluck', () => { \` `), { globalGqlIdentifierName: 'anothergql' - }) + }); expect(gqlString).toEqual(freeText(` fragment Foo on FooType { @@ -753,8 +753,8 @@ describe('graphql-tag-pluck', () => { ...Foo } } - `)) - }) + `)); + }); it('should be able to specify the GraphQL magic comment to look for', async () => { @@ -775,8 +775,8 @@ describe('graphql-tag-pluck', () => { media draftjs } - `)) - }) + `)); + }); it('should be able to specify the package name of which the GraphQL identifier should be imported from', async () => { @@ -814,8 +814,8 @@ describe('graphql-tag-pluck', () => { ...Foo } } - `)) - }) + `)); + }); it('should pluck graphql template literal from gatsby package', async () => { const gqlString = await gqlPluckFromCodeString('tmp-XXXXXX.js', freeText(` @@ -836,7 +836,7 @@ describe('graphql-tag-pluck', () => { \${fragment} \` - `)) + `)); expect(gqlString).toEqual(freeText(` fragment Foo on FooType { @@ -848,8 +848,8 @@ describe('graphql-tag-pluck', () => { ...Foo } } - `)) - }) + `)); + }); it('should pluck gql template literal from apollo-server-express package', async () => { const gqlString = await gqlPluckFromCodeString('tmp-XXXXXX.js', freeText(` @@ -870,7 +870,7 @@ describe('graphql-tag-pluck', () => { \${fragment} \` - `)) + `)); expect(gqlString).toEqual(freeText(` fragment Foo on FooType { @@ -882,8 +882,8 @@ describe('graphql-tag-pluck', () => { ...Foo } } - `)) - }) + `)); + }); it('should pluck gql template literal from @apollo/client package', async () => { const gqlString = await gqlPluckFromCodeString('tmp-XXXXXX.js', freeText(` @@ -904,7 +904,7 @@ describe('graphql-tag-pluck', () => { \${fragment} \` - `)) + `)); expect(gqlString).toEqual(freeText(` fragment Foo on FooType { @@ -916,13 +916,13 @@ describe('graphql-tag-pluck', () => { ...Foo } } - `)) - }) + `)); + }); it('should pluck magic comment template literals with a trailing semicolon', async () => { - const gqlString = await gqlPluckFromCodeString('test.js', "/* GraphQL */ `{}`;") - expect(gqlString).toEqual("{}") - }) + const gqlString = await gqlPluckFromCodeString('test.js', '/* GraphQL */ `{}`;'); + expect(gqlString).toEqual('{}'); + }); it('should pluck with comments having escaped backticks', async () => { const gqlString = await gqlPluckFromCodeString('tmp-XXXXXX.js', freeText(` @@ -936,7 +936,7 @@ describe('graphql-tag-pluck', () => { email: String! } \` - `)) + `)); expect(gqlString).toEqual(freeText(` type User { @@ -945,8 +945,8 @@ describe('graphql-tag-pluck', () => { username: String! email: String! } - `)) - }) + `)); + }); it('should pluck graphql template literal imported lazily', async () => { const gqlString = await gqlPluckFromCodeString('tmp-XXXXXX.js', freeText(` @@ -962,7 +962,7 @@ describe('graphql-tag-pluck', () => { } \` } - `)) + `)); expect(gqlString).toEqual(freeText(` type User { @@ -971,6 +971,6 @@ describe('graphql-tag-pluck', () => { username: String! email: String! } - `)) + `)); }); -}) +}); diff --git a/packages/loaders/apollo-engine/package.json b/packages/loaders/apollo-engine/package.json index 5891d5f8..d2df5c45 100644 --- a/packages/loaders/apollo-engine/package.json +++ b/packages/loaders/apollo-engine/package.json @@ -6,6 +6,7 @@ "author": "Dotan Simha ", "license": "MIT", "scripts": { + "lint": "tslint src/**/*.ts", "clean": "rimraf dist", "prebuild": "yarn clean", "build": "bob", diff --git a/packages/loaders/code-file/package.json b/packages/loaders/code-file/package.json index f5d3e08c..07cb8c1d 100644 --- a/packages/loaders/code-file/package.json +++ b/packages/loaders/code-file/package.json @@ -6,6 +6,7 @@ "author": "Dotan Simha ", "license": "MIT", "scripts": { + "lint": "tslint src/**/*.ts", "clean": "rimraf dist", "prebuild": "yarn clean", "build": "bob", diff --git a/packages/loaders/code-file/tests/load-from-code-file.spec.ts b/packages/loaders/code-file/tests/load-from-code-file.spec.ts index eec78eb6..780b6dd4 100644 --- a/packages/loaders/code-file/tests/load-from-code-file.spec.ts +++ b/packages/loaders/code-file/tests/load-from-code-file.spec.ts @@ -33,11 +33,11 @@ describe('loadFromCodeFile', () => { }); it('should consider options.cwd', async () => { - const loaded = await loader.load('valid-doc.js', { + const loaded = await loader.load('valid-doc.js', { path, fs, cwd: path.resolve(__dirname, 'test-files'), - noRequire: true, + noRequire: true, }); const doc = parse(loaded.rawSDL); diff --git a/packages/loaders/git/package.json b/packages/loaders/git/package.json index 0aed5204..9d3f07b3 100644 --- a/packages/loaders/git/package.json +++ b/packages/loaders/git/package.json @@ -6,6 +6,7 @@ "author": "Dotan Simha ", "license": "MIT", "scripts": { + "lint": "tslint src/**/*.ts", "clean": "rimraf dist", "prebuild": "yarn clean", "build": "bob", @@ -28,7 +29,7 @@ "devDependencies": { "@ardatan/bob": "0.2.7", "graphql": "14.5.8", - "graphql-tools": "4.0.6", + "@ardatan/graphql-tools": "4.1.0", "typescript": "3.7.5" }, "dependencies": { diff --git a/packages/loaders/github/package.json b/packages/loaders/github/package.json index 59cfd1e7..9af049ae 100644 --- a/packages/loaders/github/package.json +++ b/packages/loaders/github/package.json @@ -6,6 +6,7 @@ "author": "Dotan Simha ", "license": "MIT", "scripts": { + "lint": "tslint src/**/*.ts", "clean": "rimraf dist", "prebuild": "yarn clean", "build": "bob", @@ -28,7 +29,7 @@ "devDependencies": { "@ardatan/bob": "0.2.7", "graphql": "14.5.8", - "graphql-tools": "4.0.6", + "@ardatan/graphql-tools": "4.1.0", "typescript": "3.7.5" }, "dependencies": { diff --git a/packages/loaders/graphql-file/package.json b/packages/loaders/graphql-file/package.json index 0e7e6986..3a7dd6c8 100644 --- a/packages/loaders/graphql-file/package.json +++ b/packages/loaders/graphql-file/package.json @@ -6,6 +6,7 @@ "author": "Dotan Simha ", "license": "MIT", "scripts": { + "lint": "tslint src/**/*.ts", "clean": "rimraf dist", "prebuild": "yarn clean", "build": "bob", @@ -27,7 +28,7 @@ }, "devDependencies": { "@ardatan/bob": "0.2.7", - "@kamilkisiela/graphql-tools": "4.0.6", + "@ardatan/graphql-tools": "4.1.0", "graphql": "14.5.8", "typescript": "3.7.5" }, diff --git a/packages/loaders/graphql-file/src/index.ts b/packages/loaders/graphql-file/src/index.ts index c0657025..cab89bb4 100644 --- a/packages/loaders/graphql-file/src/index.ts +++ b/packages/loaders/graphql-file/src/index.ts @@ -28,7 +28,6 @@ export class GraphQLFileLoader implements UniversalLoader { - const { resolve, isAbsolute } = options.path; const normalizedFilePath = isAbsolute(pointer) ? pointer : resolve(options.cwd || process.cwd(), pointer); const { readFileSync } = options.fs; diff --git a/packages/loaders/json-file/package.json b/packages/loaders/json-file/package.json index 3700be04..4d8ef51f 100644 --- a/packages/loaders/json-file/package.json +++ b/packages/loaders/json-file/package.json @@ -6,6 +6,7 @@ "author": "Dotan Simha ", "license": "MIT", "scripts": { + "lint": "tslint src/**/*.ts", "clean": "rimraf dist", "prebuild": "yarn clean", "build": "bob", @@ -27,7 +28,7 @@ }, "devDependencies": { "@ardatan/bob": "0.2.7", - "@kamilkisiela/graphql-tools": "4.0.6", + "@ardatan/graphql-tools": "4.1.0", "graphql": "14.5.8", "typescript": "3.7.5" }, diff --git a/packages/loaders/json-file/src/index.ts b/packages/loaders/json-file/src/index.ts index 1d971fc6..bcb55c1e 100644 --- a/packages/loaders/json-file/src/index.ts +++ b/packages/loaders/json-file/src/index.ts @@ -28,9 +28,7 @@ export class JsonFileLoader implements DocumentLoader { } async load(pointer: SchemaPointerSingle, options: JsonFileLoaderOptions): Promise { - if (options.path) { - } const { resolve: resolvePath, isAbsolute } = options.path; const normalizedFilepath = isAbsolute(pointer) ? pointer : resolvePath(options.cwd || process.cwd(), pointer); diff --git a/packages/loaders/module/package.json b/packages/loaders/module/package.json index 92fbf19d..e02ddec3 100644 --- a/packages/loaders/module/package.json +++ b/packages/loaders/module/package.json @@ -6,6 +6,7 @@ "author": "Dotan Simha ", "license": "MIT", "scripts": { + "lint": "tslint src/**/*.ts", "clean": "rimraf dist", "prebuild": "yarn clean", "build": "bob", diff --git a/packages/loaders/prisma/package.json b/packages/loaders/prisma/package.json index cc3b34c8..419d3235 100644 --- a/packages/loaders/prisma/package.json +++ b/packages/loaders/prisma/package.json @@ -6,6 +6,7 @@ "author": "Dotan Simha ", "license": "MIT", "scripts": { + "lint": "tslint src/**/*.ts", "clean": "rimraf dist", "prebuild": "yarn clean", "build": "bob", diff --git a/packages/loaders/prisma/src/index.ts b/packages/loaders/prisma/src/index.ts index eac86f73..09e4bb5c 100644 --- a/packages/loaders/prisma/src/index.ts +++ b/packages/loaders/prisma/src/index.ts @@ -15,12 +15,7 @@ export class PrismaLoader extends UrlLoader { return 'prisma'; } async canLoad(prismaConfigFilePath: string, options: PrismaLoaderOptions) { - if ( - typeof prismaConfigFilePath === 'string' && - prismaConfigFilePath.endsWith('prisma.yml') && - options.fs && - options.path && - options.os) { + if (typeof prismaConfigFilePath === 'string' && prismaConfigFilePath.endsWith('prisma.yml') && options.fs && options.path && options.os) { const path = options.path || (await import('path')); const joinedYmlPath = path.join(options.cwd || process.cwd(), prismaConfigFilePath); const fs = options.fs; diff --git a/packages/loaders/url/package.json b/packages/loaders/url/package.json index aade302d..7df72846 100644 --- a/packages/loaders/url/package.json +++ b/packages/loaders/url/package.json @@ -6,6 +6,7 @@ "author": "Dotan Simha ", "license": "MIT", "scripts": { + "lint": "tslint src/**/*.ts", "clean": "rimraf dist", "prebuild": "yarn clean", "build": "bob", @@ -33,13 +34,13 @@ "apollo-server-express": "2.9.16", "express": "4.17.1", "graphql": "14.5.8", - "graphql-tools": "4.0.6", "jest": "25.1.0", "supertest": "4.0.2", "ts-jest": "25.0.0", "typescript": "3.7.5" }, "dependencies": { + "@ardatan/graphql-tools": "4.1.0", "@graphql-toolkit/common": "0.9.4", "cross-fetch": "3.0.4", "tslib": "1.10.0", diff --git a/packages/loaders/url/src/index.ts b/packages/loaders/url/src/index.ts index aa5994e2..b9813c3c 100644 --- a/packages/loaders/url/src/index.ts +++ b/packages/loaders/url/src/index.ts @@ -3,7 +3,7 @@ import { SchemaPointerSingle, Source, DocumentLoader, SingleFileOptions, parseGr import { isWebUri } from 'valid-url'; import { fetch as crossFetch } from 'cross-fetch'; import { makeRemoteExecutableSchema } from '@ardatan/graphql-tools'; -import { Fetcher } from 'graphql-tools/dist/stitching/makeRemoteExecutableSchema'; +import { Fetcher } from '@ardatan/graphql-tools/dist/stitching/makeRemoteExecutableSchema'; export type FetchFn = typeof import('cross-fetch').fetch; diff --git a/packages/loaders/url/tests/url-loader.spec.ts b/packages/loaders/url/tests/url-loader.spec.ts index 6c674a74..9730b056 100644 --- a/packages/loaders/url/tests/url-loader.spec.ts +++ b/packages/loaders/url/tests/url-loader.spec.ts @@ -43,7 +43,7 @@ describe('Schema URL Loader', () => { data: {} }; } - } as any + } as any; }); try { @@ -99,8 +99,8 @@ describe('Schema URL Loader', () => { const calls = getMockedCalls(testUrl); expect(calls.length).toBe(1); const call = await calls[0]; - expect(call.req._header).toContain(`Accept: application/json`) - expect(call.req._header).toContain(`Content-Type: application/json`) + expect(call.req._header).toContain(`Accept: application/json`); + expect(call.req._header).toContain(`Content-Type: application/json`); }); it('Should pass extra headers when they are specified as object', async () => { @@ -112,9 +112,9 @@ describe('Schema URL Loader', () => { const calls = getMockedCalls(testUrl); expect(calls.length).toBe(1); const call = await calls[0]; - expect(call.req._header).toContain(`Accept: application/json`) - expect(call.req._header).toContain(`Content-Type: application/json`) - expect(call.req._header).toContain(`Auth: 1`) + expect(call.req._header).toContain(`Accept: application/json`); + expect(call.req._header).toContain(`Content-Type: application/json`); + expect(call.req._header).toContain(`Auth: 1`); }); it('Should pass extra headers when they are specified as array', async () => { @@ -126,13 +126,13 @@ describe('Schema URL Loader', () => { const calls = getMockedCalls(testUrl); expect(calls.length).toBe(1); const call = await calls[0]; - expect(call.req._header).toContain(`Accept: application/json`) - expect(call.req._header).toContain(`Content-Type: application/json`) - expect(call.req._header).toContain(`A: 1`) - expect(call.req._header).toContain(`B: 2`) - expect(call.req._header).toContain(`C: 3`) + expect(call.req._header).toContain(`Accept: application/json`); + expect(call.req._header).toContain(`Content-Type: application/json`); + expect(call.req._header).toContain(`A: 1`); + expect(call.req._header).toContain(`B: 2`); + expect(call.req._header).toContain(`C: 3`); }); - + it('Absolute file path should not be accepted as URL', async () => { expect(await loader.canLoad(process.cwd(), {})).toBeFalsy(); }); diff --git a/packages/relay-operation-optimizer/package.json b/packages/relay-operation-optimizer/package.json index ff8098d6..b568c4f2 100644 --- a/packages/relay-operation-optimizer/package.json +++ b/packages/relay-operation-optimizer/package.json @@ -10,6 +10,7 @@ "license": "MIT", "repository": "git@github.com:ardatan/graphql-toolkit.git", "scripts": { + "lint": "tslint src/**/*.ts", "clean": "rimraf dist", "prebuild": "yarn clean", "build": "bob", diff --git a/packages/schema-merging/package.json b/packages/schema-merging/package.json index a0872fce..28a6be45 100644 --- a/packages/schema-merging/package.json +++ b/packages/schema-merging/package.json @@ -6,6 +6,7 @@ "author": "Dotan Simha ", "license": "MIT", "scripts": { + "lint": "tslint src/**/*.ts", "clean": "rimraf dist", "prebuild": "yarn clean", "build": "bob", @@ -37,7 +38,7 @@ "dependencies": { "@graphql-toolkit/common": "0.9.4", "deepmerge": "4.2.2", - "graphql-tools": "4.0.6", + "@ardatan/graphql-tools": "4.1.0", "tslib": "1.10.0" }, "publishConfig": { diff --git a/packages/schema-merging/src/typedefs-mergers/fields.ts b/packages/schema-merging/src/typedefs-mergers/fields.ts index 0f9a32fd..f638b81e 100644 --- a/packages/schema-merging/src/typedefs-mergers/fields.ts +++ b/packages/schema-merging/src/typedefs-mergers/fields.ts @@ -53,7 +53,7 @@ export function mergeFields, config?: Omit, 'commentDescriptions'>) { + // tslint:disable-next-line: no-console console.info(` GraphQL Toolkit/Epoxy Deprecation Notice; diff --git a/packages/schema-merging/tests/merge-schemas.spec.ts b/packages/schema-merging/tests/merge-schemas.spec.ts index cd712687..37619808 100644 --- a/packages/schema-merging/tests/merge-schemas.spec.ts +++ b/packages/schema-merging/tests/merge-schemas.spec.ts @@ -1,13 +1,11 @@ -import { makeExecutableSchema } from "graphql-tools"; -import gql from "graphql-tag"; -import { graphql, buildSchema, GraphQLScalarType, Kind, buildASTSchema, GraphQLSchema, ListValueNode } from "graphql"; -import { mergeSchemas, mergeSchemasAsync } from "../src/merge-schemas"; -import { printSchemaWithDirectives } from "@graphql-toolkit/common"; +import { makeExecutableSchema } from '@ardatan/graphql-tools'; +import { graphql, buildSchema, GraphQLScalarType, Kind, buildASTSchema, GraphQLSchema, ListValueNode } from 'graphql'; +import { mergeSchemas, mergeSchemasAsync } from '../src/merge-schemas'; describe('Merge Schemas', () => { it('should merge two valid executable schemas', async () => { const fooSchema = makeExecutableSchema({ - typeDefs: gql` + typeDefs: /* GraphQL */` type Query { foo: String } @@ -19,7 +17,7 @@ describe('Merge Schemas', () => { } }); const barSchema = makeExecutableSchema({ - typeDefs: gql` + typeDefs: /* GraphQL */` type Query { bar: String } @@ -47,7 +45,7 @@ describe('Merge Schemas', () => { }); it('should merge two valid executable schemas async', async () => { const fooSchema = makeExecutableSchema({ - typeDefs: gql` + typeDefs: /* GraphQL */` type Query { foo: String } @@ -59,7 +57,7 @@ describe('Merge Schemas', () => { } }); const barSchema = makeExecutableSchema({ - typeDefs: gql` + typeDefs: /* GraphQL */` type Query { bar: String } @@ -87,7 +85,7 @@ describe('Merge Schemas', () => { }); it('should merge two valid executable schemas with extra resolvers', async () => { const fooSchema = makeExecutableSchema({ - typeDefs: gql` + typeDefs: /* GraphQL */` type Query { foo: String } @@ -99,7 +97,7 @@ describe('Merge Schemas', () => { } }); const barSchema = makeExecutableSchema({ - typeDefs: gql` + typeDefs: /* GraphQL */` type Query { bar: String qux: String @@ -135,7 +133,7 @@ describe('Merge Schemas', () => { }); it('should merge two valid executable schemas with extra typeDefs and resolvers', async () => { const fooSchema = makeExecutableSchema({ - typeDefs: gql` + typeDefs: /* GraphQL */` type Query { foo: String } @@ -147,7 +145,7 @@ describe('Merge Schemas', () => { } }); const barSchema = makeExecutableSchema({ - typeDefs: gql` + typeDefs: /* GraphQL */` type Query { bar: String } @@ -161,7 +159,7 @@ describe('Merge Schemas', () => { const { errors, data } = await graphql({ schema: mergeSchemas({ schemas: [fooSchema, barSchema], - typeDefs: gql` + typeDefs: /* GraphQL */` type Query { qux: String } @@ -187,7 +185,7 @@ describe('Merge Schemas', () => { }); it('should merge two valid schemas by keeping their directives to be used in extra typeDefs', async () => { const fooSchema = makeExecutableSchema({ - typeDefs: gql` + typeDefs: /* GraphQL */` directive @fooDirective on FIELD_DEFINITION type Query { foo: String @@ -200,7 +198,7 @@ describe('Merge Schemas', () => { } }); const barSchema = makeExecutableSchema({ - typeDefs: gql` + typeDefs: /* GraphQL */` type Query { bar: String } @@ -214,7 +212,7 @@ describe('Merge Schemas', () => { const { errors, data } = await graphql({ schema: mergeSchemas({ schemas: [fooSchema, barSchema], - typeDefs: gql` + typeDefs: /* GraphQL */` type Query { qux: String @fooDirective } @@ -240,7 +238,7 @@ describe('Merge Schemas', () => { }); it('should merge valid schemas with interfaces correctly', async () => { const fooSchema = makeExecutableSchema({ - typeDefs: gql` + typeDefs: /* GraphQL */` interface Foo { foo: String } @@ -253,9 +251,9 @@ describe('Merge Schemas', () => { qux: String } ` - }) + }); const barSchema = makeExecutableSchema({ - typeDefs: gql` + typeDefs: /* GraphQL */` interface Foo { foo: String } @@ -308,7 +306,7 @@ describe('Merge Schemas', () => { expect(data.bar.bar).toBe('bar'); expect(data.qux.foo).toBe('foo'); expect(data.qux.qux).toBe('qux'); - }) + }); it('should merge scalars (part of resolvers)', async () => { const now = new Date(); @@ -321,7 +319,7 @@ describe('Merge Schemas', () => { Date: new GraphQLScalarType({ name: 'DateTime', serialize(value) { - return new Date(value).toISOString() + return new Date(value).toISOString(); }, parseValue(value) { return new Date(value); @@ -356,11 +354,11 @@ describe('Merge Schemas', () => { }); expect(data.a).toEqual(now.toISOString()); - }) + }); it('should merge when directive uses enum', () => { const merged = mergeSchemas({ - schemas: [buildASTSchema(gql` + schemas: [buildSchema(/* GraphQL */` directive @date(format: DateFormat) on FIELD_DEFINITION enum DateFormat { @@ -368,7 +366,7 @@ describe('Merge Schemas', () => { ISO } `)], - typeDefs: gql` + typeDefs: /* GraphQL */` scalar Date type Query { today: Date @date @@ -390,10 +388,10 @@ describe('Merge Schemas', () => { let prev: GraphQLSchema = base; - while(num--) { - prev = mergeSchemas({schemas: [prev, base]}) + while (num--) { + prev = mergeSchemas({schemas: [prev, base]}); } expect((prev.getQueryType().getFields().test.astNode.directives[0].arguments[0].value as ListValueNode).values).toHaveLength(1); }); -}) +}); diff --git a/packages/schema-merging/tests/merge-typedefs.spec.ts b/packages/schema-merging/tests/merge-typedefs.spec.ts index 07e86c9e..041e5bf5 100644 --- a/packages/schema-merging/tests/merge-typedefs.spec.ts +++ b/packages/schema-merging/tests/merge-typedefs.spec.ts @@ -1068,7 +1068,7 @@ describe('Merge TypeDefs', () => { } `) ]; - + const mergedTypes = mergeTypeDefs(types); const expectedEnumType = stripWhitespaces(` @@ -1089,8 +1089,8 @@ describe('Merge TypeDefs', () => { const separateTypes = stripWhitespaces(print(mergedTypes)); expect(separateTypes).toContain(expectedEnumType); - - }) + + }); it('preserves the field comments', () => { const types = [clientType, productType]; diff --git a/tslint.json b/tslint.json new file mode 100644 index 00000000..3c75ea2f --- /dev/null +++ b/tslint.json @@ -0,0 +1,78 @@ +{ + "rules": { + "align": [ + true, + "parameters" + ], + "class-name": true, + "curly": true, + "eofline": true, + "forin": false, + "indent": [ + true, + "spaces" + ], + "label-position": true, + "max-line-length": [ + false + ], + "member-access": false, + "member-ordering": [ + false + ], + "no-arg": true, + "no-bitwise": true, + "no-console": true, + "no-construct": true, + "no-debugger": true, + "no-duplicate-variable": true, + "no-empty": false, + "no-eval": true, + "no-implicit-dependencies": true, + "no-inferrable-types": true, + "no-shadowed-variable": false, + "no-string-literal": false, + "no-switch-case-fall-through": true, + "no-trailing-whitespace": [ + true, + "ignore-template-strings" + ], + "no-unused-expression": true, + "no-use-before-declare": false, + "no-var-keyword": false, + "object-literal-sort-keys": false, + "no-conditional-assignment": true, + "one-line": [ + true, + "check-open-brace", + "check-whitespace" + ], + "quotemark": [ + true, + "single" + ], + "radix": false, + "semicolon": [ + true, + "ignore-bound-class-methods" + ], + "triple-equals": [ + true, + "allow-null-check" + ], + "variable-name": [ + true, + "check-format", + "allow-leading-underscore", + "allow-pascal-case" + ], + "whitespace": [ + true, + "check-branch", + "check-decl", + "check-operator", + "check-separator", + "check-type" + ] + } +} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 6a17fa13..eeef69e2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -814,17 +814,6 @@ "@types/yargs" "^15.0.0" chalk "^3.0.0" -"@kamilkisiela/graphql-tools@4.0.6": - version "4.0.6" - resolved "https://registry.yarnpkg.com/@kamilkisiela/graphql-tools/-/graphql-tools-4.0.6.tgz#6dcf4d18bedaf34f6ab1d5bad2414e530d0875d1" - integrity sha512-IPWa+dOFCE4zaCsrJrAMp7yWXnfOZLNhqoMEOmn958WkLM0mmsDc/W/Rh7/7xopIT6P0oizb6/N1iH5HnNXOUA== - dependencies: - apollo-link "^1.2.3" - apollo-utilities "^1.0.1" - deprecated-decorator "^0.1.6" - iterall "^1.1.3" - uuid "^3.1.0" - "@lerna/add@3.20.0": version "3.20.0" resolved "https://registry.yarnpkg.com/@lerna/add/-/add-3.20.0.tgz#bea7edf36fc93fb72ec34cb9ba854c48d4abf309" @@ -4562,7 +4551,7 @@ graphql-tag@2.10.1, graphql-tag@^2.10.1, graphql-tag@^2.9.2: resolved "https://registry.yarnpkg.com/graphql-tag/-/graphql-tag-2.10.1.tgz#10aa41f1cd8fae5373eaf11f1f67260a3cad5e02" integrity sha512-jApXqWBzNXQ8jYa/HLkZJaVw9jgwNqZkywa2zfFn16Iv1Zb7ELNHkJaXHR7Quvd5SIGsy6Ny7SUKATgnu05uEg== -graphql-tools@4.0.6, graphql-tools@^4.0.0: +graphql-tools@^4.0.0: version "4.0.6" resolved "https://registry.yarnpkg.com/graphql-tools/-/graphql-tools-4.0.6.tgz#0e729e73db05ade3df10a2f92511be544972a844" integrity sha512-jHLQw8x3xmSNRBCsaZqelXXsFfUSUSktSCUP8KYHiX1Z9qEuwcMpAf+FkdBzk8aTAFqOlPdNZ3OI4DKKqGKUqg== @@ -9083,7 +9072,7 @@ vscode-uri@^1.0.6: resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-1.0.8.tgz#9769aaececae4026fb6e22359cb38946580ded59" integrity sha512-obtSWTlbJ+a+TFRYGaUumtVwb+InIUVI0Lu0VBUAPmj2cU5JutEXg3xUE0c2J5Tcy7h2DEKVJBFi+Y9ZSFzzPQ== -vue-template-compiler@2.6.11: +vue-template-compiler@^2.6.11: version "2.6.11" resolved "https://registry.yarnpkg.com/vue-template-compiler/-/vue-template-compiler-2.6.11.tgz#c04704ef8f498b153130018993e56309d4698080" integrity sha512-KIq15bvQDrcCjpGjrAhx4mUlyyHfdmTaoNfeoATHLAiWB+MU3cx4lOzMwrnUh9cCxy0Lt1T11hAFY6TQgroUAA==