Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LINT: (Feedback) Make public-api-boundaries less strict #83

Closed
azinit opened this issue Feb 1, 2022 · 1 comment · Fixed by #87
Closed

LINT: (Feedback) Make public-api-boundaries less strict #83

azinit opened this issue Feb 1, 2022 · 1 comment · Fixed by #87

Comments

@azinit
Copy link
Member

azinit commented Feb 1, 2022

Problem

import/no-internal-modules (со слов @Krakazybik) не может отследить место , откуда вызывается импорт

Из-за этого для плагина импорты типа entities/foo/ui/bar - то же, что и ./ui/bar внутри сущности foo

И из-за этого "весь умный линтинг" со стороны DX сводится к "ставь реэкспорты везде где можно, независимо от слоев"

Idea

Разделения на "уровни строгости" вряд ли удастся достичь в рамках конфига. Но хотелось бы тем или иным путем - отключить триггеринг на отсутствие внутренних реэкспортов
(да, это все еще считается плохой практикой, лезть во внутренности внутри внутренностей, но это не так критично, по сравнению с Slices PublicAPI и Segments PublicAPI)

Solution

  • Как вариант - заиспользовать no-restricted-imports как более общую альтернативу no-internal-modules
  • При этом попытаться переосмыслить, как можно запретить линтинг внутренностей слайсов, но чтобы это можно было делать внутри самих слайсов 🤔

Example

// describe("Slices PublicAPI")
// 👎 Fail
import { Issues } from "pages/issues/ui";
import { IssueDetails } from "widgets/issue-details/ui/details"
import { AuthForm } from "features/auth-form/ui/form"
import { Button } from "shared/ui/button/button";
import { saveOrder } from "entities/order/model/actions";
import { orderModel } from "entities/order/model";
import { TicketCard } from "@/entities/ticket/ui";
// 👍 Pass
import { Issues } from "pages/issues";
import { IssueDetails } from "widgets/issue-details"
import { AuthForm } from "features/auth-form"
import { Button } from "shared/ui/button";
import { orderModel } from "entities/order";
import { TicketCard } from "@/entities/ticket";
import { AuthForm } from "features/auth/form"
import { Button } from "shared/ui";

// describe("Allow internal deep-imports")
// 👍 Pass (то же, что и Fail у SlicesAPI, но "место использования" тут влияет)
/** @path widgets/issue-details/index.ts */
import { IssueDetails } from "./ui/details"
/** @path features/auth-form/index.ts */
import { AuthForm } from "./ui/form"
/** @path features/auth-form/ui/form/content.tsx */
import * as authModel from "../../model";
/** @path shared/ui */
import { Button } from "./button/button";
/** @path entities/order/index.ts */
import { saveOrder } from "./model/actions";
import { orderModel } from "./model";
import { TicketCard } from "@/entities/ticket/ui";

Reference

#75 (comment)

@azinit
Copy link
Member Author

azinit commented Feb 1, 2022

@Krakazybik мб тебе тут будет что добавить 🤔

@azinit azinit pinned this issue Feb 2, 2022
@Krakazybik Krakazybik linked a pull request Feb 2, 2022 that will close this issue
3 tasks
@azinit azinit closed this as completed in #87 Feb 4, 2022
@azinit azinit changed the title LINT-75: (Feedback) Make public-api-boundaries less strict LINT: (Feedback) Make public-api-boundaries less strict Feb 4, 2022
@azinit azinit unpinned this issue Feb 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant