Comparing version 1.0.13 to 1.0.14
@@ -13,2 +13,3 @@ { | ||
"requireLineFeedAtFileEnd": true, | ||
"excludeFiles": ["test/data/exclude-files.js"], | ||
"validateJSDoc": { | ||
@@ -15,0 +16,0 @@ "checkParamNames": true, |
@@ -0,1 +1,6 @@ | ||
Version 1.0.14: | ||
* Option `additionalRules` (@markelog). | ||
* disallowQuotedKeysInObjects: Exclusion array (@nschonni). | ||
* | ||
Version 1.0.13: | ||
@@ -2,0 +7,0 @@ * Option `validateLineBreaks` (@twoRoger). |
var vowFs = require('vow-fs'); | ||
var Vow = require('vow'); | ||
var minimatch = require('minimatch'); | ||
var glob = require('glob'); | ||
var StringChecker = require('./string-checker'); | ||
var utils = require('util'); | ||
var path = require('path'); | ||
@@ -31,3 +33,12 @@ /** | ||
}); | ||
// remove "excludeFiles" from checking for unsupported rules | ||
(config.additionalRules || []).forEach(function(pattern) { | ||
glob.sync(path.resolve(process.cwd(), pattern)).map(function(path) { | ||
var Rule = require(path); | ||
this.registerRule(new Rule()); | ||
}, this); | ||
}, this); | ||
// remove "excludeFiles" and "additionalRules" from checking for unsupported rules | ||
delete config.additionalRules; | ||
delete config.excludeFiles; | ||
@@ -34,0 +45,0 @@ |
@@ -11,9 +11,53 @@ var assert = require('assert'); | ||
assert( | ||
typeof disallowQuotedKeysInObjects === 'boolean', | ||
OPTION_NAME + ' options requires boolean value' | ||
disallowQuotedKeysInObjects === true || disallowQuotedKeysInObjects === 'allButReserved', | ||
OPTION_NAME + ' options should be "true" or an array of exceptions' | ||
); | ||
assert( | ||
disallowQuotedKeysInObjects === true, | ||
'disallowQuotedKeysInObjects option requires true value or should be removed' | ||
); | ||
this._mode = disallowQuotedKeysInObjects; | ||
this._keywords = { | ||
'arguments': true, | ||
'break': true, | ||
'case': true, | ||
'catch': true, | ||
'class': true, | ||
'continue': true, | ||
'debugger': true, | ||
'default': true, | ||
'delete': true, | ||
'do': true, | ||
'else': true, | ||
'enum': true, | ||
'eval': true, | ||
'export': true, | ||
'extends': true, | ||
'finally': true, | ||
'for': true, | ||
'function': true, | ||
'if': true, | ||
'implements': true, | ||
'import': true, | ||
'in': true, | ||
'instanceof': true, | ||
'interface': true, | ||
'let': true, | ||
'new': true, | ||
'package': true, | ||
'private': true, | ||
'protected': true, | ||
'public': true, | ||
'return': true, | ||
'static': true, | ||
'super': true, | ||
'switch': true, | ||
'this': true, | ||
'throw': true, | ||
'try': true, | ||
'typeof': true, | ||
'var': true, | ||
'void': true, | ||
'while': true, | ||
'with': true, | ||
'yield': true | ||
}; | ||
}, | ||
@@ -27,5 +71,11 @@ | ||
var KEY_NAME_RE = /^(0|[1-9][0-9]*|[a-zA-Z_$]+[\w$]*)$/; // number or identifier | ||
var keywords = this._keywords; | ||
var mode = this._mode; | ||
file.iterateNodesByType('ObjectExpression', function(node) { | ||
node.properties.forEach(function(prop) { | ||
var key = prop.key; | ||
if (mode === 'allButReserved' && keywords[key.value]) { | ||
return; | ||
} | ||
if (key.type === 'Literal' && | ||
@@ -32,0 +82,0 @@ typeof key.value === 'string' && |
@@ -5,3 +5,3 @@ { | ||
"name" : "jscs", | ||
"version" : "1.0.13", | ||
"version" : "1.0.14", | ||
"repository" : "https://github.com/mdevils/node-jscs", | ||
@@ -34,3 +34,4 @@ "contributors" : [ | ||
"commander": "1.2.0", | ||
"minimatch": "0.2.12" | ||
"minimatch": "0.2.12", | ||
"glob": "3.2.7" | ||
}, | ||
@@ -46,4 +47,4 @@ "devDependencies" : { | ||
"scripts": { | ||
"test" : "./node_modules/.bin/jshint . && node bin/jscs lib test && ./node_modules/.bin/mocha -u bdd -R spec" | ||
"test" : "jshint . && node bin/jscs lib test && mocha -u bdd -R spec" | ||
} | ||
} |
@@ -95,3 +95,3 @@ node-jscs [![Build Status](https://travis-ci.org/mdevils/node-jscs.png?branch=master)](https://travis-ci.org/mdevils/node-jscs) | ||
*/, | ||
*/ | ||
"requireSpacesInFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true }, | ||
@@ -111,3 +111,3 @@ | ||
*/, | ||
*/ | ||
"disallowSpacesInFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true }, | ||
@@ -231,8 +231,15 @@ | ||
Option: disallowQuotedKeysInObjects | ||
Possible values: | ||
`true`: for strict mode, | ||
"allButReserved" allows ES3+ reserved words to remain quoted. This is helpfull when using this option with JSHint's `es3` option. | ||
Disallows quoted keys in object if possible. | ||
Valid example: | ||
Valid example for mode true: | ||
var x = {a: 1}; | ||
var x = { a: { default: 1 } }; | ||
Valid example for mode "allButReserved": | ||
var x = {a: 1, 'default': 2}; | ||
Invalid example: | ||
@@ -587,3 +594,3 @@ | ||
*/ | ||
"safeContextKeyword": "that" | ||
"safeContextKeyword": "that", | ||
@@ -613,3 +620,9 @@ /* | ||
*/ | ||
"excludeFiles": ["node_modules/**"] | ||
"excludeFiles": ["node_modules/**"], | ||
/* | ||
Option: additionalRules | ||
Pluggable rules | ||
*/ | ||
"additionalRules": ["project-rules/*.js"] | ||
} | ||
@@ -616,0 +629,0 @@ ``` |
@@ -53,2 +53,10 @@ var Checker = require('../lib/checker'); | ||
}); | ||
it('should not report if reserved words when "allButReserved" mode is used', function() { | ||
checker = new Checker(); | ||
checker.registerDefaultRules(); | ||
checker.configure({ disallowQuotedKeysInObjects: 'allButReserved' }); | ||
assert(checker.checkString('var x = { "default": 1, "class": "foo" }').isEmpty()); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
413218
107
10268
647
7
10
+ Addedglob@3.2.7
+ Addedglob@3.2.7(transitive)
+ Addedinherits@2.0.4(transitive)