@hublo/sentinel 1.1.0-alpha.2 → 1.1.0-alpha.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 +148 -35
- package/dist/bin/sentinel.js +119 -48
- package/dist/chunk-FLLX5MN3.js +3155 -0
- package/dist/index.d.ts +59 -37
- package/dist/index.js +1 -1
- package/oxlint/nest.json +184 -187
- package/oxlint/node.json +27 -30
- package/oxlint/react.json +189 -204
- package/oxlint/svelte.json +215 -0
- package/package.json +6 -4
- package/dist/chunk-EZCRU6XE.js +0 -2062
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
declare function registerAdapters(): void;
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* The domain vocabulary: the fixed sets of verbs, targets, and
|
|
4
|
+
* The domain vocabulary: the fixed sets of verbs, targets, and presets, and the
|
|
5
5
|
* types derived from them. This is the model, and the extension point: adding a
|
|
6
|
-
* verb / target /
|
|
6
|
+
* verb / target / preset is a one-line edit to a list here, and because the types
|
|
7
7
|
* are DERIVED (`(typeof LIST)[number]`), the compiler forces every switch/handler
|
|
8
8
|
* to cover the new member.
|
|
9
9
|
*
|
|
@@ -21,9 +21,15 @@ type Verb = (typeof VERBS)[number];
|
|
|
21
21
|
/** Targets: the kind of check. The CLI `--<target>` flags map 1:1 to these. */
|
|
22
22
|
declare const TARGETS: readonly ["lint", "format", "typescript", "build", "test", "static-analysis", "runtime-analysis", "arch"];
|
|
23
23
|
type Target = (typeof TARGETS)[number];
|
|
24
|
-
/**
|
|
25
|
-
declare const
|
|
26
|
-
type
|
|
24
|
+
/** Presets: the stack preset a project resolves to (strict by default). */
|
|
25
|
+
declare const PRESET_NAMES: readonly ["react", "nest", "svelte", "node"];
|
|
26
|
+
type PresetName = (typeof PRESET_NAMES)[number];
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated Renamed to `PresetName`. Kept so an existing `import type { Flavour }` keeps
|
|
29
|
+
* compiling: the CLI kept `--flavour` working for the same reason, and breaking the type
|
|
30
|
+
* while sparing the flag would be an odd place to draw the line.
|
|
31
|
+
*/
|
|
32
|
+
type Flavour = PresetName;
|
|
27
33
|
|
|
28
34
|
/**
|
|
29
35
|
* The adapter contract, as PURE types (no runtime). Every tool (eslint, biome,
|
|
@@ -38,15 +44,15 @@ type Flavour = (typeof FLAVOURS)[number];
|
|
|
38
44
|
/**
|
|
39
45
|
* Normalized context for `--init`, built and guaranteed by the engine. The
|
|
40
46
|
* adapter TRUSTS this shape (no re-validation): `cwd` is the absolute module root,
|
|
41
|
-
* `
|
|
47
|
+
* `preset` is resolved (explicit `--preset`, else detected). The adapter may READ
|
|
42
48
|
* the module through bounded resolvers to plan, but never writes, the engine
|
|
43
49
|
* applies the returned plan.
|
|
44
50
|
*/
|
|
45
51
|
interface UpdateContext {
|
|
46
52
|
/** Absolute path to the module root. */
|
|
47
53
|
cwd: string;
|
|
48
|
-
/** The resolved, validated
|
|
49
|
-
|
|
54
|
+
/** The resolved, validated preset. */
|
|
55
|
+
preset: PresetName;
|
|
50
56
|
}
|
|
51
57
|
/** Resolved context for a single `--run`/`--report` against one module. */
|
|
52
58
|
interface RunContext {
|
|
@@ -54,8 +60,8 @@ interface RunContext {
|
|
|
54
60
|
module: string;
|
|
55
61
|
/** Absolute path to the module root. */
|
|
56
62
|
cwd: string;
|
|
57
|
-
/** The resolved
|
|
58
|
-
|
|
63
|
+
/** The resolved preset (explicit `--preset`, else detected). Guaranteed set. */
|
|
64
|
+
preset: PresetName;
|
|
59
65
|
/** CI mode: adapters must exit non-zero on failure. */
|
|
60
66
|
ci: boolean;
|
|
61
67
|
/** Apply auto-fixes where the tool supports it. */
|
|
@@ -66,6 +72,22 @@ interface RunContext {
|
|
|
66
72
|
* cap. Undefined lets the adapter use its default.
|
|
67
73
|
*/
|
|
68
74
|
maxDiagnostics?: number;
|
|
75
|
+
/**
|
|
76
|
+
* Extra options for the underlying tool, taken verbatim from after `--` on the command
|
|
77
|
+
* line. Empty for a normal run.
|
|
78
|
+
*
|
|
79
|
+
* This is the "what would turning this on cost?" seam. A preset defers rules
|
|
80
|
+
* (`noImplicitAny`, `noUnusedLocals`, …) and `--inspect` reports them as deferred, which
|
|
81
|
+
* is honest but answers a question nobody asked: what a developer wants to know is how
|
|
82
|
+
* much debt is behind the deferral. Rather than sentinel modelling that question one flag
|
|
83
|
+
* at a time, `--run` forwards the tool's own options, so any question the tool can already
|
|
84
|
+
* answer is one command away.
|
|
85
|
+
*
|
|
86
|
+
* An adapter that honours these MUST make the result impossible to mistake for a standard
|
|
87
|
+
* check: these options can weaken a run as easily as strengthen it, and `--run` is what CI
|
|
88
|
+
* calls. The engine echoes them on stderr and carries them in the `--json` envelope.
|
|
89
|
+
*/
|
|
90
|
+
toolArgs?: readonly string[];
|
|
69
91
|
}
|
|
70
92
|
/**
|
|
71
93
|
* A single, DECLARATIVE file operation an `--init` wants to happen. Adapters
|
|
@@ -74,7 +96,7 @@ interface RunContext {
|
|
|
74
96
|
*
|
|
75
97
|
* The split matters: an adapter says WHAT and WHY (tool meaning); the engine does
|
|
76
98
|
* the read/merge/write mechanics (format-agnostic plumbing). So an adapter stays
|
|
77
|
-
* a pure function of the
|
|
99
|
+
* a pure function of the preset, with no coupling to where files live.
|
|
78
100
|
*/
|
|
79
101
|
type FileOperation =
|
|
80
102
|
/** Create or replace a file the adapter fully owns (the thin stub). */
|
|
@@ -152,7 +174,7 @@ interface UpdatePlan {
|
|
|
152
174
|
operations: FileOperation[];
|
|
153
175
|
notes?: string[];
|
|
154
176
|
/**
|
|
155
|
-
* Set when the adapter CANNOT set this module up at all (no preset for the
|
|
177
|
+
* Set when the adapter CANNOT set this module up at all (no preset for the preset,
|
|
156
178
|
* a config chain it does not handle, …). The engine reports it as a FAILURE with a
|
|
157
179
|
* non-zero exit, never as a silent success: `--init` that writes nothing must not
|
|
158
180
|
* look like adoption to a person reading a log or to a script reading `$?`. Carries
|
|
@@ -171,7 +193,7 @@ interface AdapterResult {
|
|
|
171
193
|
}
|
|
172
194
|
/**
|
|
173
195
|
* Adoption + conformity of one module for one target, for `--status`. Read from the
|
|
174
|
-
* module's COMMITTED config (no tool run, no
|
|
196
|
+
* module's COMMITTED config (no tool run, no preset guessing), so a workspace-wide
|
|
175
197
|
* scan is a cheap coverage + drift dashboard.
|
|
176
198
|
*/
|
|
177
199
|
interface StatusReport {
|
|
@@ -185,7 +207,7 @@ interface StatusReport {
|
|
|
185
207
|
drift: string[];
|
|
186
208
|
}
|
|
187
209
|
/**
|
|
188
|
-
* One tool implementation for one target (and, optionally, a subset of
|
|
210
|
+
* One tool implementation for one target (and, optionally, a subset of presets,
|
|
189
211
|
* see `appliesTo`). The CLI verbs map onto these: `--run` -> run, `--inspect` ->
|
|
190
212
|
* inspect, `--init` -> plan(+write), `--report` -> report, `--status` -> status.
|
|
191
213
|
*/
|
|
@@ -195,22 +217,22 @@ interface Adapter {
|
|
|
195
217
|
/** The runner name, selectable via `--runner` (e.g. 'eslint'). */
|
|
196
218
|
readonly runner: string;
|
|
197
219
|
/**
|
|
198
|
-
* Whether this adapter handles the given
|
|
220
|
+
* Whether this adapter handles the given preset. Resolution filters candidates
|
|
199
221
|
* by this, so a React-only adapter is never picked for a Nest project, and two
|
|
200
|
-
* adapters can share a (target, runner) if they specialise different
|
|
222
|
+
* adapters can share a (target, runner) if they specialise different presets.
|
|
201
223
|
*/
|
|
202
|
-
appliesTo(
|
|
224
|
+
appliesTo(preset: PresetName): boolean;
|
|
203
225
|
/**
|
|
204
|
-
* The
|
|
226
|
+
* The preset this module has COMMITTED to, read from its own config, or undefined when
|
|
205
227
|
* it has not adopted a preset yet. Optional: an adapter implements it only when its tool's
|
|
206
|
-
* config states the
|
|
228
|
+
* config states the preset unambiguously.
|
|
207
229
|
*
|
|
208
230
|
* The engine prefers this over dependency detection, because in a monorepo dependencies are
|
|
209
231
|
* hoisted to the root: `host-admin` declares no `react`, so detection honestly answers
|
|
210
232
|
* `node` while the committed `extends` says `.../tsconfig/react`. Reporting the detected
|
|
211
233
|
* value there would show every adopted module as `node`, which is simply untrue.
|
|
212
234
|
*/
|
|
213
|
-
|
|
235
|
+
declaredPreset?(cwd: string): PresetName | undefined;
|
|
214
236
|
/**
|
|
215
237
|
* Plan what `--init` should write, as declarative operations (see
|
|
216
238
|
* `FileOperation`). Given a normalized `UpdateContext`, the adapter may READ the
|
|
@@ -246,7 +268,7 @@ interface Adapter {
|
|
|
246
268
|
declare abstract class BaseAdapter implements Adapter {
|
|
247
269
|
abstract readonly target: Target;
|
|
248
270
|
abstract readonly runner: string;
|
|
249
|
-
abstract appliesTo(
|
|
271
|
+
abstract appliesTo(preset: PresetName): boolean;
|
|
250
272
|
abstract plan(context: UpdateContext): UpdatePlan | Promise<UpdatePlan>;
|
|
251
273
|
abstract run(ctx: RunContext): Promise<AdapterResult>;
|
|
252
274
|
inspect(_ctx: RunContext): Promise<unknown>;
|
|
@@ -256,11 +278,11 @@ declare abstract class BaseAdapter implements Adapter {
|
|
|
256
278
|
|
|
257
279
|
/**
|
|
258
280
|
* Framework detection from a module's package.json dependencies. DETERMINISTIC:
|
|
259
|
-
* a dependency maps to exactly one
|
|
281
|
+
* a dependency maps to exactly one preset, and a module with no framework
|
|
260
282
|
* dependency is a plain TypeScript library (`node`). This is not the old silent
|
|
261
283
|
* guessing (there is no "assume react" fallback); `node` is a real preset.
|
|
262
284
|
*
|
|
263
|
-
* Reusable across tools: every tool's `--init` needs the module's
|
|
285
|
+
* Reusable across tools: every tool's `--init` needs the module's preset to
|
|
264
286
|
* pick its preset, so this lives in core, not in the TypeScript role.
|
|
265
287
|
*/
|
|
266
288
|
|
|
@@ -269,8 +291,8 @@ interface PackageDependencies {
|
|
|
269
291
|
dependencies?: Record<string, string>;
|
|
270
292
|
devDependencies?: Record<string, string>;
|
|
271
293
|
}
|
|
272
|
-
/** The
|
|
273
|
-
declare function detectFramework(packageJson: PackageDependencies):
|
|
294
|
+
/** The preset for a module, from its dependencies. `node` when no framework. */
|
|
295
|
+
declare function detectFramework(packageJson: PackageDependencies): PresetName;
|
|
274
296
|
|
|
275
297
|
interface DispatchOptions {
|
|
276
298
|
/** Always `init` (dispatch is the write path); other verbs route through `analyse`. */
|
|
@@ -278,8 +300,8 @@ interface DispatchOptions {
|
|
|
278
300
|
target: Target;
|
|
279
301
|
runner?: string;
|
|
280
302
|
cwd: string;
|
|
281
|
-
/** Declared
|
|
282
|
-
|
|
303
|
+
/** Declared preset (`--preset`), else resolved by `detectFramework` from deps. */
|
|
304
|
+
preset?: PresetName;
|
|
283
305
|
/** `--dry-run`: preview the plan instead of writing anything. */
|
|
284
306
|
dryRun?: boolean;
|
|
285
307
|
/** `--json`: emit the dry-run preview as machine-readable JSON. */
|
|
@@ -289,18 +311,18 @@ declare function dispatch(opts: DispatchOptions): Promise<number>;
|
|
|
289
311
|
|
|
290
312
|
/**
|
|
291
313
|
* Adapter registry. Tool branches register their adapters here; the CLI resolves
|
|
292
|
-
* an adapter by (target,
|
|
314
|
+
* an adapter by (target, preset, runner). A default runner per target keeps the
|
|
293
315
|
* common invocation tool-agnostic (`sentinel --lint`), while `--runner` overrides
|
|
294
|
-
* it. Resolution is
|
|
316
|
+
* it. Resolution is preset-aware: candidates are filtered by `appliesTo(preset)`,
|
|
295
317
|
* so a React-only adapter is never picked for a Nest project, and two adapters can
|
|
296
|
-
* share a (target, runner) if they specialise different
|
|
318
|
+
* share a (target, runner) if they specialise different presets.
|
|
297
319
|
*/
|
|
298
320
|
|
|
299
321
|
/**
|
|
300
322
|
* Register a tool adapter (called from each role's registration, wired into the
|
|
301
323
|
* bootstrap in `src/adapters.ts`). No (target, runner) uniqueness guard here: two
|
|
302
|
-
* adapters may share one for different
|
|
303
|
-
* runner AND
|
|
324
|
+
* adapters may share one for different presets; a genuine clash (same target,
|
|
325
|
+
* runner AND preset) is caught at resolve time, where the preset is known.
|
|
304
326
|
*/
|
|
305
327
|
declare function register(adapter: Adapter): void;
|
|
306
328
|
/** Set the default runner for a target. */
|
|
@@ -309,13 +331,13 @@ declare function setDefaultRunner(target: Target, runner: string): void;
|
|
|
309
331
|
declare function all(): readonly Adapter[];
|
|
310
332
|
/**
|
|
311
333
|
* Resolve one adapter by target, honouring an explicit `--runner` or the target's
|
|
312
|
-
* default. When a `
|
|
334
|
+
* default. When a `preset` is known it also filters by `appliesTo`, so a
|
|
313
335
|
* React-only adapter is never picked for Nest; when it is absent (sentinel does
|
|
314
336
|
* not detect it), every adapter for the target is a candidate. Throws with an
|
|
315
337
|
* actionable message for each failure mode: no adapter for the target (yet), none
|
|
316
|
-
* that handles the
|
|
317
|
-
* adapters claiming the same (target, runner,
|
|
338
|
+
* that handles the preset, an ambiguous choice, an unknown runner, or two
|
|
339
|
+
* adapters claiming the same (target, runner, preset).
|
|
318
340
|
*/
|
|
319
|
-
declare function resolve(target: Target,
|
|
341
|
+
declare function resolve(target: Target, preset?: PresetName, runner?: string): Adapter;
|
|
320
342
|
|
|
321
|
-
export { type Adapter, type AdapterResult, BaseAdapter, type DispatchOptions, type FileOperation, type Flavour, type PackageDependencies, type RunContext, type Target, type UpdateContext, type UpdatePlan, type Verb, all, detectFramework, dispatch, register, registerAdapters, resolve, setDefaultRunner };
|
|
343
|
+
export { type Adapter, type AdapterResult, BaseAdapter, type DispatchOptions, type FileOperation, type Flavour, type PackageDependencies, type PresetName, type RunContext, type Target, type UpdateContext, type UpdatePlan, type Verb, all, detectFramework, dispatch, register, registerAdapters, resolve, setDefaultRunner };
|