Skip to content

Commit

Permalink
Enable 'no-prototype-builtins' ESLint rule (#1888)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed May 21, 2019
1 parent dec3cc5 commit e7c1fde
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.yml
Expand Up @@ -84,7 +84,7 @@ rules:
no-irregular-whitespace: error
no-misleading-character-class: error
no-obj-calls: error
no-prototype-builtins: off # TODO
no-prototype-builtins: error
no-regex-spaces: error
no-sparse-arrays: error
no-template-curly-in-string: error
Expand Down
2 changes: 1 addition & 1 deletion src/execution/__tests__/variables-test.js
Expand Up @@ -80,7 +80,7 @@ function fieldWithInputArg(inputArg) {
type: GraphQLString,
args: { input: inputArg },
resolve(_, args) {
if (args.hasOwnProperty('input')) {
if ('input' in args) {
return inspect(args.input);
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/language/parser.js
Expand Up @@ -1424,7 +1424,7 @@ function parseDirectiveLocations(lexer: Lexer<*>): Array<NameNode> {
function parseDirectiveLocation(lexer: Lexer<*>): NameNode {
const start = lexer.token;
const name = parseName(lexer);
if (DirectiveLocation.hasOwnProperty(name.value)) {
if (DirectiveLocation[name.value] !== undefined) {
return name;
}
throw unexpected(lexer, start);
Expand Down
8 changes: 4 additions & 4 deletions src/type/definition.js
Expand Up @@ -759,7 +759,7 @@ function defineFieldMap<TSource, TContext>(
`${config.name}.${fieldName} field config must be an object`,
);
invariant(
!fieldConfig.hasOwnProperty('isDeprecated'),
!('isDeprecated' in fieldConfig),
`${config.name}.${fieldName} should provide "deprecationReason" ` +
'instead of "isDeprecated".',
);
Expand Down Expand Up @@ -1253,7 +1253,7 @@ function defineEnumValues(
`representing an internal value but got: ${inspect(value)}.`,
);
invariant(
!value.hasOwnProperty('isDeprecated'),
!('isDeprecated' in value),
`${type.name}.${valueName} should provide "deprecationReason" instead ` +
'of "isDeprecated".',
);
Expand All @@ -1263,7 +1263,7 @@ function defineEnumValues(
isDeprecated: Boolean(value.deprecationReason),
deprecationReason: value.deprecationReason,
astNode: value.astNode,
value: value.hasOwnProperty('value') ? value.value : valueName,
value: 'value' in value ? value.value : valueName,
};
});
}
Expand Down Expand Up @@ -1379,7 +1379,7 @@ function defineInputFieldMap(
);
return mapValue(fieldMap, (fieldConfig, fieldName) => {
invariant(
!fieldConfig.hasOwnProperty('resolve'),
!('resolve' in fieldConfig),
`${config.name}.${fieldName} field has a resolve property, but ` +
'Input Types cannot define resolvers.',
);
Expand Down

0 comments on commit e7c1fde

Please sign in to comment.