larrylint 0.1.1 → 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.
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  Opinionated rules for [Laioutr](https://laioutr.com) apps: an ESLint preset for your editor and a CLI for CI.
9
9
 
10
- Laioutr apps are Nuxt modules with a lot of moving parts: sections and blocks, orchestr handlers, middleware, API clients, server routes. larrylint keeps them where they belong and stops the imports that make a codebase drift, like app code pulling in server code, handlers importing each other, or one business domain reaching into another. It also catches the mistakes that only show up in Studio or in production, like schema fields that never reach the component, links Studio can't follow, or cookies the page cache hands to every visitor.
10
+ Laioutr apps are Nuxt modules with a lot of moving parts: sections and blocks, orchestr handlers, middleware, API clients, server routes. larrylint keeps them where they belong and stops the imports that make a codebase drift, like app code pulling in server code or handlers importing each other. It also catches the mistakes that only show up in Studio or in production, like schema fields that never reach the component, fallbacks that never apply, or cookies written after orchestr has sent the headers.
11
11
 
12
12
  ## Usage
13
13
 
@@ -25,7 +25,7 @@ npx larrylint init
25
25
 
26
26
  After that, `eslint .` and your editor report larrylint's rules next to your own.
27
27
 
28
- `ui-kit-tags` and `token-namespaces` read the app's installed `@laioutr-core/ui-kit`, `@laioutr-core/ui` and `@laioutr-core/canonical-types`, so install the app's dependencies first. larrylint stops with an error when one of them is missing.
28
+ `token-namespaces` reads the app's installed `@laioutr-core/canonical-types`, so install the app's dependencies first. larrylint stops with an error when it's missing.
29
29
 
30
30
  ## Rules
31
31
 
@@ -33,11 +33,10 @@ After that, `eslint .` and your editor report larrylint's rules next to your own
33
33
 
34
34
  | Rule | Description |
35
35
  | --- | --- |
36
- | `larrylint/layers` | App, server and shared code stay apart, and runtime code doesn't import build-time code, or `node:` modules outside the server. Nothing imports orchestr handlers, only handlers and media libraries import middleware, and API clients stay out of handlers and server utils. Utils are the bottom layer, followed by composables, components and sections. Domains stay apart. |
37
- | `larrylint/known-folders` | Runtime files live in the folders of the [layout](#layout), where the other rules know what to check. |
38
- | `larrylint/heavy-imports` | Sections, blocks and plugins load the packages in `heavyPackages` with `import()`. Laioutr registers them globally, so a static import lands in the chunk every page loads. |
36
+ | `larrylint/layers` | App, server and shared code stay apart, and runtime code doesn't import build-time code, or `node:` modules outside the server. Nothing imports orchestr handlers, and handlers get API clients from the orchestr context. Utils are the bottom layer, followed by composables, components and sections. |
37
+ | `larrylint/heavy-imports` | Sections, blocks and plugins load the packages in `heavyPackages` with `import()`: frontend-core imports every section and block up front, and plugins run on every page, so a static import lands in the chunk every page loads. |
39
38
  | `larrylint/config-keys` | Runtime config keys like `'@laioutr-app/shopware'` are the app itself or one of its dependencies, otherwise the config is missing at runtime. |
40
- | `larrylint/public-config` | The module doesn't copy its options into `runtimeConfig.public`, which reaches the browser with every token among them. |
39
+ | `larrylint/public-config` | The module doesn't copy its whole options object into `runtimeConfig.public`, which reaches the browser with every token among them. |
41
40
 
42
41
  Type imports are fine across most layers, since they don't end up in the bundle.
43
42
 
@@ -45,55 +44,37 @@ Type imports are fine across most layers, since they don't end up in the bundle.
45
44
 
46
45
  | Rule | Description |
47
46
  | --- | --- |
48
- | `larrylint/orchestr-files` | Laioutr loads every file in `orchestr/` as a server plugin, so only handler files belong there. |
49
- | `larrylint/orchestr-cookies` | Handlers and middleware don't set cookies or redirect, since the page cache replays the response to every visitor. |
50
- | `larrylint/handler-domains` | Handlers live in a domain folder, e.g. `orchestr/<domain>/`. |
51
- | `larrylint/handler-exports` | Handler files export their handler as default and nothing else. |
52
- | `larrylint/handler-context` | Handlers take config and clients from the middleware context and the request from their arguments, not from `useRuntimeConfig()` or `useEvent()`. |
53
- | `larrylint/resolver-undefined` | Component resolvers resolve fields to empty values like `''`, not `undefined` or `null`, which Studio shows as "...". |
54
- | `larrylint/resolver-passthrough` | Component resolvers use `passthrough.get()`: `require()` fails the whole resolver when another query didn't set the value. |
55
- | `larrylint/action-errors` | Actions return client errors as a status in their output. A thrown 4xx arrives as a failed action, since the action transport drops status codes. |
47
+ | `larrylint/orchestr-files` | Laioutr loads every file in `orchestr/` as a Nitro plugin, so only handler files belong there. |
48
+ | `larrylint/orchestr-cookies` | Cookies and headers are only written in `extendRequest()` and action handlers, since query, link and resolver handlers and `use()` middleware can run after the headers are sent. Cookies go through frontend-core's `setManagedCookie()` and `deleteManagedCookie()`, which the Studio preview needs. |
49
+ | `larrylint/handler-exports` | Handler files export their handler as default. Without one, the build fails. |
56
50
  | `larrylint/middleware-files` | `server/middleware/` only holds orchestr and Nitro middleware; helpers go to `server/utils/`. |
57
51
  | `larrylint/initware-throws` | `extendRequest()` doesn't throw, directly or through a function it calls: it runs before every query, so a throw takes down every page. |
58
- | `larrylint/orchestr-meta` | `defineOrchestr.meta({ app })` is the package name, which traces use to tell which app's middleware ran. |
59
- | `larrylint/token-namespaces` | Your own tokens stay out of the namespaces of Laioutr's canonical types, like `ecommerce/`, where registration order decides which handler wins. |
60
- | `larrylint/token-nullable` | Entity component tokens have no nullable top-level fields, which Studio can't bind. |
52
+ | `larrylint/token-namespaces` | Your own tokens stay out of the namespaces of Laioutr's canonical types, like `ecommerce/`, where a later canonical-types release or another app can take the same id. |
61
53
 
62
54
  ### Sections and blocks
63
55
 
64
56
  | Rule | Description |
65
57
  | --- | --- |
66
- | `larrylint/definition-folder` | `defineSection()` lives in `app/sections/` and `defineBlock()` in `app/blocks/`, and every `.vue` there has one. |
67
- | `larrylint/definition-prefix` | Sections are named `Section*.vue`, blocks `Block*.vue`. |
58
+ | `larrylint/definition-folder` | `defineSection()` lives in `app/sections/` and `defineBlock()` in `app/blocks/` (or `section/` and `block/`), and every `.vue` there has one. |
68
59
  | `larrylint/component-name` | The `component` of a definition matches its file name. |
69
- | `larrylint/definition-description` | Definitions have a `studio.description`, which Studio shows in its section and block picker. |
70
- | `larrylint/root-id` | The root element has no `id`: frontend-core replaces it with its own. |
60
+ | `larrylint/definition-description` | Definitions have a `studio.description`, which Studio shows in its section picker and AI agents read through Laioutr's MCP server. |
71
61
  | `larrylint/single-root` | Sections and blocks render one root element, also through a component they wrap. Otherwise Vue drops the `data-lfc-*` markers frontend-core adds. |
72
- | `larrylint/slot-children` | Nothing counts slot children with `.length`: Studio passes all blocks of a slot as one Fragment. |
73
- | `larrylint/reserved-field-names` | No top-level schema fields named `style`, `class`, `key`, `ref`, `is`, `slot`, `refFor` or `refKey`, which Vue swallows before they reach the component. |
74
- | `larrylint/field-name-case` | Top-level schema fields are camelCase, since they become props. |
62
+ | `larrylint/slot-children` | Nothing counts slot children with `.length`: frontend-core passes all blocks of a slot as one Fragment. |
63
+ | `larrylint/reserved-field-names` | No top-level schema fields named `key`, `ref`, `ref_for`, `ref_key`, `class` or `style`, which Vue handles itself, and no `slots` on sections, which frontend-core overwrites. |
64
+ | `larrylint/field-name-case` | Top-level schema field names have no `-` and don't start with `$`: Vue camelizes the one and rejects the other. |
75
65
  | `larrylint/required-fields` | Schema fields have no `required`, which Studio ignores. Give them a `default` instead. |
76
- | `larrylint/schema-groups` | Schema groups are Studio's panels, in the order Content, Design, Rules. |
77
- | `larrylint/unused-fields` | The component reads every schema field it defines, so editors don't get fields that do nothing. |
78
- | `larrylint/dead-fallbacks` | No `??` fallbacks or `undefined` checks on props that are never `undefined`: unset checkbox, select, radio and toggle fields arrive as `false`, unset text fields as `''`. |
66
+ | `larrylint/unused-fields` | The component reads every schema field it defines, directly, through the section it's a block of, or in another field's `if`, so editors don't get fields that do nothing. |
67
+ | `larrylint/dead-fallbacks` | No `??` fallbacks that never apply: frontend-core fills unset pickers with their first option, checkboxes with `false` and text fields with `''`. |
79
68
 
80
69
  ### Frontend
81
70
 
82
71
  | Rule | Description |
83
72
  | --- | --- |
84
- | `larrylint/button-type` | No `type` on the ui-kit button: it always renders its `button-type` prop, so `type="submit"` silently renders a dead button. Autofixable. |
85
- | `larrylint/ui-kit-tags` | `<l-*>` tags are ui-kit or ui components. Anything else renders nothing. |
86
- | `larrylint/mutation-errors` | An awaited or dropped `mutateAsync()` handles its error. Otherwise a failed mutation replaces the whole section or block with frontend-core's "Retry" state. |
87
- | `larrylint/orchestr-store` | Components read orchestr data through composables, not `useOrchestrStore()`. |
88
- | `larrylint/resolve-result` | Nothing tests the result of `linkResolver.resolve()`, which is never empty: a link it can't resolve comes back as a `#missing-required-params…` string. |
89
- | `larrylint/hand-built-links` | Internal links come from `linkResolver`, not from paths like `` `/hotels/${slug}` ``, which break when a page type's route changes. |
90
- | `larrylint/internal-anchors` | Internal links use `<NuxtLink>`: a plain `<a>` reloads the page and breaks Studio's navigation sync. |
91
-
92
- ### Canonical types
93
-
94
- | Rule | What it checks |
95
- | --- | --- |
96
- | `larrylint/money` | Money amounts are integers in minor units, e.g. `1999` for 19.99, and currencies are ISO 4217 codes like `EUR`. |
73
+ | `larrylint/button-type` | No `type` on the ui-kit buttons: they always render their `button-type` prop, so `type="submit"` silently renders a dead button. Autofixable. |
74
+ | `larrylint/mutation-errors` | An awaited or dropped `mutateAsync()` handles its error. Otherwise a failed mutation replaces the whole section or block with frontend-core's "Retry" state, or ends up as an unhandled rejection. |
75
+ | `larrylint/resolve-result` | Nothing tests the result of `linkResolver.resolve()`: a link it can't resolve comes back as a `#…` fallback, not as an empty value. |
76
+ | `larrylint/hand-built-links` | Links to pages come from `linkResolver`, not from paths like `` `/hotels/${slug}` ``: page paths are set per page and language in Studio, and each market adds its own prefix, like `/en`. |
77
+ | `larrylint/internal-anchors` | Internal and resolved links use `<NuxtLink>`: a plain `<a>` reloads the page and breaks Studio's navigation sync. |
97
78
 
98
79
  ## Layout
99
80
 
@@ -104,8 +85,8 @@ src/
104
85
  ├── module.ts # build time
105
86
  └── runtime/
106
87
  ├── app/
107
- │ ├── sections/ # Section*.vue with defineSection()
108
- │ ├── blocks/ # Block*.vue with defineBlock()
88
+ │ ├── sections/ # defineSection() components, or section/
89
+ │ ├── blocks/ # defineBlock() components, or block/
109
90
  │ ├── components/
110
91
  │ ├── composables/
111
92
  │ ├── overrides/ # replacements for upstream components
@@ -115,7 +96,7 @@ src/
115
96
  │ └── utils/
116
97
  ├── server/
117
98
  │ ├── orchestr/
118
- │ │ ├── <domain>/ # *.query.ts, *.resolver.ts, *.link.ts, *.action.ts, *.template.ts, *.page-index.ts
99
+ │ │ ├── <entity>/ # *.query.ts, *.resolver.ts, *.link.ts, *.action.ts, *.template.ts, *.page-index.ts
119
100
  │ │ └── plugins/
120
101
  │ ├── middleware/ # orchestr middleware and the builders handlers use
121
102
  │ ├── client/ # API clients, nothing else
@@ -123,12 +104,9 @@ src/
123
104
  │ ├── plugins/ # Nitro plugins
124
105
  │ ├── media-library/ # or media-libraries/
125
106
  │ └── utils/
126
- │ └── <domain>/
127
107
  └── shared/ # code for both the app and the server
128
108
  ```
129
109
 
130
- A domain is a folder in `server/orchestr/`, together with the `server/utils/` folder of the same name. Other folders in `server/utils/`, like `tracking/`, hold shared helpers that every domain may use.
131
-
132
110
  ## Baseline
133
111
 
134
112
  On an existing codebase, `larrylint init` records all current violations in `larrylint-baseline.json`, counted per file and rule. A file stays quiet as long as it has no more violations of a rule than recorded. Once it gets more, all of them show again, like ESLint's bulk suppressions. The baseline applies in your editor, in `eslint .` and in the CLI.
@@ -141,17 +119,11 @@ npx larrylint --baseline
141
119
 
142
120
  ## Configuration
143
121
 
144
- Most apps need none. Two options tune the rules:
145
-
146
- - `sharedDomains`: domains every other domain may import, for `layers`.
147
- - `heavyPackages`: packages that sections, blocks and plugins must load with `import()`, for `heavy-imports`.
148
-
149
- Set them in your `package.json`:
122
+ Most apps need none. `heavyPackages` lists the packages that sections, blocks and plugins must load with `import()`, for `heavy-imports`. Set it in your `package.json`:
150
123
 
151
124
  ```json
152
125
  {
153
126
  "larrylint": {
154
- "sharedDomains": ["product"],
155
127
  "heavyPackages": ["leaflet"]
156
128
  }
157
129
  }
@@ -163,7 +135,6 @@ Or in a `larrylint.config.ts`:
163
135
  import { defineLarrylintConfig } from 'larrylint'
164
136
 
165
137
  export default defineLarrylintConfig({
166
- sharedDomains: ['product'],
167
138
  heavyPackages: ['leaflet'],
168
139
  })
169
140
  ```
@@ -1,4 +1,4 @@
1
1
  var name = "larrylint";
2
- var version = "0.1.1";
2
+ var version = "0.2.0";
3
3
  var description = "Opinionated rules for Laioutr apps, as an ESLint preset and a CLI.";
4
4
  export { description, name, version };