pasika 0.1.6 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/README.md +40 -55
  2. package/dist/eslint/pasika/index.d.ts +18 -0
  3. package/dist/eslint/pasika/index.js +18 -3
  4. package/dist/eslint/pasika/rules/enforce-barrel-exports.d.ts +9 -0
  5. package/dist/eslint/pasika/rules/enforce-barrel-exports.js +78 -0
  6. package/dist/eslint/pasika/rules/enforce-cn-merge.d.ts +9 -0
  7. package/dist/eslint/pasika/rules/enforce-cn-merge.js +84 -0
  8. package/dist/eslint/pasika/rules/enforce-cva-variant-props.d.ts +9 -0
  9. package/dist/eslint/pasika/rules/enforce-cva-variant-props.js +76 -0
  10. package/dist/eslint/pasika/rules/filename-case.js +10 -0
  11. package/dist/eslint/pasika/rules/import-boundaries.d.ts +2 -0
  12. package/dist/eslint/pasika/rules/{organization-imports.js → import-boundaries.js} +11 -1
  13. package/dist/eslint/pasika/rules/no-arbitrary-tailwind.d.ts +9 -0
  14. package/dist/eslint/pasika/rules/no-arbitrary-tailwind.js +107 -0
  15. package/dist/eslint/pasika/rules/no-mixed-concerns.d.ts +9 -0
  16. package/dist/eslint/pasika/rules/no-mixed-concerns.js +84 -0
  17. package/package.json +5 -16
  18. package/claude/hooks/.vulyk +0 -3
  19. package/claude/hooks/AGENTS.md +0 -3
  20. package/claude/hooks/CLAUDE.md +0 -1
  21. package/claude/hooks/claude-hooks.md +0 -30
  22. package/claude/hooks/notification.sh +0 -38
  23. package/claude/hooks/protect-files.sh +0 -21
  24. package/claude/hooks/status-line/index.js +0 -57
  25. package/claude/scripts/render-settings.ts +0 -223
  26. package/claude/settings.base.json +0 -38
  27. package/dist/claude/scripts/render-settings.js +0 -145
  28. package/dist/eslint/pasika/rules/organization-imports.d.ts +0 -2
  29. package/dist/eslint.config.js +0 -7
  30. package/dist/scripts/pasika.js +0 -59
  31. package/docs/agent-conventions.md +0 -27
  32. package/docs/claude/hooks.md +0 -30
  33. package/docs/code-organization-guide/code-organization-guide.md +0 -69
  34. package/docs/code-organization-guide/references/application-architecture-reference.md +0 -149
  35. package/docs/code-organization-guide/rules/component-placement-rule.md +0 -119
  36. package/docs/code-organization-guide/rules/configuration-rule.md +0 -42
  37. package/docs/code-organization-guide/rules/constants-rule.md +0 -74
  38. package/docs/code-organization-guide/rules/exports-and-imports-rule.md +0 -84
  39. package/docs/code-organization-guide/rules/folder-nesting-rule.md +0 -82
  40. package/docs/code-organization-guide/rules/hook-extraction-rule.md +0 -141
  41. package/docs/code-organization-guide/rules/interactive-component-rule.md +0 -97
  42. package/docs/code-organization-guide/rules/jsx-hygiene-rule.md +0 -67
  43. package/docs/code-organization-guide/rules/locales-rule.md +0 -53
  44. package/docs/code-organization-guide/rules/nameable-visual-concept-rule.md +0 -66
  45. package/docs/code-organization-guide/rules/no-mixed-concerns-rule.md +0 -63
  46. package/docs/code-organization-guide/rules/repeated-structure-rule.md +0 -93
  47. package/docs/code-organization-guide/rules/smart-vs-dumb-component-rule.md +0 -112
  48. package/docs/code-organization-guide/rules/sole-state-owner-rule.md +0 -101
  49. package/docs/code-organization-guide/rules/types-and-schemas-rule.md +0 -139
  50. package/docs/code-organization-guide/rules/utilities-rule.md +0 -86
  51. package/docs/documentation-guide/_templates/grouped-reference.md +0 -11
  52. package/docs/documentation-guide/_templates/guide.md +0 -19
  53. package/docs/documentation-guide/_templates/rule.md +0 -21
  54. package/docs/documentation-guide/_templates/single-lookup-reference.md +0 -5
  55. package/docs/documentation-guide/documentation-guide.md +0 -13
  56. package/docs/documentation-guide/references/documentation-types-reference.md +0 -9
  57. package/docs/documentation-guide/rules/guide-creation-rule.md +0 -113
  58. package/docs/documentation-guide/rules/reference-creation-rule.md +0 -132
  59. package/docs/documentation-guide/rules/rule-creation-rule.md +0 -81
  60. package/docs/documentation-guide/rules/template-usage-rule.md +0 -49
  61. package/docs/shadcn-theme.md +0 -121
  62. package/docs/styling-guide/rules/arbitrary-value-rule.md +0 -31
  63. package/docs/styling-guide/rules/class-composition-rule.md +0 -52
  64. package/docs/styling-guide/rules/component-ui-state-rule.md +0 -53
  65. package/docs/styling-guide/rules/component-variant-rule.md +0 -125
  66. package/docs/styling-guide/rules/global-stylesheet-rule.md +0 -67
  67. package/docs/styling-guide/rules/theme-and-utility-definition-rule.md +0 -86
  68. package/docs/styling-guide/styling-guide.md +0 -14
@@ -1,74 +0,0 @@
1
- # Constants Rule
2
-
3
- Duplicated constants are hard to keep in sync, while extracting every single-use value creates unnecessary files. This rule keeps reused constants in one file and leaves single-use values close to their consumer.
4
-
5
- - A value MUST remain in its declaring component or file until another file imports it independently; it MUST then be extracted as a constant.
6
- - Extracted constants MUST live in a `constants/` folder at the closest common folder (CCF) of their consumers.
7
- - Consumers MUST import an extracted constant through the `index.ts` in that constant's `constants/` folder.
8
- - A `constants/` folder MUST either define its constants directly in `index.ts` or group related constants in kebab-case files that `index.ts` named-re-exports.
9
- - When a constant's CCF is `src/features/`, it MUST move to `src/constants/`.
10
- - A constant MAY live in `src/config/<module>/` instead of a `constants/` folder when a developer determines that it configures application behavior and is best understood alongside the configuration that parameterizes it, even when consumers exist outside the config module.
11
-
12
- ## Incorrect — Constant Imported Without `constants/index.ts`
13
-
14
- ```ts
15
- // src/features/billing/constants/max-retries.ts
16
- export const maxRetries = 3;
17
- ```
18
-
19
- ```ts
20
- // src/features/billing/hooks/use-retry-payment.ts
21
- import { maxRetries } from "../constants/max-retries";
22
- ```
23
-
24
- Why: the consumer bypasses the feature's `constants/index.ts`.
25
-
26
- ## Correct — Grouped Constants Re-Exported from `constants/index.ts`
27
-
28
- ```ts
29
- // src/features/billing/constants/retry.ts
30
- export const maxRetries = 3;
31
- export const retryDelayMs = 1_000;
32
-
33
- // src/features/billing/constants/index.ts
34
- export { maxRetries, retryDelayMs } from "./retry";
35
- ```
36
-
37
- ```ts
38
- // src/features/billing/hooks/use-retry-payment.ts
39
- import { maxRetries } from "../constants";
40
- ```
41
-
42
- Why: the constants are available through the feature's `constants/index.ts`.
43
-
44
- ## Incorrect — Feature and Composition Constant Kept in a Feature
45
-
46
- ```ts
47
- // src/features/billing/constants/index.ts
48
- export const paymentRetryDelayMs = 1_000;
49
-
50
- // src/features/billing/hooks/use-retry-payment.ts
51
- import { paymentRetryDelayMs } from "../constants";
52
-
53
- // src/compositions/BillingDashboard.tsx
54
- import { paymentRetryDelayMs } from "@/features/billing/constants";
55
- ```
56
-
57
- Why: the feature and composition have `src/` as their CCF, but the constant remains in the billing feature.
58
-
59
- ## Correct — Feature and Composition Constant in `src/constants/`
60
-
61
- ```ts
62
- // src/constants/index.ts
63
- export const paymentRetryDelayMs = 1_000;
64
- ```
65
-
66
- ```tsx
67
- // src/features/billing/hooks/use-retry-payment.ts
68
- import { paymentRetryDelayMs } from "@/constants";
69
-
70
- // src/compositions/BillingDashboard.tsx
71
- import { paymentRetryDelayMs } from "@/constants";
72
- ```
73
-
74
- Why: the feature and composition have `src/` as their CCF, so the constant lives in `src/constants/`.
@@ -1,84 +0,0 @@
1
- # Exports and Imports Rule
2
-
3
- Without consistent exports, import paths, and layer boundaries, it is harder to tell what a file contains and which files may depend on it. This rule gives each file a predictable export style and keeps imports consistent with the application structure.
4
-
5
- - A file that exports values MUST use named exports unless a framework or third-party package requires a different export style for that file.
6
- - Imports MUST use relative paths for the same folder, a direct subfolder, or one folder up.
7
- - Imports MUST use the `@/*` alias for anything beyond one folder up.
8
- - A file under `src/compositions/` MUST NOT import from `src/app/`.
9
- - A file in a feature folder MUST NOT import from another feature folder, `src/compositions/`, or `src/app/`.
10
- - A file under `src/shared/` MUST NOT import from `src/app/`, `src/compositions/`, or a feature folder.
11
- - A file in the `root` layer MUST NOT import from `src/app/`, `src/compositions/`, a feature folder, or `src/shared/`.
12
- - A configuration module MUST import only from root support folders and its own files.
13
- ## Incorrect — Single-Export Utility Uses a Default Export
14
-
15
- ```ts
16
- // src/utils/format-duration.ts
17
- export default function formatDuration(seconds: number): string {
18
- const minutes = Math.floor(seconds / 60);
19
- const remainder = seconds % 60;
20
- return `${minutes}:${String(remainder).padStart(2, "0")}`;
21
- }
22
- ```
23
-
24
- Why: files use named exports even when they expose one item.
25
-
26
- ## Correct — Single-Export Utility Uses a Named Export
27
-
28
- ```ts
29
- // src/utils/format-duration.ts
30
- export function formatDuration(seconds: number): string {
31
- const minutes = Math.floor(seconds / 60);
32
- const remainder = seconds % 60;
33
- return `${minutes}:${String(remainder).padStart(2, "0")}`;
34
- }
35
- ```
36
-
37
- Why: the utility uses the same named-export form as every other file that does not have a package-required export contract.
38
-
39
- ## Incorrect — Deep Relative Path
40
-
41
- ```ts
42
- // src/features/stream/StreamBoard/schedule.ts
43
- import { debounce } from "../../../utils/debounce";
44
- ```
45
-
46
- Why: reaching more than one folder up hides the cross-scope dependency in relative path traversal.
47
-
48
- ## Correct — Alias Across Scopes and Relative Paths Nearby
49
-
50
- ```ts
51
- // src/features/stream/StreamBoard/schedule.ts
52
- import { debounce } from "@/utils/debounce";
53
- import { formatSlot } from "./utils/format-slot";
54
- import { type StreamSlot } from "./types";
55
- import { buildSchedule } from "../schedule-builder";
56
- ```
57
-
58
- Why: the alias identifies the distant dependency while nearby files keep short relative paths.
59
-
60
- ## Incorrect — Next.js Page Uses a Named Export
61
-
62
- ```tsx
63
- // src/app/contact/page.tsx
64
- import { locales } from "@/locales";
65
-
66
- export function Page(): React.JSX.Element {
67
- return <main>{locales.contactUs}</main>;
68
- }
69
- ```
70
-
71
- Why: Next.js requires a `page.tsx` file to default-export its page component.
72
-
73
- ## Correct — Next.js Page Uses a Default Export
74
-
75
- ```tsx
76
- // src/app/contact/page.tsx
77
- import { locales } from "@/locales";
78
-
79
- export default function Page(): React.JSX.Element {
80
- return <main>{locales.contactUs}</main>;
81
- }
82
- ```
83
-
84
- Why: the page follows the export contract Next.js requires.
@@ -1,82 +0,0 @@
1
- # Folder Nesting Rule
2
-
3
- Without nesting, exclusive children can look reusable and their relationship to the parent is easy to miss in review. This rule groups them with their parent and keeps them out of the folder's public API.
4
-
5
- - An exclusive child component is imported only by its parent component. A component MUST stay flat until it has one or more exclusive child components, then MUST be nested in a folder with the same name.
6
- - A component MUST NOT be nested only because it has support files.
7
- - A nested component's support files MUST live in its folder.
8
- - The nested folder's `index.ts` MUST named-re-export the nested component and MUST NOT re-export its exclusive children.
9
-
10
- ## Incorrect — Exclusive Children Kept Flat
11
-
12
- ```text
13
- src/features/blog/
14
- BlogPage.tsx # owns exclusive children
15
- blog-header.tsx # exclusive child — no sibling needs it
16
- blog-footer.tsx # exclusive child — no sibling needs it
17
- hooks/
18
- use-blog-filter.ts # used only by BlogPage
19
- ```
20
-
21
- Why: `BlogPage` owns children that no sibling uses, but all three files sit as flat siblings. Nothing in the tree shows that `blog-header.tsx` and `blog-footer.tsx` belong to `BlogPage` rather than to any other component in the folder.
22
-
23
- ## Correct — Exclusive Children Nested
24
-
25
- ```text
26
- src/features/blog/
27
- BlogPage/
28
- index.ts # re-exports only BlogPage.tsx
29
- BlogPage.tsx
30
- blog-header.tsx # not re-exported from index.ts
31
- blog-footer.tsx # not re-exported from index.ts
32
- hooks/
33
- use-blog-filter.ts
34
- ```
35
-
36
- Why: nesting `BlogPage` into `BlogPage/` makes the parent–child relationship visible in the filesystem, lets the children stay scoped to their concrete consumer, and gives the folder a barrel that re-exports only the nested component.
37
-
38
- ## Incorrect — Support Files Cause Unnecessary Nesting
39
-
40
- ```text
41
- src/features/blog/
42
- BlogPage/
43
- index.ts
44
- BlogPage.tsx
45
- hooks/
46
- use-blog-filter.ts
47
- ```
48
-
49
- Why: support files alone do not make `BlogPage` a nested component.
50
-
51
- ## Correct — Support Files Keep a Component Flat
52
-
53
- ```text
54
- src/features/blog/
55
- BlogPage.tsx
56
- hooks/
57
- use-blog-filter.ts
58
- ```
59
-
60
- Why: without exclusive children, `BlogPage` stays flat and its support files remain at the feature scope.
61
-
62
- ## Incorrect — Exclusive Child Re-Exported
63
-
64
- ```ts
65
- // src/features/blog/BlogPage/index.ts
66
- export { BlogPage } from "./BlogPage";
67
- export { BlogHeader } from "./blog-header";
68
- ```
69
-
70
- Why: the barrel re-exports the child as well as the nested component, so outside consumers can import `blog-header.tsx` through `index.ts` and the child stops being exclusive to `BlogPage`.
71
-
72
- ## Correct — Only the Nested Component Re-Exported
73
-
74
- ```tsx
75
- // src/features/blog/BlogPage/index.ts
76
- export { BlogPage } from "./BlogPage";
77
-
78
- // src/features/blog/BlogPage/BlogPage.tsx
79
- import { BlogHeader } from "./blog-header";
80
- ```
81
-
82
- Why: the barrel exposes only the nested component, so it does not expose the child.
@@ -1,141 +0,0 @@
1
- # Hook Extraction Rule
2
-
3
- Keeping every hook inline makes components bloated, while extracting every hook adds indirection without benefit. This rule defines concrete reuse and imperative-complexity triggers for extraction.
4
-
5
- - A custom hook MUST be extracted to its own file when two or more consumers use it.
6
- - A custom hook with exactly one consumer MUST be extracted when it contains two or more imperative categories and can be described as one coherent behavior.
7
- - An extracted custom hook MUST live in a `hooks/` folder at the closest common folder (CCF) of its consumers.
8
- - When a custom hook's CCF is `src/features/`, it MUST move to `src/hooks/`.
9
- - The imperative categories MUST be subscriptions, external I/O and persistence, DOM manipulation, or resource lifecycle.
10
- - Each operation MUST count toward only one imperative category.
11
- - Subscriptions MUST include event listeners and registration or cleanup APIs such as `on()` and `off()`.
12
- - External I/O and persistence MUST include network requests, asynchronous reads or writes, and browser storage.
13
- - DOM manipulation MUST include imperative APIs such as `focus()`, `classList`, observers, or imperative rendering.
14
- - Resource lifecycle MUST include setup and teardown APIs such as `load()`, `destroy()`, or `dispose()`.
15
- - A custom hook with one consumer that does not meet the two-category threshold MUST stay inline in its consumer file.
16
-
17
- ## Incorrect — Two Imperative Categories Left Inline
18
-
19
- ```tsx
20
- // src/features/player/player.tsx
21
- export function Player({ src }: PlayerProps): React.JSX.Element {
22
- useEffect(() => {
23
- player.on("play", handlePlay);
24
- player.on("pause", handlePause);
25
- player.load(src);
26
-
27
- return () => {
28
- player.off("play", handlePlay);
29
- player.off("pause", handlePause);
30
- player.destroy();
31
- };
32
- }, [src]);
33
-
34
- return <PlayerView />;
35
- }
36
- ```
37
-
38
- Why: one coherent player-setup behavior combines subscriptions with resource lifecycle, so leaving it inline crosses the two-category threshold.
39
-
40
- ## Correct — Complex Single-Use Hook Extracted
41
-
42
- ```ts
43
- // src/features/player/hooks/use-player-setup.ts
44
- export function usePlayerSetup(src: string): void {
45
- useEffect(() => {
46
- player.on("play", handlePlay);
47
- player.on("pause", handlePause);
48
- player.load(src);
49
-
50
- return () => {
51
- player.off("play", handlePlay);
52
- player.off("pause", handlePause);
53
- player.destroy();
54
- };
55
- }, [src]);
56
- }
57
- ```
58
-
59
- ```tsx
60
- // src/features/player/player.tsx
61
- import { usePlayerSetup } from "./hooks/use-player-setup";
62
-
63
- export function Player({ src }: PlayerProps): React.JSX.Element {
64
- usePlayerSetup(src);
65
- return <PlayerView />;
66
- }
67
- ```
68
-
69
- Why: the named hook owns the subscription and resource lifecycle for one coherent behavior, keeping the component focused on rendering.
70
-
71
- ## Incorrect — Reused Hook Kept Inline
72
-
73
- ```tsx
74
- // src/features/billing/invoice.tsx
75
- const useInvoiceSort = (invoices: Invoice[]): Invoice[] => {
76
- return useMemo(() => invoices.toSorted(byDate), [invoices]);
77
- };
78
-
79
- // src/features/billing/invoice-summary.tsx
80
- const useInvoiceSort = (invoices: Invoice[]): Invoice[] => {
81
- return useMemo(() => invoices.toSorted(byDate), [invoices]);
82
- };
83
- ```
84
-
85
- Why: two components use the same hook behavior, so keeping it inline duplicates it.
86
-
87
- ## Correct — Reused Hook Extracted
88
-
89
- ```ts
90
- // src/features/billing/hooks/use-invoice-sort.ts
91
- export function useInvoiceSort(invoices: Invoice[]): Invoice[] {
92
- return useMemo(() => invoices.toSorted(byDate), [invoices]);
93
- }
94
- ```
95
-
96
- ```tsx
97
- // src/features/billing/invoice.tsx
98
- import { useInvoiceSort } from "./hooks/use-invoice-sort";
99
-
100
- // src/features/billing/invoice-summary.tsx
101
- import { useInvoiceSort } from "./hooks/use-invoice-sort";
102
- ```
103
-
104
- Why: the hook has two consumers, so it has its own file.
105
-
106
- ## Incorrect — Simple Single-Use Hook Extracted
107
-
108
- ```ts
109
- // src/features/billing/hooks/use-invoice-sort.ts
110
- export function useInvoiceSort(invoices: Invoice[]): Invoice[] {
111
- return useMemo(() => invoices.toSorted(byDate), [invoices]);
112
- }
113
- ```
114
-
115
- ```tsx
116
- // src/features/billing/invoice.tsx
117
- import { useInvoiceSort } from "./hooks/use-invoice-sort";
118
-
119
- export function Invoice({ invoices }: InvoiceProps): React.JSX.Element {
120
- const sortedInvoices = useInvoiceSort(invoices);
121
- return <InvoiceList invoices={sortedInvoices} />;
122
- }
123
- ```
124
-
125
- Why: the hook has one consumer and no imperative category, so its separate file adds indirection before an extraction trigger exists.
126
-
127
- ## Correct — Simple Single-Use Hook Inline
128
-
129
- ```tsx
130
- // src/features/billing/invoice.tsx
131
- const useInvoiceSort = (invoices: Invoice[]): Invoice[] => {
132
- return useMemo(() => invoices.toSorted(byDate), [invoices]);
133
- };
134
-
135
- export function Invoice({ invoices }: InvoiceProps): React.JSX.Element {
136
- const sortedInvoices = useInvoiceSort(invoices);
137
- return <InvoiceList invoices={sortedInvoices} />;
138
- }
139
- ```
140
-
141
- Why: the hook stays beside its sole consumer until reuse or imperative complexity provides a mechanical extraction trigger.
@@ -1,97 +0,0 @@
1
- # Interactive Component Rule
2
-
3
- Large component files need a clear way to decide what to extract first. This rule treats interactive elements as meaningful component boundaries instead of extracting arbitrary layout elements.
4
-
5
- - An [interactive HTML element](https://html.spec.whatwg.org/multipage/dom.html#interactive-content) MUST be extracted to a component with a descriptive name.
6
-
7
- ## Incorrect — Interactive Element Kept Inline
8
-
9
- ```tsx
10
- // src/features/layout/header-section.tsx
11
- import { locales } from "@/locales";
12
-
13
- export function HeaderSection({
14
- onMenuClick,
15
- searchPlaceholder,
16
- }: {
17
- onMenuClick: () => void;
18
- searchPlaceholder: string;
19
- }): React.JSX.Element {
20
- return (
21
- <header>
22
- <h1>{locales.layout.headerTitle}</h1>
23
-
24
- <button onClick={onMenuClick} aria-label={locales.layout.openMenu}>
25
- <Icon name="menu" />
26
- </button>
27
-
28
- <input type="search" placeholder={searchPlaceholder} />
29
- </header>
30
- );
31
- }
32
- ```
33
-
34
- Why: the interactive elements remain mixed into `HeaderSection` instead of having their own components.
35
-
36
- ## Correct — Interactive Element Extracted
37
-
38
- ```text
39
- src/features/layout/
40
- header-section/
41
- index.ts # re-exports only header-section.tsx
42
- header-section.tsx
43
- menu-button.tsx # exclusive child — imported directly
44
- search-field.tsx # exclusive child — imported directly
45
- ```
46
-
47
- ```tsx
48
- // src/features/layout/header-section/menu-button.tsx
49
- type MenuButtonProps = React.ComponentProps<"button">;
50
-
51
- export function MenuButton({ onClick, ...props }: MenuButtonProps): React.JSX.Element {
52
- return (
53
- <button {...props} onClick={onClick}>
54
- <Icon name="menu" />
55
- </button>
56
- );
57
- }
58
- ```
59
-
60
- ```tsx
61
- // src/features/layout/header-section/search-field.tsx
62
- type SearchFieldProps = Omit<React.ComponentProps<"input">, "type">;
63
-
64
- export function SearchField(props: SearchFieldProps): React.JSX.Element {
65
- return <input {...props} type="search" />;
66
- }
67
- ```
68
-
69
- ```tsx
70
- // src/features/layout/header-section/header-section.tsx — now imports both interactive units instead of inline JSX
71
-
72
- import { MenuButton } from "./menu-button";
73
- import { SearchField } from "./search-field";
74
- import { locales } from "@/locales";
75
-
76
- type HeaderSectionProps = {
77
- onMenuClick: () => void;
78
- searchPlaceholder: string;
79
- };
80
-
81
- export function HeaderSection({
82
- onMenuClick,
83
- searchPlaceholder,
84
- }: HeaderSectionProps): React.JSX.Element {
85
- return (
86
- <header>
87
- <h1>{locales.layout.headerTitle}</h1>
88
-
89
- <MenuButton onClick={onMenuClick} aria-label={locales.layout.openMenu} />
90
-
91
- <SearchField placeholder={searchPlaceholder} />
92
- </header>
93
- );
94
- }
95
- ```
96
-
97
- Why: each interactive element now has its own descriptive component, leaving `HeaderSection` to compose them.
@@ -1,67 +0,0 @@
1
- # JSX Hygiene Rule
2
-
3
- JSX should show the component's structure, not its calculations. This rule moves complex expressions before `return` while keeping simple JSX readable.
4
-
5
- - Arithmetic, chained built-in method calls, calls to functions declared outside the component, nested ternaries, and conditions containing two or more logical operators MUST be extracted before `return`, including in JSX attributes.
6
- - An inline expression MAY contain one condition with up to one logical operator, one ternary, or one built-in method call. `cn()` MAY be called inline. An event handler MAY make one call inline.
7
-
8
- ## Incorrect — Computation in JSX
9
-
10
- ```tsx
11
- return (
12
- <div>
13
- <span>{Math.floor((Date.now() - new Date(record.updatedAt).getTime()) / 86400000)} {locales.daysAgo}</span>
14
- <ul>
15
- {items
16
- .filter((x) => x.active)
17
- .sort(byDate)
18
- .map(renderItem)}
19
- </ul>
20
- <p>
21
- {formatDate(record.updatedAt, "long")} — {calculateTotal(items)}
22
- </p>
23
- {isLoading ? <Spinner /> : hasError ? <Error /> : <Content />}
24
- {isLoggedIn && hasPermission && isOwner && featureEnabled && <AdminPanel />}
25
- <span>{new Date(post.publishedAt).toLocaleDateString()}</span>
26
- {Math.round(score * 100)}%
27
- </div>
28
- );
29
- ```
30
-
31
- Why: calculations, chained methods, function calls, nested ternaries, and long guards all belong outside the return.
32
-
33
- ## Correct — Computation Before `return`
34
-
35
- ```tsx
36
- const daysSinceUpdate = Math.floor((Date.now() - new Date(record.updatedAt).getTime()) / 86400000);
37
- const activeItems = items.filter((x) => x.active).sort(byDate);
38
- const updatedLabel = formatDate(record.updatedAt, "long");
39
- const total = calculateTotal(items);
40
- const canShowAdmin = isLoggedIn && hasPermission && isOwner && featureEnabled;
41
- const publishDate = new Date(post.publishedAt).toLocaleDateString();
42
- const scorePercent = Math.round(score * 100);
43
-
44
- let statusView = <Content />;
45
- if (isLoading) {
46
- statusView = <Spinner />;
47
- } else if (hasError) {
48
- statusView = <Error />;
49
- }
50
-
51
- return (
52
- <div>
53
- <span>{daysSinceUpdate} {locales.daysAgo}</span>
54
- <ul>{activeItems.map(renderItem)}</ul>
55
- <p>
56
- {updatedLabel} — {total}
57
- </p>
58
- {statusView}
59
- {scorePercent}%
60
- <div className={cn("base", isActive && "bg-primary-100")} />
61
- {canShowAdmin && <AdminPanel />}
62
- <span>{publishDate}</span>
63
- </div>
64
- );
65
- ```
66
-
67
- Why: calculations, chained methods, custom function calls, and nested ternaries now resolve before the return, so only simple conditions, single method calls, and `cn()` stay inline.
@@ -1,53 +0,0 @@
1
- # Locales Rule
2
-
3
- When locale strings are scattered across components and constants, they are hard to find and keep consistent. This rule keeps them in one central file, puts each feature's strings together, and uses readable keys.
4
-
5
- - All locales MUST live in the named `locales` object exported from `src/locales/index.ts`.
6
- - Locales read only by files in one feature folder MUST live in an object with the camelCase form of its feature folder name (for example, `user-settings` becomes `userSettings`).
7
- - Locales read by files in more than one feature folder or by `src/shared/`, `src/compositions/`, `src/app/`, or root support folders MUST live at the top level of `locales`.
8
- - A namespaced locale MUST be read through its full dotted path (`locales.stream.watchLiveStream`).
9
- - A locale key MUST be camelCase English based on the text, unless a direct translation would be unclear or unwieldy. In that case, it MAY describe the message's purpose instead.
10
-
11
- ## Incorrect — Flat Feature Locale Keys
12
-
13
- ```ts
14
- // src/locales/index.ts
15
- export const locales = {
16
- streamPlayerLiveText: "Дивитись прямий ефір", // describes the element, not the text
17
- ctaButton: "Прийняти всі cookies", // describes the element, not the text
18
- youSuccessfullySubscribedToUpdates: "Ви успішно підписалися на оновлення", // direct translation — unwieldy
19
- };
20
- ```
21
-
22
- ```tsx
23
- // src/features/stream/stream-player.tsx
24
- locales.streamPlayerLiveText; // no namespace — collides with any other feature that picks this key
25
- ```
26
-
27
- Why: the first two keys describe elements instead of text, the direct translation is unwieldy, and the flat structure does not show that `streamPlayerLiveText` belongs to the stream feature.
28
-
29
- ## Correct — Namespaced Feature Locale Keys
30
-
31
- ```ts
32
- // src/locales/index.ts
33
- export const locales = {
34
- stream: {
35
- watchLiveStream: "Дивитись прямий ефір",
36
- },
37
- acceptAllCookies: "Прийняти всі cookies", // shared — direct text-based key
38
- subscriptionConfirmed: "Ви успішно підписалися на оновлення", // shared — describes the message's purpose
39
- };
40
- ```
41
-
42
- ```tsx
43
- // src/features/stream/stream-player.tsx
44
- locales.stream.watchLiveStream; // namespaced by feature
45
-
46
- // src/shared/cookie-banner.tsx
47
- locales.acceptAllCookies; // shared — read from the top level
48
-
49
- // src/shared/subscription-form.tsx
50
- locales.subscriptionConfirmed; // shared — read from the top level
51
- ```
52
-
53
- Why: the stream feature has its own namespace, while shared strings stay at the top level. `acceptAllCookies` is based on the text, while `subscriptionConfirmed` describes the message's purpose instead of using an unwieldy direct translation.
@@ -1,66 +0,0 @@
1
- # Nameable Visual Concept Rule
2
-
3
- Some groups of elements can be given a clear component name but have no file of their own. This rule recommends extracting those groups into descriptive components.
4
-
5
- - A block of elements SHOULD be extracted to a component when one clear name describes the whole block.
6
-
7
- ## Incorrect — Nameable Visual Block Kept Inline
8
-
9
- ```tsx
10
- // src/features/feed/feed-view.tsx
11
- export function FeedView(): React.JSX.Element {
12
- return (
13
- <main>
14
- <article>
15
- <Avatar />
16
- <UserName />
17
- <PostTimestamp />
18
- <PostBody />
19
- </article>
20
- </main>
21
- );
22
- }
23
- ```
24
-
25
- Why: the avatar, username, and timestamp form a message header but remain inline in `FeedView`.
26
-
27
- ## Correct — Nameable Visual Block Extracted
28
-
29
- ```text
30
- src/features/feed/
31
- feed-view/
32
- index.ts # re-exports only feed-view.tsx
33
- feed-view.tsx
34
- message-header.tsx # exclusive child — imported directly by feed-view.tsx
35
- ```
36
-
37
- ```tsx
38
- // src/features/feed/feed-view/feed-view.tsx
39
- import { MessageHeader } from "./message-header";
40
-
41
- export function FeedView(): React.JSX.Element {
42
- return (
43
- <main>
44
- <article>
45
- <MessageHeader />
46
- <PostBody />
47
- </article>
48
- </main>
49
- );
50
- }
51
- ```
52
-
53
- ```tsx
54
- // src/features/feed/feed-view/message-header.tsx
55
- export function MessageHeader(): React.JSX.Element {
56
- return (
57
- <header>
58
- <Avatar />
59
- <UserName />
60
- <PostTimestamp />
61
- </header>
62
- );
63
- }
64
- ```
65
-
66
- Why: `MessageHeader` gives the group a clear name and its own file, while `FeedView` only composes it.