Skip to content

Commit

Permalink
Resolves #42, resolves #30
Browse files Browse the repository at this point in the history
  • Loading branch information
brenolf committed Apr 27, 2016
1 parent da91b57 commit af545b3
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 6 deletions.
27 changes: 27 additions & 0 deletions lib/dictionaries/jscs/disallowSpaceAfterComma.js
@@ -0,0 +1,27 @@
/**
* @fileoverview Translation for `disallowSpaceAfterComma` (JSCS) to ESLint
* @author Breno Lima de Freitas <https://breno.io>
* @copyright 2016 Breno Lima de Freitas. All rights reserved.
* See LICENSE file in root directory for full license.
*/

'use strict'

//------------------------------------------------------------------------------
// Rule Translation Definition
//------------------------------------------------------------------------------

module.exports = {
name: 'comma-spacing',
truthy: function(__current__) {
if (__current__) {
__current__[1].after = false

return __current__
}

return [2, {
after: false
}]
}
};
15 changes: 10 additions & 5 deletions lib/dictionaries/jscs/disallowSpaceBeforeComma.js
Expand Up @@ -13,10 +13,15 @@

module.exports = {
name: 'comma-spacing',
truthy: [
2,
{
'before': false
truthy: function(__current__) {
if (__current__) {
__current__[1].before = false

return __current__
}

return [2, {
before: false
}]
}
]
};
27 changes: 27 additions & 0 deletions lib/dictionaries/jscs/requireSpaceAfterComma.js
@@ -0,0 +1,27 @@
/**
* @fileoverview Translation for `requireSpaceAfterComma` (JSCS) to ESLint
* @author Breno Lima de Freitas <https://breno.io>
* @copyright 2016 Breno Lima de Freitas. All rights reserved.
* See LICENSE file in root directory for full license.
*/

'use strict'

//------------------------------------------------------------------------------
// Rule Translation Definition
//------------------------------------------------------------------------------

module.exports = {
name: 'comma-spacing',
truthy: function(__current__) {
if (__current__) {
__current__[1].after = true

return __current__
}

return [2, {
after: true
}]
}
};
4 changes: 3 additions & 1 deletion lib/dictionaries/jscs/requireSpaceBeforeComma.js
Expand Up @@ -20,6 +20,8 @@ module.exports = {
return __current__
}

return [2, {'before': true}]
return [2, {
before: true
}]
}
};
27 changes: 27 additions & 0 deletions test/dictionaries/jscs/disallowSpaceAfterComma.test.js
@@ -0,0 +1,27 @@
/**
* @fileoverview Tests for `disallowSpaceAfterComma` (JSCS) translation
* @author Breno Lima de Freitas <https://breno.io>
* @copyright 2016 Breno Lima de Freitas. All rights reserved.
* See LICENSE file in root directory for full license.
*/

'use strict'

//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------

var lib = require('../../../lib/dictionaries/jscs/disallowSpaceAfterComma.js')

var getFn = caller(lib)

describe('jscs#disallowSpaceAfterComma', function() {
it('converts the rule correctly', function() {
var fn = getFn()
var fnBound = getFn([2, { 'before': true, 'after': true }])

expect(fn()).to.eql([2, {'after': false}])

expect(fnBound()).to.eql([2, { 'before': true, 'after': false }])
})
})
27 changes: 27 additions & 0 deletions test/dictionaries/jscs/disallowSpaceBeforeComma.test.js
@@ -0,0 +1,27 @@
/**
* @fileoverview Tests for `disallowSpaceBeforeComma` (JSCS) translation
* @author Breno Lima de Freitas <https://breno.io>
* @copyright 2016 Breno Lima de Freitas. All rights reserved.
* See LICENSE file in root directory for full license.
*/

'use strict'

//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------

var lib = require('../../../lib/dictionaries/jscs/disallowSpaceBeforeComma.js')

var getFn = caller(lib)

describe('jscs#disallowSpaceBeforeComma', function() {
it('converts the rule correctly', function() {
var fn = getFn()
var fnBound = getFn([2, { 'before': true, 'after': true }])

expect(fn()).to.eql([2, {'before': false}])

expect(fnBound()).to.eql([2, { 'before': false, 'after': true }])
})
})

0 comments on commit af545b3

Please sign in to comment.