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

eslint

Package Overview
Dependencies
Maintainers
1
Versions
372
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.4.0 to 0.4.1

lib/formatters/tap.js

2

conf/eslint.json

@@ -17,2 +17,3 @@ {

"no-console": 2,
"no-constant-condition": 2,
"no-control-regex": 2,

@@ -109,2 +110,3 @@ "no-debugger": 2,

"sort-vars": 0,
"space-in-brackets": [0, "never"],
"space-infix-ops": 2,

@@ -111,0 +113,0 @@ "space-return-throw-case": 2,

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

* Get a local config object.
* @param {Config} helper The configuration helper to use.
* @param {string} directory the directory to start looking for a local config

@@ -79,0 +80,0 @@ * @returns {Object} the local config object (empty object if there is no local config)

25

lib/eslint.js

@@ -29,6 +29,6 @@ /**

/**
* Parses a list of "option:value" options from a string and invokes the callback
* on each option-value pair.
* @param {string} string
* @param {function} callback
* Parses a list of "name:value" options from a string and invokes the callback
* on each name-value pair.
* @param {string} string The string to parse.
* @param {Function} callback The function to call for each name-value pair.
* @returns {void}

@@ -86,5 +86,5 @@ */

/**
* @param {Scope} scope
* @param {string} name
* @returns {Variable}
* @param {Scope} scope The scope object to check.
* @param {string} name The name of the variable to look up.
* @returns {Variable} The variable object if found or null if not.
*/

@@ -97,4 +97,6 @@ function getVariable(scope, name) {

return true;
} else {
return false;
}
return false;
});

@@ -110,2 +112,3 @@ return variable;

* @param {Scope} globalScope The global scope.
* @param {Object} config The existing configuration data.
* @returns {void}

@@ -313,3 +316,4 @@ */

} catch(ex) {
throw new Error("Error while loading rule '" + key + "'.");
ex.message = "Error while loading rule '" + key + "': " + ex.message;
throw ex;
}

@@ -508,3 +512,4 @@

// first global function has its comments stolen by Program
return findJSDocComment(((parent.type === "Program") ? parent : node).leadingComments);
var nodeToCheck = (node.leadingComments ? node : parent);
return findJSDocComment(nodeToCheck.leadingComments);

@@ -511,0 +516,0 @@ case "FunctionExpression":

@@ -22,8 +22,8 @@ /**

*
* @param {String} message to escape
* @return escaped message as {String}
* @param {string} message to escape
* @returns {string} escaped message
*/
function escapeSpecialCharacters(str) {
function escapeSpecialCharacters(message) {
str = str || "";
message = message || "";
var pairs = {

@@ -37,3 +37,3 @@ "&": "&",

return str.replace(/[&"'<>]/g, function(c) {
return message.replace(/[&"'<>]/g, function(c) {
return pairs[c];

@@ -40,0 +40,0 @@ });

@@ -42,8 +42,8 @@ /**

*
* @param {String} message to escape
* @return escaped message as {String}
* @param {string} message message to escape
* @returns {string} escaped message
*/
function escapeSpecialCharacters(str) {
function escapeSpecialCharacters(message) {
str = str || "";
message = message || "";
var pairs = {

@@ -57,3 +57,3 @@ "&": "&amp;",

return str.replace(/[&"'<>]/g, function(c) {
return message.replace(/[&"'<>]/g, function(c) {
return pairs[c];

@@ -60,0 +60,0 @@ });

@@ -55,5 +55,5 @@ /**

getMessageType(message, rules),
chalk.blue(message.message.replace(/\.$/, "")),
message.message.replace(/\.$/, ""),
chalk.gray(message.ruleId)
]
];
}),

@@ -60,0 +60,0 @@ {

@@ -23,10 +23,9 @@ /**

node.properties.forEach(function(property) {
var keyName = property.key.name || property.key.value;
var key = property.kind + "-" + keyName;
// Create a safe key by prefixing with "$-".
var safeKey = "$-" + (property.key.name || property.key.value);
if (nodeProps[safeKey]) {
context.report(node, "Duplicate key '{{key}}'.", { key: safeKey.split("-")[1] });
if (nodeProps[key]) {
context.report(node, "Duplicate key '{{key}}'.", { key: keyName });
} else {
nodeProps[safeKey] = true;
nodeProps[key] = true;
}

@@ -33,0 +32,0 @@ });

@@ -19,4 +19,4 @@ /**

* Gets the declared variable, defined in `scope`, that `ref` refers to.
* @param {Scope} scope
* @param {Reference} ref
* @param {Scope} scope The scope in which to search.
* @param {Reference} ref The reference to find in the scope.
* @returns {Variable} The variable, or null if ref refers to an undeclared variable.

@@ -23,0 +23,0 @@ */

@@ -21,3 +21,3 @@ /**

if (node.arguments.length === 1) {
if (node.arguments.length < 2) {
context.report(node, "Missing radix parameter.");

@@ -24,0 +24,0 @@ } else {

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

var always = context.options[0] !== "never";
//--------------------------------------------------------------------------

@@ -19,18 +21,30 @@ // Helpers

function checkTokenForSemicolon(node, token) {
if (token.type !== "Punctuator" || token.value !== ";") {
context.report(node, node.loc.end, "Missing semicolon.");
}
}
/**
* Checks a node to see if it's followed by a semicolon.
* @param {ASTNode} node The node to check.
* @returns {void}
*/
function checkForSemicolon(node) {
function checkForSemicolon(node) {
// get tokens for the node plus one more token at the end
var tokens = context.getTokens(node),
nextToken = tokens.pop();
token = tokens.pop();
checkTokenForSemicolon(node, nextToken);
if (always) {
if (token.type !== "Punctuator" || token.value !== ";") {
context.report(node, node.loc.end, "Missing semicolon.");
}
} else {
if (token.type === "Punctuator" && token.value === ";") {
context.report(node, node.loc.end, "Extra semicolon.");
}
}
}
/**
* Checks to see if there's a semicolon after a variable declaration.
* @param {ASTNode} node The node to check.
* @returns {void}
*/
function checkForSemicolonForVariableDeclaration(node) {
// get tokens for the node plus one more token at the end
var ancestors = context.getAncestors(),

@@ -54,6 +68,24 @@ parentIndex = ancestors.length - 1,

"VariableDeclaration": checkForSemicolonForVariableDeclaration,
"ExpressionStatement": checkForSemicolon
"ExpressionStatement": checkForSemicolon,
"ReturnStatement": checkForSemicolon,
"DebuggerStatement": checkForSemicolon,
"BreakStatement": checkForSemicolon,
"ContinueStatement": checkForSemicolon,
"EmptyStatement": function (node) {
var tokens,
token;
if (!always) {
tokens = context.getTokens(node, 0, 1);
token = tokens.pop();
if (!(/[\[\(\/\+\-]/.test(token.value))) {
context.report(node, "Extra semicolon.");
}
}
}
};
};

@@ -19,2 +19,5 @@ /**

var options = context.options[0] || {},
prefer = options.prefer || {};
//--------------------------------------------------------------------------

@@ -24,2 +27,7 @@ // Helpers

/**
* Validate the JSDoc node and output warnings if anything is wrong.
* @param {ASTNode} node The AST node to check.
* @returns {void}
*/
function checkJSDoc(node) {

@@ -73,6 +81,2 @@ var jsdocNode = context.getJSDocComment(node),

case "return":
hasReturns = true;
context.report(jsdocNode, "Use @returns instead.");
break;
case "returns":

@@ -95,2 +99,7 @@ hasReturns = true;

// check tag preferences
if (prefer.hasOwnProperty(tag.title)) {
context.report(jsdocNode, "Use @{{name}} instead.", { name: prefer[tag.title] });
}
});

@@ -97,0 +106,0 @@

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

@@ -5,0 +5,0 @@ "description": "An Esprima-based pattern checker for JavaScript.",

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