-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Bug Description
The public-api
rule incorrectly handles file extensions in fix suggestions when converting from specific file imports to directory imports.
Current Behavior
When importing from:
import { unblockNode, unblockNodesBulk } from "@/entities/node/api.ts";
The rule suggests:
import { unblockNode, unblockNodesBulk } from "@/entities/node.ts";
Expected Behavior
The rule should suggest:
import { unblockNode, unblockNodesBulk } from "@/entities/node";
Root Cause
In src/rules/public-api/model/convert-to-public-api.ts
, the convertToPublicApi
function removes the segment path (e.g., /api.ts
) but doesn't account for the case where the remaining path still has a file extension that should be removed when the result is a directory reference.
Reproduction
// Input
import { something } from "@/entities/node/api.ts";
// Current incorrect output
import { something } from "@/entities/node.ts";
// Expected correct output
import { something } from "@/entities/node";
Proposed Solution
The convertToPublicApi
function should check if the resulting path ends with a file extension (.ts
, .js
, etc.) and remove it when the result is meant to be a directory import.
Files Affected
src/rules/public-api/model/convert-to-public-api.ts
- Main logicsrc/rules/public-api/index.test.ts
- Add test case
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working