Skip to content

Commit e7c1fde

Browse files
Enable 'no-prototype-builtins' ESLint rule (#1888)
1 parent dec3cc5 commit e7c1fde

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

.eslintrc.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ rules:
8484
no-irregular-whitespace: error
8585
no-misleading-character-class: error
8686
no-obj-calls: error
87-
no-prototype-builtins: off # TODO
87+
no-prototype-builtins: error
8888
no-regex-spaces: error
8989
no-sparse-arrays: error
9090
no-template-curly-in-string: error

src/execution/__tests__/variables-test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function fieldWithInputArg(inputArg) {
8080
type: GraphQLString,
8181
args: { input: inputArg },
8282
resolve(_, args) {
83-
if (args.hasOwnProperty('input')) {
83+
if ('input' in args) {
8484
return inspect(args.input);
8585
}
8686
},

src/language/parser.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1424,7 +1424,7 @@ function parseDirectiveLocations(lexer: Lexer<*>): Array<NameNode> {
14241424
function parseDirectiveLocation(lexer: Lexer<*>): NameNode {
14251425
const start = lexer.token;
14261426
const name = parseName(lexer);
1427-
if (DirectiveLocation.hasOwnProperty(name.value)) {
1427+
if (DirectiveLocation[name.value] !== undefined) {
14281428
return name;
14291429
}
14301430
throw unexpected(lexer, start);

src/type/definition.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ function defineFieldMap<TSource, TContext>(
759759
`${config.name}.${fieldName} field config must be an object`,
760760
);
761761
invariant(
762-
!fieldConfig.hasOwnProperty('isDeprecated'),
762+
!('isDeprecated' in fieldConfig),
763763
`${config.name}.${fieldName} should provide "deprecationReason" ` +
764764
'instead of "isDeprecated".',
765765
);
@@ -1253,7 +1253,7 @@ function defineEnumValues(
12531253
`representing an internal value but got: ${inspect(value)}.`,
12541254
);
12551255
invariant(
1256-
!value.hasOwnProperty('isDeprecated'),
1256+
!('isDeprecated' in value),
12571257
`${type.name}.${valueName} should provide "deprecationReason" instead ` +
12581258
'of "isDeprecated".',
12591259
);
@@ -1263,7 +1263,7 @@ function defineEnumValues(
12631263
isDeprecated: Boolean(value.deprecationReason),
12641264
deprecationReason: value.deprecationReason,
12651265
astNode: value.astNode,
1266-
value: value.hasOwnProperty('value') ? value.value : valueName,
1266+
value: 'value' in value ? value.value : valueName,
12671267
};
12681268
});
12691269
}
@@ -1379,7 +1379,7 @@ function defineInputFieldMap(
13791379
);
13801380
return mapValue(fieldMap, (fieldConfig, fieldName) => {
13811381
invariant(
1382-
!fieldConfig.hasOwnProperty('resolve'),
1382+
!('resolve' in fieldConfig),
13831383
`${config.name}.${fieldName} field has a resolve property, but ` +
13841384
'Input Types cannot define resolvers.',
13851385
);

0 commit comments

Comments
 (0)