Skip to content

Commit ed2563b

Browse files
ESLint: mark unused arguments with underscore (#2259)
1 parent 53df69a commit ed2563b

File tree

10 files changed

+24
-29
lines changed

10 files changed

+24
-29
lines changed

.eslintrc.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,7 @@ rules:
189189
no-undef: error
190190
no-undef-init: error
191191
no-undefined: off
192-
no-unused-vars:
193-
[error, { vars: all, args: after-used, argsIgnorePattern: '^_' }]
192+
no-unused-vars: [error, { vars: all, args: all, argsIgnorePattern: '^_' }]
194193
no-use-before-define: off
195194

196195
# Node.js and CommonJS

src/__tests__/starWarsSchema.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ const queryType = new GraphQLObjectType({
259259
type: episodeEnum,
260260
},
261261
},
262-
resolve: (root, { episode }) => getHero(episode),
262+
resolve: (_source, { episode }) => getHero(episode),
263263
},
264264
human: {
265265
type: humanType,
@@ -269,7 +269,7 @@ const queryType = new GraphQLObjectType({
269269
type: GraphQLNonNull(GraphQLString),
270270
},
271271
},
272-
resolve: (root, { id }) => getHuman(id),
272+
resolve: (_source, { id }) => getHuman(id),
273273
},
274274
droid: {
275275
type: droidType,
@@ -279,7 +279,7 @@ const queryType = new GraphQLObjectType({
279279
type: GraphQLNonNull(GraphQLString),
280280
},
281281
},
282-
resolve: (root, { id }) => getDroid(id),
282+
resolve: (_source, { id }) => getDroid(id),
283283
},
284284
}),
285285
});

src/execution/__tests__/executor-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,7 @@ describe('Execute: Handles basic execution tasks', () => {
932932
fields: {
933933
field: {
934934
type: GraphQLString,
935-
resolve: (data, args) => inspect(args),
935+
resolve: (_source, args) => inspect(args),
936936
args: {
937937
a: { type: GraphQLBoolean },
938938
b: { type: GraphQLBoolean },
@@ -1038,7 +1038,7 @@ describe('Execute: Handles basic execution tasks', () => {
10381038
});
10391039
const document = parse('{ foo }');
10401040

1041-
function fieldResolver(source, args, context, info) {
1041+
function fieldResolver(_source, _args, _context, info) {
10421042
// For the purposes of test, just return the name of the field!
10431043
return info.fieldName;
10441044
}
@@ -1076,7 +1076,7 @@ describe('Execute: Handles basic execution tasks', () => {
10761076
});
10771077

10781078
let possibleTypes;
1079-
function typeResolver(source, context, info, abstractType) {
1079+
function typeResolver(_source, _context, info, abstractType) {
10801080
// Resolver should be able to figure out all possible types on its own
10811081
possibleTypes = info.schema.getPossibleTypes(abstractType);
10821082

src/execution/__tests__/mutations-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class Root {
4444
}
4545

4646
promiseAndFailToChangeTheNumber(): Promise<NumberHolder> {
47-
return new Promise((resolve, reject) => {
47+
return new Promise((_resolve, reject) => {
4848
process.nextTick(() => {
4949
reject(new Error('Cannot change the number'));
5050
});

src/execution/__tests__/union-interface-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ describe('Execute: Union and intersection types', () => {
465465
fields: {
466466
name: { type: GraphQLString },
467467
},
468-
resolveType(obj, context, { schema: _schema, rootValue }) {
468+
resolveType(_source, context, { schema: _schema, rootValue }) {
469469
encounteredContext = context;
470470
encounteredSchema = _schema;
471471
encounteredRootValue = rootValue;

src/language/__tests__/visitor-test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ describe('Visitor', () => {
6666
const ast = parse('{ a }', { noLocation: true });
6767

6868
visit(ast, {
69-
enter(node, key, parent, path) {
69+
enter(_node, _key, _parent, path) {
7070
checkVisitorFnArgs(ast, arguments);
7171
visited.push(['enter', path.slice()]);
7272
},
73-
leave(node, key, parent, path) {
73+
leave(_node, _key, _parent, path) {
7474
checkVisitorFnArgs(ast, arguments);
7575
visited.push(['leave', path.slice()]);
7676
},
@@ -95,7 +95,7 @@ describe('Visitor', () => {
9595
const visitedNodes = [];
9696

9797
visit(ast, {
98-
enter(node, key, parent, path, ancestors) {
98+
enter(node, key, parent, _path, ancestors) {
9999
const inArray = typeof key === 'number';
100100
if (inArray) {
101101
visitedNodes.push(parent);
@@ -105,7 +105,7 @@ describe('Visitor', () => {
105105
const expectedAncestors = visitedNodes.slice(0, -2);
106106
expect(ancestors).to.deep.equal(expectedAncestors);
107107
},
108-
leave(node, key, parent, path, ancestors) {
108+
leave(_node, key, _parent, _path, ancestors) {
109109
const expectedAncestors = visitedNodes.slice(0, -2);
110110
expect(ancestors).to.deep.equal(expectedAncestors);
111111

src/type/__tests__/enumType-test.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const QueryType = new GraphQLObjectType({
4040
fromInt: { type: GraphQLInt },
4141
fromString: { type: GraphQLString },
4242
},
43-
resolve(value, { fromEnum, fromInt, fromString }) {
43+
resolve(_source, { fromEnum, fromInt, fromString }) {
4444
return fromInt !== undefined
4545
? fromInt
4646
: fromString !== undefined
@@ -54,7 +54,7 @@ const QueryType = new GraphQLObjectType({
5454
fromEnum: { type: ColorType },
5555
fromInt: { type: GraphQLInt },
5656
},
57-
resolve(value, { fromEnum, fromInt }) {
57+
resolve(_source, { fromEnum, fromInt }) {
5858
return fromInt !== undefined ? fromInt : fromEnum;
5959
},
6060
},
@@ -70,7 +70,7 @@ const QueryType = new GraphQLObjectType({
7070
provideGoodValue: { type: GraphQLBoolean },
7171
provideBadValue: { type: GraphQLBoolean },
7272
},
73-
resolve(value, { fromEnum, provideGoodValue, provideBadValue }) {
73+
resolve(_source, { fromEnum, provideGoodValue, provideBadValue }) {
7474
if (provideGoodValue) {
7575
// Note: this is one of the references of the internal values which
7676
// ComplexEnum allows.
@@ -93,9 +93,7 @@ const MutationType = new GraphQLObjectType({
9393
favoriteEnum: {
9494
type: ColorType,
9595
args: { color: { type: ColorType } },
96-
resolve(value, { color }) {
97-
return color;
98-
},
96+
resolve: (_source, { color }) => color,
9997
},
10098
},
10199
});
@@ -106,9 +104,7 @@ const SubscriptionType = new GraphQLObjectType({
106104
subscribeToEnum: {
107105
type: ColorType,
108106
args: { color: { type: ColorType } },
109-
resolve(value, { color }) {
110-
return color;
111-
},
107+
resolve: (_source, { color }) => color,
112108
},
113109
},
114110
});

src/type/introspection.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ export const __Type = new GraphQLObjectType({
247247
},
248248
possibleTypes: {
249249
type: GraphQLList(GraphQLNonNull(__Type)),
250-
resolve(type, args, context, { schema }) {
250+
resolve(type, _args, _context, { schema }) {
251251
if (isAbstractType(type)) {
252252
return schema.getPossibleTypes(type);
253253
}
@@ -437,7 +437,7 @@ export const SchemaMetaFieldDef: GraphQLField<mixed, mixed> = {
437437
type: GraphQLNonNull(__Schema),
438438
description: 'Access the current type schema of this server.',
439439
args: [],
440-
resolve: (source, args, context, { schema }) => schema,
440+
resolve: (_source, _args, _context, { schema }) => schema,
441441
deprecationReason: undefined,
442442
extensions: undefined,
443443
astNode: undefined,
@@ -457,7 +457,7 @@ export const TypeMetaFieldDef: GraphQLField<mixed, mixed> = {
457457
astNode: undefined,
458458
},
459459
],
460-
resolve: (source, { name }, context, { schema }) => schema.getType(name),
460+
resolve: (_source, { name }, _context, { schema }) => schema.getType(name),
461461
deprecationReason: undefined,
462462
extensions: undefined,
463463
astNode: undefined,
@@ -468,7 +468,7 @@ export const TypeNameMetaFieldDef: GraphQLField<mixed, mixed> = {
468468
type: GraphQLNonNull(GraphQLString),
469469
description: 'The name of the current Object type at runtime.',
470470
args: [],
471-
resolve: (source, args, context, { parentType }) => parentType.name,
471+
resolve: (_source, _args, _context, { parentType }) => parentType.name,
472472
deprecationReason: undefined,
473473
extensions: undefined,
474474
astNode: undefined,

src/validation/rules/FieldsOnCorrectType.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ function getSuggestedTypeNames(
110110
* that may be the result of a typo.
111111
*/
112112
function getSuggestedFieldNames(
113-
schema: GraphQLSchema,
113+
_schema: GraphQLSchema,
114114
type: GraphQLOutputType,
115115
fieldName: string,
116116
): Array<string> {

src/validation/rules/KnownDirectives.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export function KnownDirectives(
4040
}
4141

4242
return {
43-
Directive(node, key, parent, path, ancestors) {
43+
Directive(node, _key, _parent, _path, ancestors) {
4444
const name = node.name.value;
4545
const locations = locationsMap[name];
4646

0 commit comments

Comments
 (0)