Skip to content

Commit

Permalink
Fix: object-curly-newline minProperties w/default export (fixes #10101)…
Browse files Browse the repository at this point in the history
… (#10103)

minProperties only tracks ImportSpecifier and ExportSpecifier nodes
  • Loading branch information
platinumazure committed Mar 21, 2018
1 parent 6f9e155 commit abc765c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/rules/object-curly-newline.js
Expand Up @@ -116,7 +116,8 @@ function areLineBreaksRequired(node, options, first, last) {
} else {

// is ImportDeclaration or ExportNamedDeclaration
objectProperties = node.specifiers;
objectProperties = node.specifiers
.filter(s => s.type === "ImportSpecifier" || s.type === "ExportSpecifier");
}

return objectProperties.length >= options.minProperties ||
Expand Down
17 changes: 17 additions & 0 deletions tests/lib/rules/object-curly-newline.js
Expand Up @@ -493,6 +493,10 @@ ruleTester.run("object-curly-newline", rule, {
].join("\n"),
options: [{ ImportDeclaration: { minProperties: 3 } }]
},
{
code: "import DefaultExport, {a} from 'module';",
options: [{ ImportDeclaration: { minProperties: 2 } }]
},

// "ExportDeclaration" ---------------------------------------------
{
Expand Down Expand Up @@ -1590,6 +1594,19 @@ ruleTester.run("object-curly-newline", rule, {
{ line: 3, column: 1, message: "Unexpected line break before this closing brace." }
]
},
{
code: "import DefaultExport, {a, b} from 'module';",
output: [
"import DefaultExport, {",
"a, b",
"} from 'module';"
].join("\n"),
options: [{ ImportDeclaration: { minProperties: 2 } }],
errors: [
{ line: 1, column: 23, message: "Expected a line break after this opening brace." },
{ line: 1, column: 28, message: "Expected a line break before this closing brace." }
]
},

// "ExportDeclaration" ---------------------------------------------
{
Expand Down

0 comments on commit abc765c

Please sign in to comment.