Skip to content

Commit a147355

Browse files
committed
Formalize Agent & Documentation Standards #7237
1 parent dfcf39f commit a147355

2 files changed

Lines changed: 45 additions & 2 deletions

File tree

.github/CODING_GUIDELINES.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,45 @@ export default Base;
193193
- empty line
194194

195195
## 5. Config order
196+
197+
## JSDoc for Configs
198+
199+
To ensure consistency and enable static analysis, the following JSDoc standards for configs are mandatory.
200+
201+
### The `@reactive` Tag
202+
203+
A config is considered **reactive** if its definition within the `static config` block (anywhere in its prototype chain) ends with a trailing underscore (`_`). This is the single source of truth for reactivity.
204+
205+
- The `@reactive` tag **MUST** be included in the JSDoc comment block for any config that is reactive.
206+
- This tag signals that the framework generates public `get()` and `set()` methods, along with `beforeGet`, `beforeSet`, and `afterSet` hooks.
207+
208+
**Correct Example:**
209+
```javascript
210+
/**
211+
* My cool reactive property.
212+
* @member {Boolean} myProperty_=true
213+
* @reactive
214+
*/
215+
myProperty_: true,
216+
```
217+
218+
### The `@protected` Tag
219+
220+
The `@protected` tag restricts a config to internal use within a class and its subclasses. It should be used sparingly.
221+
222+
- This tag **MUST ONLY** be used for configs that are not intended to be part of the public API for component instantiation or modification.
223+
- A prime example is the `className` config, which is an internal detail.
224+
- It **MUST NOT** be used for configs that developers are expected to use, such as `items`, `layout`, `style`, `width`, etc.
225+
226+
**Correct Example:**
227+
```javascript
228+
/**
229+
* @member {String} className='Neo.button.Base'
230+
* @protected
231+
*/
232+
className: 'Neo.button.Base',
233+
```
234+
196235
```javascript
197236
static config = {
198237
/**

AGENTS.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,17 @@ At the beginning of every new session, you **MUST** perform the following steps
2727
- The distinction between class namespaces (e.g., `Neo.component.Base`) and `ntype` shortcuts (e.g., `'button'`).
2828

2929
3. **Read the Base Class (`src/core/Base.mjs`):** This is the foundation for all components and classes. Focus on:
30-
- The `static config` system: Understand the difference between reactive configs (e.g., `myConfig_`) which generate
31-
hooks, and non-reactive configs which are set on the prototype.
30+
- The `static config` system: **CRITICAL:** You must deeply understand the difference between **reactive configs** (e.g., `myConfig_`), which generate `before/afterSet` hooks and are fundamental to the framework's reactivity, and **non-reactive configs**, which are applied to the prototype. Misinterpreting this is a critical failure. The trailing underscore is the key indicator.
3231
- The instance lifecycle: `construct()`, `onConstructed()`, `initAsync()`, and `destroy()`.
3332
- The reactivity hooks: `beforeGet*`, `beforeSet*`, `afterSet*`.
3433

3534
4. **Understand the Two Component Models:** Read the file `learn/gettingstarted/DescribingTheUI.md` to understand the
3635
difference between functional and class-based components, and how they interoperate.
3736

37+
5. **Read the Coding Guidelines:** Parse the file `.github/CODING_GUIDELINES.md` to ensure all code and
38+
documentation changes adhere to the project's established standards, paying special attention to the
39+
JSDoc rules for configs.
40+
3841
## 3. The Knowledge Base: Your Primary Source of Truth
3942

4043
Your primary directive is to rely on the project's internal knowledge base, not your pre-existing training data.
@@ -209,6 +212,7 @@ Integrate the query tool into your development process.
209212
4. **Verify:** After making changes, run any relevant verification tools, such as tests, to ensure your changes are
210213
correct and meet the project's standards. For bug fixes, ensure you've created regression tests
211214
(see `learn/guides/UnitTestingWithSiesta.md` for guidance).
215+
212216
5. **Use `text` over `html` in VDOM:** When creating VDOM nodes, always prefer using the `text` property over the `html`
213217
property. `text` is mapped to the `textContent` DOM attribute, which is inherently secure against XSS attacks. `html`
214218
is mapped to `innerHTML` and should be avoided unless you are intentionally rendering trusted HTML content.

0 commit comments

Comments
 (0)