diff --git a/.eslintrc.yml b/.eslintrc.yml index 496ee220c2..d8719a90e9 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -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 diff --git a/src/execution/__tests__/variables-test.js b/src/execution/__tests__/variables-test.js index 4aa8cac98a..f833194328 100644 --- a/src/execution/__tests__/variables-test.js +++ b/src/execution/__tests__/variables-test.js @@ -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); } }, diff --git a/src/language/parser.js b/src/language/parser.js index aa0bf952bf..491d400743 100644 --- a/src/language/parser.js +++ b/src/language/parser.js @@ -1424,7 +1424,7 @@ function parseDirectiveLocations(lexer: Lexer<*>): Array { 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); diff --git a/src/type/definition.js b/src/type/definition.js index 43873407ba..6eab19ce00 100644 --- a/src/type/definition.js +++ b/src/type/definition.js @@ -759,7 +759,7 @@ function defineFieldMap( `${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".', ); @@ -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".', ); @@ -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, }; }); } @@ -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.', );