Skip to content

Commit abc765c

Browse files
authoredMar 21, 2018
Fix: object-curly-newline minProperties w/default export (fixes #10101) (#10103)
minProperties only tracks ImportSpecifier and ExportSpecifier nodes
1 parent 6f9e155 commit abc765c

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed
 

‎lib/rules/object-curly-newline.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ function areLineBreaksRequired(node, options, first, last) {
116116
} else {
117117

118118
// is ImportDeclaration or ExportNamedDeclaration
119-
objectProperties = node.specifiers;
119+
objectProperties = node.specifiers
120+
.filter(s => s.type === "ImportSpecifier" || s.type === "ExportSpecifier");
120121
}
121122

122123
return objectProperties.length >= options.minProperties ||

‎tests/lib/rules/object-curly-newline.js

+17
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,10 @@ ruleTester.run("object-curly-newline", rule, {
493493
].join("\n"),
494494
options: [{ ImportDeclaration: { minProperties: 3 } }]
495495
},
496+
{
497+
code: "import DefaultExport, {a} from 'module';",
498+
options: [{ ImportDeclaration: { minProperties: 2 } }]
499+
},
496500

497501
// "ExportDeclaration" ---------------------------------------------
498502
{
@@ -1590,6 +1594,19 @@ ruleTester.run("object-curly-newline", rule, {
15901594
{ line: 3, column: 1, message: "Unexpected line break before this closing brace." }
15911595
]
15921596
},
1597+
{
1598+
code: "import DefaultExport, {a, b} from 'module';",
1599+
output: [
1600+
"import DefaultExport, {",
1601+
"a, b",
1602+
"} from 'module';"
1603+
].join("\n"),
1604+
options: [{ ImportDeclaration: { minProperties: 2 } }],
1605+
errors: [
1606+
{ line: 1, column: 23, message: "Expected a line break after this opening brace." },
1607+
{ line: 1, column: 28, message: "Expected a line break before this closing brace." }
1608+
]
1609+
},
15931610

15941611
// "ExportDeclaration" ---------------------------------------------
15951612
{

0 commit comments

Comments
 (0)
Please sign in to comment.