Socket
Socket
Sign inDemoInstall

jscs

Package Overview
Dependencies
11
Maintainers
3
Versions
95
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.6.1 to 1.6.2

lib/rules/disallow-space-before-object-values.js

11

lib/rules/disallow-space-after-keywords.js
var assert = require('assert');
var defaultKeywords = require('../utils').spacedKeywords;

@@ -8,3 +9,11 @@ module.exports = function() {};

configure: function(keywords) {
assert(Array.isArray(keywords), 'disallowSpaceAfterKeywords option requires array value');
assert(
Array.isArray(keywords) || keywords === true,
'disallowSpaceAfterKeywords option requires array or true value'
);
if (keywords === true) {
keywords = defaultKeywords;
}
this._keywordIndex = {};

@@ -11,0 +20,0 @@ for (var i = 0, l = keywords.length; i < l; i++) {

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

@@ -8,3 +9,11 @@ module.exports = function() {};

configure: function(statementTypes) {
assert(Array.isArray(statementTypes), 'requireCurlyBraces option requires array value');
assert(
Array.isArray(statementTypes) || statementTypes === true,
'requireCurlyBraces option requires array or true value'
);
if (statementTypes === true) {
statementTypes = defaultKeywords;
}
this._typeIndex = {};

@@ -11,0 +20,0 @@ for (var i = 0, l = statementTypes.length; i < l; i++) {

@@ -8,2 +8,4 @@ var assert = require('assert');

var defaultKeywords = require('../utils').spacedKeywords;
module.exports = function() {};

@@ -14,3 +16,10 @@

configure: function(keywords) {
assert(Array.isArray(keywords), 'requireSpaceAfterKeywords option requires array value');
assert(
Array.isArray(keywords) || keywords === true,
'requireSpaceAfterKeywords option requires array or true value');
if (keywords === true) {
keywords = defaultKeywords;
}
this._keywordIndex = {};

@@ -17,0 +26,0 @@ for (var i = 0, l = keywords.length; i < l; i++) {

@@ -74,3 +74,5 @@ var esprima = require('esprima');

this.registerRule(new (require('./rules/require-space-after-object-keys'))());
this.registerRule(new (require('./rules/require-space-before-object-values'))());
this.registerRule(new (require('./rules/disallow-space-after-object-keys'))());
this.registerRule(new (require('./rules/disallow-space-before-object-values'))());
this.registerRule(new (require('./rules/disallow-quoted-keys-in-objects'))());

@@ -120,2 +122,4 @@ this.registerRule(new (require('./rules/disallow-dangling-underscores'))());

this.registerRule(new (require('./rules/validate-parameter-separator'))());
this.registerRule(new (require('./rules/require-capitalized-constructors'))());

@@ -227,3 +231,3 @@

filename = filename || 'input';
str = str.replace(/^#!?[^\n]+\n/gm, '\n');
str = str.replace(/^#!?[^\n]+\n/gm, '');

@@ -230,0 +234,0 @@ var tree;

@@ -69,2 +69,39 @@ // 7.5.2 Keywords

/**
* All keywords where spaces are a stylistic choice
* @type {Array}
*/
exports.spacedKeywords = [
'do',
'for',
'if',
'else',
'switch',
'case',
'try',
'catch',
'void',
'while',
'with',
'return',
'typeof',
'function'
];
/**
* All keywords where curly braces are a stylistic choice
* @type {Array}
*/
exports.curlyBracedKeywords = [
'if',
'else',
'for',
'while',
'do',
'try',
'catch',
'case',
'default'
];
/**
* Returns true if word is keyword in ECMAScript 3 specification.

@@ -71,0 +108,0 @@ *

4

package.json

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

"name": "jscs",
"version": "1.6.1",
"version": "1.6.2",
"main": "lib/checker",

@@ -49,3 +49,3 @@ "homepage": "https://github.com/mdevils/node-jscs",

"rewire": "~2.1.0",
"separated-coverage": "~2.1.1",
"separated-coverage": "~2.3.0",
"sinon": "~1.10.0",

@@ -52,0 +52,0 @@ "xml2js": "~0.4.2"

@@ -29,2 +29,3 @@ # node-jscs

* Web Essentials for Visual Studio 2013: https://github.com/madskristensen/WebEssentials2013/
* IntelliJ IDEA, RubyMine, WebStorm, PhpStorm, PyCharm plugin: https://github.com/idok/jscs-plugin

@@ -223,6 +224,20 @@ ### Extensions

Type: `Array`
Type: `Array` or `Boolean`
Values: Array of quoted keywords
Values: Array of quoted keywords or `true` to require curly braces after the following keywords:
```js
[
'if',
'else',
'for',
'while',
'do',
'try',
'catch',
'case',
'default'
]
```
JSHint: [`curly`](http://jshint.com/docs/options/#curly)

@@ -264,5 +279,5 @@

Type: `Array`
Type: `Array` or `Boolean`
Values: Array of quoted keywords
Values: Array of quoted keywords or `true` to require all of the keywords below to have a space afterward.

@@ -273,11 +288,16 @@ #### Example

"requireSpaceAfterKeywords": [
"do",
"for",
"if",
"else",
"for",
"switch",
"case",
"try",
"catch",
"void",
"while",
"do",
"switch",
"with",
"return",
"try",
"catch"
"typeof",
"function"
]

@@ -304,5 +324,5 @@ ```

Type: `Array`
Type: `Array` or `Boolean`
Values: Array of quoted keywords
Values: Array of quoted keywords or `true` to disallow spaces after all possible keywords.

@@ -1386,2 +1406,48 @@ #### Example

### disallowSpaceBeforeObjectValues
Disallows space after object keys.
Type: `Boolean`
Values: `true`
#### Example
```js
"disallowSpaceBeforeObjectValues": true
```
##### Valid
```js
var x = {a:1};
```
##### Invalid
```js
var x = {a: 1};
```
### requireSpaceBeforeObjectValues
Requires space after object keys.
Type: `Boolean`
Values: `true`
#### Example
```js
"requireSpaceBeforeObjectValues": true
```
##### Valid
```js
var x = {a: 1};
```
##### Invalid
```js
var x = {a:1};
```
### disallowCommaBeforeLineBreak

@@ -1960,144 +2026,2 @@

### validateLineBreaks
Option to check line break characters
Type: `String`
Values: `"CR"`, `"LF"`, `"CRLF"`
#### Example
```js
"validateLineBreaks": "LF"
```
##### Valid
```js
var x = 1;<LF>
x++;
```
##### Invalid
```js
var x = 1;<CRLF>
x++;
```
### validateQuoteMarks
Requires all quote marks to be either the supplied value, or consistent if `true`
Type: `String` or `Object`
Values:
- `"\""`: all strings require double quotes
- `"'"`: all strings require single quotes
- `true`: all strings require the quote mark first encountered in the source code
- `Object`:
- `escape`: allow the "other" quote mark to be used, but only to avoid having to escape
- `mark`: the same effect as the non-object values
JSHint: [`quotmark`](http://jshint.com/docs/options/#quotmark)
#### Example
```js
"validateQuoteMarks": "\""
```
```js
"validateQuoteMarks": { "mark": "\"", "escape": true }
```
##### Valid example for mode `{ "mark": "\"", "escape": true }`
```js
var x = "x";
var y = '"x"';
```
##### Invalid example for mode `{ "mark": "\"", "escape": true }`
```js
var x = "x";
var y = 'x';
```
##### Valid example for mode `"\""` or mode `true`
```js
var x = "x";
```
##### Valid example for mode `"'"` or mode `true`
```js
var x = 'x';
```
##### Invalid example for mode `true`
```js
var x = "x", y = 'y';
```
### validateIndentation
Validates indentation for arrays, objects, switch statements, and block statements
Type: `Integer` or `String`
Values: A positive integer or `"\t"`
JSHint: [`indent`](http://jshint.com/docs/options/#indent)
#### Example
```js
"validateIndentation": "\t"
```
##### Valid example for mode `2`
```js
if (a) {
b=c;
function(d) {
e=f;
}
}
```
##### Invalid example for mode `2`
```js
if (a) {
b=c;
function(d) {
e=f;
}
}
```
##### Valid example for mode "\t"
```js
if (a) {
b=c;
function(d) {
e=f;
}
}
```
##### Invalid example for mode "\t"
```js
if (a) {
b=c;
function(d) {
e=f;
}
}
```
### disallowMixedSpacesAndTabs

@@ -2399,28 +2323,2 @@

### safeContextKeyword
Option to check `var that = this` expressions
Type: `Array` or `String`
Values: String value used for context local declaration
#### Example
```js
"safeContextKeyword": ["that"]
```
##### Valid
```js
var that = this;
```
##### Invalid
```js
var _this = this;
```
### requireDotNotation

@@ -2517,52 +2415,2 @@

### validateJSDoc
Enables JSDoc validation.
Type: `Object`
Values:
- "checkParamNames" ensures param names in jsdoc and in function declaration are equal
- "requireParamTypes" ensures params in jsdoc contains type
- "checkRedundantParams" reports redundant params in jsdoc
#### Example
```js
"validateJSDoc": {
"checkParamNames": true,
"checkRedundantParams": true,
"requireParamTypes": true
}
```
##### Valid
```js
/**
* Adds style error to the list
*
* @param {String} message
* @param {Number|Object} line
* @param {Number} [column]
*/
add: function(message, line, column) {
}
```
##### Invalid
```js
/**
* Adds style error to the list
*
* @param {String} message
* @param {Number|Object} line
* @param {Number} [column]
*/
add: function() {
}
```
### requireSpaceAfterLineComment

@@ -2840,2 +2688,249 @@

### validateLineBreaks
Option to check line break characters
Type: `String`
Values: `"CR"`, `"LF"`, `"CRLF"`
#### Example
```js
"validateLineBreaks": "LF"
```
##### Valid
```js
var x = 1;<LF>
x++;
```
##### Invalid
```js
var x = 1;<CRLF>
x++;
```
### validateQuoteMarks
Requires all quote marks to be either the supplied value, or consistent if `true`
Type: `String` or `Object`
Values:
- `"\""`: all strings require double quotes
- `"'"`: all strings require single quotes
- `true`: all strings require the quote mark first encountered in the source code
- `Object`:
- `escape`: allow the "other" quote mark to be used, but only to avoid having to escape
- `mark`: the same effect as the non-object values
JSHint: [`quotmark`](http://jshint.com/docs/options/#quotmark)
#### Example
```js
"validateQuoteMarks": "\""
```
```js
"validateQuoteMarks": { "mark": "\"", "escape": true }
```
##### Valid example for mode `{ "mark": "\"", "escape": true }`
```js
var x = "x";
var y = '"x"';
```
##### Invalid example for mode `{ "mark": "\"", "escape": true }`
```js
var x = "x";
var y = 'x';
```
##### Valid example for mode `"\""` or mode `true`
```js
var x = "x";
```
##### Valid example for mode `"'"` or mode `true`
```js
var x = 'x';
```
##### Invalid example for mode `true`
```js
var x = "x", y = 'y';
```
### validateIndentation
Validates indentation for arrays, objects, switch statements, and block statements
Type: `Integer` or `String`
Values: A positive integer or `"\t"`
JSHint: [`indent`](http://jshint.com/docs/options/#indent)
#### Example
```js
"validateIndentation": "\t"
```
##### Valid example for mode `2`
```js
if (a) {
b=c;
function(d) {
e=f;
}
}
```
##### Invalid example for mode `2`
```js
if (a) {
b=c;
function(d) {
e=f;
}
}
```
##### Valid example for mode "\t"
```js
if (a) {
b=c;
function(d) {
e=f;
}
}
```
##### Invalid example for mode "\t"
```js
if (a) {
b=c;
function(d) {
e=f;
}
}
```
### validateParameterSeparator
Enable validation of separators between function parameters.
Type: `String`
Values:
- `", "`: function parameters are immediately followed by a comma then a space
- `" ,"`: function parameters are immediately followed by a space then a comma
- `" , "`: function parameters are immediately followed by a space, a comma then a space
#### Example
```js
"validateParameterSeparator": ", "
```
##### Valid
```js
function a(b, c) {}
```
##### Invalid
```js
function a(b , c) {}
```
### validateJSDoc
Enables JSDoc validation.
Type: `Object`
Values:
- "checkParamNames" ensures param names in jsdoc and in function declaration are equal
- "requireParamTypes" ensures params in jsdoc contains type
- "checkRedundantParams" reports redundant params in jsdoc
#### Example
```js
"validateJSDoc": {
"checkParamNames": true,
"checkRedundantParams": true,
"requireParamTypes": true
}
```
##### Valid
```js
/**
* Adds style error to the list
*
* @param {String} message
* @param {Number|Object} line
* @param {Number} [column]
*/
add: function(message, line, column) {
}
```
##### Invalid
```js
/**
* Adds style error to the list
*
* @param {String} message
* @param {Number|Object} line
* @param {Number} [column]
*/
add: function() {
}
```
### safeContextKeyword
Option to check `var that = this` expressions
Type: `Array` or `String`
Values: String value used for context local declaration
#### Example
```js
"safeContextKeyword": ["that"]
```
##### Valid
```js
var that = this;
```
##### Invalid
```js
var _this = this;
```
## Removed Rules

@@ -2842,0 +2937,0 @@

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc