Socket
Socket
Sign inDemoInstall

eslint

Package Overview
Dependencies
Maintainers
1
Versions
369
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

lib/rules/no-negated-in-lhs.js

639

conf/environments.json

@@ -39,323 +39,334 @@ {

"browser": {
"addEventListener" : false,
"applicationCache" : false,
"ArrayBuffer" : false,
"atob" : false,
"Audio" : false,
"Blob" : false,
"blur" : false,
"btoa" : false,
"cancelAnimationFrame" : false,
"clearInterval" : false,
"clearTimeout" : false,
"close" : false,
"closed" : false,
"crypto" : false,
"DataView" : false,
"defaultStatus" : false,
"devicePixelRatio" : false,
"dispatchEvent" : false,
"document" : false,
"DOMParser" : false,
"Element" : false,
"FileReader" : false,
"find" : false,
"Float32Array" : false,
"Float64Array" : false,
"focus" : false,
"FormData" : false,
"frameElement" : false,
"frames" : false,
"getComputedStyle" : false,
"getSelection" : false,
"history" : false,
"HTMLAnchorElement" : false,
"HTMLBaseElement" : false,
"HTMLBodyElement" : false,
"HTMLBRElement" : false,
"HTMLButtonElement" : false,
"HTMLCanvasElement" : false,
"HTMLDirectoryElement" : false,
"HTMLDivElement" : false,
"HTMLDListElement" : false,
"HTMLElement" : false,
"HTMLFieldSetElement" : false,
"HTMLFontElement" : false,
"HTMLFormElement" : false,
"HTMLFrameElement" : false,
"HTMLFrameSetElement" : false,
"HTMLHeadElement" : false,
"HTMLHeadingElement" : false,
"HTMLHRElement" : false,
"HTMLHtmlElement" : false,
"HTMLIFrameElement" : false,
"HTMLImageElement" : false,
"HTMLInputElement" : false,
"HTMLLabelElement" : false,
"HTMLLegendElement" : false,
"HTMLLIElement" : false,
"HTMLLinkElement" : false,
"HTMLMapElement" : false,
"HTMLMenuElement" : false,
"HTMLMetaElement" : false,
"HTMLModElement" : false,
"HTMLObjectElement" : false,
"HTMLOListElement" : false,
"HTMLOptGroupElement" : false,
"HTMLOptionElement" : false,
"HTMLParagraphElement" : false,
"HTMLParamElement" : false,
"HTMLPreElement" : false,
"HTMLQuoteElement" : false,
"HTMLScriptElement" : false,
"HTMLSelectElement" : false,
"HTMLStyleElement" : false,
"HTMLTableCaptionElement" : false,
"HTMLTableCellElement" : false,
"HTMLTableColElement" : false,
"HTMLTableElement" : false,
"HTMLTableRowElement" : false,
"HTMLTableSectionElement" : false,
"HTMLTextAreaElement" : false,
"HTMLTitleElement" : false,
"HTMLUListElement" : false,
"HTMLVideoElement" : false,
"Image" : false,
"indexedDB" : false,
"innerHeight" : false,
"innerWidth" : false,
"Int16Array" : false,
"Int32Array" : false,
"Int8Array" : false,
"Intl" : false,
"length" : false,
"localStorage" : false,
"location" : false,
"matchMedia" : false,
"MessageChannel" : false,
"MessageEvent" : false,
"MessagePort" : false,
"moveBy" : false,
"moveTo" : false,
"MutationObserver" : false,
"name" : false,
"navigator" : false,
"Node" : false,
"NodeFilter" : false,
"onbeforeunload" : true,
"onblur" : true,
"onerror" : true,
"onfocus" : true,
"onload" : true,
"onresize" : true,
"onunload" : true,
"open" : false,
"openDatabase" : false,
"opener" : false,
"Option" : false,
"outerHeight" : false,
"outerWidth" : false,
"pageXOffset" : false,
"pageYOffset" : false,
"parent" : false,
"postMessage" : false,
"print" : false,
"removeEventListener" : false,
"requestAnimationFrame" : false,
"resizeBy" : false,
"resizeTo" : false,
"screen" : false,
"screenX" : false,
"screenY" : false,
"scroll" : false,
"scrollbars" : false,
"scrollBy" : false,
"scrollTo" : false,
"scrollX" : false,
"scrollY" : false,
"self" : false,
"sessionStorage" : false,
"setInterval" : false,
"setTimeout" : false,
"SharedWorker" : false,
"showModalDialog" : false,
"stop" : false,
"SVGAElement" : false,
"SVGAltGlyphDefElement" : false,
"SVGAltGlyphElement" : false,
"SVGAltGlyphItemElement" : false,
"SVGAngle" : false,
"SVGAnimateColorElement" : false,
"SVGAnimatedAngle" : false,
"SVGAnimatedBoolean" : false,
"SVGAnimatedEnumeration" : false,
"SVGAnimatedInteger" : false,
"SVGAnimatedLength" : false,
"SVGAnimatedLengthList" : false,
"SVGAnimatedNumber" : false,
"SVGAnimatedNumberList" : false,
"SVGAnimatedPreserveAspectRatio" : false,
"SVGAnimatedRect" : false,
"SVGAnimatedString" : false,
"SVGAnimatedTransformList" : false,
"SVGAnimateElement" : false,
"SVGAnimateMotionElement" : false,
"SVGAnimateTransformElement" : false,
"SVGAnimationElement" : false,
"SVGCircleElement" : false,
"SVGClipPathElement" : false,
"SVGColor" : false,
"SVGComponentTransferFunctionElement" : false,
"SVGCursorElement" : false,
"SVGDefsElement" : false,
"SVGDescElement" : false,
"SVGDocument" : false,
"SVGElement" : false,
"SVGElementInstance" : false,
"SVGElementInstanceList" : false,
"SVGEllipseElement" : false,
"SVGFEBlendElement" : false,
"SVGFEColorMatrixElement" : false,
"SVGFEComponentTransferElement" : false,
"SVGFECompositeElement" : false,
"SVGFEConvolveMatrixElement" : false,
"SVGFEDiffuseLightingElement" : false,
"SVGFEDisplacementMapElement" : false,
"SVGFEDistantLightElement" : false,
"SVGFEFloodElement" : false,
"SVGFEFuncAElement" : false,
"SVGFEFuncBElement" : false,
"SVGFEFuncGElement" : false,
"SVGFEFuncRElement" : false,
"SVGFEGaussianBlurElement" : false,
"SVGFEImageElement" : false,
"SVGFEMergeElement" : false,
"SVGFEMergeNodeElement" : false,
"SVGFEMorphologyElement" : false,
"SVGFEOffsetElement" : false,
"SVGFEPointLightElement" : false,
"SVGFESpecularLightingElement" : false,
"SVGFESpotLightElement" : false,
"SVGFETileElement" : false,
"SVGFETurbulenceElement" : false,
"SVGFilterElement" : false,
"SVGFontElement" : false,
"SVGFontFaceElement" : false,
"SVGFontFaceFormatElement" : false,
"SVGFontFaceNameElement" : false,
"SVGFontFaceSrcElement" : false,
"SVGFontFaceUriElement" : false,
"SVGForeignObjectElement" : false,
"SVGGElement" : false,
"SVGGlyphElement" : false,
"SVGGlyphRefElement" : false,
"SVGGradientElement" : false,
"SVGHKernElement" : false,
"SVGImageElement" : false,
"SVGLength" : false,
"SVGLengthList" : false,
"SVGLinearGradientElement" : false,
"SVGLineElement" : false,
"SVGMarkerElement" : false,
"SVGMaskElement" : false,
"SVGMatrix" : false,
"SVGMetadataElement" : false,
"SVGMissingGlyphElement" : false,
"SVGMPathElement" : false,
"SVGNumber" : false,
"SVGNumberList" : false,
"SVGPaint" : false,
"SVGPathElement" : false,
"SVGPathSeg" : false,
"SVGPathSegArcAbs" : false,
"SVGPathSegArcRel" : false,
"SVGPathSegClosePath" : false,
"SVGPathSegCurvetoCubicAbs" : false,
"SVGPathSegCurvetoCubicRel" : false,
"SVGPathSegCurvetoCubicSmoothAbs" : false,
"SVGPathSegCurvetoCubicSmoothRel" : false,
"SVGPathSegCurvetoQuadraticAbs" : false,
"SVGPathSegCurvetoQuadraticRel" : false,
"SVGPathSegCurvetoQuadraticSmoothAbs" : false,
"SVGPathSegCurvetoQuadraticSmoothRel" : false,
"SVGPathSegLinetoAbs" : false,
"SVGPathSegLinetoHorizontalAbs" : false,
"SVGPathSegLinetoHorizontalRel" : false,
"SVGPathSegLinetoRel" : false,
"SVGPathSegLinetoVerticalAbs" : false,
"SVGPathSegLinetoVerticalRel" : false,
"SVGPathSegList" : false,
"SVGPathSegMovetoAbs" : false,
"SVGPathSegMovetoRel" : false,
"SVGPatternElement" : false,
"SVGPoint" : false,
"SVGPointList" : false,
"SVGPolygonElement" : false,
"SVGPolylineElement" : false,
"SVGPreserveAspectRatio" : false,
"SVGRadialGradientElement" : false,
"SVGRect" : false,
"SVGRectElement" : false,
"SVGRenderingIntent" : false,
"SVGScriptElement" : false,
"SVGSetElement" : false,
"SVGStopElement" : false,
"SVGStringList" : false,
"SVGStyleElement" : false,
"SVGSVGElement" : false,
"SVGSwitchElement" : false,
"SVGSymbolElement" : false,
"SVGTextContentElement" : false,
"SVGTextElement" : false,
"SVGTextPathElement" : false,
"SVGTextPositioningElement" : false,
"SVGTitleElement" : false,
"SVGTransform" : false,
"SVGTransformList" : false,
"SVGTRefElement" : false,
"SVGTSpanElement" : false,
"SVGUnitTypes" : false,
"SVGUseElement" : false,
"SVGViewElement" : false,
"SVGViewSpec" : false,
"SVGVKernElement" : false,
"top" : false,
"Uint16Array" : false,
"Uint32Array" : false,
"Uint8Array" : false,
"Uint8ClampedArray" : false,
"WebSocket" : false,
"window" : false,
"Worker" : false,
"XMLHttpRequest" : false,
"XMLSerializer" : false,
"XPathEvaluator" : false,
"XPathExpression" : false,
"XPathResult" : false
"globals": {
"addEventListener" : false,
"applicationCache" : false,
"ArrayBuffer" : false,
"atob" : false,
"Audio" : false,
"Blob" : false,
"blur" : false,
"btoa" : false,
"cancelAnimationFrame" : false,
"clearInterval" : false,
"clearTimeout" : false,
"close" : false,
"closed" : false,
"crypto" : false,
"DataView" : false,
"defaultStatus" : false,
"devicePixelRatio" : false,
"dispatchEvent" : false,
"document" : false,
"DOMParser" : false,
"Element" : false,
"FileReader" : false,
"find" : false,
"Float32Array" : false,
"Float64Array" : false,
"focus" : false,
"FormData" : false,
"frameElement" : false,
"frames" : false,
"getComputedStyle" : false,
"getSelection" : false,
"history" : false,
"HTMLAnchorElement" : false,
"HTMLBaseElement" : false,
"HTMLBodyElement" : false,
"HTMLBRElement" : false,
"HTMLButtonElement" : false,
"HTMLCanvasElement" : false,
"HTMLDirectoryElement" : false,
"HTMLDivElement" : false,
"HTMLDListElement" : false,
"HTMLElement" : false,
"HTMLFieldSetElement" : false,
"HTMLFontElement" : false,
"HTMLFormElement" : false,
"HTMLFrameElement" : false,
"HTMLFrameSetElement" : false,
"HTMLHeadElement" : false,
"HTMLHeadingElement" : false,
"HTMLHRElement" : false,
"HTMLHtmlElement" : false,
"HTMLIFrameElement" : false,
"HTMLImageElement" : false,
"HTMLInputElement" : false,
"HTMLLabelElement" : false,
"HTMLLegendElement" : false,
"HTMLLIElement" : false,
"HTMLLinkElement" : false,
"HTMLMapElement" : false,
"HTMLMenuElement" : false,
"HTMLMetaElement" : false,
"HTMLModElement" : false,
"HTMLObjectElement" : false,
"HTMLOListElement" : false,
"HTMLOptGroupElement" : false,
"HTMLOptionElement" : false,
"HTMLParagraphElement" : false,
"HTMLParamElement" : false,
"HTMLPreElement" : false,
"HTMLQuoteElement" : false,
"HTMLScriptElement" : false,
"HTMLSelectElement" : false,
"HTMLStyleElement" : false,
"HTMLTableCaptionElement" : false,
"HTMLTableCellElement" : false,
"HTMLTableColElement" : false,
"HTMLTableElement" : false,
"HTMLTableRowElement" : false,
"HTMLTableSectionElement" : false,
"HTMLTextAreaElement" : false,
"HTMLTitleElement" : false,
"HTMLUListElement" : false,
"HTMLVideoElement" : false,
"Image" : false,
"indexedDB" : false,
"innerHeight" : false,
"innerWidth" : false,
"Int16Array" : false,
"Int32Array" : false,
"Int8Array" : false,
"Intl" : false,
"length" : false,
"localStorage" : false,
"location" : false,
"matchMedia" : false,
"MessageChannel" : false,
"MessageEvent" : false,
"MessagePort" : false,
"moveBy" : false,
"moveTo" : false,
"MutationObserver" : false,
"name" : false,
"navigator" : false,
"Node" : false,
"NodeFilter" : false,
"onbeforeunload" : true,
"onblur" : true,
"onerror" : true,
"onfocus" : true,
"onload" : true,
"onresize" : true,
"onunload" : true,
"open" : false,
"openDatabase" : false,
"opener" : false,
"Option" : false,
"outerHeight" : false,
"outerWidth" : false,
"pageXOffset" : false,
"pageYOffset" : false,
"parent" : false,
"postMessage" : false,
"print" : false,
"removeEventListener" : false,
"requestAnimationFrame" : false,
"resizeBy" : false,
"resizeTo" : false,
"screen" : false,
"screenX" : false,
"screenY" : false,
"scroll" : false,
"scrollbars" : false,
"scrollBy" : false,
"scrollTo" : false,
"scrollX" : false,
"scrollY" : false,
"self" : false,
"sessionStorage" : false,
"setInterval" : false,
"setTimeout" : false,
"SharedWorker" : false,
"showModalDialog" : false,
"stop" : false,
"SVGAElement" : false,
"SVGAltGlyphDefElement" : false,
"SVGAltGlyphElement" : false,
"SVGAltGlyphItemElement" : false,
"SVGAngle" : false,
"SVGAnimateColorElement" : false,
"SVGAnimatedAngle" : false,
"SVGAnimatedBoolean" : false,
"SVGAnimatedEnumeration" : false,
"SVGAnimatedInteger" : false,
"SVGAnimatedLength" : false,
"SVGAnimatedLengthList" : false,
"SVGAnimatedNumber" : false,
"SVGAnimatedNumberList" : false,
"SVGAnimatedPreserveAspectRatio" : false,
"SVGAnimatedRect" : false,
"SVGAnimatedString" : false,
"SVGAnimatedTransformList" : false,
"SVGAnimateElement" : false,
"SVGAnimateMotionElement" : false,
"SVGAnimateTransformElement" : false,
"SVGAnimationElement" : false,
"SVGCircleElement" : false,
"SVGClipPathElement" : false,
"SVGColor" : false,
"SVGComponentTransferFunctionElement" : false,
"SVGCursorElement" : false,
"SVGDefsElement" : false,
"SVGDescElement" : false,
"SVGDocument" : false,
"SVGElement" : false,
"SVGElementInstance" : false,
"SVGElementInstanceList" : false,
"SVGEllipseElement" : false,
"SVGFEBlendElement" : false,
"SVGFEColorMatrixElement" : false,
"SVGFEComponentTransferElement" : false,
"SVGFECompositeElement" : false,
"SVGFEConvolveMatrixElement" : false,
"SVGFEDiffuseLightingElement" : false,
"SVGFEDisplacementMapElement" : false,
"SVGFEDistantLightElement" : false,
"SVGFEFloodElement" : false,
"SVGFEFuncAElement" : false,
"SVGFEFuncBElement" : false,
"SVGFEFuncGElement" : false,
"SVGFEFuncRElement" : false,
"SVGFEGaussianBlurElement" : false,
"SVGFEImageElement" : false,
"SVGFEMergeElement" : false,
"SVGFEMergeNodeElement" : false,
"SVGFEMorphologyElement" : false,
"SVGFEOffsetElement" : false,
"SVGFEPointLightElement" : false,
"SVGFESpecularLightingElement" : false,
"SVGFESpotLightElement" : false,
"SVGFETileElement" : false,
"SVGFETurbulenceElement" : false,
"SVGFilterElement" : false,
"SVGFontElement" : false,
"SVGFontFaceElement" : false,
"SVGFontFaceFormatElement" : false,
"SVGFontFaceNameElement" : false,
"SVGFontFaceSrcElement" : false,
"SVGFontFaceUriElement" : false,
"SVGForeignObjectElement" : false,
"SVGGElement" : false,
"SVGGlyphElement" : false,
"SVGGlyphRefElement" : false,
"SVGGradientElement" : false,
"SVGHKernElement" : false,
"SVGImageElement" : false,
"SVGLength" : false,
"SVGLengthList" : false,
"SVGLinearGradientElement" : false,
"SVGLineElement" : false,
"SVGMarkerElement" : false,
"SVGMaskElement" : false,
"SVGMatrix" : false,
"SVGMetadataElement" : false,
"SVGMissingGlyphElement" : false,
"SVGMPathElement" : false,
"SVGNumber" : false,
"SVGNumberList" : false,
"SVGPaint" : false,
"SVGPathElement" : false,
"SVGPathSeg" : false,
"SVGPathSegArcAbs" : false,
"SVGPathSegArcRel" : false,
"SVGPathSegClosePath" : false,
"SVGPathSegCurvetoCubicAbs" : false,
"SVGPathSegCurvetoCubicRel" : false,
"SVGPathSegCurvetoCubicSmoothAbs" : false,
"SVGPathSegCurvetoCubicSmoothRel" : false,
"SVGPathSegCurvetoQuadraticAbs" : false,
"SVGPathSegCurvetoQuadraticRel" : false,
"SVGPathSegCurvetoQuadraticSmoothAbs" : false,
"SVGPathSegCurvetoQuadraticSmoothRel" : false,
"SVGPathSegLinetoAbs" : false,
"SVGPathSegLinetoHorizontalAbs" : false,
"SVGPathSegLinetoHorizontalRel" : false,
"SVGPathSegLinetoRel" : false,
"SVGPathSegLinetoVerticalAbs" : false,
"SVGPathSegLinetoVerticalRel" : false,
"SVGPathSegList" : false,
"SVGPathSegMovetoAbs" : false,
"SVGPathSegMovetoRel" : false,
"SVGPatternElement" : false,
"SVGPoint" : false,
"SVGPointList" : false,
"SVGPolygonElement" : false,
"SVGPolylineElement" : false,
"SVGPreserveAspectRatio" : false,
"SVGRadialGradientElement" : false,
"SVGRect" : false,
"SVGRectElement" : false,
"SVGRenderingIntent" : false,
"SVGScriptElement" : false,
"SVGSetElement" : false,
"SVGStopElement" : false,
"SVGStringList" : false,
"SVGStyleElement" : false,
"SVGSVGElement" : false,
"SVGSwitchElement" : false,
"SVGSymbolElement" : false,
"SVGTextContentElement" : false,
"SVGTextElement" : false,
"SVGTextPathElement" : false,
"SVGTextPositioningElement" : false,
"SVGTitleElement" : false,
"SVGTransform" : false,
"SVGTransformList" : false,
"SVGTRefElement" : false,
"SVGTSpanElement" : false,
"SVGUnitTypes" : false,
"SVGUseElement" : false,
"SVGViewElement" : false,
"SVGViewSpec" : false,
"SVGVKernElement" : false,
"top" : false,
"Uint16Array" : false,
"Uint32Array" : false,
"Uint8Array" : false,
"Uint8ClampedArray" : false,
"WebSocket" : false,
"window" : false,
"Worker" : false,
"XMLHttpRequest" : false,
"XMLSerializer" : false,
"XPathEvaluator" : false,
"XPathExpression" : false,
"XPathResult" : false
}
},
"node": {
"__filename" : false,
"__dirname" : false,
"Buffer" : false,
"DataView" : false,
"console" : false,
"exports" : true,
"GLOBAL" : false,
"global" : false,
"module" : false,
"process" : false,
"require" : false,
"setTimeout" : false,
"clearTimeout" : false,
"setInterval" : false,
"clearInterval" : false,
"setImmediate" : false,
"clearImmediate": false
"globals": {
"__filename" : false,
"__dirname" : false,
"Buffer" : false,
"DataView" : false,
"console" : false,
"exports" : true,
"GLOBAL" : false,
"global" : false,
"module" : false,
"process" : false,
"require" : false,
"setTimeout" : false,
"clearTimeout" : false,
"setInterval" : false,
"clearInterval" : false,
"setImmediate" : false,
"clearImmediate": false
},
"rules": {
"no-global-strict": 0,
"no-mixed-requires": 2
}
},
"amd": {
"require" : false,
"define" : false
"globals": {
"require" : false,
"define" : false
}
}
}

@@ -51,2 +51,3 @@ {

"no-self-compare": 0,
"no-spaced-func": 1,
"no-sync": 0,

@@ -65,2 +66,3 @@ "no-underscore-dangle": 2,

"no-redeclare": 2,
"no-negated-in-lhs": 2,

@@ -88,3 +90,2 @@ "brace-style": 0,

"semi": 2,
"smarter-eqeqeq": 0,
"strict": 2,

@@ -91,0 +92,0 @@ "unnecessary-strict": 2,

@@ -12,2 +12,3 @@ /**

path = require("path"),
environments = require("../conf/environments.json"),
util = require("./util");

@@ -44,3 +45,4 @@

/**
* Build a config object
* Build a config object merging the base config (conf/eslint.json), the
* environments config (conf/environments.json) and eventually the user config.
* @param {string} directory the directory to start looking for a local config

@@ -51,3 +53,4 @@ * @return {object} config object

var config,
customConfig;
userConfig,
envConfig = {};

@@ -62,9 +65,25 @@ directory = path.dirname(directory);

if (this.useSpecificConfig) {
customConfig = this.useSpecificConfig;
userConfig = this.useSpecificConfig;
} else {
customConfig = getLocalConfig.call(this, directory);
userConfig = getLocalConfig.call(this, directory);
}
this.cache[directory] = config = this.mergeConfigs(Object.create(this.baseConfig), customConfig);
if (userConfig.env) {
envConfig.rules = {};
Object.keys(userConfig.env).forEach(function (name) {
var environment = environments[name].rules;
if (userConfig.env[name] && environment) {
Object.keys(environment).forEach(function(name) {
envConfig.rules[name] = environment[name];
});
}
});
}
config = this.mergeConfigs(Object.create(this.baseConfig), envConfig);
config = this.mergeConfigs(config, userConfig);
this.cache[directory] = config;
return config;

@@ -71,0 +90,0 @@ };

@@ -77,3 +77,3 @@ /**

if (parseBoolean(value) && Object.hasOwnProperty.call(environments, name)) {
util.mixin(declaredGlobals, environments[name]);
util.mixin(declaredGlobals, environments[name].globals);
}

@@ -119,3 +119,3 @@ });

Object.keys(config.env).forEach(function (name) {
var environment = environments[name];
var environment = environments[name].globals;
if (config.env[name] && environment) {

@@ -288,3 +288,3 @@ Object.keys(environment).forEach(function(name) {

// gather data that may be needed by the rules
currentScopes = escope.analyze(ast).scopes;
currentScopes = escope.analyze(ast, { ignoreEval: true }).scopes;

@@ -349,12 +349,2 @@ /* get all tokens from the ast and store them as a hashtable to

/**
* Determines if the file should be interpreted as running in a Node.js
* environment instead of a browser environment.
* @returns {boolean} True if the file should be interpreted as running in
* a Node.js environment, false if not.
*/
api.isNodeJS = function() {
return currentConfig.env ? currentConfig.env.nodejs : false;
};
/**
* Gets the source code for the given node.

@@ -361,0 +351,0 @@ * @param {ASTNode} [node] The AST node to get the text for.

@@ -15,3 +15,2 @@ /**

"getAllComments",
"isNodeJS",
"getAncestors",

@@ -70,36 +69,5 @@ "getScope"

RuleContext.prototype = {
constructor: RuleContext,
/**
* Determines if an AST node matches a specific pattern. The pattern is simply
* a space-separated list of node types indicating the ancestry of the given node.
* @param {ASTNode} node The node to test.
* @param {string} pattern The pattern to test against.
* @returns {boolean} True if the pattern matches, false if not.
*/
match: function(node, pattern) {
var patternParts = pattern.split(/\s/g),
current = node;
/*
* The pattern is evaluated from right to left, so popping off the last item
* and comparing it to the current node repeats until there aren't any more
* parts to test. If the node doesn't match at any point, the operation
* is aborted.
*/
while (patternParts && current) {
if (current.type === patternParts.pop()) {
current = current.parent;
} else {
return false;
}
}
return true;
}
constructor: RuleContext
};
module.exports = RuleContext;

@@ -14,2 +14,12 @@ /**

function isTypeOf(node) {
return [node.left, node.right].some(function(node) {
return node.type === "UnaryExpression" && node.operator === "typeof";
});
}
function bothAreSameTypeLiterals(node) {
return node.left.type === "Literal" && node.right.type === "Literal" && typeof node.left.value === typeof node.right.value;
}
return {

@@ -19,2 +29,6 @@ "BinaryExpression": function(node) {

if (context.options[0] === "smart" && (isTypeOf(node) || bothAreSameTypeLiterals(node))) {
return;
}
if (operator === "==") {

@@ -27,2 +41,2 @@ context.report(node, "Expected '===' and instead saw '=='.");

};
};
};

@@ -25,3 +25,3 @@ /**

if (constructorName.charAt(0) === constructorName.charAt(0).toLowerCase()) {
if (constructorName && constructorName.charAt(0) === constructorName.charAt(0).toLowerCase()) {
context.report(node, "A constructor name should start with an uppercase letter.");

@@ -28,0 +28,0 @@ }

@@ -22,3 +22,4 @@ /**

var parent = context.getAncestors().pop();
if (parent.type === "NewExpression" && parent.callee.name === "RegExp") {
if ((parent.type === "NewExpression" || parent.type === "CallExpression") &&
parent.callee.type === "Identifier" && parent.callee.name === "RegExp") {

@@ -25,0 +26,0 @@ // there could be an invalid regular expression string

@@ -17,4 +17,6 @@ /**

"BinaryExpression": function(node) {
if (node.left.type === "Identifier" && node.right.type === "Identifier" && node.left.name === node.right.name ||
node.left.type === "Literal" && node.right.type === "Literal" && node.left.value === node.right.value) {
var operators = ["===", "==", "!==","!=", ">", "<", ">=", "<="];
if (operators.indexOf(node.operator) > -1 &&
(node.left.type === "Identifier" && node.right.type === "Identifier" && node.left.name === node.right.name ||
node.left.type === "Literal" && node.right.type === "Literal" && node.left.value === node.right.value)) {
context.report(node, "Comparing to itself is potentially pointless.");

@@ -21,0 +23,0 @@ }

@@ -14,5 +14,23 @@ /**

function isPragma(expression, parent) {
var isStrict = expression.type === "Literal" && expression.value === "use strict",
isGlobalStrict = isStrict && (parent.type === "Program" && parent.body[0].expression === expression),
isLocalStrict = isStrict && (parent.type === "BlockStatement" && parent.body[0].expression === expression);
return isGlobalStrict || isLocalStrict;
}
return {
"ExpressionStatement": function(node) {
if (node.expression.type !== "AssignmentExpression" && node.expression.type !== "CallExpression" && node.expression.type !== "NewExpression") {
var type = node.expression.type,
parent = context.getAncestors().pop();
if (
!/^(?:Assignment|Call|New|Update)Expression$/.test(type) &&
("UnaryExpression" !== type || "delete" !== node.expression.operator) &&
!isPragma(node.expression, parent)
) {
context.report(node, "Expected an assignment or function call and instead saw an expression.");

@@ -19,0 +37,0 @@ }

@@ -17,6 +17,6 @@ /**

"FunctionExpression": function(node) {
var ancestors = context.getAncestors();
if (ancestors.pop().type !== "CallExpression") {
if (!/CallExpression|NewExpression/.test(ancestors.pop().type)) {
var tokens = context.getTokens(node, 1, 1);

@@ -23,0 +23,0 @@ if (tokens[0].value === "(" && tokens[tokens.length - 1].value === ")") {

{
"name": "eslint",
"version": "0.1.1",
"version": "0.1.2",
"author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",

@@ -12,6 +12,13 @@ "description": "An Esprima-based pattern checker for JavaScript.",

"changelog": "bash scripts/changelog-update.sh",
"test": "bash scripts/test.sh",
"lint": "node node_modules/jshint/bin/jshint ./conf/eslint.json ./lib",
"test": "node ./node_modules/grunt-cli/bin/grunt test",
"lint": "node ./node_modules/grunt-cli/bin/grunt jshint",
"bundle": "bash scripts/bundle.sh"
},
"files": [
"LICENSE",
"README.md",
"bin",
"conf",
"lib"
],
"repository": {

@@ -25,3 +32,2 @@ "type": "git",

"esprima": "*",
"jshint": "*",
"escope": "1.0.0"

@@ -31,6 +37,15 @@ },

"vows": "~0.7.0",
"istanbul": "~0.1.10",
"sinon": "*",
"jshint": "~2.1.4",
"commonjs-everywhere": "~0.9.0"
"commonjs-everywhere": "~0.9.0",
"mocha": "~1.13.0",
"chai": "~1.8.1",
"grunt": "~0.4.1",
"grunt-contrib-jshint": "~0.6.4",
"grunt-vows-runner": "~0.6.0",
"grunt-istanbul-coverage": "0.0.2",
"grunt-istanbul": "~0.2.3",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-copy": "~0.4.1",
"grunt-cli": "~0.1.11",
"grunt-mocha-test": "~0.7.0"
},

@@ -37,0 +52,0 @@ "keywords": [

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