@geonosis/oxlint-plugin-biological-architecture 0.1.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.
- package/LICENSE +202 -0
- package/README.md +81 -0
- package/dist/chunk-74VWOEPL.js +85 -0
- package/dist/chunk-KZ5XEK6F.js +83 -0
- package/dist/discover-atoms.js +59 -0
- package/dist/index.js +3916 -0
- package/dist/presets.js +8 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# @geonosis/oxlint-plugin-biological-architecture
|
|
2
|
+
|
|
3
|
+
54 architecture rules as an oxlint JS plugin: which tier a file belongs to, what it may import,
|
|
4
|
+
where state is allowed to live, and the backend invariants that go with them. Nothing is hardcoded
|
|
5
|
+
to a repo — every list of brands, features, tables or paths is an option whose default does nothing
|
|
6
|
+
until it is configured.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pnpm add -D @geonosis/oxlint-plugin-biological-architecture oxlint
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
`.oxlintrc.json`:
|
|
15
|
+
|
|
16
|
+
```jsonc
|
|
17
|
+
{
|
|
18
|
+
"jsPlugins": ["@geonosis/oxlint-plugin-biological-architecture"],
|
|
19
|
+
"rules": {
|
|
20
|
+
"biological-architecture/atom-no-deps": "error",
|
|
21
|
+
"biological-architecture/cell-must-not-compose-cell": "error",
|
|
22
|
+
"biological-architecture/tissue-no-hooks": "error"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Rules are namespaced `biological-architecture/<rule>` — the plugin's identity, not the package's, so
|
|
28
|
+
renaming the package would not rename every rule id in every consumer. oxlint loads the **build**,
|
|
29
|
+
so `dist/` is what a rule change has to reach.
|
|
30
|
+
|
|
31
|
+
A rule with options takes them as the second element, as usual:
|
|
32
|
+
|
|
33
|
+
```jsonc
|
|
34
|
+
"biological-architecture/no-brand-names": [
|
|
35
|
+
"error",
|
|
36
|
+
{ "brands": ["acme"], "allowedSubstrings": ["media.acme.com"] }
|
|
37
|
+
]
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The presets are exported as `configs`, so a config can list a preset's rules rather than hand-copy
|
|
41
|
+
them:
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import { PRESETS } from '@geonosis/oxlint-plugin-biological-architecture/presets'
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## The tiers
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
atoms → molecules → compounds → organelles → cells → tissues
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
State lives **only** at the organelle and cell tiers. Everything above the cell arranges;
|
|
54
|
+
everything below the organelle is inert. A cell never composes another cell.
|
|
55
|
+
|
|
56
|
+
## Presets
|
|
57
|
+
|
|
58
|
+
| preset | rules | what it is |
|
|
59
|
+
| --- | --- | --- |
|
|
60
|
+
| `frontend` (= `recommended`) | 35 | tier direction, state placement, element choice, file shape |
|
|
61
|
+
| `backend-workflows` | 12 | workflows, the data layer, single source of truth |
|
|
62
|
+
| `tenant-scoping` | 4 | every row placed, scoped and narrowed to one organisation |
|
|
63
|
+
| `backend-d1` | 2 | Cloudflare D1 facts — false on an engine with transactions |
|
|
64
|
+
| `backend-medusa` | 1 | the storefront route surface |
|
|
65
|
+
| `backend-sagaflow-cf` | 1 | durable runs on Cloudflare Workflows — false of an inline saga |
|
|
66
|
+
| `comment-ceiling` | 1 | the comment posture, opt-in (+ oxlint's `capitalized-comments`) |
|
|
67
|
+
|
|
68
|
+
A rule that is false on another stack gets its own preset rather than riding along in a generic
|
|
69
|
+
one: a preset carrying a repo fact is a repo fact wearing a preset's name.
|
|
70
|
+
|
|
71
|
+
## Where to read on
|
|
72
|
+
|
|
73
|
+
- `RULES.md` — every rule, its preset, which source tree it came from, and how each divergence was
|
|
74
|
+
resolved.
|
|
75
|
+
- `skills/geonosis-code/SKILL.md` in the repository — **generated** from every rule's `fixShape`:
|
|
76
|
+
the shape each gate accepts, in one short document meant to be read before writing code.
|
|
77
|
+
|
|
78
|
+
Every rule exports `{ meta, create, fixShape }`, and a staleness test fails when the committed skill
|
|
79
|
+
is not what the rules generate, so a rule and its remedy cannot drift apart.
|
|
80
|
+
|
|
81
|
+
Apache-2.0.
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// src/presets.ts
|
|
2
|
+
var FRONTEND = [
|
|
3
|
+
"atom-no-deps",
|
|
4
|
+
"cell-must-be-stateful",
|
|
5
|
+
"cell-must-not-compose-cell",
|
|
6
|
+
"cell-no-tissues",
|
|
7
|
+
"cells-folder-index-is-barrel",
|
|
8
|
+
"compound-must-be-stateless",
|
|
9
|
+
"compound-no-stores",
|
|
10
|
+
"effect-hook-naming",
|
|
11
|
+
"molecule-atoms-only",
|
|
12
|
+
"molecule-must-compose",
|
|
13
|
+
"next-route-segment-is-thin-delegate",
|
|
14
|
+
"no-brand-names",
|
|
15
|
+
"no-card-shaped-div",
|
|
16
|
+
"no-cross-feature-stores",
|
|
17
|
+
"no-duplicate-jsx-patterns",
|
|
18
|
+
"no-hook-in-component-disguise",
|
|
19
|
+
"no-inert-hidden-jsx",
|
|
20
|
+
"no-inline-data-in-jsx",
|
|
21
|
+
"no-invalid-feature-folders",
|
|
22
|
+
"no-logic-in-component-files",
|
|
23
|
+
"no-raw-html-atoms",
|
|
24
|
+
"no-react-namespace",
|
|
25
|
+
"no-renamed-html-props",
|
|
26
|
+
"no-render-prop-reader",
|
|
27
|
+
"no-trivial-wrapper-component",
|
|
28
|
+
"no-ts-in-bio-folders",
|
|
29
|
+
"no-type-definitions-in-components",
|
|
30
|
+
"organelle-dependency",
|
|
31
|
+
"organelle-single-source",
|
|
32
|
+
"tissue-must-compose",
|
|
33
|
+
"tissue-no-data-props",
|
|
34
|
+
"tissue-no-hooks",
|
|
35
|
+
"tissue-no-organelles",
|
|
36
|
+
"tissue-no-stores",
|
|
37
|
+
"zustand-v5-best-practices"
|
|
38
|
+
];
|
|
39
|
+
var BACKEND_WORKFLOWS = [
|
|
40
|
+
"constants-in-constants-file",
|
|
41
|
+
"dialect-through-the-seam",
|
|
42
|
+
"document-sagas-are-generic",
|
|
43
|
+
"documents-share-one-table",
|
|
44
|
+
"no-orm-outside-db",
|
|
45
|
+
"no-raw-sql-outside-allowed",
|
|
46
|
+
"no-void-port",
|
|
47
|
+
"queue-loop-is-the-library",
|
|
48
|
+
"ssot-no-inline-facts",
|
|
49
|
+
"ssot-no-process-env",
|
|
50
|
+
"tables-declare-their-plane",
|
|
51
|
+
"time-through-the-door"
|
|
52
|
+
];
|
|
53
|
+
var BACKEND_D1 = ["no-d1-transaction", "worker-handles-are-scoped"];
|
|
54
|
+
var BACKEND_SAGAFLOW_CF = ["step-opens-its-own-cell"];
|
|
55
|
+
var BACKEND_MEDUSA = ["store-route-scopes-tenant-data"];
|
|
56
|
+
var TENANT_SCOPING = [
|
|
57
|
+
"queries-require-org-scope",
|
|
58
|
+
"store-route-scopes-tenant-data",
|
|
59
|
+
"tables-declare-their-plane",
|
|
60
|
+
"tenant-tables-carry-org-id"
|
|
61
|
+
];
|
|
62
|
+
var RULE_PREFIX = "biological-architecture";
|
|
63
|
+
var asRules = (names) => Object.fromEntries(names.map((name) => [`${RULE_PREFIX}/${name}`, "error"]));
|
|
64
|
+
var COMMENT_CEILING = {
|
|
65
|
+
rules: {
|
|
66
|
+
...asRules(["max-comment-density"]),
|
|
67
|
+
"capitalized-comments": "error"
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
var PRESETS = {
|
|
71
|
+
"backend-d1": { rules: asRules(BACKEND_D1) },
|
|
72
|
+
"backend-medusa": { rules: asRules(BACKEND_MEDUSA) },
|
|
73
|
+
"backend-sagaflow-cf": { rules: asRules(BACKEND_SAGAFLOW_CF) },
|
|
74
|
+
"backend-workflows": { rules: asRules(BACKEND_WORKFLOWS) },
|
|
75
|
+
"comment-ceiling": COMMENT_CEILING,
|
|
76
|
+
frontend: { rules: asRules(FRONTEND) },
|
|
77
|
+
recommended: { rules: asRules(FRONTEND) },
|
|
78
|
+
"tenant-scoping": { rules: asRules(TENANT_SCOPING) }
|
|
79
|
+
};
|
|
80
|
+
var rulesOfPreset = (preset) => Object.keys(PRESETS[preset].rules).filter((id) => id.startsWith(`${RULE_PREFIX}/`)).map((id) => id.slice(RULE_PREFIX.length + 1));
|
|
81
|
+
|
|
82
|
+
export {
|
|
83
|
+
PRESETS,
|
|
84
|
+
rulesOfPreset
|
|
85
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// src/presets.ts
|
|
2
|
+
var FRONTEND = [
|
|
3
|
+
"atom-no-deps",
|
|
4
|
+
"cell-must-be-stateful",
|
|
5
|
+
"cell-must-not-compose-cell",
|
|
6
|
+
"cell-no-tissues",
|
|
7
|
+
"cells-folder-index-is-barrel",
|
|
8
|
+
"compound-must-be-stateless",
|
|
9
|
+
"compound-no-stores",
|
|
10
|
+
"effect-hook-naming",
|
|
11
|
+
"molecule-atoms-only",
|
|
12
|
+
"molecule-must-compose",
|
|
13
|
+
"next-route-segment-is-thin-delegate",
|
|
14
|
+
"no-brand-names",
|
|
15
|
+
"no-card-shaped-div",
|
|
16
|
+
"no-cross-feature-stores",
|
|
17
|
+
"no-duplicate-jsx-patterns",
|
|
18
|
+
"no-hook-in-component-disguise",
|
|
19
|
+
"no-inert-hidden-jsx",
|
|
20
|
+
"no-inline-data-in-jsx",
|
|
21
|
+
"no-invalid-feature-folders",
|
|
22
|
+
"no-logic-in-component-files",
|
|
23
|
+
"no-raw-html-atoms",
|
|
24
|
+
"no-react-namespace",
|
|
25
|
+
"no-renamed-html-props",
|
|
26
|
+
"no-render-prop-reader",
|
|
27
|
+
"no-trivial-wrapper-component",
|
|
28
|
+
"no-ts-in-bio-folders",
|
|
29
|
+
"no-type-definitions-in-components",
|
|
30
|
+
"organelle-dependency",
|
|
31
|
+
"organelle-single-source",
|
|
32
|
+
"tissue-must-compose",
|
|
33
|
+
"tissue-no-data-props",
|
|
34
|
+
"tissue-no-hooks",
|
|
35
|
+
"tissue-no-organelles",
|
|
36
|
+
"tissue-no-stores",
|
|
37
|
+
"zustand-v5-best-practices"
|
|
38
|
+
];
|
|
39
|
+
var BACKEND_WORKFLOWS = [
|
|
40
|
+
"constants-in-constants-file",
|
|
41
|
+
"dialect-through-the-seam",
|
|
42
|
+
"document-sagas-are-generic",
|
|
43
|
+
"documents-share-one-table",
|
|
44
|
+
"no-orm-outside-db",
|
|
45
|
+
"no-raw-sql-outside-allowed",
|
|
46
|
+
"no-void-port",
|
|
47
|
+
"queue-loop-is-the-library",
|
|
48
|
+
"ssot-no-inline-facts",
|
|
49
|
+
"ssot-no-process-env",
|
|
50
|
+
"tables-declare-their-plane",
|
|
51
|
+
"time-through-the-door"
|
|
52
|
+
];
|
|
53
|
+
var BACKEND_D1 = ["no-d1-transaction", "worker-handles-are-scoped"];
|
|
54
|
+
var BACKEND_MEDUSA = ["store-route-scopes-tenant-data"];
|
|
55
|
+
var TENANT_SCOPING = [
|
|
56
|
+
"queries-require-org-scope",
|
|
57
|
+
"store-route-scopes-tenant-data",
|
|
58
|
+
"tables-declare-their-plane",
|
|
59
|
+
"tenant-tables-carry-org-id"
|
|
60
|
+
];
|
|
61
|
+
var RULE_PREFIX = "biological-architecture";
|
|
62
|
+
var asRules = (names) => Object.fromEntries(names.map((name) => [`${RULE_PREFIX}/${name}`, "error"]));
|
|
63
|
+
var COMMENT_CEILING = {
|
|
64
|
+
rules: {
|
|
65
|
+
...asRules(["max-comment-density"]),
|
|
66
|
+
"capitalized-comments": "error"
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
var PRESETS = {
|
|
70
|
+
"backend-d1": { rules: asRules(BACKEND_D1) },
|
|
71
|
+
"backend-medusa": { rules: asRules(BACKEND_MEDUSA) },
|
|
72
|
+
"backend-workflows": { rules: asRules(BACKEND_WORKFLOWS) },
|
|
73
|
+
"comment-ceiling": COMMENT_CEILING,
|
|
74
|
+
frontend: { rules: asRules(FRONTEND) },
|
|
75
|
+
recommended: { rules: asRules(FRONTEND) },
|
|
76
|
+
"tenant-scoping": { rules: asRules(TENANT_SCOPING) }
|
|
77
|
+
};
|
|
78
|
+
var rulesOfPreset = (preset) => Object.keys(PRESETS[preset].rules).filter((id) => id.startsWith(`${RULE_PREFIX}/`)).map((id) => id.slice(RULE_PREFIX.length + 1));
|
|
79
|
+
|
|
80
|
+
export {
|
|
81
|
+
PRESETS,
|
|
82
|
+
rulesOfPreset
|
|
83
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// src/discover-atoms.ts
|
|
2
|
+
import { readdirSync, readFileSync } from "fs";
|
|
3
|
+
import { basename, join } from "path";
|
|
4
|
+
var GENERIC_ELEMENTS = /* @__PURE__ */ new Set(["div", "span"]);
|
|
5
|
+
function buildAtomRestrictions(atomsDir, importPathPrefix = "@kit/ui/atoms") {
|
|
6
|
+
const mappings = scanAtomMappings(atomsDir);
|
|
7
|
+
return mappings.map(({ atomName, nativeElement }) => ({
|
|
8
|
+
message: `Use <${toPascalCase(atomName)}> from '${importPathPrefix}/${atomName}' instead of raw <${nativeElement}>. Native HTML elements that have an atom wrapper must not be used directly in molecules/compounds/cells/tissues - use the atom to preserve consistent styling and behavior.`,
|
|
9
|
+
selector: `JSXOpeningElement[name.name='${nativeElement}']`
|
|
10
|
+
}));
|
|
11
|
+
}
|
|
12
|
+
function buildAtomRuleRestrictions(atomsDir, importPathPrefix = "@kit/ui/atoms") {
|
|
13
|
+
const mappings = scanAtomMappings(atomsDir);
|
|
14
|
+
return mappings.map(({ atomName, nativeElement }) => ({
|
|
15
|
+
atom: toPascalCase(atomName),
|
|
16
|
+
element: nativeElement,
|
|
17
|
+
importPath: `${importPathPrefix}/${atomName}`
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
function scanAtomMappings(atomsDir) {
|
|
21
|
+
const entries = readdirSync(atomsDir, { withFileTypes: true });
|
|
22
|
+
const candidates = /* @__PURE__ */ new Map();
|
|
23
|
+
for (const entry of entries) {
|
|
24
|
+
if (!entry.isFile()) continue;
|
|
25
|
+
if (!entry.name.endsWith(".tsx")) continue;
|
|
26
|
+
const atomFile = entry.name;
|
|
27
|
+
const atomName = basename(atomFile, ".tsx");
|
|
28
|
+
const content = readFileSync(join(atomsDir, atomFile), "utf8");
|
|
29
|
+
const nativeElement = detectFirstNativeJsxElement(content);
|
|
30
|
+
if (!nativeElement) continue;
|
|
31
|
+
if (GENERIC_ELEMENTS.has(nativeElement)) continue;
|
|
32
|
+
const existing = candidates.get(nativeElement) || [];
|
|
33
|
+
existing.push({ atomFile, atomName, nativeElement });
|
|
34
|
+
candidates.set(nativeElement, existing);
|
|
35
|
+
}
|
|
36
|
+
const mappings = [];
|
|
37
|
+
for (const [element, list] of candidates) {
|
|
38
|
+
const exact = list.find((m) => m.atomName === element);
|
|
39
|
+
const chosen = exact ?? list[0];
|
|
40
|
+
if (chosen) mappings.push(chosen);
|
|
41
|
+
}
|
|
42
|
+
return mappings;
|
|
43
|
+
}
|
|
44
|
+
function detectFirstNativeJsxElement(source) {
|
|
45
|
+
const slotMatch = source.match(/Slot\s*:\s*['"]([a-z][a-z0-9]*)['"]/);
|
|
46
|
+
if (slotMatch?.[1]) return slotMatch[1];
|
|
47
|
+
const cleaned = source.replaceAll(/\/\/.*$/gm, "").replaceAll(/\/\*[\s\S]*?\*\//g, "").replaceAll(/(["'`])(?:\\.|(?!\1)[^\\])*\1/g, '""');
|
|
48
|
+
const match = cleaned.match(/<([a-z][a-z0-9]*)\b/);
|
|
49
|
+
return match?.[1] ?? null;
|
|
50
|
+
}
|
|
51
|
+
function toPascalCase(kebab) {
|
|
52
|
+
return kebab.split("-").map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("");
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
buildAtomRestrictions,
|
|
56
|
+
buildAtomRuleRestrictions,
|
|
57
|
+
detectFirstNativeJsxElement,
|
|
58
|
+
scanAtomMappings
|
|
59
|
+
};
|