fix: Added linting rule to disable use of object prototypes (#2939)

This commit is contained in:
Wyatt Johnson
2020-04-17 17:12:36 +00:00
committed by GitHub
parent 5b92f7e968
commit 0e9621c499
10 changed files with 70 additions and 57 deletions
+11 -3
View File
@@ -37,7 +37,7 @@ export default class Entrypoints {
constructor(manifest: Manifest) {
for (const entry in manifest.entrypoints) {
if (!manifest.entrypoints.hasOwnProperty(entry)) {
if (!Object.prototype.hasOwnProperty.call(manifest.entrypoints, entry)) {
continue;
}
@@ -47,7 +47,12 @@ export default class Entrypoints {
// Itterate over the extension's in the entrypoint.
for (const extension in manifest.entrypoints[entry]) {
if (!manifest.entrypoints[entry].hasOwnProperty(extension)) {
if (
!Object.prototype.hasOwnProperty.call(
manifest.entrypoints[entry],
extension
)
) {
continue;
}
@@ -61,7 +66,10 @@ export default class Entrypoints {
for (const src of assets) {
// Search for the entry in the assets.
for (const name in manifest) {
if (name !== "entrypoints" && !manifest.hasOwnProperty(name)) {
if (
name !== "entrypoints" &&
!Object.prototype.hasOwnProperty.call(manifest, name)
) {
continue;
}
+1 -1
View File
@@ -20,7 +20,7 @@ export async function mapFieldsetToErrorCodes<T>(
if (err instanceof CoralError) {
// Then loop over all the fieldSpecs...
for (const param in errorMap) {
if (!errorMap.hasOwnProperty(param)) {
if (!Object.prototype.hasOwnProperty.call(errorMap, param)) {
continue;
}
+1 -1
View File
@@ -36,7 +36,7 @@ export function loadPersistedQueries(): PersistedQuery[] {
// Go over each of the persisted queries and collect the ID and query to
// merge in.
for (const id in persistedQueries) {
if (!persistedQueries.hasOwnProperty(id)) {
if (!Object.prototype.hasOwnProperty.call(persistedQueries, id)) {
continue;
}
+1 -1
View File
@@ -464,7 +464,7 @@ export function invertEncodedActionCounts(
actionCounts: EncodedCommentActionCounts
): EncodedCommentActionCounts {
for (const key in actionCounts) {
if (!actionCounts.hasOwnProperty(key)) {
if (!Object.prototype.hasOwnProperty.call(actionCounts, key)) {
continue;
}
@@ -101,7 +101,7 @@ export function mergeCommentStatusCount(
const mergedStatusCounts = createEmptyCommentStatusCounts();
for (const commentCounts of statusCounts) {
for (const status in commentCounts) {
if (!commentCounts.hasOwnProperty(status)) {
if (!Object.prototype.hasOwnProperty.call(commentCounts, status)) {
continue;
}
@@ -147,7 +147,7 @@ export function calculateTotalCommentCount(
): number {
let count = 0;
for (const status in commentCounts) {
if (!commentCounts.hasOwnProperty(status)) {
if (!Object.prototype.hasOwnProperty.call(commentCounts, status)) {
continue;
}
@@ -126,7 +126,7 @@ function fillAndConvertStringToNumber<
>(input: T, initial: U): U {
const result: U = Object.assign({}, initial);
for (const key in input) {
if (!input.hasOwnProperty(key)) {
if (!Object.prototype.hasOwnProperty.call(input, key)) {
continue;
}
@@ -51,7 +51,7 @@ class Scraper {
for (const rule of this.rules) {
for (const property in rule) {
if (!rule.hasOwnProperty(property)) {
if (!Object.prototype.hasOwnProperty.call(rule, property)) {
continue;
}