From a0401e280b8ccb1146b3431baa8ae4884fa1edb3 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Sun, 15 May 2016 11:38:56 -0700 Subject: [PATCH 1/2] Fix too-long line in newline-after-import --- src/rules/newline-after-import.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rules/newline-after-import.js b/src/rules/newline-after-import.js index 56149a4fd..ca7f1ca22 100644 --- a/src/rules/newline-after-import.js +++ b/src/rules/newline-after-import.js @@ -96,7 +96,9 @@ module.exports = function (context) { return } - if (nextStatement && (!nextRequireCall || !containsNodeOrEqual(nextStatement, nextRequireCall))) { + if (nextStatement && + (!nextRequireCall || !containsNodeOrEqual(nextStatement, nextRequireCall))) { + checkForNewLine(statementWithRequireCall, nextStatement, 'require') } }) From b377fc6459654b83973c8c143ba67217ce81de79 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Sun, 15 May 2016 11:39:44 -0700 Subject: [PATCH 2/2] prefer-default-export: count destructured exports --- src/rules/prefer-default-export.js | 12 ++++++++++-- tests/src/rules/prefer-default-export.js | 4 ++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/rules/prefer-default-export.js b/src/rules/prefer-default-export.js index 871cd8187..5d41d59bc 100644 --- a/src/rules/prefer-default-export.js +++ b/src/rules/prefer-default-export.js @@ -15,7 +15,15 @@ module.exports = function(context) { } }, 'ExportNamedDeclaration': function(node) { - namedExportCount++ + if (node.declaration && + node.declaration.declarations.length && + node.declaration.declarations[0].id.type === 'ObjectPattern') { + + namedExportCount += node.declaration.declarations[0].id.properties.length + } else { + namedExportCount++ + } + namedExportNode = node }, 'ExportDefaultDeclaration': function() { @@ -23,7 +31,7 @@ module.exports = function(context) { }, 'Program:exit': function() { - if (namedExportCount === 1 && specifierExportCount < 2 && !hasDefaultExport) { + if (namedExportCount === 1 && specifierExportCount < 2 && !hasDefaultExport) { context.report(namedExportNode, 'Prefer default export.') } }, diff --git a/tests/src/rules/prefer-default-export.js b/tests/src/rules/prefer-default-export.js index c3827eeba..354d91423 100644 --- a/tests/src/rules/prefer-default-export.js +++ b/tests/src/rules/prefer-default-export.js @@ -21,6 +21,10 @@ ruleTester.run('prefer-default-export', rule, { code: ` export { foo, bar }`, }), + test({ + code: ` + export const { foo, bar } = item;`, + }), test({ code: ` export { foo as default }`,