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.1 to 0.4.2

1

conf/environments.json

@@ -360,2 +360,3 @@ {

"rules": {
"no-catch-shadow": 0,
"no-console": 0,

@@ -362,0 +363,0 @@ "no-global-strict": 0,

2

conf/eslint.json

@@ -85,3 +85,3 @@ {

"block-scoped-var": 0,
"brace-style": 0,
"brace-style": [0, "1tbs"],
"camelcase": 2,

@@ -88,0 +88,0 @@ "complexity": [0, 11],

@@ -413,3 +413,3 @@ /**

message = location;
location = {};
location = node.loc.start;
}

@@ -426,4 +426,4 @@

message: message,
line: location.line || node.loc.start.line,
column: location.column || node.loc.start.column,
line: location.line,
column: location.column,
source: api.getSource(node)

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

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

* @param {ASTNode} node The AST node related to the message.
* @param {Object=} location The location of the error.
* @param {string} message The message to display to the user.

@@ -63,4 +64,4 @@ * @param {Object} opts Optional template data which produces a formatted message

*/
this.report = function(node, message, opts) {
eslint.report(ruleId, node, message, opts);
this.report = function(node, location, message, opts) {
eslint.report(ruleId, node, location, message, opts);
};

@@ -67,0 +68,0 @@

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

module.exports = function(context) {
var style = context.options[0] || "1tbs";
var MESSAGE = "Opening curly brace does not appear on the same line as controlling statement.";
var OPEN_MESSAGE = "Opening curly brace does not appear on the same line as controlling statement.",
CLOSE_MESSAGE = "Closing curly brace does not appear on the same line as the subsequent block.";

@@ -21,2 +23,9 @@ //--------------------------------------------------------------------------

/**
* Binds a list of properties to a function that verifies that the opening
* curly brace is on the same line as its controlling statement of a given
* node.
* @param {...string} The properties to check on the node.
* @returns {Function} A function that will perform the check on a node
*/
function checkBlock() {

@@ -31,3 +40,3 @@ var blockProperties = arguments;

if (tokens[0].loc.start.line !== tokens[1].loc.start.line) {
context.report(node, MESSAGE);
context.report(node, OPEN_MESSAGE);
}

@@ -39,2 +48,79 @@ }

/**
* Enforces the configured brace style on IfStatements
* @param {ASTNode} node An IfStatement node.
* @returns {void}
*/
function checkIfStatement(node) {
var tokens;
checkBlock("consequent", "alternate")(node);
if (node.alternate && node.alternate.type === "BlockStatement") {
tokens = context.getTokens(node.alternate, 2);
if (style === "1tbs") {
if (tokens[0].loc.start.line !== tokens[1].loc.start.line) {
context.report(node.alternate, CLOSE_MESSAGE);
}
} else if (style === "stroustrup") {
if (tokens[0].loc.start.line === tokens[1].loc.start.line) {
context.report(node.alternate, CLOSE_MESSAGE);
}
}
}
}
/**
* Enforces the configured brace style on TryStatements
* @param {ASTNode} node A TryStatement node.
* @returns {void}
*/
function checkTryStatement(node) {
var tokens;
checkBlock("block", "finalizer")(node);
if (node.finalizer && node.finalizer.type === "BlockStatement") {
tokens = context.getTokens(node.finalizer, 2);
if (style === "1tbs") {
if (tokens[0].loc.start.line !== tokens[1].loc.start.line) {
context.report(node.finalizer, CLOSE_MESSAGE);
}
} else if (style === "stroustrup") {
if (tokens[0].loc.start.line === tokens[1].loc.start.line) {
context.report(node.finalizer, CLOSE_MESSAGE);
}
}
}
}
/**
* Enforces the configured brace style on CatchClauses
* @param {ASTNode} node A CatchClause node.
* @returns {void}
*/
function checkCatchClause(node) {
var tokens;
checkBlock("body")(node);
if (node.body && node.body.type === "BlockStatement") {
tokens = context.getTokens(node, 1);
if (style === "1tbs") {
if (tokens[0].loc.start.line !== tokens[1].loc.start.line) {
context.report(node, CLOSE_MESSAGE);
}
} else if (style === "stroustrup") {
if (tokens[0].loc.start.line === tokens[1].loc.start.line) {
context.report(node, CLOSE_MESSAGE);
}
}
}
}
/**
* Enforces the configured brace style on SwitchStatements
* @param {ASTNode} node A SwitchStatement node.
* @returns {void}
*/
function checkSwitchStatement(node) {

@@ -45,3 +131,3 @@ var tokens;

if (tokens[0].loc.start.line !== tokens[1].loc.start.line) {
context.report(node, MESSAGE);
context.report(node, OPEN_MESSAGE);
}

@@ -52,3 +138,3 @@ } else {

if (tokens.pop().loc.start.line !== tokens.pop().loc.start.line) {
context.report(node, MESSAGE);
context.report(node, OPEN_MESSAGE);
}

@@ -64,5 +150,5 @@ }

"FunctionDeclaration": checkBlock("body"),
"IfStatement": checkBlock("consequent", "alternate"),
"TryStatement": checkBlock("block", "finalizer"),
"CatchClause": checkBlock("body"),
"IfStatement": checkIfStatement,
"TryStatement": checkTryStatement,
"CatchClause": checkCatchClause,
"DoWhileStatement": checkBlock("body"),

@@ -69,0 +155,0 @@ "WhileStatement": checkBlock("body"),

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

function wrapped(node) {
var tokens = context.getTokens(node, 1, 1);
return tokens[0].value === "(" && tokens[tokens.length - 1].value === ")";
}
return {
"CallExpression": function(node) {
if (node.callee.type === "FunctionExpression") {
var tokens = context.getTokens(node.callee, 1, 1);
if (tokens[0].value !== "(" && tokens[tokens.length - 1].value !== ")") {
context.report(node, "Wrap an immediate function invocation in parentheses.");
}
if (node.callee.type === "FunctionExpression" && !wrapped(node) && !wrapped(node.callee)) {
context.report(node, "Wrap an immediate function invocation in parentheses.");
}

@@ -24,0 +26,0 @@ }

{
"name": "eslint",
"version": "0.4.1",
"version": "0.4.2",
"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