Skip to content

Commit

Permalink
refactor if conditions in prefer-default-export to improve readibility
Browse files Browse the repository at this point in the history
Co-authored-by: Jordan Harband <ljharb@gmail.com>
  • Loading branch information
azyzz228 and ljharb committed Nov 26, 2022
1 parent c204a03 commit 8dfa229
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/rules/prefer-default-export.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,9 @@ module.exports = {
if (hasDefaultExport || hasStarExport || hasTypeExport) {
return;
}
if (target === 'single') {
if (specifierExportCount === 1) {
context.report(namedExportNode, SINGLE_EXPORT_ERROR_MESSAGE);
}
} else if (target === 'any') {
if (specifierExportCount > 0) {
if (target === 'single' && specifierExportCount === 1) {
context.report(namedExportNode, SINGLE_EXPORT_ERROR_MESSAGE);
} else if (target === 'any' && specifierExportCount > 0) {
context.report(namedExportNode, ANY_EXPORT_ERROR_MESSAGE);
}
}
Expand Down

0 comments on commit 8dfa229

Please sign in to comment.