Skip to content

Conversation

@Rel1cx
Copy link
Owner

@Rel1cx Rel1cx commented Jan 6, 2026

No description provided.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the duplicate imports and exports rules by adding automatic merge suggestions. The changes transform these rules from simple detection-only rules to ones that can suggest concrete fixes by merging duplicate import/export statements.

Key Changes

  • Added suggestion generation with automatic merge functionality for both duplicate imports and exports
  • Refactored data tracking from simple Sets to structured objects that store full import/export information
  • Updated error messages to be more concise and accurate

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
packages/tsl-module/src/rules/no-duplicate-imports.ts Refactored to track full import details and added buildMergedImport function to generate merge suggestions
packages/tsl-module/src/rules/no-duplicate-imports.test.ts Added test expectations for merge suggestions including complex cases with inline type modifiers
packages/tsl-module/src/rules/no-duplicate-exports.ts Refactored to track export declarations and added buildSuggestions function for generating merge proposals
packages/tsl-module/src/rules/no-duplicate-exports.test.ts Added test expectations for merge suggestions
packages/tsl-module/docs/variables/noDuplicateImports.md Updated documentation to reflect "detect and merge" functionality
packages/tsl-module/docs/variables/noDuplicateExports.md Updated documentation to reflect "detect and merge" functionality
packages/tsl-module/docs/README.md Updated rule descriptions in the main documentation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +113 to +117
&& ts.isNamedImports(namedBindings)
? namedBindings.elements.map((el) => el.getText())
: [],
namespaceImport: namedBindings != null
&& ts.isNamespaceImport(namedBindings)
Copy link

Copilot AI Jan 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's inconsistent indentation in this conditional expression. Lines 112-113 use different indentation than line 114, making the code harder to read. The logical AND operator on line 113 should align consistently with the ternary expression.

Suggested change
&& ts.isNamedImports(namedBindings)
? namedBindings.elements.map((el) => el.getText())
: [],
namespaceImport: namedBindings != null
&& ts.isNamespaceImport(namedBindings)
&& ts.isNamedImports(namedBindings)
? namedBindings.elements.map((el) => el.getText())
: [],
namespaceImport: namedBindings != null
&& ts.isNamespaceImport(namedBindings)

Copilot uses AI. Check for mistakes.
function decodeImportClause(node: AST.ImportClause) {
const { name, namedBindings } = node;
return {
defaultImport: name?.getText(),
Copy link

Copilot AI Jan 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The decodeImportClause function returns unit for the namespaceImport field when not present (line 119), but returns undefined for the defaultImport field when name is absent (line 111). This inconsistency means the types don't match the ImportInfo interface which expects both fields to be string | unit. The defaultImport should also return unit when not present.

Suggested change
defaultImport: name?.getText(),
defaultImport: name != null ? name.getText() : unit,

Copilot uses AI. Check for mistakes.
@Rel1cx Rel1cx merged commit 0d73639 into main Jan 6, 2026
9 checks passed
@Rel1cx Rel1cx deleted the tsl-module branch January 6, 2026 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants