-
Notifications
You must be signed in to change notification settings - Fork 4
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Кое-что поправить бы (виноват), а в целом топ 🚀
rules/layers-slices/slices.test.js
Outdated
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"}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue:
Лучше бы все же более "каноничные" примеры описывать в тесткейсах, а не выдуманные)
(тем более в референсной ишью такое есть)
suggestion:
Кажется, так гораздо нагляднее и "стабильнее" будет
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:
Как видишь, в указанном примере еще добавил относительные импорты - т.к. их тоже тут не стоит забывать 🤔
There was a problem hiding this comment.
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:
Тут нужен комментарий, что концепция компьютедов сейчас активно обсуждается кортимой и по сути является экспериментальным подходом по развязыванию сущностей)
См. подробнее тут
rules/layers-slices/slices.test.js
Outdated
@@ -12,6 +12,18 @@ const eslint = new ESLint({ | |||
|
|||
describe("Import boundaries between slices and layers", () => { | |||
|
|||
describe("IDDQD boundaries", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thoughts:
Потомки разгребая залежи Антарктиды потом долго будут задаваться вопросом, что за IDDQD встречается в писании культа FSD...
rules/layers-slices/layers.test.js
Outdated
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); | ||
}); | ||
}) | ||
|
There was a problem hiding this comment.
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}/!(_*){,/*}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Т.е. делаем запрет на импорты для всех слайсов, что начинаются НЕ с "_"?
Или как это трактовать?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ну да, но тут про разрешаем )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥 🔥 🔥
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}/_*`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thoughts:
Чет резко усложнилась реализация))
Надеюсь, что оправданно
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thoughts:
Уже триггернуться хотел))
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"; | ||
`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
praise:
Круто, что дополнительно пролинтил основные ограничения для GodMode!
Description
Добавлено:
References
#75 (comment)
Checklist