Socket
Socket
Sign inDemoInstall

jscs

Package Overview
Dependencies
Maintainers
4
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jscs - npm Package Compare versions

Comparing version 1.11.0 to 1.11.1

2

lib/checker.js

@@ -25,3 +25,3 @@ var vowFs = require('vow-fs');

*/
Checker.prototype.configure = function(config) {
Checker.prototype.configure = function(/*config*/) {
StringChecker.prototype.configure.apply(this, arguments);

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

@@ -13,9 +13,5 @@ /**

var Vow = require('vow');
var supportsColor = require('supports-color');
var exit = require('exit');
var fs = require('fs');
var path = require('path');
module.exports = function(program) {

@@ -22,0 +18,0 @@ var reporter;

@@ -1,2 +0,1 @@

var path = require('path');
var fs = require('fs');

@@ -94,3 +93,3 @@

}.bind(this))
.then(function flushConfig(config) {
.then(function flushConfig() {
fs.writeFileSync(process.cwd() + '/.jscsrc', JSON.stringify(this._config, null, '\t'));

@@ -162,23 +161,4 @@ console.log('Generated a .jscsrc configuration file in ' + process.cwd());

function promisify(fn) {
return function() {
var deferred = Vow.defer();
var args = [].slice.call(arguments);
args.push(function(err, result) {
if (err) {
deferred.reject(err);
} else {
deferred.resolve(result);
}
});
fn.apply(null, args);
return deferred.promise();
};
}
/** @private */
Generator.prototype._showPrompt = promisify(prompt.get.bind(prompt));
Generator.prototype._showPrompt = utils.promisify(prompt.get.bind(prompt));

@@ -185,0 +165,0 @@ /**

@@ -147,3 +147,3 @@ var treeIterator = require('./tree-iterator');

var tokenHash = {};
this._tree.tokens = this._tree.tokens.filter(function(token, i) {
this._tree.tokens = this._tree.tokens.filter(function(token) {
var hashKey = token.range[0] + '_' + token.range[1];

@@ -189,3 +189,2 @@ var isDuplicate = tokenHash[hashKey];

var startPos = comments[i].range[0];
var endPos = comments[i].range[1];
if (partialComments.length) {

@@ -192,0 +191,0 @@ tokenCommentsAfterIndex[tokenIndex] = partialComments;

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

file.iterateTokensByType('Keyword', function(token, i, tokens) {
file.iterateTokensByType('Keyword', function(token) {
if (keywordIndex[token.value]) {

@@ -60,0 +60,0 @@ var prevToken = file.getPrevToken(token);

@@ -60,3 +60,3 @@ /**

tokens.forEach(function(token, i) {
tokens.forEach(function(token) {
if (lastToken) {

@@ -63,0 +63,0 @@ if (lastToken.type === 'Punctuator' && operators.indexOf(lastToken.value) > -1) {

@@ -94,5 +94,5 @@ /**

file.iterateTokensByType('Keyword', function(token, i, tokens) {
file.iterateTokensByType('Keyword', function(token) {
if (keywordIndex[token.value]) {
var prevToken = tokens[i - 1];
var prevToken = file.getPrevToken(token);

@@ -99,0 +99,0 @@ if (prevToken && token.loc.start.line - prevToken.loc.end.line > 1) {

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

var lines = file.getLines();
var tokens = file.getTokens();

@@ -57,0 +56,0 @@ file.iterateNodesByType('BlockStatement', function(node) {

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

file.iterateNodesByType('ObjectExpression', function(node) {
var tokens = file.getTokens();
var openingBracket = file.getFirstNodeToken(node);

@@ -61,0 +60,0 @@ var nextToken = file.getNextToken(openingBracket);

@@ -6,3 +6,6 @@ /**

*
* Values: `true`
* Values:
* - `true`
* - `"ignoreSingleLine"` ignores objects if the object only takes up a single line
* - `"ignoreMultiLine"` ignores objects if the object takes up multiple lines
*

@@ -32,6 +35,13 @@ * #### Example

configure: function(disallow) {
var modes = {
'ignoreSingleLine': 'ignoreSingleLine',
'ignoreMultiLine': 'ignoreMultiLine'
};
assert(
disallow === true,
this.getOptionName() + ' option requires true value or should be removed'
disallow === true || typeof disallow === 'string' && modes[disallow],
this.getOptionName() +
' option requires true value requires one of the following values: ' +
Object.keys(modes).join(', ')
);
this._mode = disallow === true ? true : modes[disallow];
},

@@ -44,7 +54,14 @@

check: function(file, errors) {
var mode = this._mode;
file.iterateNodesByType('ObjectExpression', function(node) {
node.properties.forEach(function(property) {
if (property.shorthand) {
if (property.shorthand || property.method) {
return;
}
if (mode === 'ignoreSingleLine' && node.loc.start.line === node.loc.end.line) {
return;
}
if (mode === 'ignoreMultiLine' && node.loc.start.line !== node.loc.end.line) {
return;
}

@@ -51,0 +68,0 @@ var token = file.getFirstNodeToken(property.key);

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

var operatorIndex = this._operatorIndex;
var tokens = file.getTokens();

@@ -61,0 +60,0 @@ file.iterateNodesByType(['UnaryExpression', 'UpdateExpression'], function(node) {

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

var assert = require('assert');
var util = require('util');

@@ -66,3 +65,3 @@ var defaultKeywords = require('../utils').spacedKeywords;

file.iterateTokensByType(['Keyword'], function(token, i, tokens) {
file.iterateTokensByType(['Keyword'], function(token) {
if (keywordIndex[token.value]) {

@@ -69,0 +68,0 @@ var prevToken = file.getPrevToken(token);

@@ -44,3 +44,3 @@ /**

node.properties.forEach(function(property) {
if (property.shorthand) {
if (property.shorthand || property.method) {
return;

@@ -47,0 +47,0 @@ }

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

var operatorIndex = this._operatorIndex;
var tokens = file.getTokens();

@@ -62,0 +61,0 @@ // 'UpdateExpression' involve only ++ and -- operators

@@ -50,5 +50,6 @@ /**

file.iterateNodesByType(['CallExpression'], function(node) {
node.arguments.forEach(function(param, i) {
node.arguments.forEach(function(param) {
var token = file.getFirstNodeToken(param);
var punctuatorToken = file.getPrevToken(token);
if (punctuatorToken.value === ',') {

@@ -55,0 +56,0 @@ errors.assert.noWhitespaceBetween({

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

check: function(file, errors) {
var tokens = file.getTokens();
file.iterateNodesByType('CallExpression', function(node) {

@@ -48,0 +46,0 @@ var lastCalleeToken = file.getLastNodeToken(node.callee);

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

check: function(file, errors) {
var tokens = file.getTokens();
file.iterateNodesByType(['ConditionalExpression'], function(node) {

@@ -107,0 +105,0 @@

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

var beforeClose = file.getPrevToken(closeBracket);
var value = afterOpen.value;

@@ -105,0 +104,0 @@ // Skip for empty array brackets

@@ -6,3 +6,3 @@ /**

*
* Values: `true` or Object with either `"only"` with array of tokens or `"all"` with `true` value
* Values: `true` or Object with either `"only"` with array of tokens
*

@@ -49,4 +49,9 @@ * #### Example

var error = 'disallowSpacesInsideParentheses option requires' +
' true or object value with "all" or "only" properties ';
' true or object value with "only" properties ';
// backcompat for 1.10: {all: true} #1027
if (isObject && option.all === true) {
option = true;
}
if (typeof option === 'boolean') {

@@ -83,6 +88,5 @@ assert(option === true, error);

file.iterateTokenByValue('(', function(token, index, tokens) {
file.iterateTokenByValue('(', function(token) {
var nextToken = file.getNextToken(token);
var value = nextToken.value;
var type = nextToken.type;

@@ -100,6 +104,5 @@ if (only && !(value in only)) {

file.iterateTokenByValue(')', function(token, index, tokens) {
file.iterateTokenByValue(')', function(token) {
var prevToken = file.getPrevToken(token);
var value = prevToken.value;
var type = prevToken.type;

@@ -106,0 +109,0 @@ if (only) {

@@ -61,4 +61,4 @@ /**

check: function(file, errors) {
var tokens = file.getTokens();
var mode = this._mode;
file.iterateNodesByType('ObjectExpression', function(node) {

@@ -71,3 +71,3 @@ if (node.loc.start.line === node.loc.end.line || node.properties < 2) {

var skip = node.properties.some(function(property, index) {
if (property.shorthand) {
if (property.shorthand || property.method) {
return true;

@@ -74,0 +74,0 @@ }

@@ -74,3 +74,3 @@ /**

}
var tokens = file.getTokens();
var openingBracket = file.getFirstNodeToken(node);

@@ -77,0 +77,0 @@ var nextToken = file.getNextToken(openingBracket);

@@ -76,3 +76,3 @@ /**

check: function(file, errors) {
file.iterateTokensByType('Identifier', function(token, index, tokens) {
file.iterateTokensByType('Identifier', function(token) {
var value = token.value;

@@ -83,6 +83,10 @@ if (value.replace(/^_+|_+$/g, '').indexOf('_') === -1 || value.toUpperCase() === value) {

if (this._ignoreProperties) {
if (index + 1 < tokens.length && tokens[index + 1].value === ':') {
var nextToken = file.getNextToken(token);
var prevToken = file.getPrevToken(token);
if (nextToken && nextToken.value === ':') {
return;
}
if (index > 0 && tokens[index - 1].value === '.') {
if (prevToken && prevToken.value === '.') {
return;

@@ -89,0 +93,0 @@ }

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

file.iterateTokensByType('Keyword', function(token, i, tokens) {
file.iterateTokensByType('Keyword', function(token) {
if (keywordIndex[token.value]) {
var prevToken = file.getPrevToken(token);
errors.assert.differentLine({

@@ -63,0 +61,0 @@ token: file.getPrevToken(token),

@@ -93,5 +93,5 @@ /**

file.iterateTokensByType('Keyword', function(token, i, tokens) {
file.iterateTokensByType('Keyword', function(token) {
if (keywordIndex[token.value]) {
var prevToken = tokens[i - 1];
var prevToken = file.getPrevToken(token);

@@ -98,0 +98,0 @@ // Handle special case of 'else if' construct.

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

var assert = require('assert');
var utils = require('../utils');

@@ -49,3 +48,3 @@ module.exports = function() { };

node.properties.forEach(function(prop) {
if (prop.shorthand) {
if (prop.shorthand || prop.method) {
return;

@@ -52,0 +51,0 @@ }

@@ -44,3 +44,3 @@ /**

node.properties.forEach(function(property) {
if (property.shorthand) {
if (property.shorthand || property.method) {
return;

@@ -47,0 +47,0 @@ }

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

var operatorIndex = this._operatorIndex;
var tokens = file.getTokens();

@@ -61,0 +60,0 @@ file.iterateNodesByType(['UnaryExpression', 'UpdateExpression'], function(node) {

@@ -44,3 +44,3 @@ /**

node.properties.forEach(function(property) {
if (property.shorthand) {
if (property.shorthand || property.method) {
return;

@@ -47,0 +47,0 @@ }

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

var operatorIndex = this._operatorIndex;
var tokens = file.getTokens();

@@ -62,0 +61,0 @@ // 'UpdateExpression' involve only ++ and -- operators

@@ -50,3 +50,3 @@ /**

file.iterateNodesByType(['CallExpression'], function(node) {
node.arguments.forEach(function(param, i) {
node.arguments.forEach(function(param) {
var punctuatorToken = file.getPrevToken(file.getFirstNodeToken(param));

@@ -56,4 +56,3 @@ if (punctuatorToken.value === ',') {

token: punctuatorToken,
nextToken: file.getNextToken(punctuatorToken),
spaces: 1
nextToken: file.getNextToken(punctuatorToken)
});

@@ -60,0 +59,0 @@ }

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

check: function(file, errors) {
var tokens = file.getTokens();
file.iterateNodesByType('CallExpression', function(node) {

@@ -48,0 +46,0 @@ var lastCalleeToken = file.getLastNodeToken(node.callee);

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

check: function(file, errors) {
var tokens = file.getTokens();
file.iterateNodesByType(['ConditionalExpression'], function(node) {

@@ -97,0 +95,0 @@ var test = node.test;

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

var beforeClose = file.getPrevToken(closeBracket);
var value = afterOpen.value;

@@ -104,0 +103,0 @@ // Skip for empty array brackets

@@ -103,6 +103,5 @@ /**

file.iterateTokenByValue('(', function(token, index, tokens) {
file.iterateTokenByValue('(', function(token) {
var nextToken = file.getNextToken(token);
var value = nextToken.value;
var type = nextToken.type;

@@ -127,6 +126,5 @@ if (value in exceptions) {

file.iterateTokenByValue(')', function(token, index, tokens) {
file.iterateTokenByValue(')', function(token) {
var prevToken = file.getPrevToken(token);
var value = prevToken.value;
var type = prevToken.type;

@@ -133,0 +131,0 @@ if (value in exceptions) {

@@ -189,3 +189,3 @@ /**

function markChildren(node) {
getChildren(node).forEach(function(childNode, i) {
getChildren(node).forEach(function(childNode) {
if (childNode.loc.start.line !== node.loc.start.line) {

@@ -192,0 +192,0 @@ markCheck(childNode);

@@ -155,4 +155,4 @@ var utils = require('util');

message: message,
line: token.loc.start.line,
column: token.loc.start.column
line: actualTokenBefore.loc.end.line,
column: actualTokenBefore.loc.end.column
});

@@ -181,4 +181,4 @@ }

message: options.message || 'Illegal ' + expectedTokenBefore.value + ' was found before ' + token.value,
line: token.loc.start.line,
column: token.loc.start.column
line: actualTokenBefore.loc.end.line,
column: actualTokenBefore.loc.end.column
});

@@ -185,0 +185,0 @@ }

var path = require('path');
var Vow = require('vow');

@@ -219,2 +220,29 @@ // 7.5.2 Keywords

/**
* Wraps a function such that you can interact with a promise and not a
* node-style callback.
*
* @param {Function} fn - function that expects a node-style callback
* @return {Function} When invoked with arguments, returns a promise resolved/rejected
* based on the results of the wrapped node-style callback
*/
exports.promisify = function(fn) {
return function() {
var deferred = Vow.defer();
var args = [].slice.call(arguments);
args.push(function(err, result) {
if (err) {
deferred.reject(err);
} else {
deferred.resolve(result);
}
});
fn.apply(null, args);
return deferred.promise();
};
};
/**
* All possible binary operators supported by JSCS

@@ -221,0 +249,0 @@ * @type {Array}

@@ -5,3 +5,3 @@ {

"name": "jscs",
"version": "1.11.0",
"version": "1.11.1",
"main": "lib/checker",

@@ -8,0 +8,0 @@ "homepage": "https://github.com/jscs-dev/node-jscs",

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