@pyreon/lint 0.11.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 (81) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +214 -0
  3. package/lib/analysis/index.js.html +5406 -0
  4. package/lib/index.js +2955 -0
  5. package/lib/index.js.map +1 -0
  6. package/lib/types/index.d.ts +260 -0
  7. package/lib/types/index.d.ts.map +1 -0
  8. package/package.json +56 -0
  9. package/src/cache.ts +51 -0
  10. package/src/cli.ts +199 -0
  11. package/src/config/ignore.ts +159 -0
  12. package/src/config/loader.ts +72 -0
  13. package/src/config/presets.ts +62 -0
  14. package/src/index.ts +40 -0
  15. package/src/lint.ts +226 -0
  16. package/src/reporter.ts +85 -0
  17. package/src/rules/accessibility/dialog-a11y.ts +32 -0
  18. package/src/rules/accessibility/overlay-a11y.ts +33 -0
  19. package/src/rules/accessibility/toast-a11y.ts +38 -0
  20. package/src/rules/architecture/dev-guard-warnings.ts +57 -0
  21. package/src/rules/architecture/no-circular-import.ts +59 -0
  22. package/src/rules/architecture/no-cross-layer-import.ts +75 -0
  23. package/src/rules/architecture/no-deep-import.ts +32 -0
  24. package/src/rules/architecture/no-error-without-prefix.ts +75 -0
  25. package/src/rules/form/no-submit-without-validation.ts +45 -0
  26. package/src/rules/form/no-unregistered-field.ts +45 -0
  27. package/src/rules/form/prefer-field-array.ts +41 -0
  28. package/src/rules/hooks/no-raw-addeventlistener.ts +28 -0
  29. package/src/rules/hooks/no-raw-localstorage.ts +35 -0
  30. package/src/rules/hooks/no-raw-setinterval.ts +41 -0
  31. package/src/rules/index.ts +208 -0
  32. package/src/rules/jsx/no-and-conditional.ts +32 -0
  33. package/src/rules/jsx/no-children-access.ts +44 -0
  34. package/src/rules/jsx/no-classname.ts +27 -0
  35. package/src/rules/jsx/no-htmlfor.ts +27 -0
  36. package/src/rules/jsx/no-index-as-by.ts +70 -0
  37. package/src/rules/jsx/no-map-in-jsx.ts +43 -0
  38. package/src/rules/jsx/no-missing-for-by.ts +27 -0
  39. package/src/rules/jsx/no-onchange.ts +46 -0
  40. package/src/rules/jsx/no-props-destructure.ts +64 -0
  41. package/src/rules/jsx/no-ternary-conditional.ts +32 -0
  42. package/src/rules/jsx/use-by-not-key.ts +33 -0
  43. package/src/rules/lifecycle/no-dom-in-setup.ts +53 -0
  44. package/src/rules/lifecycle/no-effect-in-mount.ts +36 -0
  45. package/src/rules/lifecycle/no-missing-cleanup.ts +80 -0
  46. package/src/rules/lifecycle/no-mount-in-effect.ts +35 -0
  47. package/src/rules/performance/no-eager-import.ts +28 -0
  48. package/src/rules/performance/no-effect-in-for.ts +41 -0
  49. package/src/rules/performance/no-large-for-without-by.ts +28 -0
  50. package/src/rules/performance/prefer-show-over-display.ts +47 -0
  51. package/src/rules/reactivity/no-bare-signal-in-jsx.ts +56 -0
  52. package/src/rules/reactivity/no-effect-assignment.ts +65 -0
  53. package/src/rules/reactivity/no-nested-effect.ts +33 -0
  54. package/src/rules/reactivity/no-peek-in-tracked.ts +35 -0
  55. package/src/rules/reactivity/no-signal-in-loop.ts +59 -0
  56. package/src/rules/reactivity/no-signal-leak.ts +58 -0
  57. package/src/rules/reactivity/no-unbatched-updates.ts +77 -0
  58. package/src/rules/reactivity/prefer-computed.ts +56 -0
  59. package/src/rules/router/index.ts +4 -0
  60. package/src/rules/router/no-href-navigation.ts +51 -0
  61. package/src/rules/router/no-imperative-navigate-in-render.ts +83 -0
  62. package/src/rules/router/no-missing-fallback.ts +87 -0
  63. package/src/rules/router/prefer-use-is-active.ts +45 -0
  64. package/src/rules/ssr/no-mismatch-risk.ts +47 -0
  65. package/src/rules/ssr/no-window-in-ssr.ts +76 -0
  66. package/src/rules/ssr/prefer-request-context.ts +56 -0
  67. package/src/rules/store/no-duplicate-store-id.ts +43 -0
  68. package/src/rules/store/no-mutate-store-state.ts +37 -0
  69. package/src/rules/store/no-store-outside-provider.ts +59 -0
  70. package/src/rules/styling/no-dynamic-styled.ts +60 -0
  71. package/src/rules/styling/no-inline-style-object.ts +30 -0
  72. package/src/rules/styling/no-theme-outside-provider.ts +45 -0
  73. package/src/rules/styling/prefer-cx.ts +44 -0
  74. package/src/runner.ts +170 -0
  75. package/src/tests/runner.test.ts +1043 -0
  76. package/src/types.ts +125 -0
  77. package/src/utils/ast.ts +192 -0
  78. package/src/utils/imports.ts +122 -0
  79. package/src/utils/index.ts +39 -0
  80. package/src/utils/source.ts +36 -0
  81. package/src/watcher.ts +118 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-present Vit Bokisch
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,214 @@
1
+ # @pyreon/lint
2
+
3
+ Pyreon-specific linter powered by [oxc-parser](https://github.com/nicolo-ribaudo/oxc-parser) — 51 rules across 11 categories for signals, JSX, SSR, performance, and architecture.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ bun add @pyreon/lint
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### CLI
14
+
15
+ ```bash
16
+ # Lint current directory with recommended preset
17
+ pyreon-lint
18
+
19
+ # Lint specific paths
20
+ pyreon-lint src/ components/
21
+
22
+ # Use a preset
23
+ pyreon-lint --preset strict src/
24
+
25
+ # Auto-fix fixable issues
26
+ pyreon-lint --fix src/
27
+
28
+ # JSON output
29
+ pyreon-lint --format json src/
30
+
31
+ # Only show errors (skip warnings and info)
32
+ pyreon-lint --quiet src/
33
+
34
+ # Override a rule
35
+ pyreon-lint --rule pyreon/no-map-in-jsx=off src/
36
+
37
+ # List all rules
38
+ pyreon-lint --list
39
+ ```
40
+
41
+ ### Programmatic API
42
+
43
+ ```ts
44
+ import { lint, listRules, lintFile, applyFixes } from "@pyreon/lint"
45
+
46
+ // Lint files
47
+ const result = lint({
48
+ paths: ["src/"],
49
+ preset: "recommended",
50
+ fix: false,
51
+ quiet: false,
52
+ })
53
+
54
+ console.log(`${result.totalErrors} errors, ${result.totalWarnings} warnings`)
55
+
56
+ // List all rules
57
+ for (const rule of listRules()) {
58
+ console.log(`${rule.id} (${rule.severity}): ${rule.description}`)
59
+ }
60
+
61
+ // Lint a single source string
62
+ import { getPreset } from "@pyreon/lint"
63
+ import { allRules } from "@pyreon/lint/rules"
64
+
65
+ const fileResult = lintFile("app.tsx", source, allRules, getPreset("recommended"))
66
+ ```
67
+
68
+ ## Rules (51)
69
+
70
+ ### Reactivity (8)
71
+
72
+ | Rule | Severity | Fixable | Description |
73
+ |------|----------|---------|-------------|
74
+ | `pyreon/no-bare-signal-in-jsx` | error | Yes | Flags `{count()}` in JSX text — wrap in `() =>` |
75
+ | `pyreon/no-signal-in-loop` | error | No | Flags signal()/computed() inside loops |
76
+ | `pyreon/no-nested-effect` | warn | No | Flags effect() inside effect() |
77
+ | `pyreon/no-peek-in-tracked` | error | No | Flags .peek() inside effect/computed |
78
+ | `pyreon/no-unbatched-updates` | warn | No | Flags 3+ .set() calls without batch() |
79
+ | `pyreon/prefer-computed` | warn | No | Suggests computed() for effect with single .set() |
80
+ | `pyreon/no-effect-assignment` | warn | No | Flags effect with single .update() |
81
+ | `pyreon/no-signal-leak` | warn | No | Reports unused signal declarations |
82
+
83
+ ### JSX (11)
84
+
85
+ | Rule | Severity | Fixable | Description |
86
+ |------|----------|---------|-------------|
87
+ | `pyreon/no-map-in-jsx` | warn | No | Prefer `<For>` over .map() in JSX |
88
+ | `pyreon/use-by-not-key` | error | Yes | Use `by` not `key` on `<For>` |
89
+ | `pyreon/no-classname` | error | Yes | Use `class` not `className` |
90
+ | `pyreon/no-htmlfor` | error | Yes | Use `for` not `htmlFor` |
91
+ | `pyreon/no-onchange` | warn | Yes | Prefer `onInput` over `onChange` on inputs |
92
+ | `pyreon/no-ternary-conditional` | warn | No | Prefer `<Show>` over ternary with JSX |
93
+ | `pyreon/no-and-conditional` | warn | No | Prefer `<Show>` over `&&` with JSX |
94
+ | `pyreon/no-index-as-by` | warn | No | Don't use index as `by` prop |
95
+ | `pyreon/no-missing-for-by` | warn | No | `<For>` should have `by` prop |
96
+ | `pyreon/no-props-destructure` | error | No | Don't destructure component props |
97
+ | `pyreon/no-children-access` | info | No | Direct props.children access in renderers |
98
+
99
+ ### Lifecycle (4)
100
+
101
+ | Rule | Severity | Fixable | Description |
102
+ |------|----------|---------|-------------|
103
+ | `pyreon/no-missing-cleanup` | warn | No | onMount with timers needs cleanup return |
104
+ | `pyreon/no-mount-in-effect` | warn | No | Don't call onMount inside effect |
105
+ | `pyreon/no-effect-in-mount` | info | No | effect() inside onMount is unusual |
106
+ | `pyreon/no-dom-in-setup` | warn | No | DOM queries outside onMount/effect |
107
+
108
+ ### Performance (4)
109
+
110
+ | Rule | Severity | Fixable | Description |
111
+ |------|----------|---------|-------------|
112
+ | `pyreon/no-large-for-without-by` | error | No | `<For>` must have `by` for reconciliation |
113
+ | `pyreon/no-effect-in-for` | warn | No | Don't create effects inside `<For>` |
114
+ | `pyreon/no-eager-import` | info | No | Lazy-load heavy packages |
115
+ | `pyreon/prefer-show-over-display` | info | No | Use `<Show>` instead of CSS display toggle |
116
+
117
+ ### SSR (3)
118
+
119
+ | Rule | Severity | Fixable | Description |
120
+ |------|----------|---------|-------------|
121
+ | `pyreon/no-window-in-ssr` | error | No | Browser globals outside safe scopes |
122
+ | `pyreon/no-mismatch-risk` | warn | No | Non-deterministic calls in JSX |
123
+ | `pyreon/prefer-request-context` | warn | No | Module-level state in server files |
124
+
125
+ ### Architecture (5)
126
+
127
+ | Rule | Severity | Fixable | Description |
128
+ |------|----------|---------|-------------|
129
+ | `pyreon/no-circular-import` | error | No | Enforce package layer order |
130
+ | `pyreon/no-deep-import` | warn | No | No @pyreon/*/src/ imports |
131
+ | `pyreon/no-cross-layer-import` | error | No | Core can't import ui-system |
132
+ | `pyreon/dev-guard-warnings` | error | No | console.warn/error needs `__DEV__` |
133
+ | `pyreon/no-error-without-prefix` | warn | Yes | Errors need [Pyreon] prefix |
134
+
135
+ ### Store (3)
136
+
137
+ | Rule | Severity | Fixable | Description |
138
+ |------|----------|---------|-------------|
139
+ | `pyreon/no-store-outside-provider` | warn | No | Store hooks need provider in SSR |
140
+ | `pyreon/no-mutate-store-state` | warn | No | Use actions, not direct .set() |
141
+ | `pyreon/no-duplicate-store-id` | error | No | Unique defineStore() IDs |
142
+
143
+ ### Form (3)
144
+
145
+ | Rule | Severity | Fixable | Description |
146
+ |------|----------|---------|-------------|
147
+ | `pyreon/no-unregistered-field` | warn | No | useField() without register() |
148
+ | `pyreon/no-submit-without-validation` | warn | No | useForm onSubmit without validators |
149
+ | `pyreon/prefer-field-array` | info | No | signal([]) in form files |
150
+
151
+ ### Styling (4)
152
+
153
+ | Rule | Severity | Fixable | Description |
154
+ |------|----------|---------|-------------|
155
+ | `pyreon/no-inline-style-object` | warn | No | Inline style objects in JSX |
156
+ | `pyreon/no-dynamic-styled` | warn | No | styled() inside functions |
157
+ | `pyreon/prefer-cx` | info | No | Use cx() for class composition |
158
+ | `pyreon/no-theme-outside-provider` | warn | No | useTheme() without provider |
159
+
160
+ ### Hooks (3)
161
+
162
+ | Rule | Severity | Fixable | Description |
163
+ |------|----------|---------|-------------|
164
+ | `pyreon/no-raw-addeventlistener` | info | No | Use useEventListener() |
165
+ | `pyreon/no-raw-setinterval` | info | No | Wrap timers in onMount |
166
+ | `pyreon/no-raw-localstorage` | info | No | Use useStorage() |
167
+
168
+ ### Accessibility (3)
169
+
170
+ | Rule | Severity | Fixable | Description |
171
+ |------|----------|---------|-------------|
172
+ | `pyreon/toast-a11y` | warn | No | Toast components need role/aria-live |
173
+ | `pyreon/dialog-a11y` | warn | No | `<dialog>` needs aria-label |
174
+ | `pyreon/overlay-a11y` | warn | No | `<Overlay>` needs role/aria-label |
175
+
176
+ ## Presets
177
+
178
+ | Preset | Description |
179
+ |--------|-------------|
180
+ | `recommended` | All rules at default severity |
181
+ | `strict` | All warnings promoted to errors |
182
+ | `app` | Recommended minus library-only rules |
183
+ | `lib` | Strict plus architecture checks |
184
+
185
+ ## Custom Rules
186
+
187
+ ```ts
188
+ import type { Rule } from "@pyreon/lint"
189
+
190
+ const myRule: Rule = {
191
+ meta: {
192
+ id: "custom/my-rule",
193
+ category: "reactivity",
194
+ description: "My custom rule",
195
+ severity: "warn",
196
+ fixable: false,
197
+ },
198
+ create(context) {
199
+ return {
200
+ CallExpression(node, parent) {
201
+ // Your rule logic
202
+ context.report({
203
+ message: "Something is wrong",
204
+ span: { start: node.start, end: node.end },
205
+ })
206
+ },
207
+ }
208
+ },
209
+ }
210
+ ```
211
+
212
+ ## License
213
+
214
+ MIT