Repository: brenolf/polyjuice (js)

Issue:
Add `SpacesInsideParenthesizedExpression` rules
* http://jscs.info/rule/disallowSpacesInsideParenthesizedExpression
* http://jscs.info/rule/requireSpacesInsideParenthesizedExpression

Pull request description:
Resolves #34

Patch:
diff --git a/lib/dictionaries/jscs.js b/lib/dictionaries/jscs.js
index ff0b0b3..39f3500 100644
--- a/lib/dictionaries/jscs.js
+++ b/lib/dictionaries/jscs.js
@@ -805,5 +805,43 @@ module.exports = {
   'requireSpaceBeforeBinaryOperators': {
     name: 'space-infix-ops',
     truthy: 2
+  },
+
+  'disallowSpacesInsideParenthesizedExpression': {
+    name: 'space-in-parens',
+    truthy: function (value) {
+      if (value === true) {
+        return [2, 'never']
+      }
+
+      var exceptions = []
+
+      var except = value.allExcept
+
+      if (value.allExcept.indexOf('{') > -1 || except.indexOf('}' > -1)) {
+        exceptions.push('{}')
+      }
+
+      return [2, 'never', { 'exceptions': exceptions }]
+    }
+  },
+
+  'requireSpacesInsideParenthesizedExpression': {
+    name: 'space-in-parens',
+    truthy: function (value) {
+      if (value === true) {
+        return [2, 'always']
+      }
+
+      var exceptions = []
+
+      var except = value.allExcept
+
+      if (value.allExcept.indexOf('{') > -1 || except.indexOf('}') > -1) {
+        exceptions.push('{}')
+      }
+
+      return [2, 'always', { 'exceptions': exceptions }]
+    }
   }
 }


Test patch:
diff --git a/test/dictionaries/jscs.test.js b/test/dictionaries/jscs.test.js
index 7be3461..196c3eb 100644
--- a/test/dictionaries/jscs.test.js
+++ b/test/dictionaries/jscs.test.js
@@ -620,8 +620,30 @@ describe('jscs', function () {
       'A', 'B'
     ])
 
-    expect(fn('CLRF')).to.eql(['ArrowFunctionExpression'])
+    expect(fn()).to.eql(['ArrowFunctionExpression'])
 
-    expect(fnBound('LF')).to.eql(['A', 'B', 'ArrowFunctionExpression'])
+    expect(fnBound()).to.eql(['A', 'B', 'ArrowFunctionExpression'])
+  })
+
+  it('converts requireSpacesInsideParenthesizedExpression correctly',
+  function () {
+    var fn = getFn('requireSpacesInsideParenthesizedExpression')
+
+    expect(fn(true)).to.eql([2, 'always'])
+
+    expect(fn({
+      'allExcept': ['{', '}']
+    })).to.eql([2, 'always', { 'exceptions': ['{}'] }])
+  })
+
+  it('converts disallowSpacesInsideParenthesizedExpression correctly',
+  function () {
+    var fn = getFn('disallowSpacesInsideParenthesizedExpression')
+
+    expect(fn(true)).to.eql([2, 'never'])
+
+    expect(fn({
+      'allExcept': ['{', '}']
+    })).to.eql([2, 'never', { 'exceptions': ['{}'] }])
   })
 })