From 3c6164ebdc0319a3a8ceb21a2e49af5a0d0a5ef8 Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Thu, 14 Nov 2019 18:25:25 +0200 Subject: [PATCH] ESLint: mark unused arguments with underscore --- .eslintrc.yml | 3 +-- src/__tests__/starWarsSchema.js | 6 +++--- src/execution/__tests__/executor-test.js | 6 +++--- src/execution/__tests__/mutations-test.js | 2 +- src/execution/__tests__/union-interface-test.js | 2 +- src/language/__tests__/visitor-test.js | 8 ++++---- src/type/__tests__/enumType-test.js | 14 +++++--------- src/type/introspection.js | 8 ++++---- src/validation/rules/FieldsOnCorrectType.js | 2 +- src/validation/rules/KnownDirectives.js | 2 +- 10 files changed, 24 insertions(+), 29 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index 5327b59090..9c56dd2300 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -189,8 +189,7 @@ rules: no-undef: error no-undef-init: error no-undefined: off - no-unused-vars: - [error, { vars: all, args: after-used, argsIgnorePattern: '^_' }] + no-unused-vars: [error, { vars: all, args: all, argsIgnorePattern: '^_' }] no-use-before-define: off # Node.js and CommonJS diff --git a/src/__tests__/starWarsSchema.js b/src/__tests__/starWarsSchema.js index 5e6c1d3203..df4586d12b 100644 --- a/src/__tests__/starWarsSchema.js +++ b/src/__tests__/starWarsSchema.js @@ -259,7 +259,7 @@ const queryType = new GraphQLObjectType({ type: episodeEnum, }, }, - resolve: (root, { episode }) => getHero(episode), + resolve: (_source, { episode }) => getHero(episode), }, human: { type: humanType, @@ -269,7 +269,7 @@ const queryType = new GraphQLObjectType({ type: GraphQLNonNull(GraphQLString), }, }, - resolve: (root, { id }) => getHuman(id), + resolve: (_source, { id }) => getHuman(id), }, droid: { type: droidType, @@ -279,7 +279,7 @@ const queryType = new GraphQLObjectType({ type: GraphQLNonNull(GraphQLString), }, }, - resolve: (root, { id }) => getDroid(id), + resolve: (_source, { id }) => getDroid(id), }, }), }); diff --git a/src/execution/__tests__/executor-test.js b/src/execution/__tests__/executor-test.js index 7d9ba3db94..4c3dbb4b0e 100644 --- a/src/execution/__tests__/executor-test.js +++ b/src/execution/__tests__/executor-test.js @@ -932,7 +932,7 @@ describe('Execute: Handles basic execution tasks', () => { fields: { field: { type: GraphQLString, - resolve: (data, args) => inspect(args), + resolve: (_source, args) => inspect(args), args: { a: { type: GraphQLBoolean }, b: { type: GraphQLBoolean }, @@ -1038,7 +1038,7 @@ describe('Execute: Handles basic execution tasks', () => { }); const document = parse('{ foo }'); - function fieldResolver(source, args, context, info) { + function fieldResolver(_source, _args, _context, info) { // For the purposes of test, just return the name of the field! return info.fieldName; } @@ -1076,7 +1076,7 @@ describe('Execute: Handles basic execution tasks', () => { }); let possibleTypes; - function typeResolver(source, context, info, abstractType) { + function typeResolver(_source, _context, info, abstractType) { // Resolver should be able to figure out all possible types on its own possibleTypes = info.schema.getPossibleTypes(abstractType); diff --git a/src/execution/__tests__/mutations-test.js b/src/execution/__tests__/mutations-test.js index 6e3567cb16..07f3c4ae00 100644 --- a/src/execution/__tests__/mutations-test.js +++ b/src/execution/__tests__/mutations-test.js @@ -44,7 +44,7 @@ class Root { } promiseAndFailToChangeTheNumber(): Promise { - return new Promise((resolve, reject) => { + return new Promise((_resolve, reject) => { process.nextTick(() => { reject(new Error('Cannot change the number')); }); diff --git a/src/execution/__tests__/union-interface-test.js b/src/execution/__tests__/union-interface-test.js index 7f9bd4223a..9dfd264f33 100644 --- a/src/execution/__tests__/union-interface-test.js +++ b/src/execution/__tests__/union-interface-test.js @@ -465,7 +465,7 @@ describe('Execute: Union and intersection types', () => { fields: { name: { type: GraphQLString }, }, - resolveType(obj, context, { schema: _schema, rootValue }) { + resolveType(_source, context, { schema: _schema, rootValue }) { encounteredContext = context; encounteredSchema = _schema; encounteredRootValue = rootValue; diff --git a/src/language/__tests__/visitor-test.js b/src/language/__tests__/visitor-test.js index ccbd333d05..5023c425a8 100644 --- a/src/language/__tests__/visitor-test.js +++ b/src/language/__tests__/visitor-test.js @@ -66,11 +66,11 @@ describe('Visitor', () => { const ast = parse('{ a }', { noLocation: true }); visit(ast, { - enter(node, key, parent, path) { + enter(_node, _key, _parent, path) { checkVisitorFnArgs(ast, arguments); visited.push(['enter', path.slice()]); }, - leave(node, key, parent, path) { + leave(_node, _key, _parent, path) { checkVisitorFnArgs(ast, arguments); visited.push(['leave', path.slice()]); }, @@ -95,7 +95,7 @@ describe('Visitor', () => { const visitedNodes = []; visit(ast, { - enter(node, key, parent, path, ancestors) { + enter(node, key, parent, _path, ancestors) { const inArray = typeof key === 'number'; if (inArray) { visitedNodes.push(parent); @@ -105,7 +105,7 @@ describe('Visitor', () => { const expectedAncestors = visitedNodes.slice(0, -2); expect(ancestors).to.deep.equal(expectedAncestors); }, - leave(node, key, parent, path, ancestors) { + leave(_node, key, _parent, _path, ancestors) { const expectedAncestors = visitedNodes.slice(0, -2); expect(ancestors).to.deep.equal(expectedAncestors); diff --git a/src/type/__tests__/enumType-test.js b/src/type/__tests__/enumType-test.js index 3607dba074..0b87bb45c6 100644 --- a/src/type/__tests__/enumType-test.js +++ b/src/type/__tests__/enumType-test.js @@ -40,7 +40,7 @@ const QueryType = new GraphQLObjectType({ fromInt: { type: GraphQLInt }, fromString: { type: GraphQLString }, }, - resolve(value, { fromEnum, fromInt, fromString }) { + resolve(_source, { fromEnum, fromInt, fromString }) { return fromInt !== undefined ? fromInt : fromString !== undefined @@ -54,7 +54,7 @@ const QueryType = new GraphQLObjectType({ fromEnum: { type: ColorType }, fromInt: { type: GraphQLInt }, }, - resolve(value, { fromEnum, fromInt }) { + resolve(_source, { fromEnum, fromInt }) { return fromInt !== undefined ? fromInt : fromEnum; }, }, @@ -70,7 +70,7 @@ const QueryType = new GraphQLObjectType({ provideGoodValue: { type: GraphQLBoolean }, provideBadValue: { type: GraphQLBoolean }, }, - resolve(value, { fromEnum, provideGoodValue, provideBadValue }) { + resolve(_source, { fromEnum, provideGoodValue, provideBadValue }) { if (provideGoodValue) { // Note: this is one of the references of the internal values which // ComplexEnum allows. @@ -93,9 +93,7 @@ const MutationType = new GraphQLObjectType({ favoriteEnum: { type: ColorType, args: { color: { type: ColorType } }, - resolve(value, { color }) { - return color; - }, + resolve: (_source, { color }) => color, }, }, }); @@ -106,9 +104,7 @@ const SubscriptionType = new GraphQLObjectType({ subscribeToEnum: { type: ColorType, args: { color: { type: ColorType } }, - resolve(value, { color }) { - return color; - }, + resolve: (_source, { color }) => color, }, }, }); diff --git a/src/type/introspection.js b/src/type/introspection.js index a48010e32e..a3b099462e 100644 --- a/src/type/introspection.js +++ b/src/type/introspection.js @@ -247,7 +247,7 @@ export const __Type = new GraphQLObjectType({ }, possibleTypes: { type: GraphQLList(GraphQLNonNull(__Type)), - resolve(type, args, context, { schema }) { + resolve(type, _args, _context, { schema }) { if (isAbstractType(type)) { return schema.getPossibleTypes(type); } @@ -437,7 +437,7 @@ export const SchemaMetaFieldDef: GraphQLField = { type: GraphQLNonNull(__Schema), description: 'Access the current type schema of this server.', args: [], - resolve: (source, args, context, { schema }) => schema, + resolve: (_source, _args, _context, { schema }) => schema, deprecationReason: undefined, extensions: undefined, astNode: undefined, @@ -457,7 +457,7 @@ export const TypeMetaFieldDef: GraphQLField = { astNode: undefined, }, ], - resolve: (source, { name }, context, { schema }) => schema.getType(name), + resolve: (_source, { name }, _context, { schema }) => schema.getType(name), deprecationReason: undefined, extensions: undefined, astNode: undefined, @@ -468,7 +468,7 @@ export const TypeNameMetaFieldDef: GraphQLField = { type: GraphQLNonNull(GraphQLString), description: 'The name of the current Object type at runtime.', args: [], - resolve: (source, args, context, { parentType }) => parentType.name, + resolve: (_source, _args, _context, { parentType }) => parentType.name, deprecationReason: undefined, extensions: undefined, astNode: undefined, diff --git a/src/validation/rules/FieldsOnCorrectType.js b/src/validation/rules/FieldsOnCorrectType.js index 29a64603a3..902df79447 100644 --- a/src/validation/rules/FieldsOnCorrectType.js +++ b/src/validation/rules/FieldsOnCorrectType.js @@ -110,7 +110,7 @@ function getSuggestedTypeNames( * that may be the result of a typo. */ function getSuggestedFieldNames( - schema: GraphQLSchema, + _schema: GraphQLSchema, type: GraphQLOutputType, fieldName: string, ): Array { diff --git a/src/validation/rules/KnownDirectives.js b/src/validation/rules/KnownDirectives.js index 5177b24172..8e2fbb1860 100644 --- a/src/validation/rules/KnownDirectives.js +++ b/src/validation/rules/KnownDirectives.js @@ -40,7 +40,7 @@ export function KnownDirectives( } return { - Directive(node, key, parent, path, ancestors) { + Directive(node, _key, _parent, _path, ancestors) { const name = node.name.value; const locations = locationsMap[name];