dittory 0.0.2 → 0.0.4
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 +102 -0
- package/dist/analyzeProps-6k4QTasK.mjs +1274 -0
- package/dist/analyzeProps-6k4QTasK.mjs.map +1 -0
- package/dist/cli.mjs +42 -214
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +94 -4
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
- package/dist/analyzeProps-CoEqudRM.mjs +0 -568
- package/dist/analyzeProps-CoEqudRM.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -87,6 +87,108 @@ Found 2 function(s) with constant arguments out of 24 function(s).
|
|
|
87
87
|
| **Functions** | Arguments passed to exported function calls |
|
|
88
88
|
| **Class Methods** | Arguments passed to methods of exported classes |
|
|
89
89
|
|
|
90
|
+
## Supported Detection Patterns
|
|
91
|
+
|
|
92
|
+
### Value Types
|
|
93
|
+
|
|
94
|
+
| Pattern | Example | Supported |
|
|
95
|
+
|---------|---------|-----------|
|
|
96
|
+
| String literals | `"hello"` | ✅ |
|
|
97
|
+
| Number literals | `42` | ✅ |
|
|
98
|
+
| Boolean literals | `true`, `false` | ✅ |
|
|
99
|
+
| Enum values | `Status.Active` | ✅ |
|
|
100
|
+
| Imported constants | `import { VALUE } from "./constants"` | ✅ |
|
|
101
|
+
| Variable references | `const x = 3; fn(x)` | ✅ |
|
|
102
|
+
| Variable chains | `const a = 1; const b = a; fn(b)` → resolves to `1` | ✅ |
|
|
103
|
+
| Object literals | `{ nested: { value: 1 } }` | ✅ |
|
|
104
|
+
| Function references | `onClick={handleClick}` | ✅ (by location) |
|
|
105
|
+
| `undefined` | `fn(undefined)` | ✅ |
|
|
106
|
+
|
|
107
|
+
### Parameter Propagation (Call Graph Analysis)
|
|
108
|
+
|
|
109
|
+
dittory can track values through component/function chains:
|
|
110
|
+
|
|
111
|
+
```tsx
|
|
112
|
+
// App passes "42" to Parent, Parent passes props.number to Child
|
|
113
|
+
// → Child.number is detected as constant "42"
|
|
114
|
+
|
|
115
|
+
const Child = ({ number }) => <div>{number}</div>;
|
|
116
|
+
const Parent = ({ number }) => <Child number={number} />;
|
|
117
|
+
export const App = () => <Parent number="42" />;
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
| Pattern | Example | Supported |
|
|
121
|
+
|---------|---------|-----------|
|
|
122
|
+
| Direct props access | `props.value` | ✅ |
|
|
123
|
+
| Destructured props | `({ value }) => ...` | ✅ |
|
|
124
|
+
| Nested access | `props.user.name` | ✅ |
|
|
125
|
+
| Multi-level chains | `A → B → C` propagation | ✅ |
|
|
126
|
+
| Circular reference protection | Prevents infinite loops | ✅ |
|
|
127
|
+
|
|
128
|
+
### Scope
|
|
129
|
+
|
|
130
|
+
| Pattern | Supported |
|
|
131
|
+
|---------|-----------|
|
|
132
|
+
| Exported functions/components | ✅ |
|
|
133
|
+
| Non-exported (internal) functions | ❌ |
|
|
134
|
+
|
|
135
|
+
## Unsupported Detection Patterns
|
|
136
|
+
|
|
137
|
+
### Spread Syntax
|
|
138
|
+
|
|
139
|
+
```tsx
|
|
140
|
+
// ❌ Props passed via spread are NOT tracked
|
|
141
|
+
const Parent = ({ num, ...others }) => <Child {...others} />;
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Dynamic Values
|
|
145
|
+
|
|
146
|
+
```tsx
|
|
147
|
+
// ❌ Values computed at runtime
|
|
148
|
+
<Button count={items.length} />
|
|
149
|
+
<Input value={getValue()} />
|
|
150
|
+
<List items={data.filter(x => x.active)} />
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Conditional Branches
|
|
154
|
+
|
|
155
|
+
When different code paths pass different values, dittory correctly identifies them as different values (not constant):
|
|
156
|
+
|
|
157
|
+
```tsx
|
|
158
|
+
// Different values in branches → correctly NOT reported as constant
|
|
159
|
+
const App = () => {
|
|
160
|
+
if (condition) {
|
|
161
|
+
return <Button variant="primary" />;
|
|
162
|
+
}
|
|
163
|
+
return <Button variant="secondary" />;
|
|
164
|
+
};
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Note: This is expected behavior. dittory performs static analysis and considers all code paths.
|
|
168
|
+
|
|
169
|
+
### Template Literals
|
|
170
|
+
|
|
171
|
+
```tsx
|
|
172
|
+
// ❌ Template strings with expressions
|
|
173
|
+
<Label text={`Hello, ${name}`} />
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Array/Object Spread in Arguments
|
|
177
|
+
|
|
178
|
+
```tsx
|
|
179
|
+
// ❌ Spread in function arguments
|
|
180
|
+
fn(...args);
|
|
181
|
+
fn({ ...defaults, custom: value });
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Higher-Order Components / Render Props
|
|
185
|
+
|
|
186
|
+
```tsx
|
|
187
|
+
// ❌ HOC patterns are not analyzed
|
|
188
|
+
const Enhanced = withAuth(Component);
|
|
189
|
+
<Enhanced role="admin" />
|
|
190
|
+
```
|
|
191
|
+
|
|
90
192
|
## CLI Options
|
|
91
193
|
|
|
92
194
|
| Option | Description | Default |
|