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.7.2 to 1.7.3

lib/options/esnext.js

2

lib/checker.js

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

var fileExtensions = require('./options/file-extensions');
var esnext = require('./options/esnext');

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

additionalRules(config, this, cwd);
esnext(config);

@@ -36,0 +38,0 @@ StringChecker.prototype.configure.apply(this, arguments);

57

lib/rules/validate-indentation.js

@@ -50,6 +50,30 @@ var assert = require('assert');

function markPop(node, indents) {
linesToCheck[node.loc.end.line - 1].pop = indents;
function markPop(node, outdents) {
linesToCheck[node.loc.end.line - 1].pop = outdents;
}
function markExtraPops(node, count) {
linesToCheck[node.loc.end.line - 1].extraPops = count;
}
function markCasePop(caseNode, children) {
var outdentNode = getCaseOutdent(children);
var outdents;
// If a case statement has a `break` or `return` as a direct child and it is the
// first one encountered, use it as the example for all future case indentation
if (outdentNode && _this._breakIndents === null) {
_this._breakIndents = (caseNode.loc.start.column === outdentNode.loc.start.column) ? 1 : 0;
}
// If a case statement has no `break` nor `return` as a direct child
// (e.g. an if nested in a case statement), mark that there is an extra
// pop because there is no statement that "closes" the case statement
if (!outdentNode) {
markExtraPops(caseNode, 1);
} else {
markPop(caseNode, _this._breakIndents);
}
}
function markPushAndCheck(pushNode, indents) {

@@ -100,2 +124,3 @@ linesToCheck[pushNode.loc.start.line - 1].push = indents;

var idx = indentStack.length - 1;
var extraPops = line.extraPops;

@@ -124,2 +149,6 @@ if (line.pop === null) {

while (extraPops--) {
indentStack.pop();
}
return expected;

@@ -150,13 +179,12 @@ }

function getBreakIndents(caseNode, children) {
if (_this._breakIndents === null) {
children.some(function(node) {
if (node.type === 'BreakStatement' || node.type === 'ReturnStatement') {
_this._breakIndents = (caseNode.loc.start.column === node.loc.start.column) ? 1 : 0;
return true;
}
});
}
function getCaseOutdent(caseChildren) {
var outdentNode;
caseChildren.some(function(node) {
if (node.type === 'BreakStatement' || node.type === 'ReturnStatement') {
outdentNode = node;
return true;
}
});
return _this._breakIndents;
return outdentNode;
}

@@ -247,3 +275,3 @@

markChildren(node);
markPop(node, getBreakIndents(node, children));
markCasePop(node, children);
markPushAndCheck(node, 1);

@@ -301,3 +329,4 @@ } else if (children.length === 0) {

pop: null,
check: null
check: null,
extraPops: 0
};

@@ -304,0 +333,0 @@ });

@@ -185,2 +185,6 @@ var defaultEsprima = require('esprima');

if (config.esnext) {
this._esprima = harmonyEsprima;
}
var configRules = Object.keys(config);

@@ -187,0 +191,0 @@ var activeRules = this._activeRules;

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

"name": "jscs",
"version": "1.7.2",
"version": "1.7.3",
"main": "lib/checker",

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

@@ -202,2 +202,16 @@ # node-jscs

### esnext
Attempts to parse your code as ES6 using the harmony version of the esprima parser.
Type: `Boolean`
Value: `true`
#### Example
```js
"esnext": true
```
## Error Suppression

@@ -204,0 +218,0 @@

Sorry, the diff of this file is too big to display

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