-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from brenolf/add-SpaceBeforeComma
- Loading branch information
Showing
6 changed files
with
121 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
}] | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
}] | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,8 @@ module.exports = { | |
return __current__ | ||
} | ||
|
||
return [2, {'before': true}] | ||
return [2, { | ||
before: true | ||
}] | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }]) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }]) | ||
}) | ||
}) |