New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-hammerhead

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-hammerhead - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

20

lib/rules/proto-methods.js
module.exports = function (context) {
"use strict";
exports.ERR_MSG = 'You must use the native function';
var illegalArrayFuncNames = ['filter', 'forEach', 'every', 'map', 'some', 'reduce', 'reduceRight'];

@@ -10,8 +10,13 @@ return {

if (property && (property.name === 'call' || property.name === 'apply')) {
var childNode = node.callee.object.object;
if (property) {
if (property.name === 'call' || property.name === 'apply') {
var childNode = node.callee.object.object;
if (childNode && childNode.property && childNode.property.name === 'prototype' &&
childNode.object && (childNode.object.name === 'Array' || childNode.object.name === 'Object'))
return context.report(node, exports.ERR_MSG);
if (childNode && childNode.property && childNode.property.name === 'prototype' &&
childNode.object && (childNode.object.name === 'Array' || childNode.object.name === 'Object'))
return context.report(node, module.exports.USING_PROTO_DIRECTLY_ERR_MSG);
}
if (illegalArrayFuncNames.indexOf(property.name) !== -1)
return context.report(node, module.exports.USING_ILLEGAL_ARRAY_FUNC_ERR_MSG.replace('%s', property.name));
}

@@ -21,1 +26,4 @@ }

};
module.exports.USING_PROTO_DIRECTLY_ERR_MSG = 'Forbidden to call a function directly from the prototype Array or Object (GH-245)';
module.exports.USING_ILLEGAL_ARRAY_FUNC_ERR_MSG = 'Forbidden to use the "%s" function because it is slower than inline code and may be replaced by any framework (GH-245)';
{
"name": "eslint-plugin-hammerhead",
"version": "0.0.2",
"version": "0.0.3",
"description": "Specific rules for the hammerhead.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -15,3 +15,4 @@ 'use strict';

'savedArraySlice.apply(arguments, []);',
'savedObjectMethod.apply(x, [y]);'
'savedObjectMethod.apply(x, [y]);',
'filter();'
],

@@ -26,9 +27,37 @@

errors: [
{ message: rule.ERR_MSG },
{ message: rule.ERR_MSG },
{ message: rule.ERR_MSG },
{ message: rule.ERR_MSG }
{ message: rule.USING_PROTO_DIRECTLY_ERR_MSG },
{ message: rule.USING_PROTO_DIRECTLY_ERR_MSG },
{ message: rule.USING_PROTO_DIRECTLY_ERR_MSG },
{ message: rule.USING_PROTO_DIRECTLY_ERR_MSG }
]
},
{
code: 'arr.filter()',
errors: [{ message: rule.USING_ILLEGAL_ARRAY_FUNC_ERR_MSG.replace('%s', 'filter') }]
},
{
code: 'variable.forEach()',
errors: [{ message: rule.USING_ILLEGAL_ARRAY_FUNC_ERR_MSG.replace('%s', 'forEach') }]
},
{
code: 's.every()',
errors: [{ message: rule.USING_ILLEGAL_ARRAY_FUNC_ERR_MSG.replace('%s', 'every') }]
},
{
code: 'q1.map()',
errors: [{ message: rule.USING_ILLEGAL_ARRAY_FUNC_ERR_MSG.replace('%s', 'map') }]
},
{
code: '[2,3].some()',
errors: [{ message: rule.USING_ILLEGAL_ARRAY_FUNC_ERR_MSG.replace('%s', 'some') }]
},
{
code: 'x().reduce()',
errors: [{ message: rule.USING_ILLEGAL_ARRAY_FUNC_ERR_MSG.replace('%s', 'reduce') }]
},
{
code: 'sk.reduceRight()',
errors: [{ message: rule.USING_ILLEGAL_ARRAY_FUNC_ERR_MSG.replace('%s', 'reduceRight') }]
}
]
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc