Skip to content

ESLint: mark unused arguments with underscore #2259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/starWarsSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ const queryType = new GraphQLObjectType({
type: episodeEnum,
},
},
resolve: (root, { episode }) => getHero(episode),
resolve: (_source, { episode }) => getHero(episode),
},
human: {
type: humanType,
Expand All @@ -269,7 +269,7 @@ const queryType = new GraphQLObjectType({
type: GraphQLNonNull(GraphQLString),
},
},
resolve: (root, { id }) => getHuman(id),
resolve: (_source, { id }) => getHuman(id),
},
droid: {
type: droidType,
Expand All @@ -279,7 +279,7 @@ const queryType = new GraphQLObjectType({
type: GraphQLNonNull(GraphQLString),
},
},
resolve: (root, { id }) => getDroid(id),
resolve: (_source, { id }) => getDroid(id),
},
}),
});
Expand Down
6 changes: 3 additions & 3 deletions src/execution/__tests__/executor-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/execution/__tests__/mutations-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Root {
}

promiseAndFailToChangeTheNumber(): Promise<NumberHolder> {
return new Promise((resolve, reject) => {
return new Promise((_resolve, reject) => {
process.nextTick(() => {
reject(new Error('Cannot change the number'));
});
Expand Down
2 changes: 1 addition & 1 deletion src/execution/__tests__/union-interface-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/language/__tests__/visitor-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()]);
},
Expand All @@ -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);
Expand All @@ -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);

Expand Down
14 changes: 5 additions & 9 deletions src/type/__tests__/enumType-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
},
},
Expand All @@ -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.
Expand All @@ -93,9 +93,7 @@ const MutationType = new GraphQLObjectType({
favoriteEnum: {
type: ColorType,
args: { color: { type: ColorType } },
resolve(value, { color }) {
return color;
},
resolve: (_source, { color }) => color,
},
},
});
Expand All @@ -106,9 +104,7 @@ const SubscriptionType = new GraphQLObjectType({
subscribeToEnum: {
type: ColorType,
args: { color: { type: ColorType } },
resolve(value, { color }) {
return color;
},
resolve: (_source, { color }) => color,
},
},
});
Expand Down
8 changes: 4 additions & 4 deletions src/type/introspection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -437,7 +437,7 @@ export const SchemaMetaFieldDef: GraphQLField<mixed, mixed> = {
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,
Expand All @@ -457,7 +457,7 @@ export const TypeMetaFieldDef: GraphQLField<mixed, mixed> = {
astNode: undefined,
},
],
resolve: (source, { name }, context, { schema }) => schema.getType(name),
resolve: (_source, { name }, _context, { schema }) => schema.getType(name),
deprecationReason: undefined,
extensions: undefined,
astNode: undefined,
Expand All @@ -468,7 +468,7 @@ export const TypeNameMetaFieldDef: GraphQLField<mixed, mixed> = {
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,
Expand Down
2 changes: 1 addition & 1 deletion src/validation/rules/FieldsOnCorrectType.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> {
Expand Down
2 changes: 1 addition & 1 deletion src/validation/rules/KnownDirectives.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down