fix: add "no-prototype-builtins" eslint-rule and fix all occurences
This commit is contained in:
committed by
Nils Knappmeier
parent
1988878087
commit
f7f05d7558
+2
-1
@@ -57,6 +57,7 @@ module.exports = {
|
||||
"no-with": "error",
|
||||
"radix": "error",
|
||||
"wrap-iife": "error",
|
||||
"no-prototype-builtins": "error",
|
||||
|
||||
|
||||
// Variables //
|
||||
@@ -114,4 +115,4 @@ module.exports = {
|
||||
"ecmaVersion": 6,
|
||||
"ecmaFeatures": {}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -29,7 +29,7 @@ BenchWarmer.prototype = {
|
||||
});
|
||||
},
|
||||
push: function(name, fn) {
|
||||
if (this.names.indexOf(name) == -1) {
|
||||
if (this.names.indexOf(name) === -1) {
|
||||
this.names.push(name);
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ BenchWarmer.prototype = {
|
||||
|
||||
var errors = false, prop, bench;
|
||||
for (prop in self.errors) {
|
||||
if (self.errors.hasOwnProperty(prop)
|
||||
if (Object.prototype.hasOwnProperty.call(self, prop)
|
||||
&& self.errors[prop].error.message !== 'EWOT') {
|
||||
errors = true;
|
||||
break;
|
||||
@@ -86,9 +86,8 @@ BenchWarmer.prototype = {
|
||||
|
||||
if (errors) {
|
||||
print('\n\nErrors:\n');
|
||||
for (prop in self.errors) {
|
||||
if (self.errors.hasOwnProperty(prop)
|
||||
&& self.errors[prop].error.message !== 'EWOT') {
|
||||
Object.keys(self.errors).forEach(function(prop) {
|
||||
if (self.errors[prop].error.message !== 'EWOT') {
|
||||
bench = self.errors[prop];
|
||||
print('\n' + bench.name + ':\n');
|
||||
print(bench.error.message);
|
||||
@@ -97,7 +96,7 @@ BenchWarmer.prototype = {
|
||||
}
|
||||
print('\n');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
callback();
|
||||
|
||||
@@ -125,14 +125,12 @@ CodeGen.prototype = {
|
||||
objectLiteral: function(obj) {
|
||||
let pairs = [];
|
||||
|
||||
for (let key in obj) {
|
||||
if (obj.hasOwnProperty(key)) {
|
||||
let value = castChunk(obj[key], this);
|
||||
if (value !== 'undefined') {
|
||||
pairs.push([this.quotedString(key), ':', value]);
|
||||
}
|
||||
Object.keys(obj).forEach(key => {
|
||||
let value = castChunk(obj[key], this);
|
||||
if (value !== 'undefined') {
|
||||
pairs.push([this.quotedString(key), ':', value]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
let ret = this.generateList(pairs);
|
||||
ret.prepend('{');
|
||||
|
||||
@@ -218,13 +218,13 @@ JavaScriptCompiler.prototype = {
|
||||
// aliases will not be used, but this case is already being run on the client and
|
||||
// we aren't concern about minimizing the template size.
|
||||
let aliasCount = 0;
|
||||
for (let alias in this.aliases) { // eslint-disable-line guard-for-in
|
||||
Object.keys(this.aliases).forEach(alias => {
|
||||
let node = this.aliases[alias];
|
||||
if (this.aliases.hasOwnProperty(alias) && node.children && node.referenceCount > 1) {
|
||||
if (node.children && node.referenceCount > 1) {
|
||||
varDeclarations += ', alias' + (++aliasCount) + '=' + alias;
|
||||
node.children[0] = 'alias' + aliasCount;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
let params = ['container', 'depth0', 'helpers', 'partials', 'data'];
|
||||
|
||||
|
||||
@@ -62,18 +62,16 @@ export default function(instance) {
|
||||
} else {
|
||||
let priorKey;
|
||||
|
||||
for (let key in context) {
|
||||
if (context.hasOwnProperty(key)) {
|
||||
// We're running the iterations one step out of sync so we can detect
|
||||
// the last iteration without have to scan the object twice and create
|
||||
// an itermediate keys array.
|
||||
if (priorKey !== undefined) {
|
||||
execIteration(priorKey, i - 1);
|
||||
}
|
||||
priorKey = key;
|
||||
i++;
|
||||
Object.keys(context).forEach(key => {
|
||||
// We're running the iterations one step out of sync so we can detect
|
||||
// the last iteration without have to scan the object twice and create
|
||||
// an itermediate keys array.
|
||||
if (priorKey !== undefined) {
|
||||
execIteration(priorKey, i - 1);
|
||||
}
|
||||
}
|
||||
priorKey = key;
|
||||
i++;
|
||||
});
|
||||
if (priorKey !== undefined) {
|
||||
execIteration(priorKey, i - 1, true);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ export default function(instance) {
|
||||
if (!obj) {
|
||||
return obj;
|
||||
}
|
||||
if (dangerousPropertyRegex.test(String(field)) && !obj.propertyIsEnumerable(field)) {
|
||||
if (dangerousPropertyRegex.test(String(field)) && !Object.prototype.propertyIsEnumerable.call(obj, field)) {
|
||||
return undefined;
|
||||
}
|
||||
return obj[field];
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ describe('compiler', function() {
|
||||
Handlebars.compile(' \n {{#if}}\n{{/def}}')();
|
||||
equal(true, false, 'Statement must throw exception. This line should not be executed.');
|
||||
} catch (err) {
|
||||
equal(err.propertyIsEnumerable('column'), true, 'Checking error column');
|
||||
equal(Object.prototype.propertyIsEnumerable.call(err, 'column'), true, 'Checking error column');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
+2
-2
@@ -211,12 +211,12 @@ describe('Regressions', function() {
|
||||
// It's valid to execute a block against an undefined context, but
|
||||
// helpers can not do so, so we expect to have an empty object here;
|
||||
for (var name in this) {
|
||||
if (this.hasOwnProperty(name)) {
|
||||
if (Object.prototype.hasOwnProperty.call(this, name)) {
|
||||
return 'found';
|
||||
}
|
||||
}
|
||||
// And to make IE happy, check for the known string as length is not enumerated.
|
||||
return (this == 'bat' ? 'found' : 'not');
|
||||
return (this === 'bat' ? 'found' : 'not');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user