feature-sliced / eslint-config

🍰 Lint feature-sliced concepts by existing eslint plugins
https://npmjs.com/@feature-sliced/eslint-config
MIT License
117 stars 4 forks source link

Implement base version #8

Closed azinit closed 3 years ago

azinit commented 3 years ago

With primary functional:

to restrict imports (not private paths, only public API) ```ts // Fail import { Issues } from "pages/issues"; import { IssueDetails } from "features/issue-details" import { Button } from "shared/components/button"; // Pass import Routing from "pages"; // specific pages shouldn't be reexported import { IssueDetails } from "features" // all features should be reexported, for usage import { Button } from "shared/components"; // all components should be reexported, for usage ```
to order imports (app > pages > features > shared > models) ```ts // Fail import { Helper } from "./helpers"; import axios from "axios"; import { data } from "../fixtures"; import { Button } from "shared/components" import { IssueDetails, RepoList } from "features" import { debounce } from "shared/helpers" // Pass import axios from "axios"; // 1) external libs import { IssueDetails, RepoList } from "features" // 2) features import { Button } from "shared/components" // 3) shared/** import { debounce } from "shared/helpers" import { data } from "../fixtures"; // 4) parent import { Helper } from "./helpers"; // 5) sibling ```
to use only absolute imports (relative - only for module internal using) > **NOTE:** Be sure, that your tsconfig allows you to use absolute imports > - `baseUrl: "./src"` ```ts // Fail import Routing from "../../pages" import { IssueDetails } from "../features"; import { Button } from "../shared/components"; // Pass import Routing from "pages" import { IssueDetails } from "features"; import { Button } from "shared/components"; ```