Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit 585fdbd

Browse files
committed
disallowAllowSpacesInsideParentheses: reintroduce archaic "all" config option
Fixes #1027
1 parent b9e72cb commit 585fdbd

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

lib/rules/disallow-spaces-inside-parentheses.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Type: `Object` or `Boolean`
55
*
6-
* Values: `true` or Object with either `"only"` with array of tokens or `"all"` with `true` value
6+
* Values: `true` or Object with either `"only"` with array of tokens
77
*
88
* #### Example
99
*
@@ -45,7 +45,12 @@ module.exports.prototype = {
4545
var isObject = typeof option === 'object';
4646

4747
var error = 'disallowSpacesInsideParentheses option requires' +
48-
' true or object value with "all" or "only" properties ';
48+
' true or object value with "only" properties ';
49+
50+
// backcompat for 1.10: {all: true} #1027
51+
if (isObject && option.all === true) {
52+
option = true;
53+
}
4954

5055
if (typeof option === 'boolean') {
5156
assert(option === true, error);

test/rules/disallow-spaces-inside-parentheses.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ describe('rules/disallow-spaces-inside-parentheses', function() {
2121
checker.configure({ disallowSpacesInsideParentheses: {} });
2222
});
2323
});
24+
25+
it('should throw when all is specified but not true', function() {
26+
assert.throws(function() {
27+
checker.configure({ disallowSpacesInsideParentheses: { all: ['invalid'] } });
28+
});
29+
});
2430
});
2531

2632
describe('true', function() {
@@ -64,6 +70,18 @@ describe('rules/disallow-spaces-inside-parentheses', function() {
6470
});
6571
});
6672

73+
describe('"all" option', function() {
74+
beforeEach(function() {
75+
checker.configure({ disallowSpacesInsideParentheses: { all: true } });
76+
});
77+
78+
it('should report illegal space after opening round bracket', function() {
79+
assert(checker.checkString('( 1 + 2) * 3').getErrorCount() === 1);
80+
assert(checker.checkString('if ( 1 + 2)\n 3').getErrorCount() === 1);
81+
assert(checker.checkString('function my( a, b) { }').getErrorCount() === 1);
82+
});
83+
});
84+
6785
describe('es6', function() {
6886
beforeEach(function() {
6987
checker.configure({

0 commit comments

Comments
 (0)