문제: `check:i18n`은 화면 파일 전체에 `/[가-힣]/`를 돌린다. 한국어 주석
한 줄에 실패하고, 영어 JSX 문구와 영어 접근성 이름은 통과한다. 샘플
화면에도 영어 literal이 이미 있었다(목록 h1 "Reference feature",
`limit {n}`, 목록 aria-label, 상세 "DetailPage"·"Resource ID"·"Created",
폼·상태 eyebrow). ko-KR 사용자에게 영어 문구와 스크린리더 이름이 섞인다.
고른 방법: (B) 문구 literal 검사를 ESLint `no-restricted-syntax` 선택자로
옮긴다(`eslint.config.ts`의 `screenTextSelectors`).
- 대상: 글자(`\p{L}`)가 든 `JSXText`, 표시·접근성 속성(`aria-label`,
`aria-description`, `aria-roledescription`, `aria-valuetext`,
`aria-placeholder`, `title`, `placeholder`, `alt`, `label`)의 문자열
literal, 그리고 `{"..."}` 형태의 같은 literal. 주석은 AST에 없어 빠진다.
구두점·숫자만 있는 문구는 통과한다.
- 범위(4.3절 "화면 코드"): 지난 `check:i18n`과 같은 폴더다. 공통 UI
폴더와 `src/features/*/presentation`. 컴포넌트 갤러리
`src/presentation/examples`는 지금처럼 뺀다. stories(`*.stories.tsx`)는
workshop 코드라 뺀다. 테스트는 이 폴더 밖이라 대상이 아니다.
- 이 항목은 일반 `no-restricted-syntax` 목록을 대체하므로 FE-OC-019
선택자(raw HTML, script 생성)를 함께 싣는다.
- `check:i18n`에는 catalog parity와 raw backend 메시지 검사만 남긴다.
raw HTML은 원래 전역 FE-OC-019 ESLint 규칙이 거절한다.
- `check:i18n:fixture`는 ESLint Node API로 같은 규칙을 fixture 트리에도
돌린다. forbidden 파일은 하나하나 거절돼야 하고(아니면 종료 코드 2),
새 `tests/fixtures/i18n/allowed` 트리(한국어 주석, 구두점, catalog
문구)는 통과해야 한다(거절되면 종료 코드 2). 게이트 기대값(종료 1,
"I18n contract failed:")은 그대로다.
- fixture 추가: allowed `korean-comment.tsx`, forbidden
`english-jsx-text.tsx`, `english-accessible-name.tsx`.
- 샘플의 영어 literal 11곳을 catalog로 옮겼다. 새 키 10개
(`reference.list.title`·`filterLimit`·`filterTags`·`resources`,
`reference.detail.eyebrow`·`titlePending`·`resourceId`·`createdAt`,
`reference.form.eyebrow`, `reference.status.eyebrow`). en-US 값은
예전 영어 문구 그대로라 en-US 화면은 바뀌지 않는다. ko-KR 화면은 한국어가
된다.
버린 대안:
- (A) 현 상태: 두 제품이 각각 막히거나 스크립트를 고쳤다.
- (C) "행동·상태 문구"만 정규식으로 고르는 제품 정책: 한국어 문장 목록에
기대 영어를 못 잡고, 템플릿 기본값으로 쓰기에 제품 특화다.
ESLint 설정은 제품이 자기 규칙으로 덮어쓸 수 있는 자리다(한 locale 제품,
고유명사 허용).
위험·한계:
- 식 안에서 만든 문구는 보지 못한다. template literal, 삼항식, 객체
prop(`heading.title` 같은 것)이 그렇다. 샘플의 이런 문구는 손으로
옮겼고, `reference-page.test.tsx`가 ko-KR main 영역을 catalog·데이터
밖 라틴 문자로 검사해 그 빈 곳을 샘플에서만 막는다.
- 고유명사·브랜드 이름도 걸린다. 제품이 선택자를 덮어쓰거나 그 줄에
`eslint-disable-next-line`을 쓴다.
- ko-KR route 제목(`route.REFERENCE_RESOURCE_*`)은 catalog 안의 영어라
그대로 뒀다(라우트 제목 정리는 0929/08-06 몫).
- `tests/e2e/reference-form.spec.ts`의 ko-KR 목록 h1 기대값을 "참조
기능"으로 바꿨다. e2e는 이 worktree에서 돌리지 않았다(webServer가
pnpm build를 부른다).
- 시각 골든(`tests/visual`)은 /examples/ui·states·platform만 찍는다.
샘플 화면과 nav 문구는 바뀌지 않아 골든 영향이 없다고 본다(미실행).
검증:
- RED(수정 전):
- E1 한글 주석 변이: `node scripts/check-i18n.ts` -> "hardcoded common
user-facing locale literal in .../reference-resource-status-page.tsx",
exit 1
- E1b 영어 JSX 문구 변이: `check-i18n.ts` PASS exit 0, `eslint` exit 0
- `check-i18n.ts --fixture` -> "I18n fixture was not rejected:
english-accessible-name.tsx, english-jsx-text.tsx", exit 2
- 새 ko-KR main 테스트: "limit 5 · tags ..." 가 남아 실패
- GREEN(수정 후):
- E1 변이: `check-i18n.ts` PASS, `eslint` exit 0
- E1b 변이: `eslint` -> 42:13 no-restricted-syntax, exit 1
- `check-i18n.ts` PASS(224 keys), `--fixture` -> forbidden 7개 모두
거절, "I18n contract failed:", exit 1. allowed에 영어 문구를 넣으면
"I18n allowed fixture was rejected", exit 2
- ko-KR main 테스트 통과
- `npx eslint src scripts tests recipes .storybook ... --max-warnings=0`
통과, app·test·node 타입 검사 통과
- vitest: tests/unit + tests/component 209 files 2725 tests,
tests/features 등 25 files 141 tests 통과
- `check-registries.ts` PASS, `check-ci-contract.ts` PASS,
`verify-documentation-readiness.ts` PASS_SCOPED
Refs: docs/reviews/2026-09-29-maturity-review/08-presentation.md 08-02, 4.3
1034 lines
30 KiB
TypeScript
1034 lines
30 KiB
TypeScript
import babelParser from "@babel/eslint-parser";
|
|
import eslint from "@eslint/js";
|
|
import reactHooks from "eslint-plugin-react-hooks";
|
|
import globals from "globals";
|
|
import type { Rule } from "eslint";
|
|
|
|
const sourceExtensions = "{ts,tsx,mts,cts}";
|
|
|
|
// 12-09. Editor-time aid only: these patterns show a layer violation while
|
|
// typing. The layer rules themselves live in .dependency-cruiser.json and are
|
|
// enforced by check:architecture, which resolves every import. Change a rule
|
|
// there first; these lists cover a subset and may lag behind it.
|
|
const layerPatterns = {
|
|
domain: [
|
|
"**/application/**",
|
|
"**/presentation/**",
|
|
"**/adapters/**",
|
|
"**/bootstrap/**",
|
|
"react",
|
|
"react-dom",
|
|
"@tanstack/**",
|
|
],
|
|
application: [
|
|
"**/presentation/**",
|
|
"**/adapters/**",
|
|
"**/bootstrap/**",
|
|
"react",
|
|
"react-dom",
|
|
"@tanstack/**",
|
|
],
|
|
presentation: [
|
|
"**/adapters/**",
|
|
"**/bootstrap/**",
|
|
"**/application/ports/out/**",
|
|
"@tanstack/**",
|
|
],
|
|
adapters: ["**/presentation/**", "**/bootstrap/**"],
|
|
};
|
|
|
|
// 12-11. Each pattern group carries the reason and the way out; the default
|
|
// message only named the pattern.
|
|
const layerMessages = {
|
|
domain:
|
|
"domain stays framework-neutral (.dependency-cruiser.json domain-is-framework-neutral). Move the code to application or pass the value in.",
|
|
application:
|
|
"application declares ports and never imports UI, adapters or bootstrap (application-does-not-know-concrete-runtime). Add a port under application/ports; bootstrap passes the adapter.",
|
|
presentation:
|
|
"presentation reaches the runtime through the application API (presentation-does-not-know-adapters). Use the application facade; bootstrap composes adapters.",
|
|
adapters:
|
|
"an adapter implements an application port and never imports UI or bootstrap (adapters-do-not-know-presentation). Pass what it needs through the port.",
|
|
} as const;
|
|
|
|
// 07-01. Deprecated aliases stay exported for downstream projects until they
|
|
// are removed, but nothing in this repository imports them. The ESLint parser
|
|
// here has no type information, so this stands in for a no-deprecated rule.
|
|
const deprecatedAliasImports = [
|
|
{
|
|
group: ["**/contracts/boundary-mapper.ts", "**/contracts/boundary-mapper"],
|
|
importNames: ["MappingResult"],
|
|
message:
|
|
"deprecated alias: import BoundaryMappingResult. The contract-side MappingResult lives in external-contract-runtime.ts.",
|
|
},
|
|
{
|
|
group: ["**/contracts/errors.ts", "**/contracts/errors"],
|
|
importNames: ["ApiFailure"],
|
|
message: "deprecated alias: import AppFailure.",
|
|
},
|
|
];
|
|
|
|
function restrictedImports(patterns: readonly string[], message: string) {
|
|
return [
|
|
"error",
|
|
{ patterns: [{ group: [...patterns], message }, ...deprecatedAliasImports] },
|
|
];
|
|
}
|
|
|
|
const restrictedBrowserDataProperties = [
|
|
"error",
|
|
...(["globalThis", "window", "self"] as const).flatMap((object) =>
|
|
[
|
|
"BroadcastChannel",
|
|
"localStorage",
|
|
"sessionStorage",
|
|
"indexedDB",
|
|
"caches",
|
|
"navigator",
|
|
"File",
|
|
"Blob",
|
|
"FileSystemFileHandle",
|
|
"FileSystemDirectoryHandle",
|
|
"showOpenFilePicker",
|
|
"showSaveFilePicker",
|
|
"URL",
|
|
].map((property) => ({
|
|
object,
|
|
property,
|
|
message:
|
|
"Browser file/storage APIs are adapter-owned; use the policy port.",
|
|
})),
|
|
),
|
|
{
|
|
object: "navigator",
|
|
property: "storage",
|
|
message: "StorageManager and OPFS access are adapter-owned.",
|
|
},
|
|
{
|
|
object: "URL",
|
|
property: "createObjectURL",
|
|
message: "Object URL allocation is owned by the preview/download adapter.",
|
|
},
|
|
{
|
|
object: "URL",
|
|
property: "revokeObjectURL",
|
|
message: "Object URL revocation is owned by the preview/download adapter.",
|
|
},
|
|
] as const;
|
|
|
|
const browserCapabilityRoots = new Set([
|
|
"globalThis",
|
|
"window",
|
|
"self",
|
|
"navigator",
|
|
"URL",
|
|
]);
|
|
const browserCapabilityProperties = new Set([
|
|
"BroadcastChannel",
|
|
"localStorage",
|
|
"sessionStorage",
|
|
"indexedDB",
|
|
"caches",
|
|
"navigator",
|
|
"storage",
|
|
"File",
|
|
"Blob",
|
|
"FileSystemFileHandle",
|
|
"FileSystemDirectoryHandle",
|
|
"showOpenFilePicker",
|
|
"showSaveFilePicker",
|
|
"URL",
|
|
"createObjectURL",
|
|
"revokeObjectURL",
|
|
]);
|
|
|
|
/**
|
|
* no-restricted-properties only recognizes the literal object identifier.
|
|
* This rule follows local aliases of browser roots so `const host =
|
|
* globalThis; host.indexedDB` cannot bypass the owned-adapter boundary.
|
|
*/
|
|
const noBrowserCapabilityAliasRule: Rule.RuleModule = {
|
|
meta: {
|
|
type: "problem",
|
|
schema: [],
|
|
messages: {
|
|
owned:
|
|
"Browser file/storage capabilities are owned by the approved common adapters.",
|
|
},
|
|
},
|
|
create(context) {
|
|
const aliases = new Set<string>();
|
|
|
|
const unwrap = (input: any): any => {
|
|
let node = input;
|
|
while (
|
|
node &&
|
|
[
|
|
"ChainExpression",
|
|
"TSAsExpression",
|
|
"TSNonNullExpression",
|
|
"TSTypeAssertion",
|
|
].includes(node.type)
|
|
) {
|
|
node = node.expression;
|
|
}
|
|
return node;
|
|
};
|
|
|
|
const propertyName = (input: any): string | null => {
|
|
const node = unwrap(input);
|
|
if (!node) return null;
|
|
if (!node.computed && node.property?.type === "Identifier") {
|
|
return node.property.name;
|
|
}
|
|
if (
|
|
node.computed &&
|
|
node.property?.type === "Literal" &&
|
|
typeof node.property.value === "string"
|
|
) {
|
|
return node.property.value;
|
|
}
|
|
if (
|
|
node.computed &&
|
|
node.property?.type === "StringLiteral"
|
|
) {
|
|
return node.property.value;
|
|
}
|
|
return null;
|
|
};
|
|
|
|
const isRootAlias = (input: any): boolean => {
|
|
const node = unwrap(input);
|
|
if (!node) return false;
|
|
if (node.type === "Identifier") {
|
|
return browserCapabilityRoots.has(node.name) ||
|
|
aliases.has(node.name);
|
|
}
|
|
if (node.type === "MemberExpression") {
|
|
return isRootAlias(node.object);
|
|
}
|
|
if (node.type === "LogicalExpression") {
|
|
return isRootAlias(node.left) || isRootAlias(node.right);
|
|
}
|
|
if (node.type === "ConditionalExpression") {
|
|
return (
|
|
isRootAlias(node.consequent) ||
|
|
isRootAlias(node.alternate)
|
|
);
|
|
}
|
|
if (node.type === "SequenceExpression") {
|
|
return node.expressions.some(isRootAlias);
|
|
}
|
|
return false;
|
|
};
|
|
|
|
const isBareRootAlias = (input: any): boolean => {
|
|
const node = unwrap(input);
|
|
if (!node) return false;
|
|
if (node.type === "Identifier") {
|
|
return browserCapabilityRoots.has(node.name) ||
|
|
aliases.has(node.name);
|
|
}
|
|
if (node.type === "LogicalExpression") {
|
|
return (
|
|
isBareRootAlias(node.left) ||
|
|
isBareRootAlias(node.right)
|
|
);
|
|
}
|
|
if (node.type === "ConditionalExpression") {
|
|
return (
|
|
isBareRootAlias(node.consequent) ||
|
|
isBareRootAlias(node.alternate)
|
|
);
|
|
}
|
|
if (node.type === "SequenceExpression") {
|
|
return node.expressions.some(isBareRootAlias);
|
|
}
|
|
return false;
|
|
};
|
|
|
|
const isDirectBrowserRoot = (input: any): boolean => {
|
|
const node = unwrap(input);
|
|
return (
|
|
node?.type === "Identifier" &&
|
|
browserCapabilityRoots.has(node.name)
|
|
);
|
|
};
|
|
|
|
const safeMethodThisBinding = (
|
|
call: any,
|
|
argumentIndex: number,
|
|
): boolean => {
|
|
if (argumentIndex !== 0) return false;
|
|
const callee = unwrap(call.callee);
|
|
if (
|
|
callee?.type !== "MemberExpression" ||
|
|
propertyName(callee) !== "bind"
|
|
) {
|
|
return false;
|
|
}
|
|
const target = unwrap(callee.object);
|
|
const targetName =
|
|
target?.type === "MemberExpression"
|
|
? propertyName(target)
|
|
: null;
|
|
return (
|
|
targetName !== null &&
|
|
!browserCapabilityProperties.has(targetName) &&
|
|
isRootAlias(target.object)
|
|
);
|
|
};
|
|
|
|
const rememberPattern = (patternInput: any, source: any): void => {
|
|
const pattern = unwrap(patternInput);
|
|
if (!pattern || !isRootAlias(source)) return;
|
|
if (pattern.type === "Identifier") {
|
|
aliases.add(pattern.name);
|
|
return;
|
|
}
|
|
if (pattern.type !== "ObjectPattern") return;
|
|
for (const property of pattern.properties ?? []) {
|
|
if (property.type !== "Property") continue;
|
|
const name =
|
|
property.computed
|
|
? property.key?.value
|
|
: property.key?.name ?? property.key?.value;
|
|
if (
|
|
typeof name === "string" &&
|
|
browserCapabilityProperties.has(name)
|
|
) {
|
|
context.report({ node: property, messageId: "owned" });
|
|
}
|
|
}
|
|
};
|
|
|
|
return {
|
|
VariableDeclarator(node: any) {
|
|
rememberPattern(node.id, node.init);
|
|
},
|
|
AssignmentExpression(node: any) {
|
|
rememberPattern(node.left, node.right);
|
|
const target = unwrap(node.left);
|
|
if (
|
|
target?.type !== "Identifier" &&
|
|
target?.type !== "ObjectPattern" &&
|
|
isBareRootAlias(node.right)
|
|
) {
|
|
context.report({ node: node.right, messageId: "owned" });
|
|
}
|
|
},
|
|
AssignmentPattern(node: any) {
|
|
rememberPattern(node.left, node.right);
|
|
},
|
|
PropertyDefinition(node: any) {
|
|
if (isBareRootAlias(node.value)) {
|
|
context.report({ node: node.value, messageId: "owned" });
|
|
}
|
|
},
|
|
MemberExpression(node: any) {
|
|
const name = propertyName(node);
|
|
if (
|
|
isRootAlias(node.object) &&
|
|
((name !== null &&
|
|
browserCapabilityProperties.has(name)) ||
|
|
(name === null && node.computed))
|
|
) {
|
|
context.report({ node, messageId: "owned" });
|
|
}
|
|
},
|
|
CallExpression(node: any) {
|
|
for (const [index, argument] of (
|
|
node.arguments ?? []
|
|
).entries()) {
|
|
const candidate =
|
|
argument.type === "SpreadElement"
|
|
? argument.argument
|
|
: argument;
|
|
if (
|
|
isDirectBrowserRoot(candidate) &&
|
|
!safeMethodThisBinding(node, index)
|
|
) {
|
|
context.report({ node: argument, messageId: "owned" });
|
|
}
|
|
}
|
|
const callee = unwrap(node.callee);
|
|
if (
|
|
callee?.type !== "MemberExpression" ||
|
|
propertyName(callee) !== "get" ||
|
|
unwrap(callee.object)?.type !== "Identifier" ||
|
|
unwrap(callee.object).name !== "Reflect" ||
|
|
!isRootAlias(node.arguments?.[0])
|
|
) {
|
|
return;
|
|
}
|
|
const key = unwrap(node.arguments?.[1]);
|
|
if (
|
|
(key?.type === "Literal" ||
|
|
key?.type === "StringLiteral") &&
|
|
typeof key.value === "string" &&
|
|
browserCapabilityProperties.has(key.value)
|
|
) {
|
|
context.report({ node, messageId: "owned" });
|
|
}
|
|
},
|
|
NewExpression(node: any) {
|
|
for (const argument of node.arguments ?? []) {
|
|
const candidate =
|
|
argument.type === "SpreadElement"
|
|
? argument.argument
|
|
: argument;
|
|
if (isBareRootAlias(candidate)) {
|
|
context.report({ node: argument, messageId: "owned" });
|
|
}
|
|
}
|
|
},
|
|
Property(node: any) {
|
|
if (
|
|
node.parent?.type === "ObjectExpression" &&
|
|
isBareRootAlias(node.value)
|
|
) {
|
|
context.report({ node: node.value, messageId: "owned" });
|
|
}
|
|
},
|
|
ArrayExpression(node: any) {
|
|
for (const element of node.elements ?? []) {
|
|
if (isBareRootAlias(element)) {
|
|
context.report({ node: element, messageId: "owned" });
|
|
}
|
|
}
|
|
},
|
|
ReturnStatement(node: any) {
|
|
if (isBareRootAlias(node.argument)) {
|
|
context.report({ node: node.argument, messageId: "owned" });
|
|
}
|
|
},
|
|
ArrowFunctionExpression(node: any) {
|
|
if (
|
|
node.expression === true &&
|
|
isBareRootAlias(node.body)
|
|
) {
|
|
context.report({ node: node.body, messageId: "owned" });
|
|
}
|
|
},
|
|
};
|
|
},
|
|
};
|
|
|
|
const browserDataBoundaryPlugin = {
|
|
rules: {
|
|
"no-capability-alias": noBrowserCapabilityAliasRule,
|
|
},
|
|
};
|
|
|
|
const commonLanguageOptions = {
|
|
ecmaVersion: "latest",
|
|
sourceType: "module",
|
|
globals: {
|
|
...globals.browser,
|
|
...globals.node,
|
|
},
|
|
};
|
|
|
|
const commonSecurityRules = {
|
|
"no-eval": "error",
|
|
"no-new-func": "error",
|
|
"no-script-url": "error",
|
|
"no-restricted-syntax": [
|
|
"error",
|
|
{
|
|
selector: "JSXAttribute[name.name='dangerouslySetInnerHTML']",
|
|
message: "Raw HTML injection is prohibited by FE-OC-019.",
|
|
},
|
|
{
|
|
selector:
|
|
"CallExpression[callee.object.name='document'][callee.property.name='createElement'][arguments.0.value='script']",
|
|
message: "Runtime script construction is prohibited by FE-OC-019.",
|
|
},
|
|
],
|
|
};
|
|
|
|
const hookRules = {
|
|
"react-hooks/rules-of-hooks": "error",
|
|
"react-hooks/exhaustive-deps": "error",
|
|
};
|
|
|
|
// 0929/08-02. Screen code takes its words from the message catalog. Comments
|
|
// are not in the AST, so only rendered text and accessible names are checked:
|
|
// JSX text and the display/accessibility attributes below that hold a letter
|
|
// in any script. Punctuation and numbers pass. Text built in an expression (a
|
|
// template literal, a ternary, an object prop such as `heading.title`) is not
|
|
// seen; review catches those. A product replaces these selectors in its own
|
|
// config, for example to allow a brand name or to drop the rule for a
|
|
// one-locale product. The component gallery (src/presentation/examples) and
|
|
// stories are workshop code and stay out; tests are outside these folders.
|
|
const screenTextDirectories = [
|
|
"src/presentation/boundaries",
|
|
"src/presentation/components",
|
|
"src/presentation/design-system",
|
|
"src/presentation/forms",
|
|
"src/presentation/layouts",
|
|
"src/presentation/pages",
|
|
"src/presentation/routes",
|
|
"src/presentation/templates",
|
|
"src/features/*/presentation",
|
|
];
|
|
const screenTextAttributes =
|
|
"/^(?:aria-label|aria-description|aria-roledescription|aria-valuetext|aria-placeholder|title|placeholder|alt|label)$/";
|
|
const screenTextMessage =
|
|
"Screen words come from the message catalog: use message(key) (0929/08-02).";
|
|
const screenTextSelectors = [
|
|
{
|
|
selector: "JSXText[value=/\\p{L}/u]",
|
|
message: screenTextMessage,
|
|
},
|
|
{
|
|
selector: `JSXElement > JSXExpressionContainer > Literal[value=/\\p{L}/u]`,
|
|
message: screenTextMessage,
|
|
},
|
|
{
|
|
selector: `JSXAttribute[name.name=${screenTextAttributes}] > Literal[value=/\\p{L}/u]`,
|
|
message: screenTextMessage,
|
|
},
|
|
{
|
|
selector: `JSXAttribute[name.name=${screenTextAttributes}] > JSXExpressionContainer > Literal[value=/\\p{L}/u]`,
|
|
message: screenTextMessage,
|
|
},
|
|
];
|
|
|
|
export default [
|
|
{
|
|
ignores: [
|
|
"dist/**",
|
|
"node_modules/**",
|
|
"artifacts/**",
|
|
"tests/fixtures/typecheck/**",
|
|
"tests/fixtures/architecture/forbidden/**",
|
|
"tests/fixtures/diagnostics/forbidden/**",
|
|
"tests/fixtures/i18n/forbidden/**",
|
|
"tests/fixtures/security/forbidden/**",
|
|
"tests/fixtures/optional-recipes/**",
|
|
"tests/fixtures/browser-file-storage-boundaries/**",
|
|
],
|
|
},
|
|
eslint.configs.recommended,
|
|
{
|
|
files: [`**/*.${sourceExtensions}`],
|
|
languageOptions: {
|
|
...commonLanguageOptions,
|
|
parserOptions: {
|
|
ecmaFeatures: { jsx: true },
|
|
},
|
|
},
|
|
plugins: {
|
|
"react-hooks": reactHooks,
|
|
},
|
|
rules: {
|
|
...commonSecurityRules,
|
|
...hookRules,
|
|
},
|
|
},
|
|
{
|
|
files: ["**/*.{ts,mts,cts}"],
|
|
languageOptions: {
|
|
...commonLanguageOptions,
|
|
parser: babelParser,
|
|
parserOptions: {
|
|
requireConfigFile: false,
|
|
babelOptions: {
|
|
plugins: [
|
|
["@babel/plugin-syntax-typescript", { isTSX: false }],
|
|
],
|
|
},
|
|
},
|
|
},
|
|
rules: {
|
|
"no-undef": "off",
|
|
"no-unused-vars": "off",
|
|
},
|
|
},
|
|
{
|
|
files: ["**/*.d.ts"],
|
|
languageOptions: {
|
|
...commonLanguageOptions,
|
|
parser: babelParser,
|
|
parserOptions: {
|
|
requireConfigFile: false,
|
|
babelOptions: {
|
|
plugins: [
|
|
["@babel/plugin-syntax-typescript", { dts: true }],
|
|
],
|
|
},
|
|
},
|
|
},
|
|
rules: {
|
|
"no-undef": "off",
|
|
"no-unused-vars": "off",
|
|
},
|
|
},
|
|
{
|
|
files: ["**/*.tsx"],
|
|
languageOptions: {
|
|
...commonLanguageOptions,
|
|
parser: babelParser,
|
|
parserOptions: {
|
|
requireConfigFile: false,
|
|
babelOptions: {
|
|
plugins: [
|
|
[
|
|
"@babel/plugin-syntax-typescript",
|
|
{ allExtensions: true, isTSX: true },
|
|
],
|
|
"@babel/plugin-syntax-jsx",
|
|
],
|
|
},
|
|
},
|
|
},
|
|
rules: {
|
|
"no-undef": "off",
|
|
"no-unused-vars": "off",
|
|
},
|
|
},
|
|
{
|
|
files: [
|
|
`src/domain/**/*.${sourceExtensions}`,
|
|
`src/application/**/*.${sourceExtensions}`,
|
|
`src/presentation/**/*.${sourceExtensions}`,
|
|
`src/bootstrap/**/*.${sourceExtensions}`,
|
|
`src/features/**/*.${sourceExtensions}`,
|
|
`src/adapters/**/*.${sourceExtensions}`,
|
|
],
|
|
ignores: [
|
|
`src/adapters/browser-file-storage/**/*.${sourceExtensions}`,
|
|
`src/adapters/browser-files/**/*.${sourceExtensions}`,
|
|
`src/adapters/browser-transfer/**/*.${sourceExtensions}`,
|
|
`src/adapters/cache-storage/**/*.${sourceExtensions}`,
|
|
`src/adapters/cross-context-invalidation/**/*.${sourceExtensions}`,
|
|
`src/adapters/service-worker/**/*.${sourceExtensions}`,
|
|
`src/bootstrap/register-service-worker.ts`,
|
|
`src/adapters/platform/browser-lifecycle.ts`,
|
|
`src/adapters/storage/**/*.${sourceExtensions}`,
|
|
`src/adapters/storage/indexeddb/**/*.${sourceExtensions}`,
|
|
`src/adapters/storage/opfs/**/*.${sourceExtensions}`,
|
|
],
|
|
plugins: {
|
|
"browser-data-boundary": browserDataBoundaryPlugin,
|
|
},
|
|
rules: {
|
|
"browser-data-boundary/no-capability-alias": "error",
|
|
},
|
|
},
|
|
{
|
|
// 07-01. Every file outside a layer rule; the layer rules below replace
|
|
// this entry and carry the same aliases through restrictedImports.
|
|
files: [`src/**/*.${sourceExtensions}`, `tests/**/*.${sourceExtensions}`],
|
|
rules: {
|
|
"no-restricted-imports": ["error", { patterns: deprecatedAliasImports }],
|
|
},
|
|
},
|
|
{
|
|
files: [`src/domain/**/*.${sourceExtensions}`],
|
|
rules: {
|
|
"no-restricted-imports": restrictedImports(layerPatterns.domain, layerMessages.domain),
|
|
"no-restricted-properties": restrictedBrowserDataProperties,
|
|
"no-restricted-globals": [
|
|
"error",
|
|
"window",
|
|
"document",
|
|
"BroadcastChannel",
|
|
"localStorage",
|
|
"sessionStorage",
|
|
"fetch",
|
|
"indexedDB",
|
|
"caches",
|
|
"navigator",
|
|
"File",
|
|
"Blob",
|
|
"FileSystemFileHandle",
|
|
"FileSystemDirectoryHandle",
|
|
"showOpenFilePicker",
|
|
"showSaveFilePicker",
|
|
],
|
|
},
|
|
},
|
|
{
|
|
files: [`src/application/**/*.${sourceExtensions}`],
|
|
rules: {
|
|
"no-restricted-imports": restrictedImports(layerPatterns.application, layerMessages.application),
|
|
"no-restricted-properties": restrictedBrowserDataProperties,
|
|
"no-restricted-globals": [
|
|
"error",
|
|
"window",
|
|
"document",
|
|
"BroadcastChannel",
|
|
"localStorage",
|
|
"sessionStorage",
|
|
"fetch",
|
|
"indexedDB",
|
|
"caches",
|
|
"navigator",
|
|
"File",
|
|
"Blob",
|
|
"FileSystemFileHandle",
|
|
"FileSystemDirectoryHandle",
|
|
"showOpenFilePicker",
|
|
"showSaveFilePicker",
|
|
],
|
|
},
|
|
},
|
|
{
|
|
files: [`src/presentation/**/*.${sourceExtensions}`],
|
|
rules: {
|
|
"no-restricted-imports": restrictedImports(layerPatterns.presentation, layerMessages.presentation),
|
|
"no-restricted-properties": restrictedBrowserDataProperties,
|
|
"no-restricted-globals": [
|
|
"error",
|
|
"fetch",
|
|
"BroadcastChannel",
|
|
"localStorage",
|
|
"sessionStorage",
|
|
"indexedDB",
|
|
"caches",
|
|
"File",
|
|
"Blob",
|
|
"FileSystemFileHandle",
|
|
"FileSystemDirectoryHandle",
|
|
"showOpenFilePicker",
|
|
"showSaveFilePicker",
|
|
],
|
|
},
|
|
},
|
|
{
|
|
files: [
|
|
`src/presentation/adapters/query/**/*.${sourceExtensions}`,
|
|
],
|
|
rules: {
|
|
"no-restricted-imports": restrictedImports(
|
|
[
|
|
"**/adapters/http/**",
|
|
"**/adapters/storage/**",
|
|
"**/adapters/auth/**",
|
|
"**/bootstrap/**",
|
|
"**/application/ports/out/**",
|
|
],
|
|
"the TanStack Query binding may import @tanstack only; reach adapters through application ports (presentation-does-not-know-adapters).",
|
|
),
|
|
},
|
|
},
|
|
{
|
|
files: [`src/presentation/templates/**/*.${sourceExtensions}`],
|
|
rules: {
|
|
"no-restricted-imports": restrictedImports(
|
|
[
|
|
"**/application/**",
|
|
"**/adapters/**",
|
|
"**/bootstrap/**",
|
|
"@tanstack/**",
|
|
],
|
|
"page templates own layout only (page-templates-own-layout-only). Take data and actions as props from the page.",
|
|
),
|
|
},
|
|
},
|
|
{
|
|
files: [
|
|
`src/bootstrap/**/*.${sourceExtensions}`,
|
|
`src/features/installed-feature-*.${sourceExtensions}`,
|
|
],
|
|
rules: {
|
|
"no-restricted-properties": restrictedBrowserDataProperties,
|
|
"no-restricted-globals": [
|
|
"error",
|
|
"BroadcastChannel",
|
|
"localStorage",
|
|
"sessionStorage",
|
|
"indexedDB",
|
|
"caches",
|
|
"File",
|
|
"Blob",
|
|
"FileSystemFileHandle",
|
|
"FileSystemDirectoryHandle",
|
|
"showOpenFilePicker",
|
|
"showSaveFilePicker",
|
|
],
|
|
},
|
|
},
|
|
{
|
|
files: [`src/adapters/**/*.${sourceExtensions}`],
|
|
rules: {
|
|
"no-restricted-imports": restrictedImports(layerPatterns.adapters, layerMessages.adapters),
|
|
"no-restricted-properties": restrictedBrowserDataProperties,
|
|
"no-restricted-globals": [
|
|
"error",
|
|
"BroadcastChannel",
|
|
"localStorage",
|
|
"sessionStorage",
|
|
"indexedDB",
|
|
"caches",
|
|
"navigator",
|
|
"File",
|
|
"Blob",
|
|
"FileSystemFileHandle",
|
|
"FileSystemDirectoryHandle",
|
|
"showOpenFilePicker",
|
|
"showSaveFilePicker",
|
|
],
|
|
},
|
|
},
|
|
{
|
|
files: [
|
|
`src/adapters/browser-file-storage/**/*.${sourceExtensions}`,
|
|
`src/adapters/browser-files/**/*.${sourceExtensions}`,
|
|
`src/adapters/browser-transfer/**/*.${sourceExtensions}`,
|
|
`src/adapters/cache-storage/**/*.${sourceExtensions}`,
|
|
`src/adapters/cross-context-invalidation/**/*.${sourceExtensions}`,
|
|
`src/adapters/service-worker/**/*.${sourceExtensions}`,
|
|
`src/bootstrap/register-service-worker.ts`,
|
|
`src/adapters/platform/browser-lifecycle.ts`,
|
|
`src/adapters/storage/**/*.${sourceExtensions}`,
|
|
`src/adapters/storage/indexeddb/**/*.${sourceExtensions}`,
|
|
`src/adapters/storage/opfs/**/*.${sourceExtensions}`,
|
|
],
|
|
rules: {
|
|
"no-restricted-properties": "off",
|
|
"no-restricted-globals": "off",
|
|
},
|
|
},
|
|
{
|
|
files: [`src/features/*/domain/**/*.${sourceExtensions}`],
|
|
rules: {
|
|
"no-restricted-imports": restrictedImports(layerPatterns.domain, layerMessages.domain),
|
|
"no-restricted-properties": restrictedBrowserDataProperties,
|
|
"no-restricted-globals": [
|
|
"error",
|
|
"window",
|
|
"document",
|
|
"BroadcastChannel",
|
|
"localStorage",
|
|
"sessionStorage",
|
|
"fetch",
|
|
"indexedDB",
|
|
"caches",
|
|
"navigator",
|
|
"File",
|
|
"Blob",
|
|
"FileSystemFileHandle",
|
|
"FileSystemDirectoryHandle",
|
|
"showOpenFilePicker",
|
|
"showSaveFilePicker",
|
|
],
|
|
},
|
|
},
|
|
{
|
|
files: [`src/features/*/application/**/*.${sourceExtensions}`],
|
|
rules: {
|
|
"no-restricted-imports": restrictedImports(layerPatterns.application, layerMessages.application),
|
|
"no-restricted-properties": restrictedBrowserDataProperties,
|
|
"no-restricted-globals": [
|
|
"error",
|
|
"window",
|
|
"document",
|
|
"BroadcastChannel",
|
|
"localStorage",
|
|
"sessionStorage",
|
|
"fetch",
|
|
"indexedDB",
|
|
"caches",
|
|
"navigator",
|
|
"File",
|
|
"Blob",
|
|
"FileSystemFileHandle",
|
|
"FileSystemDirectoryHandle",
|
|
"showOpenFilePicker",
|
|
"showSaveFilePicker",
|
|
],
|
|
},
|
|
},
|
|
{
|
|
files: [`src/features/*/presentation/**/*.${sourceExtensions}`],
|
|
rules: {
|
|
"no-restricted-imports": restrictedImports(
|
|
[
|
|
"**/features/*/adapters/**",
|
|
"**/adapters/http/**",
|
|
"**/adapters/storage/**",
|
|
"**/adapters/auth/**",
|
|
"**/bootstrap/**",
|
|
"**/application/ports/out/**",
|
|
"@tanstack/**",
|
|
],
|
|
"feature presentation calls its application API (feature-presentation-does-not-know-outbound-adapters). Bootstrap wires the adapters.",
|
|
),
|
|
"no-restricted-properties": restrictedBrowserDataProperties,
|
|
"no-restricted-globals": [
|
|
"error",
|
|
"fetch",
|
|
"BroadcastChannel",
|
|
"localStorage",
|
|
"sessionStorage",
|
|
"indexedDB",
|
|
"caches",
|
|
"File",
|
|
"Blob",
|
|
"FileSystemFileHandle",
|
|
"FileSystemDirectoryHandle",
|
|
"showOpenFilePicker",
|
|
"showSaveFilePicker",
|
|
],
|
|
},
|
|
},
|
|
{
|
|
files: [`src/features/*/adapters/**/*.${sourceExtensions}`],
|
|
rules: {
|
|
"no-restricted-imports": restrictedImports(
|
|
[
|
|
"**/presentation/**",
|
|
"**/bootstrap/**",
|
|
"@tanstack/**",
|
|
],
|
|
"a feature adapter implements the feature's ports and never imports UI or bootstrap (feature-adapters-do-not-know-presentation).",
|
|
),
|
|
"no-restricted-properties": restrictedBrowserDataProperties,
|
|
"no-restricted-globals": [
|
|
"error",
|
|
"BroadcastChannel",
|
|
"localStorage",
|
|
"sessionStorage",
|
|
"indexedDB",
|
|
"caches",
|
|
"navigator",
|
|
"File",
|
|
"Blob",
|
|
"FileSystemFileHandle",
|
|
"FileSystemDirectoryHandle",
|
|
"showOpenFilePicker",
|
|
"showSaveFilePicker",
|
|
],
|
|
},
|
|
},
|
|
{
|
|
// The same folders inside an i18n fixture tree, so check:i18n:fixture
|
|
// runs this rule on its fixtures. This entry replaces the general
|
|
// no-restricted-syntax list, so it carries the FE-OC-019 selectors too.
|
|
files: screenTextDirectories.flatMap((directory) => [
|
|
`${directory}/**/*.tsx`,
|
|
`tests/fixtures/i18n/*/${directory}/**/*.tsx`,
|
|
]),
|
|
ignores: ["**/*.stories.tsx"],
|
|
rules: {
|
|
"no-restricted-syntax": [
|
|
...commonSecurityRules["no-restricted-syntax"],
|
|
...screenTextSelectors,
|
|
],
|
|
},
|
|
},
|
|
{
|
|
files: [`tests/**/*.${sourceExtensions}`],
|
|
languageOptions: {
|
|
globals: {
|
|
...globals.browser,
|
|
...globals.node,
|
|
},
|
|
},
|
|
},
|
|
{
|
|
files: [`tests/support/browser/**/*.${sourceExtensions}`],
|
|
rules: {
|
|
"react-hooks/rules-of-hooks": "off",
|
|
},
|
|
},
|
|
{
|
|
files: [
|
|
`tests/fixtures/architecture/forbidden/**/*.${sourceExtensions}`,
|
|
],
|
|
rules: {
|
|
"no-restricted-imports": restrictedImports(
|
|
[
|
|
"**/adapters/**",
|
|
"**/application/ports/out/**",
|
|
"@tanstack/**",
|
|
"react",
|
|
"react-dom",
|
|
"**/application/**",
|
|
],
|
|
"forbidden architecture fixture: this import must be rejected.",
|
|
),
|
|
"no-restricted-globals": [
|
|
"error",
|
|
"fetch",
|
|
"localStorage",
|
|
"sessionStorage",
|
|
],
|
|
},
|
|
},
|
|
{
|
|
files: [
|
|
`tests/fixtures/browser-file-storage-boundaries/forbidden/**/*.${sourceExtensions}`,
|
|
],
|
|
plugins: {
|
|
"browser-data-boundary": browserDataBoundaryPlugin,
|
|
},
|
|
rules: {
|
|
"browser-data-boundary/no-capability-alias": "error",
|
|
"no-restricted-properties": restrictedBrowserDataProperties,
|
|
"no-restricted-globals": [
|
|
"error",
|
|
"BroadcastChannel",
|
|
"localStorage",
|
|
"sessionStorage",
|
|
"indexedDB",
|
|
"caches",
|
|
"File",
|
|
"Blob",
|
|
"FileSystemFileHandle",
|
|
"FileSystemDirectoryHandle",
|
|
"showOpenFilePicker",
|
|
"showSaveFilePicker",
|
|
],
|
|
},
|
|
},
|
|
{
|
|
// 13-06. Vite inlines every loaded VITE_* value into the bundle wherever
|
|
// code references the whole `import.meta.env` object, including values no
|
|
// code reads. Keyed reads are replaced one by one.
|
|
files: [`src/**/*.${sourceExtensions}`],
|
|
plugins: {
|
|
"build-env": {
|
|
rules: {
|
|
"no-whole-import-meta-env": {
|
|
meta: {
|
|
type: "problem",
|
|
schema: [],
|
|
messages: {
|
|
whole:
|
|
"Read build variables by key (import.meta.env.VITE_NAME). Referencing import.meta or import.meta.env as a whole bundles every VITE_* value (13-06).",
|
|
},
|
|
},
|
|
create(context: any) {
|
|
const isMember = (node: any) =>
|
|
node?.type === "MemberExpression" ||
|
|
node?.type === "OptionalMemberExpression";
|
|
return {
|
|
MetaProperty(node: any) {
|
|
if (node.meta?.name !== "import") return;
|
|
const member = node.parent;
|
|
if (!isMember(member) || member.object !== node || member.computed) {
|
|
context.report({ node, messageId: "whole" });
|
|
return;
|
|
}
|
|
if (member.property?.name !== "env") return;
|
|
const read = member.parent;
|
|
if (isMember(read) && read.object === member && !read.computed) {
|
|
return;
|
|
}
|
|
context.report({ node: member, messageId: "whole" });
|
|
},
|
|
};
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
rules: {
|
|
"build-env/no-whole-import-meta-env": "error",
|
|
},
|
|
},
|
|
];
|