Skip to content

LINT: (Public API) Add semantic-imports rule #29

@azinit

Description

@azinit

Glossary

  • "External module" - entity/foo <-> entity/bar, entity/foo <-> shared/ui/button
  • "Internal module" - entity/foo <-> entity/foo/ui, entity/foo/ui/smth <-> entitiy/foo/lib

Description

  • Restrict relative imports for external modules (enforce for internalmodules)
  • Restrict absolute imports for internalmodules (enforce for external modules)

Example

// Fail 👎 
// @path features/baz/model/index.ts
import { ... } from "../../bar" // Sibling feature-slice
import { ... } from "@/features/baz/model/smth" // Invalid access to internal resource as external module
// Pass 👍 
// @path features/baz/model/index.ts
import { ... } from "../lib" // Import of internal module as internal resource - no illegal
import { ... } from "../entities/foo" // Lower layer slice - no illegal
import { ... } from "@entities/foo" // Import as external module
import { ... } from "shared/ui/button" // Import as external module

Reference

feature-sliced/documentation#52 (reply in thread)

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions