Skip to content

Commit

Permalink
add test for excepting square brackets for never scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
Che Fisher committed Aug 10, 2019
1 parent 7c6e53e commit dcca713
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
7 changes: 1 addition & 6 deletions lib/rules/space-in-parens.js
Expand Up @@ -64,8 +64,7 @@ module.exports = {

/*
* workaround to prevent empty paren false positives
* if we always enforce a space, excepting parentheses
* then we never allow spaces inside parentheses (including empty ones)
* if we never allow a space inside parentheses this should include empty parentheses too
*/
if (ALWAYS && options.parenException) {
options.empty = true;
Expand Down Expand Up @@ -208,10 +207,6 @@ module.exports = {
return !isCloserException(left);
}

// if (left.type === "Identifier") {
// return false;
// }

if (left.type !== "Punctuator") {
return isCloserException(right);
}
Expand Down
15 changes: 12 additions & 3 deletions tests/lib/rules/space-in-parens.js
Expand Up @@ -277,12 +277,21 @@ ruleTester.run("space-in-parens", rule, {
]
},
{
code: "foo(bar( ))",
output: "foo( bar( ) )",
code: "foo(bar())",
output: "foo( bar() )",
options: ["never", { exceptions: ["()"] }],
errors: [
{ message: MISSING_OPENING_SPACE_ERROR, line: 1, column: 4 },
{ message: MISSING_CLOSING_SPACE_ERROR, line: 1, column: 11 }
{ message: MISSING_CLOSING_SPACE_ERROR, line: 1, column: 10 }
]
},
{
code: "foo([1,2], bar() )",
output: "foo( [1,2], bar())",
options: ["never", { exceptions: ["[]"] }],
errors: [
{ message: MISSING_OPENING_SPACE_ERROR, line: 1, column: 4 },
{ message: REJECTED_CLOSING_SPACE_ERROR, line: 1, column: 18 }
]
},
{
Expand Down

0 comments on commit dcca713

Please sign in to comment.