eslint-plugin-no-use-extend-native
Advanced tools
Comparing version 0.1.2 to 0.1.3
{ | ||
"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', ''); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6469
5
61
1
2
1
1