Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-no-use-extend-native

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-no-use-extend-native - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

19

package.json
{
"name": "eslint-plugin-no-use-extend-native",
"version": "0.1.2",
"version": "0.1.3",
"description": "ESLint plugin to prevent use of extended native objects",
"main": "index.js",
"scripts": {

@@ -11,6 +10,3 @@ "prepublish": "npm test",

},
"repository": {
"type": "git",
"url": "git+https://github.com/dustinspecker/eslint-plugin-no-use-extend-native.git"
},
"repository": "dustinspecker/eslint-plugin-no-use-extend-native",
"keywords": [

@@ -20,10 +16,11 @@ "eslint",

"extend",
"native"
"native",
"prototype"
],
"author": "Dustin Specker",
"license": "MIT",
"bugs": {
"url": "https://github.com/dustinspecker/eslint-plugin-no-use-extend-native/issues"
},
"homepage": "https://github.com/dustinspecker/eslint-plugin-no-use-extend-native#readme",
"files": [
"index.js",
"rules"
],
"dependencies": {

@@ -30,0 +27,0 @@ "proto-props": "^0.1.0"

'use strict';
var protoProps = require('proto-props');
/**
* Return type of value of left or right
* @param {Object} o - left or right of node.object
* @return {String} - type of o
*/
function getType(o) {
var type = typeof o.value;
if (o.regex) {
return 'RegExp';
}
return type.charAt(0).toUpperCase() + type.slice(1);
}
/**
* Returns type of binary expression result
* @param {Object} o - node's object with a BinaryExpression type
* @return {String} - type of value produced
*/
function binaryExpressionProduces(o) {
var leftType = o.left.type === 'BinaryExpression' ? binaryExpressionProduces(o.left) : getType(o.left)
, rightType = o.right.type === 'BinaryExpression' ? binaryExpressionProduces(o.right) : getType(o.right);
if (leftType === 'String' || rightType === 'String' || leftType === rightType && leftType === 'RegExp') {
return 'String';
}
if (leftType === rightType) {
return leftType;
}
return 'Unknown';
}
module.exports = function (context) {

@@ -15,2 +50,4 @@ return {

proto = 'String';
} else if (node.object.type === 'BinaryExpression') {
proto = binaryExpressionProduces(node.object);
} else {

@@ -17,0 +54,0 @@ proto = node.object.type.replace('Expression', '');

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