Skip to content
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

Enable 'no-prototype-builtins' ESLint rule #1888

Merged
merged 1 commit into from May 21, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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