import-path-alias
When imports use the package's path aliases.
The rule
Agents read this text as written when they write and review code.
Use the package's configured path alias for every import. A package has aliases when it declares imports in package.json or compilerOptions.paths in tsconfig.json, and then never uses a relative path (./, ../), not even for a sibling file, a common/ subfolder or a package entry's re-exports.
When a package declares no aliases, use relative paths consistently.
Read the alias from the package's own declaration; never write one from memory, because packages differ.
A paths alias, declared in tsconfig.json. It takes no file extension:
// tsconfig.json
"paths": { "@/*": ["./src/*"] }
import { features } from '@/features/home/common/constants/features';
An imports alias, declared in package.json. It names the real file, so it carries the extension:
// package.json
"imports": { "#src/*": "./src/*" }
import { features } from '#src/features/home/common/constants/features.ts';
Incorrect in a package with either alias:
import { features } from './common/constants/features';
Then every import of a file reads the same, wherever it is written.
Examples
The check flags the incorrect code and passes the correct code. Each example is a small repo, because this rule looks across files. It opens on the file that matters; the other files are the repo around it.
Incorrect
import { formatRate } from '../common/utils/formatRate';export const getChargeLabel = (): string => formatRate();
Correct
import { formatRate } from '@/common/utils/formatRate';export const getChargeLabel = (): string => formatRate();
Configure
- Block
"blocking"Stops a run when a file the run changed breaks the rule. - AdviseDefault
"advisory"Reports it and hands it to the refactor agent. Never stops a run. - Off
"off"Not checked. Use it when your own linter already enforces the rule.
Add this to your lightsout.config.json, then change the value.
{"standards-rule-settings": {"import-path-alias": "advisory"}}