You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|[app-imports](./docs/rules/app-imports.md)| App folder can import from shared and features with specific exceptions |
111
-
|[components-index-required](./docs/rules/components-index-required.md)| All components folders must contain an index.ts file for component exports |
112
-
|[cross-imports-alias](./docs/rules/cross-imports-alias.md)| Cross-layer imports must use the project root alias instead of absolute paths |
113
-
|[feature-imports](./docs/rules/feature-imports.md)| Features should only import from the shared layer or their own internal files |
114
-
|[feature-index-required](./docs/rules/feature-index-required.md)| Each feature folder must contain an index.ts file as its public API |
115
-
|[file-component-naming](./docs/rules/file-component-naming.md)| All Vue components must use PascalCase naming |
116
-
|[file-ts-naming](./docs/rules/file-ts-naming.md)| All TypeScript files must use camelCase naming |
117
-
|[folder-kebab-case](./docs/rules/folder-kebab-case.md)| All folders must use kebab-case naming |
118
-
|[internal-imports-relative](./docs/rules/internal-imports-relative.md)|Internal feature/shared/app imports should use relative paths instead of alias|
119
-
|[service-filename-no-suffix](./docs/rules/service-filename-no-suffix.md)| Service files must not have Service suffix |
|[app-imports](./docs/rules/app-imports.md)| App folder can import from shared and features with specific exceptions |
111
+
|[components-index-required](./docs/rules/components-index-required.md)| All components folders must contain an index.ts file for component exports |
112
+
|[cross-imports-alias](./docs/rules/cross-imports-alias.md)| Cross-layer imports must use the project root alias instead of absolute paths |
113
+
|[feature-imports](./docs/rules/feature-imports.md)| Features should only import from the shared layer or their own internal files |
114
+
|[feature-index-required](./docs/rules/feature-index-required.md)| Each feature folder must contain an index.ts file as its public API |
115
+
|[file-component-naming](./docs/rules/file-component-naming.md)| All Vue components must use PascalCase naming |
116
+
|[file-ts-naming](./docs/rules/file-ts-naming.md)| All TypeScript files must use camelCase naming |
117
+
|[folder-kebab-case](./docs/rules/folder-kebab-case.md)| All folders must use kebab-case naming |
118
+
|[internal-imports-relative](./docs/rules/internal-imports-relative.md)|Prefer relative imports for local feature/shared/app files but suggest alias for deep relative traversals.|
119
+
|[service-filename-no-suffix](./docs/rules/service-filename-no-suffix.md)| Service files must not have Service suffix |
Copy file name to clipboardExpand all lines: docs/rules/internal-imports-relative.md
+36Lines changed: 36 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,12 +17,30 @@ How it works
17
17
- Imports within shared or app when both sides are inside the same `shared` or `app` folders.
18
18
- If both source and target are within the project areas of interest but the import uses the project root alias (e.g. `@/features/...` or `@/shared/...`), the rule reports and recommends using a relative import instead.
19
19
20
+
Behavior details (new/important):
21
+
22
+
- depth control: the rule accepts a `depth` option (default: `2`) which defines how many `/` segments are allowed for relative imports before the rule suggests switching to the alias. In other words:
23
+
- Short relative imports (up to the configured `depth`) are preferred for clearly-local dependencies.
24
+
- Long/deep relative imports that exceed `depth` are considered "distant" and the rule will recommend using the project root alias (message id `useAliasImport`).
25
+
26
+
- Two message types are emitted by the rule:
27
+
-`useRelativeImport` — the import uses the project root alias but the target is local (same feature/shared/app); recommend changing to a relative import.
28
+
-`useAliasImport` — the import is a relative path that exceeds the configured `depth`; recommend changing to the project root alias for clarity.
29
+
30
+
- Alias exceptions: certain alias imports remain allowed (no report)
31
+
- Alias imports between different features (for example `@/features/featureA/...` importing `@/features/featureB/...`) are permitted.
32
+
- Alias imports from `app` files to targets outside `app` (and similarly from `shared` to outside `shared`) are permitted to avoid spurious reports when crossing architectural areas.
33
+
34
+
- Path normalization for monorepo / nested-app layouts: filenames like `apps/web/src/...` are normalized to the configured `rootPath` (for example `src/...`) before rule logic is applied. That means files under `apps/web/src` are treated the same as `src` files for the purposes of this rule.
35
+
20
36
## Options
21
37
22
38
The rule accepts an options object with the following properties:
23
39
24
40
-`ignores` (string[], default: `[]`) — array of minimatch glob patterns tested against the resolved project-relative filename. If any pattern matches, the rule will skip that file. Use this to permit exceptions during migration or for generated files.
25
41
42
+
-`depth` (number, default: `2`) — maximum number of `/` segments allowed for a relative import before the rule recommends switching to the project root alias. Increase this value if your feature layout commonly requires deeper relative traversals and you want to prefer relative imports more often.
43
+
26
44
Note: project-level settings control `rootPath`, `rootAlias`, `appPath`, `featuresPath`, and `sharedPath` used by the rule; those defaults are provided by the plugin and can be overridden via settings.
27
45
28
46
### Example configuration
@@ -62,6 +80,24 @@ import { theme } from '@/shared/utils/theme'
62
80
```
63
81
64
82
Correct:
83
+
Incorrect (relative import is too deep; prefer alias):
- The rule will still allow alias imports when crossing feature boundaries or when the import target is outside the same architectural area (see "Alias exceptions" above).
100
+
- Files that cannot be resolved to the project root (for example external scripts) are ignored; use the `ignores` option for explicit exceptions.
0 commit comments