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

83

lib/config/configuration.js

@@ -16,2 +16,3 @@ var assert = require('assert');

esprima: true,
esprimaOptions: true,
errorFilter: true

@@ -235,2 +236,17 @@ };

/**
* returns options, but not rules, from the provided config
*
* @param {Object} config
* @returns {Object}
*/
Configuration.prototype._getOptionsFromConfig = function(config) {
return Object.keys(config).reduce(function(options, key) {
if (BUILTIN_OPTIONS[key]) {
options[key] = config[key];
}
return options;
}, {});
};
/**
* Processes configuration and returns config options.

@@ -244,19 +260,23 @@ *

// NOTE: options is a separate object to ensure that future options must be added
// to BUILTIN_OPTIONS to work, which also assures they aren't mistaken for a rule
var options = this._getOptionsFromConfig(config);
// Base path
if (config.configPath) {
if (options.configPath) {
assert(
typeof config.configPath === 'string',
typeof options.configPath === 'string',
'`configPath` option requires string value'
);
this._basePath = path.dirname(config.configPath);
this._basePath = path.dirname(options.configPath);
}
// Load plugins
if (config.plugins) {
assert(Array.isArray(config.plugins), '`plugins` option requires array value');
config.plugins.forEach(this._loadPlugin, this);
if (options.plugins) {
assert(Array.isArray(options.plugins), '`plugins` option requires array value');
options.plugins.forEach(this._loadPlugin, this);
}
// Apply presets
var presetName = config.preset;
var presetName = options.preset;
if (presetName) {

@@ -274,8 +294,8 @@ this._presetName = presetName;

// File extensions
if (config.fileExtensions) {
if (options.fileExtensions) {
assert(
typeof config.fileExtensions === 'string' || Array.isArray(config.fileExtensions),
typeof options.fileExtensions === 'string' || Array.isArray(options.fileExtensions),
'`fileExtensions` option requires string or array value'
);
this._fileExtensions = [].concat(config.fileExtensions).map(function(ext) {
this._fileExtensions = [].concat(options.fileExtensions).map(function(ext) {
return ext.toLowerCase();

@@ -286,5 +306,5 @@ });

// File excludes
if (config.excludeFiles) {
assert(Array.isArray(config.excludeFiles), '`excludeFiles` option requires array value');
this._excludedFileMasks = config.excludeFiles;
if (options.excludeFiles) {
assert(Array.isArray(options.excludeFiles), '`excludeFiles` option requires array value');
this._excludedFileMasks = options.excludeFiles;
this._excludedFileMatchers = this._excludedFileMasks.map(function(fileMask) {

@@ -298,9 +318,9 @@ return new minimatch.Minimatch(path.resolve(this._basePath, fileMask), {

// Additional rules
if (config.additionalRules) {
assert(Array.isArray(config.additionalRules), '`additionalRules` option requires array value');
config.additionalRules.forEach(this._loadAdditionalRule, this);
if (options.additionalRules) {
assert(Array.isArray(options.additionalRules), '`additionalRules` option requires array value');
options.additionalRules.forEach(this._loadAdditionalRule, this);
}
if (config.hasOwnProperty('maxErrors')) {
var maxErrors = config.maxErrors === null ? null : Number(config.maxErrors);
if (options.hasOwnProperty('maxErrors')) {
var maxErrors = options.maxErrors === null ? null : Number(options.maxErrors);
assert(

@@ -313,31 +333,32 @@ maxErrors > 0 || isNaN(maxErrors) || maxErrors === null,

if (config.hasOwnProperty('esnext')) {
if (options.hasOwnProperty('esnext')) {
assert(
typeof config.esnext === 'boolean' || config.esnext === null,
typeof options.esnext === 'boolean' || options.esnext === null,
'`esnext` option requires boolean or null value'
);
this._esnextEnabled = Boolean(config.esnext);
this._esnextEnabled = Boolean(options.esnext);
}
if (config.hasOwnProperty('es3')) {
if (options.hasOwnProperty('es3')) {
assert(
typeof config.es3 === 'boolean' || config.es3 === null,
typeof options.es3 === 'boolean' || options.es3 === null,
'`es3` option requires boolean or null value'
);
this._es3Enabled = Boolean(config.es3);
this._es3Enabled = Boolean(options.es3);
}
if (config.hasOwnProperty('esprima')) {
this._loadEsprima(config.esprima);
if (options.hasOwnProperty('esprima')) {
this._loadEsprima(options.esprima);
}
if (config.hasOwnProperty('esprimaOptions')) {
this._loadEsprimaOptions(config.esprimaOptions);
if (options.hasOwnProperty('esprimaOptions')) {
this._loadEsprimaOptions(options.esprimaOptions);
}
if (config.hasOwnProperty('errorFilter')) {
this._loadErrorFilter(config.errorFilter);
if (options.hasOwnProperty('errorFilter')) {
this._loadErrorFilter(options.errorFilter);
}
// Apply config options
// NOTE: rule setting must come last in order to
// override any rules that are loaded from a preset
Object.keys(config).forEach(function(key) {

@@ -344,0 +365,0 @@ if (!BUILTIN_OPTIONS[key]) {

@@ -55,3 +55,3 @@ /**

node.properties.forEach(function(property) {
if (property.shorthand || property.method) {
if (property.shorthand || property.method || property.kind !== 'init') {
return;

@@ -58,0 +58,0 @@ }

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

node.properties.forEach(function(property) {
if (property.shorthand || property.method) {
if (property.shorthand || property.method || property.kind !== 'init') {
return;

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

@@ -70,3 +70,3 @@ /**

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

@@ -73,0 +73,0 @@ }

@@ -47,3 +47,3 @@ /**

node.properties.forEach(function(prop) {
if (prop.shorthand || prop.method) {
if (prop.shorthand || prop.method || prop.kind !== 'init') {
return;

@@ -50,0 +50,0 @@ }

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

node.properties.forEach(function(property) {
if (property.shorthand || property.method) {
if (property.shorthand || property.method || property.kind !== 'init') {
return;

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

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

node.properties.forEach(function(property) {
if (property.shorthand || property.method) {
if (property.shorthand || property.method || property.kind !== 'init') {
return;

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

@@ -368,3 +368,3 @@ /**

// whether the first statement is indented or not
if (moduleBody) {
if (moduleBody && moduleBody.body.length) {
_this._moduleIndents = moduleBody.body[0].loc.start.column > 0 ? 1 : 0;

@@ -371,0 +371,0 @@ }

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

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

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

"role": "Bug fixes, common rules"
},
{
"name": "Alexej Yaroshevich",
"email": "zxqfox@gmail.com",
"github-username": "zxqfox",
"role": "Bug fixes, common rules"
}

@@ -70,26 +76,26 @@ ],

"esprima-harmony-jscs": "1.1.0-tolerate-import",
"estraverse": "~1.9.0",
"estraverse": "~1.9.1",
"exit": "~0.1.2",
"glob": "~4.3.5",
"lodash.assign": "~3.0.0",
"minimatch": "~2.0.0",
"minimatch": "~2.0.1",
"prompt": "~0.2.14",
"strip-json-comments": "~1.0.1",
"strip-json-comments": "~1.0.2",
"supports-color": "~1.2.0",
"vow": "~0.4.3",
"vow-fs": "~0.3.1",
"xmlbuilder": "~2.4.0"
"vow": "~0.4.8",
"vow-fs": "~0.3.4",
"xmlbuilder": "~2.5.0"
},
"devDependencies": {
"browserify": "~8.1.1",
"coveralls": "~2.11.1",
"has-ansi": "~1.0.0",
"browserify": "~8.1.3",
"coveralls": "~2.11.2",
"has-ansi": "~1.0.1",
"jshint": "~2.6.0",
"mocha": "~2.1.0",
"regenerate": "~1.2.1",
"rewire": "~2.1.0",
"sinon": "~1.12.0",
"rewire": "~2.1.5",
"sinon": "~1.12.2",
"unicode-7.0.0": "~0.1.5",
"unit-coverage": "~3.3.0",
"xml2js": "~0.4.2"
"xml2js": "~0.4.4"
},

@@ -119,3 +125,3 @@ "bin": {

"lint": "jshint . && node bin/jscs lib test bin publish",
"test": "npm run lint && mocha",
"test": "npm run lint && mocha --color",
"coverage": "unit-coverage run -p common",

@@ -122,0 +128,0 @@ "coverage-html": "unit-coverage run -p common -r html -o coverage.html",

[![Build Status](https://travis-ci.org/jscs-dev/node-jscs.svg?branch=master)](https://travis-ci.org/jscs-dev/node-jscs)
[![Windows CI](https://ci.appveyor.com/api/projects/status/github/jscs-dev/node-jscs?svg=true)](https://ci.appveyor.com/project/jscs-dev/node-jscs/branch/master)
[![Coverage Status](https://img.shields.io/coveralls/jscs-dev/node-jscs.svg?style=flat)](https://coveralls.io/r/jscs-dev/node-jscs?branch=master)

@@ -34,1 +35,2 @@ [![Dependency Status](https://david-dm.org/jscs-dev/node-jscs.svg?theme=shields.io&style=flat)](https://david-dm.org/jscs-dev/node-jscs)

* [Famous](http://famo.us/)
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