From 23b427cacc3a6d16eb985ea3e5ab9b47d7a295d0 Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Sat, 25 Jan 2020 13:51:31 +0800 Subject: [PATCH] ESLint: enable bunch of TS lint rules (#2390) --- .eslintrc.yml | 4 ++-- src/type/definition.d.ts | 3 +-- src/type/definition.js | 3 +-- src/utilities/buildClientSchema.d.ts | 4 +--- src/utilities/buildClientSchema.js | 6 +----- 5 files changed, 6 insertions(+), 14 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index ea679a5859..6ceebaa758 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -461,7 +461,7 @@ overrides: '@typescript-eslint/member-ordering': off # TODO consider '@typescript-eslint/naming-convention': off # TODO consider '@typescript-eslint/no-dynamic-delete': off - '@typescript-eslint/no-empty-interface': off # TODO error + '@typescript-eslint/no-empty-interface': error '@typescript-eslint/no-explicit-any': off # TODO error '@typescript-eslint/no-extra-non-null-assertion': error '@typescript-eslint/no-extraneous-class': off # TODO consider @@ -503,7 +503,7 @@ overrides: '@typescript-eslint/triple-slash-reference': error '@typescript-eslint/typedef': off '@typescript-eslint/unbound-method': off # TODO consider - '@typescript-eslint/unified-signatures': off # TODO error + '@typescript-eslint/unified-signatures': error # Extension Rules # https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin#extension-rules diff --git a/src/type/definition.d.ts b/src/type/definition.d.ts index 954c2c7ac1..2f07ff9b9c 100644 --- a/src/type/definition.d.ts +++ b/src/type/definition.d.ts @@ -238,9 +238,8 @@ export function isNullableType(type: any): type is GraphQLNullableType; export function assertNullableType(type: any): GraphQLNullableType; export function getNullableType(type: void): undefined; -export function getNullableType(type: T): T; export function getNullableType( - type: GraphQLNonNull, + type: GraphQLNonNull | T, ): T; /** diff --git a/src/type/definition.js b/src/type/definition.js index 798bf4a77c..8ab7939cd8 100644 --- a/src/type/definition.js +++ b/src/type/definition.js @@ -474,8 +474,7 @@ export function assertNullableType(type: mixed): GraphQLNullableType { /* eslint-disable no-redeclare */ declare function getNullableType(type: void | null): void; -declare function getNullableType(type: T): T; -declare function getNullableType(type: GraphQLNonNull): T; +declare function getNullableType(type: GraphQLNonNull | T): T; export function getNullableType(type) { /* eslint-enable no-redeclare */ if (type) { diff --git a/src/utilities/buildClientSchema.d.ts b/src/utilities/buildClientSchema.d.ts index 1da5bb8a2f..a541cd307d 100644 --- a/src/utilities/buildClientSchema.d.ts +++ b/src/utilities/buildClientSchema.d.ts @@ -2,8 +2,6 @@ import { GraphQLSchema, GraphQLSchemaValidationOptions } from '../type/schema'; import { IntrospectionQuery } from './getIntrospectionQuery'; -interface Options extends GraphQLSchemaValidationOptions {} - /** * Build a GraphQLSchema for use by client tools. * @@ -18,5 +16,5 @@ interface Options extends GraphQLSchemaValidationOptions {} */ export function buildClientSchema( introspection: IntrospectionQuery, - options?: Options, + options?: GraphQLSchemaValidationOptions, ): GraphQLSchema; diff --git a/src/utilities/buildClientSchema.js b/src/utilities/buildClientSchema.js index 8c8566f57f..ba0b2ab57b 100644 --- a/src/utilities/buildClientSchema.js +++ b/src/utilities/buildClientSchema.js @@ -52,10 +52,6 @@ import { type IntrospectionNamedTypeRef, } from './getIntrospectionQuery'; -type Options = {| - ...GraphQLSchemaValidationOptions, -|}; - /** * Build a GraphQLSchema for use by client tools. * @@ -70,7 +66,7 @@ type Options = {| */ export function buildClientSchema( introspection: IntrospectionQuery, - options?: Options, + options?: GraphQLSchemaValidationOptions, ): GraphQLSchema { devAssert( isObjectLike(introspection) && isObjectLike(introspection.__schema),