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-75(feedback): GodMode for _prefix slices #95

Merged
merged 5 commits into from
Feb 10, 2022

Conversation

Krakazybik
Copy link
Member

@Krakazybik Krakazybik commented Feb 7, 2022

Description

Добавлено:

  • Игнорирование ограничений layers-slices для слайсов с _prefix

References

#75 (comment)

Checklist

  • Description added
  • Self-reviewed
  • CI pass

@Krakazybik Krakazybik self-assigned this Feb 7, 2022
@Krakazybik Krakazybik requested a review from azinit February 7, 2022 21:02
Copy link
Member

@azinit azinit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Кое-что поправить бы (виноват), а в целом топ 🚀

Comment on lines 16 to 22
it("should lint without errors in GodMode", async () => {
const report = await eslint.lintText(`
import { System } from "pages/_system";
import { Routes } from "pages/_route";
`,
{filePath: "src/pages/ui/index.js"});

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: Лучше бы все же более "каноничные" примеры описывать в тесткейсах, а не выдуманные)
(тем более в референсной ишью такое есть)

suggestion: Кажется, так гораздо нагляднее и "стабильнее" будет

Suggested change
it("should lint without errors in GodMode", async () => {
const report = await eslint.lintText(`
import { System } from "pages/_system";
import { Routes } from "pages/_route";
`,
{filePath: "src/pages/ui/index.js"});
it("should lint without errors in GodMode for pages", async () => {
const report = await eslint.lintText(`
import { FooPage } from "pages/foo";
import { BarPage } from "../bar";
`,
{filePath: "src/pages/_router/private.routes.js"});

thoughts: Как видишь, в указанном примере еще добавил относительные импорты - т.к. их тоже тут не стоит забывать 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Плюс, добавил бы еще один тесткейс для компьютедов на всякий (т.к. тесты это и про спеку "эталонности" в том числе)

        it("should lint without errors in GodMode for entities", async () => {
            const report = await eslint.lintText(`
            import { userModel } from "entities/user";
            import { postModel } from "../../Post";
            `,
                {filePath: "src/entities/_computed/UserPost/model.js"});

thoughts: Тут нужен комментарий, что концепция компьютедов сейчас активно обсуждается кортимой и по сути является экспериментальным подходом по развязыванию сущностей)

См. подробнее тут

@@ -12,6 +12,18 @@ const eslint = new ESLint({

describe("Import boundaries between slices and layers", () => {

describe("IDDQD boundaries", () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thoughts: Потомки разгребая залежи Антарктиды потом долго будут задаваться вопросом, что за IDDQD встречается в писании культа FSD...

Comment on lines 15 to 26
describe("IDDQD boundaries", () => {
it("should lint without errors in GodMode", async () => {
const report = await eslint.lintText(`
import { Routes } from "pages/_route";
import { Config } from "processes/_config";
`,
{filePath: "src/entities/ui/index.js"});

assert.strictEqual(report[0].errorCount, 0);
});
})

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick(critical): Так, тут признаю, виноват что плохо описал - но между слоями мы импорты ПОКА ЕЩЕ не разрешаем благодаря префиксу)

Необходимо сделать только слайсов

@@ -15,7 +15,7 @@ const sharedLayerRule = {
const getLayersBoundariesElements = () =>
layersLib.FS_LAYERS.map((layer) => ({
type: layer,
pattern: `${layer}/*`,
pattern: `${layer}/!(_*){,/*}`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔🤔🤔

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Т.е. делаем запрет на импорты для всех слайсов, что начинаются НЕ с "_"?

Или как это трактовать?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ну да, но тут про разрешаем )

@Krakazybik Krakazybik requested a review from azinit February 9, 2022 19:32
Copy link
Member

@azinit azinit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 🔥 🔥

Comment on lines +18 to +31
mode: "folder",
capture: ["slices"],
}));

const getGodModeRules = () =>
layersLib.FS_LAYERS.map((layer) => ({
from: `gm_${layer}`,
allow: [layer, ...layersLib.getLowerLayers(layer)]
}));

const getGodModeElements = () =>
layersLib.FS_LAYERS.map((layer) => ({
type: `gm_${layer}`,
pattern: `${layer}/_*`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thoughts: Чет резко усложнилась реализация))

Надеюсь, что оправданно

Comment on lines +27 to +33
it("should lint with errors for computed entities", async () => {
const report = await eslint.lintText(`
import { userModel } from "entities/user";
`,
{filePath: "src/entities/computed/UserPost/model.js"});

assert.strictEqual(report[0].errorCount, 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thoughts: Уже триггернуться хотел))

Comment on lines +38 to +52
import { FooPage } from "pages/foo";
import { BagFeature } from "features/bag";
import { format } from "shared/lib/format";
import { BarPage } from "../bar";
`,
{filePath: "src/pages/_router/private.routes.js"});

assert.strictEqual(report[0].errorCount, 0);
});

it("should lint with errors in GodMode for upper layers", async () => {
const report = await eslint.lintText(`
import { MainPage } from "pages/main";
import { UserFeature } from "features/user";
`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: Круто, что дополнительно пролинтил основные ограничения для GodMode!

@azinit azinit merged commit 7db4305 into master Feb 10, 2022
@azinit azinit deleted the feat/LINT-75-god-mode-in-layers-slices branch February 10, 2022 07:05
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 this pull request may close these issues.

2 participants