Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: object-curly-newline minProperties w/default export (fixes #10101) #10103

Merged
merged 1 commit into from Mar 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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