diff --git a/src/rules/default.js b/src/rules/default.js index 4aa5b965f..ed87e5442 100644 --- a/src/rules/default.js +++ b/src/rules/default.js @@ -19,7 +19,7 @@ module.exports = function (context) { if (imports.errors.length) { imports.reportErrors(context, node) - } else if (!imports.get('default')) { + } else if (imports.get('default') === undefined) { context.report(defaultSpecifier, 'No default export found in module.') } } diff --git a/tests/files/default-export-from-ignored.js b/tests/files/default-export-from-ignored.js new file mode 100644 index 000000000..3113adc1a --- /dev/null +++ b/tests/files/default-export-from-ignored.js @@ -0,0 +1 @@ +export { foo as default } from './common.js' diff --git a/tests/files/default-export-from-named.js b/tests/files/default-export-from-named.js new file mode 100644 index 000000000..916f7bafa --- /dev/null +++ b/tests/files/default-export-from-named.js @@ -0,0 +1 @@ +export { d as default } from './named-exports.js' diff --git a/tests/files/default-export-from.js b/tests/files/default-export-from.js new file mode 100644 index 000000000..1a3a112f5 --- /dev/null +++ b/tests/files/default-export-from.js @@ -0,0 +1 @@ +export default from './bar' diff --git a/tests/src/rules/default.js b/tests/src/rules/default.js index 4308d3483..003728295 100644 --- a/tests/src/rules/default.js +++ b/tests/src/rules/default.js @@ -66,6 +66,27 @@ ruleTester.run('default', rule, { parser: 'babel-eslint', }), + // #545: more ES7 cases + test({ + code: "import bar from './default-export-from.js';", + parser: 'babel-eslint', + }), + test({ + code: "import bar from './default-export-from-named.js';", + parser: 'babel-eslint', + }), + test({ + code: "import bar from './default-export-from-ignored.js';", + settings: { 'import/ignore': ['common'] }, + parser: 'babel-eslint', + }), + test({ + code: "export bar from './default-export-from-ignored.js';", + settings: { 'import/ignore': ['common'] }, + parser: 'babel-eslint', + }), + + ...SYNTAX_CASES, ],