Skip to content

Commit

Permalink
refactor: fewer consts
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Dec 13, 2023
1 parent f790043 commit 9c48cb9
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/rules/esm-message-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,7 @@ export const esmMessageImport = RuleCreator.withoutDocs({
const replacementSpecifiers = node.specifiers.filter(
(s) => s.local.name !== 'dirname' && s.local.name !== 'fileURLToPath'
);
const replacementText = replacementSpecifiers.map((s) => context.sourceCode.getText(s)).join(', ');

const replacementRange = [
node.specifiers[0].range[0],
node.specifiers[node.specifiers.length - 1].range[1],
// +
// (replacementSpecifiers.every(ASTUtils.isNodeOfType(AST_NODE_TYPES.ImportDefaultSpecifier))
// ? 0
// : 1)
] as const;
return context.report({
node,
messageId: 'unnecessaryImport',
Expand All @@ -96,7 +87,10 @@ export const esmMessageImport = RuleCreator.withoutDocs({
node,
`import ${replacementSpecifiers[0].local.name} from '${node.source.value}'`
)
: fixer.replaceTextRange(replacementRange, replacementText),
: fixer.replaceTextRange(
[node.specifiers[0].range[0], node.specifiers[node.specifiers.length - 1].range[1]],
replacementSpecifiers.map((s) => context.sourceCode.getText(s)).join(', ')
),
});
}
}
Expand Down

0 comments on commit 9c48cb9

Please sign in to comment.