Skip to content

Commit

Permalink
Resolves #34
Browse files Browse the repository at this point in the history
  • Loading branch information
brenolf committed Apr 20, 2016
1 parent e76c3f1 commit 7ee12dd
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 2 deletions.
38 changes: 38 additions & 0 deletions lib/dictionaries/jscs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }]
}
}
}
26 changes: 24 additions & 2 deletions test/dictionaries/jscs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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': ['{}'] }])
})
})

0 comments on commit 7ee12dd

Please sign in to comment.