Skip to content

Commit

Permalink
Resolves #39
Browse files Browse the repository at this point in the history
  • Loading branch information
brenolf committed Apr 27, 2016
1 parent c3d4078 commit 5b2924c
Show file tree
Hide file tree
Showing 4 changed files with 162 additions and 0 deletions.
29 changes: 29 additions & 0 deletions lib/dictionaries/jscs/disallowSpacesInGenerator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* @fileoverview Translation for `disallowSpacesInGenerator` (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: 'generator-star-spacing',
truthy: function(__current__, value) {
var obj = __current__ ? __current__[1] : {}

if (value.beforeStar) {
obj.before = false
}

if (value.afterStar) {
obj.after = false
}

return [2, obj]
}
};
29 changes: 29 additions & 0 deletions lib/dictionaries/jscs/requireSpacesInGenerator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* @fileoverview Translation for `requireSpacesInGenerator` (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: 'generator-star-spacing',
truthy: function(__current__, value) {
var obj = __current__ ? __current__[1] : {}

if (value.beforeStar) {
obj.before = true
}

if (value.afterStar) {
obj.after = true
}

return [2, obj]
}
};
52 changes: 52 additions & 0 deletions test/dictionaries/jscs/disallowSpacesInGenerator.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* @fileoverview Tests for `disallowSpacesInGenerator` (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/disallowSpacesInGenerator.js')

var getFn = caller(lib)

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

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

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

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

expect(fn({
beforeStar: false,
afterStar: false
})).to.eql([2, {}])
})
})
52 changes: 52 additions & 0 deletions test/dictionaries/jscs/requireSpacesInGenerator.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* @fileoverview Tests for `requireSpacesInGenerator` (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/requireSpacesInGenerator.js')

var getFn = caller(lib)

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

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

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

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

expect(fn({
beforeStar: false,
afterStar: false
})).to.eql([2, {}])
})
})

0 comments on commit 5b2924c

Please sign in to comment.