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.9.2 to 0.10.0-alpha

conf/nodetypes.yml

2

conf/eslint.json

@@ -42,2 +42,3 @@ {

"no-implied-eval": 2,
"no-inline-comments": 0,
"no-inner-declarations": [2, "functions"],

@@ -129,2 +130,3 @@ "no-invalid-regexp": 2,

"one-var": 0,
"operator-assignment": [0, "always"],
"padded-blocks": 0,

@@ -131,0 +133,0 @@ "quote-props": 0,

4

lib/config.js

@@ -278,7 +278,7 @@ /**

debug("Merging command line config file");
config = util.mergeConfigs(config, this.useSpecificConfig);
if (this.useSpecificConfig.env) {
config = util.mergeConfigs(config, createEnvironmentConfig(this.useSpecificConfig.env, this.options.reset));
}
config = util.mergeConfigs(config, this.useSpecificConfig);
}

@@ -285,0 +285,0 @@

/**
* @fileoverview Main ESLint object.
* @author Nicholas C. Zakas
* @copyright 2013 Nicholas C. Zakas. All rights reserved.
*/

@@ -11,4 +12,4 @@ "use strict";

var esprima = require("esprima"),
estraverse = require("estraverse"),
var esprima = require("esprima-fb"),
estraverse = require("estraverse-fb"),
escope = require("escope"),

@@ -19,3 +20,5 @@ environments = require("../conf/environments.json"),

util = require("./util"),
Validator = require("./util/validator"),
RuleContext = require("./rule-context"),
timing = require("./timing"),
EventEmitter = require("events").EventEmitter;

@@ -373,3 +376,4 @@

commentLocsEnter = [],
commentLocsExit = [];
commentLocsExit = [],
validator;

@@ -506,2 +510,3 @@ /**

commentLocsExit = [];
validator = null;
};

@@ -522,3 +527,4 @@

var ast,
shebang;
shebang,
validatorOptions = {};

@@ -542,2 +548,10 @@ // set the current parsed filename

// get settings information for ECMAScript version and JSX
if (typeof config.settings.ecmascript === "number" && config.settings.ecmascript > 5) {
validatorOptions.ecmascript = config.settings.ecmascript;
}
validatorOptions.jsx = !!config.settings.jsx;
validator = new Validator(validatorOptions);
// parse global comments and modify config

@@ -562,3 +576,6 @@ modifyConfigsFromComments(ast, config, reportingConfig);

Object.keys(rule).forEach(function(nodeType) {
api.on(nodeType, rule[nodeType]);
api.on(nodeType, timing.enabled
? timing.time(key, rule[nodeType])
: rule[nodeType]
);
});

@@ -637,6 +654,24 @@ } catch(ex) {

var comments = api.getComments(node);
var comments = api.getComments(node),
validation;
emitCommentsEnter(comments.leading);
node.parent = parent;
validation = validator.validate(node);
if (!validation.valid) {
messages.push({
fatal: true,
severity: 2,
message: validation.message,
node: node,
line: validation.line,
column: validation.column
});
// no further parsing should happen
this.break();
}
api.emit(node.type, node);

@@ -721,3 +756,3 @@ emitCommentsEnter(comments.trailing);

if (node) {
return (currentText !== null) ? currentText.slice(node.range[0] - (beforeCount || 0),
return (currentText !== null) ? currentText.slice(Math.max(node.range[0] - (beforeCount || 0), 0),
node.range[1] + (afterCount || 0)) : null;

@@ -724,0 +759,0 @@ } else {

@@ -51,3 +51,3 @@ /**

return ignorePatterns;
return ["node_modules/**"].concat(ignorePatterns);
}

@@ -54,0 +54,0 @@

/**
* @fileoverview Rule to flag non-quoted property names in object literals.
* @author Mathias Bynens <http://mathiasbynens.be/>
* @copyright 2014 Brandon Mills. All rights reserved.
*/
"use strict";
//------------------------------------------------------------------------------
// Rule Definition
// Requirements
//------------------------------------------------------------------------------

@@ -12,45 +14,54 @@

//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
module.exports = function(context) {
"use strict";
var MODE = context.options[0];
switch (MODE) {
/**
* Ensures that a property's key is quoted only when necessary
* @param {ASTNode} node Property AST node
* @returns {void}
*/
function asNeeded(node) {
var key = node.key,
tokens;
case "as-needed":
return {
Property: function(node) {
var key = node.key;
// Ensure that any quoted property names required quoting
if (key.type === "Literal" && typeof key.value === "string") {
try {
var tokens = esprima.tokenize(key.value);
if (tokens.length !== 1) {
return;
}
var t = tokens[0];
} catch(e) {
return;
}
if (t.type === "Identifier" || t.type === "Null" || t.type === "Boolean" || t.type === "Numeric" && "" + +t.value === t.value) {
context.report(node, "Unnecessarily quoted property `{{name}}` found.", key);
}
}
}
};
if (key.type === "Literal" && typeof key.value === "string") {
try {
tokens = esprima.tokenize(key.value);
} catch (e) {
return;
}
default:
return {
Property: function(node) {
var key = node.key;
// Ensure all property names are quoted
if (key.type !== "Literal" || typeof key.value !== "string") {
context.report(node, "Unquoted property `{{name}}` found.", key);
}
}
};
if (tokens.length === 1 &&
(["Identifier", "Null", "Boolean"].indexOf(tokens[0].type) >= 0 ||
(tokens[0].type === "Numeric" && "" + +tokens[0].value === tokens[0].value))
) {
context.report(node, "Unnecessarily quoted property `{{value}}` found.", key);
}
}
}
/**
* Ensures that a property's key is quoted
* @param {ASTNode} node Property AST node
* @returns {void}
*/
function always(node) {
var key = node.key;
if (!(key.type === "Literal" && typeof key.value === "string")) {
context.report(node, "Unquoted property `{{key}}` found.", {
key: key.name || key.value
});
}
}
return {
"Property": MODE === "as-needed" ? asNeeded : always
};
};
{
"name": "eslint",
"version": "0.9.2",
"version": "0.10.0-alpha",
"author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",

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

"esprima": "^1.2.2",
"esprima-fb": "^8001.1.0-dev-harmony-fb",
"estraverse": "~1.5.1",
"estraverse-fb": "^1.0.0",
"js-yaml": "~3.2.2",

@@ -64,2 +66,3 @@ "minimatch": "^1.0.0",

"jsonlint": "^1.6.2",
"leche": "^1.0.1",
"mocha": "~1.13.0",

@@ -69,2 +72,3 @@ "mocha-phantomjs": "^3.5.0",

"proxyquire": "^1.0.0",
"semver": "^4.1.0",
"shelljs": "^0.3.0",

@@ -71,0 +75,0 @@ "shelljs-nodecli": "~0.1.0",

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