@hublo/sentinel 1.5.0 → 1.5.1-alpha.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.
@@ -1298,10 +1298,259 @@ $ sentinel --init --dry-run
1298
1298
  + }
1299
1299
  + }
1300
1300
  + }
1301
+ dry run: the lint autofix runs on adoption and can rewrite source, as moving to another linter does; add --rehearse to name the files (it runs the pass in a throwaway copy, as long as the real one)
1302
+ dry run: the format autofix runs on adoption and can rewrite source, as moving to another formatter does; add --rehearse to name the files (it runs the pass in a throwaway copy, as long as the real one)
1301
1303
  dry run: would ignore static-analysis-report/ in the root .gitignore
1302
1304
  # exit: 0
1303
1305
  ```
1304
1306
 
1307
+ **--init --dry-run --rehearse (runs the autofixes in a copy, names what they rewrite)**
1308
+
1309
+ ```console
1310
+ $ sentinel --init --dry-run --rehearse
1311
+ dry run: no files written
1312
+ wrote .oxlintrc.json extending ./node_modules/@hublo/sentinel/lint/nest.json (@hublo/sentinel@<version>)
1313
+ 20 rule(s) not enforced by this preset (17 jest, 1 no-barrel-files, 1 core, 1 vitest). Run --inspect --lint for each rule and why.
1314
+ run `pnpm install`, then `pnpm run lint`
1315
+
1316
+ create .oxlintrc.json
1317
+ + {
1318
+ + "extends": [
1319
+ + "./node_modules/@hublo/sentinel/lint/nest.json"
1320
+ + ],
1321
+ + "ignorePatterns": [
1322
+ + "**/dist/**",
1323
+ + "**/node_modules/**",
1324
+ + "coverage/**",
1325
+ + "**/jest.*.{ts,js,cjs,mjs}",
1326
+ + "**/eslint.config.{js,cjs,mjs}",
1327
+ + "**/*.timestamp*",
1328
+ + "**/*.d.ts"
1329
+ + ]
1330
+ + }
1331
+
1332
+ update package.json
1333
+ - { "name": "bff-admin", "dependencies": { "@nestjs/core": "^10" } }
1334
+ + {
1335
+ + "name": "bff-admin",
1336
+ + "dependencies": {
1337
+ + "@nestjs/core": "^10"
1338
+ + },
1339
+ + "scripts": {
1340
+ + "lint": "sentinel --run --lint"
1341
+ + },
1342
+ + "devDependencies": {
1343
+ + "@hublo/sentinel": "<version>"
1344
+ + },
1345
+ + "nx": {
1346
+ + "targets": {
1347
+ + "lint": {
1348
+ + "cache": true,
1349
+ + "inputs": [
1350
+ + "default",
1351
+ + "^default",
1352
+ + "{projectRoot}/.oxlintrc.json"
1353
+ + ]
1354
+ + }
1355
+ + }
1356
+ + }
1357
+ + }
1358
+ dry run: no files written
1359
+ run `pnpm install` to fetch @hublo/sentinel (added to the module devDependencies) so `extends` and the typecheck script resolve
1360
+
1361
+ update tsconfig.json
1362
+ - { "extends": "../../tsconfig.base.json", "include": ["src"] }
1363
+ + { "extends": [
1364
+ + "../../tsconfig.base.json",
1365
+ + "@hublo/sentinel/typescript/nest"
1366
+ + ], "include": ["src"] }
1367
+
1368
+ update package.json
1369
+ - { "name": "bff-admin", "dependencies": { "@nestjs/core": "^10" } }
1370
+ + {
1371
+ + "name": "bff-admin",
1372
+ + "dependencies": {
1373
+ + "@nestjs/core": "^10"
1374
+ + },
1375
+ + "scripts": {
1376
+ + "typecheck": "sentinel --run --typescript"
1377
+ + },
1378
+ + "devDependencies": {
1379
+ + "@hublo/sentinel": "<version>"
1380
+ + },
1381
+ + "nx": {
1382
+ + "targets": {
1383
+ + "typecheck": {
1384
+ + "cache": true,
1385
+ + "inputs": [
1386
+ + "default",
1387
+ + "^default",
1388
+ + "{projectRoot}/tsconfig.json"
1389
+ + ]
1390
+ + }
1391
+ + }
1392
+ + }
1393
+ + }
1394
+ build: no Vite config in this module, so there is nothing to point at sentinel. This role moves an existing config's imports; it does not introduce a bundler. If this module builds another way (38 services here build through `@nx/webpack`), the build role does not apply to it.
1395
+ test: this module has no test and no jest leftovers, so there is nothing to do here.
1396
+ dry run: no files written
1397
+ added the three `static-analysis` scripts and static-analysis.config.mjs; declare this module's entry points there, everything else comes from the role
1398
+
1399
+ create static-analysis.config.mjs
1400
+ + import { defineStaticAnalysis } from '@hublo/sentinel/static-analysis'
1401
+ +
1402
+ + export default defineStaticAnalysis({
1403
+ + root: import.meta.dirname,
1404
+ +
1405
+ + // Files that RUN although nothing imports them: they are where reachability starts. Added to
1406
+ + // the patterns sentinel ships, never replacing them.
1407
+ + entry: [],
1408
+ +
1409
+ + // ---------------------------------------------------------------------------------------------
1410
+ + // What this module can move, with the role's value today. A setting you leave out keeps that
1411
+ + // value; a setting you write REPLACES it, including inside a list. Anything you set is printed
1412
+ + // under "measured with" in the report and marked `(module)`, because two modules measured with
1413
+ + // different settings can no longer be compared.
1414
+ + //
1415
+ + // ignore 19 patterns
1416
+ + // languages javascript, typescript, jsx, tsx, css, scss
1417
+ + // duplication.minTokens 50
1418
+ + // duplication.minLines 5
1419
+ + // duplication.tests 3 patterns
1420
+ + // deadCode.minConfidence 60
1421
+ + // deadCode.categories unused-file, unused-export, unused-symbol, unused-import
1422
+ + // graph.resolution 1
1423
+ + //
1424
+ + // A list shown as a count is not copyable, and replacing one means writing back what you keep,
1425
+ + // so read the values in full with:
1426
+ + //
1427
+ + // pnpm exec sentinel --inspect --static-analysis --json
1428
+ + //
1429
+ + // duplication.kinds: only `exact` is supported: any other kind overlaps it and double-counts
1430
+ + // tools: sentinel's own passthrough to the tool underneath; a module never names the vendor
1431
+ + //
1432
+ + // overrides: {
1433
+ + // duplication: { minTokens: 100 },
1434
+ + // },
1435
+ + })
1436
+
1437
+ update package.json
1438
+ - { "name": "bff-admin", "dependencies": { "@nestjs/core": "^10" } }
1439
+ + {
1440
+ + "name": "bff-admin",
1441
+ + "dependencies": {
1442
+ + "@nestjs/core": "^10"
1443
+ + },
1444
+ + "scripts": {
1445
+ + "static-analysis": "sentinel --run --static-analysis",
1446
+ + "static-analysis:json": "sentinel --run --static-analysis --output json",
1447
+ + "static-analysis:html": "sentinel --run --static-analysis --output html"
1448
+ + },
1449
+ + "devDependencies": {
1450
+ + "@hublo/sentinel": "<version>"
1451
+ + },
1452
+ + "nx": {
1453
+ + "targets": {
1454
+ + "static-analysis": {
1455
+ + "cache": true,
1456
+ + "inputs": [
1457
+ + "default",
1458
+ + "{projectRoot}/static-analysis.config.mjs"
1459
+ + ]
1460
+ + }
1461
+ + }
1462
+ + }
1463
+ + }
1464
+ dry run: no files written
1465
+ materialized the nest format preset into .oxfmtrc.json (@hublo/sentinel@<version>). oxfmt has no `extends`, so the values live here; `sentinel --status --format` reports modules left behind by a preset change
1466
+
1467
+ create .oxfmtrc.json
1468
+ + {
1469
+ + "$sentinel": {
1470
+ + "preset": "nest",
1471
+ + "version": "<version>",
1472
+ + "local": []
1473
+ + },
1474
+ + "printWidth": 80,
1475
+ + "semi": false,
1476
+ + "singleQuote": true,
1477
+ + "trailingComma": "all",
1478
+ + "sortPackageJson": false,
1479
+ + "sortImports": {
1480
+ + "customGroups": [
1481
+ + {
1482
+ + "groupName": "workspace",
1483
+ + "elementNamePattern": [
1484
+ + "@hublo/**",
1485
+ + "@shared/**",
1486
+ + "@front/**",
1487
+ + "@network/**"
1488
+ + ]
1489
+ + }
1490
+ + ],
1491
+ + "groups": [
1492
+ + "builtin",
1493
+ + "external",
1494
+ + "workspace",
1495
+ + [
1496
+ + "parent",
1497
+ + "index"
1498
+ + ],
1499
+ + "sibling"
1500
+ + ],
1501
+ + "newlinesBetween": true,
1502
+ + "order": "asc",
1503
+ + "ignoreCase": false
1504
+ + },
1505
+ + "ignorePatterns": [
1506
+ + "**/*.toml"
1507
+ + ]
1508
+ + }
1509
+
1510
+ update package.json
1511
+ - { "name": "bff-admin", "dependencies": { "@nestjs/core": "^10" } }
1512
+ + {
1513
+ + "name": "bff-admin",
1514
+ + "dependencies": {
1515
+ + "@nestjs/core": "^10"
1516
+ + },
1517
+ + "scripts": {
1518
+ + "format": "sentinel --run --format",
1519
+ + "format:fix": "sentinel --run --format --fix"
1520
+ + },
1521
+ + "devDependencies": {
1522
+ + "@hublo/sentinel": "<version>"
1523
+ + },
1524
+ + "nx": {
1525
+ + "targets": {
1526
+ + "format": {
1527
+ + "cache": true,
1528
+ + "inputs": [
1529
+ + "default",
1530
+ + "{projectRoot}/.oxfmtrc.json"
1531
+ + ]
1532
+ + },
1533
+ + "format:fix": {
1534
+ + "cache": false
1535
+ + }
1536
+ + }
1537
+ + }
1538
+ + }
1539
+ dry run: the lint autofix cannot be rehearsed yet: its preset is not installed in this module, which is expected before the first `pnpm install`. After it, this dry-run names what it rewrites
1540
+ dry run: the format autofix would rewrite 1 file beyond the ones above: project.json
1541
+ dry run: would ignore static-analysis-report/ in the root .gitignore
1542
+ # exit: 0
1543
+ ```
1544
+
1545
+ **--rehearse without --dry-run**
1546
+
1547
+ ```console
1548
+ $ sentinel --init --rehearse
1549
+ --rehearse only applies to --init --dry-run: the real --init runs the autofix passes themselves.
1550
+ (run "sentinel --help" for usage)
1551
+ # exit: 1
1552
+ ```
1553
+
1305
1554
  **no module and no workspace root**
1306
1555
 
1307
1556
  ```console
@@ -34,7 +34,15 @@ everywhere (`--run --json` and `--inspect` answer them), and `--migrate` is refu
34
34
  | `--static-analysis` | the config stub + three scripts + nx metadata, and ignores the report directory at the repository root | measures and reports; never exits non-zero on a finding | runner, config file, resolved settings, what this module moved |
35
35
 
36
36
  `--json` works for every verb, and stdout carries **only** the envelope, so `| jq` always
37
- parses. `--dry-run` applies to `--init` and writes nothing.
37
+ parses. `--dry-run` applies to `--init` and writes nothing. Besides the config diffs, it says
38
+ that the lint autofix and the formatter run on adoption and can rewrite source, which is what
39
+ moving to another linter or formatter does. It does not run them: on a large module that costs
40
+ what the real pass costs (260 s measured on `network`).
41
+
42
+ `--init --dry-run --rehearse` runs them, and names the source files they would rewrite
43
+ (`rewrites` in `--json`, absent without `--rehearse`): both run in a throwaway copy of the
44
+ module, outside the workspace, and what changed is read back. `--rehearse` without `--dry-run`
45
+ is refused, because a real `--init` runs the passes itself.
38
46
 
39
47
  `--output <shape>` is different, and only a role that WRITES a report reads it: `console` is the
40
48
  default and writes no file, `html` is the page you open and send, `json` is for CI and for a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hublo/sentinel",
3
- "version": "1.5.0",
3
+ "version": "1.5.1-alpha.0",
4
4
  "description": "One CLI that guards code health across Hublo repos: shared lint/typescript/build/test presets, static & dynamic analysis, and architecture checks.",
5
5
  "type": "module",
6
6
  "license": "MIT",