@trebired/code-discipline 5.5.2 → 6.0.1
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/CHANGELOG.md +18 -6
- package/README.md +45 -88
- package/dist/checks/index.d.ts +3 -3
- package/dist/checks/index.d.ts.map +1 -1
- package/dist/checks/index.js +8 -61
- package/dist/checks/index.js.map +1 -1
- package/dist/checks/native-runner.d.ts +6 -0
- package/dist/checks/native-runner.d.ts.map +1 -0
- package/dist/checks/native-runner.js +117 -0
- package/dist/checks/native-runner.js.map +1 -0
- package/dist/checks/types.d.ts +9 -3
- package/dist/checks/types.d.ts.map +1 -1
- package/dist/cli/logging.js +3 -3
- package/dist/cli/logging.js.map +1 -1
- package/dist/cli/run.js +6 -6
- package/dist/cli/run.js.map +1 -1
- package/dist/config/index.d.ts +7 -6
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +11 -11
- package/dist/config/index.js.map +1 -1
- package/dist/config/normalize/check-options.d.ts +2 -2
- package/dist/config/normalize/check-options.d.ts.map +1 -1
- package/dist/config/normalize/check-options.js +6 -4
- package/dist/config/normalize/check-options.js.map +1 -1
- package/dist/config/normalize/presets.d.ts +12 -5
- package/dist/config/normalize/presets.d.ts.map +1 -1
- package/dist/config/normalize/presets.js +121 -11
- package/dist/config/normalize/presets.js.map +1 -1
- package/dist/imports/scan.js +2 -2
- package/dist/imports/scan.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/native/native.d.ts +1 -0
- package/dist/native/native.d.ts.map +1 -1
- package/dist/native/native.js.map +1 -1
- package/dist/run.d.ts +7 -7
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +16 -13
- package/dist/run.js.map +1 -1
- package/dist/runtime/orchestrate.d.ts +5 -5
- package/dist/runtime/orchestrate.d.ts.map +1 -1
- package/dist/runtime/orchestrate.js +2 -2
- package/dist/runtime/orchestrate.js.map +1 -1
- package/dist/shared/constants.d.ts +2 -1
- package/dist/shared/constants.d.ts.map +1 -1
- package/dist/shared/constants.js +3 -2
- package/dist/shared/constants.js.map +1 -1
- package/dist/shared/log-groups.d.ts +2 -2
- package/dist/shared/log-groups.d.ts.map +1 -1
- package/dist/shared/log-groups.js +5 -5
- package/dist/shared/log-groups.js.map +1 -1
- package/dist/shared/package-metadata.d.ts +2 -1
- package/dist/shared/package-metadata.d.ts.map +1 -1
- package/dist/shared/package-metadata.js +3 -1
- package/dist/shared/package-metadata.js.map +1 -1
- package/dist/shared/rule-exclusions.js +2 -2
- package/dist/shared/rule-exclusions.js.map +1 -1
- package/dist/shared/utils.d.ts +2 -2
- package/dist/shared/utils.d.ts.map +1 -1
- package/dist/shared/utils.js +2 -2
- package/dist/shared/utils.js.map +1 -1
- package/native/darwin-arm64.node +0 -0
- package/native/darwin-x64.node +0 -0
- package/native/linux-arm64-gnu.node +0 -0
- package/native/linux-x64-gnu.node +0 -0
- package/package.json +2 -1
- package/dist/config/presets/index.d.ts +0 -8
- package/dist/config/presets/index.d.ts.map +0 -1
- package/dist/config/presets/index.js +0 -13
- package/dist/config/presets/index.js.map +0 -1
- package/dist/config/presets/trebired.d.ts +0 -5
- package/dist/config/presets/trebired.d.ts.map +0 -1
- package/dist/config/presets/trebired.js +0 -53
- package/dist/config/presets/trebired.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,18 @@ This project follows semantic versioning once published.
|
|
|
6
6
|
|
|
7
7
|
## Unreleased
|
|
8
8
|
|
|
9
|
+
## 6.0.1
|
|
10
|
+
|
|
11
|
+
- Renamed the public callable API to package-local names: `defineConfig`, `definePreset`, `run`, `createRunner`, `check`, `fix`, `findConfigModule`, `loadConfigModule`, and `loadResolvedConfig`.
|
|
12
|
+
- Removed redundant Code Discipline wording from internal function identifiers.
|
|
13
|
+
|
|
14
|
+
## 6.0.0
|
|
15
|
+
|
|
16
|
+
- Removed built-in preset names. `presets.use` now resolves npm preset packages from the checked project root, requires exact Code Discipline version alignment, and rejects nested preset declarations.
|
|
17
|
+
- Added `definePreset()` and `CodeDisciplinePresetPackage` for authoring external preset packages.
|
|
18
|
+
- Moved check-mode rule execution onto one native Rust aggregate runner, including TypeScript-family source checks, so the JavaScript side only prepares config, scan results, import manifest metadata, and output formatting.
|
|
19
|
+
- Kept fix mode sequential while reusing the required native backend for the existing native-backed fixers.
|
|
20
|
+
|
|
9
21
|
## 5.5.2
|
|
10
22
|
|
|
11
23
|
- Split preset definitions into `src/config/presets/*` and kept preset normalization focused on validation and merging.
|
|
@@ -20,7 +32,7 @@ This project follows semantic versioning once published.
|
|
|
20
32
|
- Added full-config preset support through `presets.use`, starting with the strict built-in `trebired` preset used by Trebired codebases.
|
|
21
33
|
- Moved preset application before source and rule normalization, so presets can configure logging, ignore behavior, imports, and every rule instead of only appending one rule's patterns.
|
|
22
34
|
- Added preset-aware config merging: repo config overrides scalar/object values, arrays append and dedupe, and duplicate `bannedPatterns.patterns` entries union their `allowedFiles`.
|
|
23
|
-
- Fixed the direct `
|
|
35
|
+
- Fixed the direct `run()` runner preserving configured presets when building check and fix options.
|
|
24
36
|
|
|
25
37
|
## 5.4.0
|
|
26
38
|
|
|
@@ -385,7 +397,7 @@ This project follows semantic versioning once published.
|
|
|
385
397
|
- Changed config auto-discovery to package-owned TypeScript config loading for Node and Bun.
|
|
386
398
|
- Added the `dry` rule for canonical helper registration, duplicate detection, and full-removal standalone autofix.
|
|
387
399
|
- Moved optional `package.json#imports` syncing under `rules.syncImports.packageJsonImports`.
|
|
388
|
-
- Changed `
|
|
400
|
+
- Changed `fix()` from a folderization-only mutation path into a rule-ordered fix pipeline with `ruleResults`.
|
|
389
401
|
|
|
390
402
|
## 1.5.0
|
|
391
403
|
|
|
@@ -401,8 +413,8 @@ This project follows semantic versioning once published.
|
|
|
401
413
|
|
|
402
414
|
## 1.4.0
|
|
403
415
|
|
|
404
|
-
- Added `
|
|
405
|
-
- Added `
|
|
416
|
+
- Added `run({ mode, ... })` as the package-owned runtime dispatcher for `check`, `fix`, `sync`, and startup-style sync usage.
|
|
417
|
+
- Added `createRunner(config)` so consuming apps can bind repo config once and call `.check()`, `.fix()`, `.sync()`, or `.startup()`.
|
|
406
418
|
- Refactored the package CLI to use the shared runtime dispatcher instead of maintaining separate command routing logic.
|
|
407
419
|
- Updated the README and tests around the simpler logger-style consumption path.
|
|
408
420
|
|
|
@@ -416,7 +428,7 @@ This project follows semantic versioning once published.
|
|
|
416
428
|
## 1.2.0
|
|
417
429
|
|
|
418
430
|
- Changed package logging to emit `@trebired/code-discipline initialized` on startup through the `code-discipline.initialize` group.
|
|
419
|
-
- Changed `syncImports()`, `
|
|
431
|
+
- Changed `syncImports()`, `check()`, and `fix()` to emit one final aggregated report instead of spamming per-step runtime logs.
|
|
420
432
|
- Added buffered diagnostic summaries to final logging metadata so unresolved rewrites, tsconfig retry events, and other internal steps are preserved in one report payload.
|
|
421
433
|
- Renamed the public logging type surface to package-wide `CodeDiscipline...` names while keeping compatibility aliases for the older sync-import-focused type exports.
|
|
422
434
|
|
|
@@ -437,7 +449,7 @@ This project follows semantic versioning once published.
|
|
|
437
449
|
- made `check` fully read-only
|
|
438
450
|
- made `sync` mutate imports and `tsconfig.json` only when `syncImports.fix` is `true`
|
|
439
451
|
- added explicit `fix` support for folderization moves and affected import rewrites
|
|
440
|
-
- added `
|
|
452
|
+
- added `fix()` as the structural mutation API
|
|
441
453
|
- added blocking-or-warning behavior through `stop` instead of severity levels
|
|
442
454
|
- bumped the package to `1.0.0` for the config and API cleanup
|
|
443
455
|
|
package/README.md
CHANGED
|
@@ -334,22 +334,21 @@ Rule severity is optional and now supports only `severity: "warning" | "fail"`.
|
|
|
334
334
|
Example `.trebired/code-discipline/config.ts`:
|
|
335
335
|
|
|
336
336
|
```ts
|
|
337
|
-
import {
|
|
337
|
+
import { defineConfig } from "@trebired/code-discipline";
|
|
338
338
|
|
|
339
|
-
export default
|
|
339
|
+
export default defineConfig({
|
|
340
340
|
lifecycle: {
|
|
341
341
|
async beforeRun(context) {
|
|
342
342
|
context.state.started = true;
|
|
343
343
|
},
|
|
344
344
|
},
|
|
345
345
|
presets: {
|
|
346
|
-
use: ["
|
|
346
|
+
use: ["@company/code-discipline-preset"],
|
|
347
|
+
},
|
|
348
|
+
helpers: {
|
|
347
349
|
nodeProcessBoundary: {
|
|
348
350
|
envBoundaryFiles: ["src/backend/core/env.ts"],
|
|
349
|
-
processBoundaryFiles: [
|
|
350
|
-
"src/backend/shared/process/index.ts",
|
|
351
|
-
"src/backend/shared/process/cjs.cjs",
|
|
352
|
-
],
|
|
351
|
+
processBoundaryFiles: ["src/backend/shared/process/index.ts"],
|
|
353
352
|
},
|
|
354
353
|
},
|
|
355
354
|
rules: {
|
|
@@ -374,64 +373,7 @@ export default defineCodeDisciplineConfig({
|
|
|
374
373
|
});
|
|
375
374
|
```
|
|
376
375
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
Expanded, the preset enables:
|
|
380
|
-
|
|
381
|
-
```ts
|
|
382
|
-
{
|
|
383
|
-
logging: {
|
|
384
|
-
warnings: false,
|
|
385
|
-
},
|
|
386
|
-
ignore: {
|
|
387
|
-
entries: [],
|
|
388
|
-
use_gitignore: true,
|
|
389
|
-
},
|
|
390
|
-
rules: {
|
|
391
|
-
formatting: {},
|
|
392
|
-
bannedFiles: {
|
|
393
|
-
patterns: [
|
|
394
|
-
{ glob: "**/*.spec.ts" },
|
|
395
|
-
{ glob: "**/*.spec.tsx" },
|
|
396
|
-
],
|
|
397
|
-
},
|
|
398
|
-
bannedPatterns: {
|
|
399
|
-
patterns: [
|
|
400
|
-
{ value: "trebired", allowedFiles: ["package.json"] },
|
|
401
|
-
],
|
|
402
|
-
},
|
|
403
|
-
minDeclarationName: {},
|
|
404
|
-
maxCharactersPerLine: {},
|
|
405
|
-
structuralBlankLines: {},
|
|
406
|
-
minFileLines: {},
|
|
407
|
-
maxFileLines: {
|
|
408
|
-
max: 350,
|
|
409
|
-
},
|
|
410
|
-
maxFunctionLines: {
|
|
411
|
-
max: 50,
|
|
412
|
-
},
|
|
413
|
-
redundantPathSegments: {},
|
|
414
|
-
removeComments: {},
|
|
415
|
-
imports: {
|
|
416
|
-
alias: {
|
|
417
|
-
strategy: "random",
|
|
418
|
-
},
|
|
419
|
-
allowRelative: ["./"],
|
|
420
|
-
output: {
|
|
421
|
-
type: "alias-map",
|
|
422
|
-
},
|
|
423
|
-
runtime: {
|
|
424
|
-
normalize: "relative-dot-prefix",
|
|
425
|
-
restoreAfterRun: false,
|
|
426
|
-
},
|
|
427
|
-
removeDeadImports: true,
|
|
428
|
-
},
|
|
429
|
-
dry: {},
|
|
430
|
-
},
|
|
431
|
-
}
|
|
432
|
-
```
|
|
433
|
-
|
|
434
|
-
Manual arrays merge with the preset arrays. Duplicate `bannedPatterns.patterns` entries are merged by pattern value and their `allowedFiles` are unioned, so repos can widen preset allowlists without replacing the preset rule.
|
|
376
|
+
Preset packages are resolved from the checked project root. Repo config merges on top, so local `rules`, `ignore`, and `logging` entries only describe repo-specific differences. Manual arrays merge with preset arrays. Duplicate `bannedPatterns.patterns` entries are merged by pattern value and their `allowedFiles` are unioned, so repos can widen preset allowlists without replacing the preset rule.
|
|
435
377
|
|
|
436
378
|
Source scanning covers every built-in supported source family by default:
|
|
437
379
|
|
|
@@ -445,9 +387,9 @@ So you get the full supported scan set automatically and only opt out when neede
|
|
|
445
387
|
Example scan configuration:
|
|
446
388
|
|
|
447
389
|
```ts
|
|
448
|
-
export default
|
|
390
|
+
export default defineConfig({
|
|
449
391
|
presets: {
|
|
450
|
-
use: ["
|
|
392
|
+
use: ["@company/code-discipline-preset"],
|
|
451
393
|
},
|
|
452
394
|
|
|
453
395
|
// Skip specific built-in file types when needed.
|
|
@@ -476,26 +418,41 @@ export default defineCodeDisciplineConfig({
|
|
|
476
418
|
|
|
477
419
|
### Presets
|
|
478
420
|
|
|
479
|
-
|
|
421
|
+
Preset packages are ordinary npm packages. They must default-export a preset object and declare an exact peer dependency on the same `@trebired/code-discipline` version that will load them.
|
|
480
422
|
|
|
481
|
-
|
|
423
|
+
```ts
|
|
424
|
+
import { definePreset } from "@trebired/code-discipline";
|
|
482
425
|
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
426
|
+
export default definePreset({
|
|
427
|
+
codeDisciplineVersion: "6.0.1",
|
|
428
|
+
config: {
|
|
429
|
+
logging: {
|
|
430
|
+
warnings: false,
|
|
431
|
+
},
|
|
432
|
+
ignore: {
|
|
433
|
+
use_gitignore: true,
|
|
434
|
+
},
|
|
435
|
+
rules: {
|
|
436
|
+
formatting: {},
|
|
437
|
+
maxFileLines: {
|
|
438
|
+
max: 350,
|
|
439
|
+
},
|
|
440
|
+
maxFunctionLines: {
|
|
441
|
+
max: 50,
|
|
442
|
+
},
|
|
443
|
+
},
|
|
444
|
+
},
|
|
445
|
+
});
|
|
446
|
+
```
|
|
490
447
|
|
|
491
|
-
|
|
448
|
+
Nested `presets` inside a preset package are rejected. Multiple project presets merge left to right, then the project config merges last.
|
|
492
449
|
|
|
493
|
-
|
|
450
|
+
### Helpers
|
|
494
451
|
|
|
495
452
|
`nodeProcessBoundary` is opt-in. It expands into ordinary `bannedPatterns` entries so projects can keep direct Node `process` access inside explicit boundary files.
|
|
496
453
|
|
|
497
454
|
```ts
|
|
498
|
-
|
|
455
|
+
helpers: {
|
|
499
456
|
nodeProcessBoundary: {
|
|
500
457
|
envBoundaryFiles: ["src/backend/core/env.ts"],
|
|
501
458
|
processBoundaryFiles: [
|
|
@@ -637,9 +594,9 @@ The package-owned runtime dispatcher now has two modes only:
|
|
|
637
594
|
- `fix`
|
|
638
595
|
|
|
639
596
|
```ts
|
|
640
|
-
import {
|
|
597
|
+
import { run } from "@trebired/code-discipline";
|
|
641
598
|
|
|
642
|
-
const result = await
|
|
599
|
+
const result = await run({
|
|
643
600
|
mode: "fix",
|
|
644
601
|
projectRoot: process.cwd(),
|
|
645
602
|
onlyRules: ["imports"],
|
|
@@ -656,9 +613,9 @@ const result = await codeDiscipline({
|
|
|
656
613
|
You can also bind config once:
|
|
657
614
|
|
|
658
615
|
```ts
|
|
659
|
-
import {
|
|
616
|
+
import { createRunner } from "@trebired/code-discipline";
|
|
660
617
|
|
|
661
|
-
const discipline =
|
|
618
|
+
const discipline = createRunner({
|
|
662
619
|
rules: {
|
|
663
620
|
bannedPatterns: {
|
|
664
621
|
patterns: [
|
|
@@ -695,12 +652,12 @@ Every violation is treated uniformly now. Results expose `ok`, `violationCount`,
|
|
|
695
652
|
|
|
696
653
|
Low-level helpers are still exported for advanced tooling:
|
|
697
654
|
|
|
698
|
-
- `
|
|
699
|
-
- `
|
|
655
|
+
- `check()`
|
|
656
|
+
- `fix()`
|
|
700
657
|
- `imports()`
|
|
701
|
-
- `
|
|
702
|
-
- `
|
|
703
|
-
- `
|
|
658
|
+
- `defineConfig()`
|
|
659
|
+
- `findConfigModule()`
|
|
660
|
+
- `loadResolvedConfig()`
|
|
704
661
|
- `prepareTsconfigPaths()`
|
|
705
662
|
- `restoreTsconfigPaths()`
|
|
706
663
|
- `syncPackageJsonImportsFromTsconfigPaths()`
|
package/dist/checks/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { buildNormalizedSyncOptions } from "./sync-options.js";
|
|
2
2
|
import type { CheckCodeDisciplineOptions, CheckCodeDisciplineResult, FixCodeDisciplineOptions, FixCodeDisciplineResult } from "./types.js";
|
|
3
|
-
declare function
|
|
4
|
-
declare function
|
|
5
|
-
export { buildNormalizedSyncOptions,
|
|
3
|
+
declare function check(options: CheckCodeDisciplineOptions): Promise<CheckCodeDisciplineResult>;
|
|
4
|
+
declare function fix(options: FixCodeDisciplineOptions): Promise<FixCodeDisciplineResult>;
|
|
5
|
+
export { buildNormalizedSyncOptions, check, fix };
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/checks/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/checks/index.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,KAAK,EACV,0BAA0B,EAC1B,yBAAyB,EACzB,wBAAwB,EACxB,uBAAuB,EAExB,MAAM,YAAY,CAAC;AAwGpB,iBAAe,KAAK,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAO5F;AAED,iBAAe,GAAG,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CA0BtF;AAED,OAAO,EAAE,0BAA0B,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC"}
|
package/dist/checks/index.js
CHANGED
|
@@ -1,24 +1,11 @@
|
|
|
1
1
|
import { result as createResult } from "@package/result";
|
|
2
|
-
import {
|
|
3
|
-
import { collectImportViolations } from "../imports/check.js";
|
|
2
|
+
import { normalizeCheckOptions } from "../config/normalize/check-options.js";
|
|
4
3
|
import { scanSourceFiles } from "../imports/scan.js";
|
|
5
4
|
import { runLogGroup } from "../shared/log-groups.js";
|
|
6
5
|
import { resolveLogger } from "../shared/logging.js";
|
|
7
|
-
import { filterSourceFilesForRule } from "../shared/rule-exclusions.js";
|
|
8
6
|
import { applyBannedFilesFix, applyRedundantPathSegmentsFix, applyMaxCharactersPerLineFix, applyMinFileLinesFix, applyCodeFormatterFix, applyRemoveCommentsFix, applyStructuralBlankLinesFix, applyImportsFix, } from "./apply-fixes.js";
|
|
9
7
|
import { collectFormatViolations } from "./format.js";
|
|
10
|
-
import {
|
|
11
|
-
import { collectBannedFileViolations } from "./rules/banned/files.js";
|
|
12
|
-
import { collectBannedPatternViolations } from "./rules/banned/patterns.js";
|
|
13
|
-
import { collectStructuralBlankLinesViolations } from "./rules/blank-lines/index.js";
|
|
14
|
-
import { collectDryViolations } from "./rules/dry/index.js";
|
|
15
|
-
import { runMaxCharactersPerLineRule } from "./rules/max/characters-per-line.js";
|
|
16
|
-
import { runMaxFileLinesRule } from "./rules/max/file-lines.js";
|
|
17
|
-
import { runMaxFunctionLinesRule } from "./rules/max/function-lines.js";
|
|
18
|
-
import { runRedundantPathSegmentsRule } from "./rules/redundant-path-segments/index.js";
|
|
19
|
-
import { runMinDeclarationNameRule } from "./rules/min/declaration/name.js";
|
|
20
|
-
import { runMinFileLinesRule } from "./rules/min/file/lines.js";
|
|
21
|
-
import { collectRemoveCommentsViolations } from "./rules/remove-comments.js";
|
|
8
|
+
import { collectNativeCheckViolations } from "./native-runner.js";
|
|
22
9
|
import { applyConfiguredSeverity } from "./severity.js";
|
|
23
10
|
import { buildNormalizedSyncOptions } from "./sync-options.js";
|
|
24
11
|
function sortViolations(violations) {
|
|
@@ -74,47 +61,7 @@ function attachDisciplineResult(phase, output) {
|
|
|
74
61
|
}
|
|
75
62
|
async function collectViolations(options) {
|
|
76
63
|
const sourceFiles = await scanSourceFiles(options);
|
|
77
|
-
const violations =
|
|
78
|
-
if (options.rules.bannedPatterns && shouldRunRule("banned-patterns", options.onlyRules)) {
|
|
79
|
-
violations.push(...await collectBannedPatternViolations(filterSourceFilesForRule(sourceFiles, options.rules.bannedPatterns), options));
|
|
80
|
-
}
|
|
81
|
-
if (options.rules.bannedFiles && shouldRunRule("banned-files", options.onlyRules)) {
|
|
82
|
-
violations.push(...collectBannedFileViolations(filterSourceFilesForRule(sourceFiles, options.rules.bannedFiles), options));
|
|
83
|
-
}
|
|
84
|
-
if (options.rules.minFileLines && shouldRunRule("min-file-lines", options.onlyRules)) {
|
|
85
|
-
violations.push(...await runMinFileLinesRule(filterSourceFilesForRule(sourceFiles, options.rules.minFileLines), options));
|
|
86
|
-
}
|
|
87
|
-
if (options.rules.minDeclarationName && shouldRunRule("min-declaration-name", options.onlyRules)) {
|
|
88
|
-
violations.push(...await runMinDeclarationNameRule(filterSourceFilesForRule(sourceFiles, options.rules.minDeclarationName), options));
|
|
89
|
-
}
|
|
90
|
-
if (options.rules.maxFileLines && shouldRunRule("max-file-lines", options.onlyRules)) {
|
|
91
|
-
violations.push(...await runMaxFileLinesRule(filterSourceFilesForRule(sourceFiles, options.rules.maxFileLines), options));
|
|
92
|
-
}
|
|
93
|
-
if (options.rules.maxCharactersPerLine && shouldRunRule("max-characters-per-line", options.onlyRules)) {
|
|
94
|
-
violations.push(...await runMaxCharactersPerLineRule(filterSourceFilesForRule(sourceFiles, options.rules.maxCharactersPerLine), options));
|
|
95
|
-
}
|
|
96
|
-
if (options.rules.maxFunctionLines && shouldRunRule("max-function-lines", options.onlyRules)) {
|
|
97
|
-
violations.push(...await runMaxFunctionLinesRule(filterSourceFilesForRule(sourceFiles, options.rules.maxFunctionLines), options));
|
|
98
|
-
}
|
|
99
|
-
if (options.rules.redundantPathSegments && shouldRunRule("redundant-path-segments", options.onlyRules)) {
|
|
100
|
-
violations.push(...runRedundantPathSegmentsRule(filterSourceFilesForRule(sourceFiles, options.rules.redundantPathSegments), options));
|
|
101
|
-
}
|
|
102
|
-
if (options.rules.dry && shouldRunRule("dry", options.onlyRules)) {
|
|
103
|
-
violations.push(...await collectDryViolations(filterSourceFilesForRule(sourceFiles, options.rules.dry), options));
|
|
104
|
-
}
|
|
105
|
-
if (options.rules.imports && shouldRunRule("imports", options.onlyRules)) {
|
|
106
|
-
const normalizedSyncOptions = await buildNormalizedSyncOptions(options, false);
|
|
107
|
-
if (normalizedSyncOptions) {
|
|
108
|
-
violations.push(...await collectImportViolations(filterSourceFilesForRule(sourceFiles, options.rules.imports), normalizedSyncOptions));
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
if (options.rules.removeComments && shouldRunRule("remove-comments", options.onlyRules)) {
|
|
112
|
-
violations.push(...await collectRemoveCommentsViolations(filterSourceFilesForRule(sourceFiles, options.rules.removeComments), options));
|
|
113
|
-
}
|
|
114
|
-
if (options.rules.structuralBlankLines && shouldRunRule("structural-blank-lines", options.onlyRules)) {
|
|
115
|
-
const files = filterSourceFilesForRule(sourceFiles, options.rules.structuralBlankLines);
|
|
116
|
-
violations.push(...await collectStructuralBlankLinesViolations(files, options));
|
|
117
|
-
}
|
|
64
|
+
const violations = await collectNativeCheckViolations(sourceFiles, options);
|
|
118
65
|
violations.push(...await collectFormatViolations(options));
|
|
119
66
|
return sortViolations(applyConfiguredSeverity(violations, options));
|
|
120
67
|
}
|
|
@@ -148,16 +95,16 @@ function logFixResult(result, logger) {
|
|
|
148
95
|
ruleResults: result.ruleResults,
|
|
149
96
|
}, { group: runLogGroup("fix") });
|
|
150
97
|
}
|
|
151
|
-
async function
|
|
152
|
-
const normalized = await
|
|
98
|
+
async function check(options) {
|
|
99
|
+
const normalized = await normalizeCheckOptions(options, "check");
|
|
153
100
|
const logger = resolveLogger(normalized.logging);
|
|
154
101
|
const violations = await collectViolations(normalized);
|
|
155
102
|
const result = attachDisciplineResult("check", summarizeViolations(violations));
|
|
156
103
|
logSummary("check", result, logger);
|
|
157
104
|
return result;
|
|
158
105
|
}
|
|
159
|
-
async function
|
|
160
|
-
const normalized = await
|
|
106
|
+
async function fix(options) {
|
|
107
|
+
const normalized = await normalizeCheckOptions(options, "fix");
|
|
161
108
|
const logger = resolveLogger(normalized.logging);
|
|
162
109
|
const state = {
|
|
163
110
|
deletedFiles: 0,
|
|
@@ -183,5 +130,5 @@ async function fixCodeDiscipline(options) {
|
|
|
183
130
|
logFixResult(result, logger);
|
|
184
131
|
return result;
|
|
185
132
|
}
|
|
186
|
-
export { buildNormalizedSyncOptions,
|
|
133
|
+
export { buildNormalizedSyncOptions, check, fix };
|
|
187
134
|
//# sourceMappingURL=index.js.map
|
package/dist/checks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/checks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,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|
+
import type { CodeDisciplineViolation } from "../shared/discipline-types.js";
|
|
2
|
+
import type { ScannedSourceFile } from "../imports/types.js";
|
|
3
|
+
import type { NormalizedCheckCodeDisciplineOptions } from "./types.js";
|
|
4
|
+
declare function collectNativeCheckViolations(sourceFiles: ScannedSourceFile[], options: NormalizedCheckCodeDisciplineOptions): Promise<CodeDisciplineViolation[]>;
|
|
5
|
+
export { collectNativeCheckViolations };
|
|
6
|
+
//# sourceMappingURL=native-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-runner.d.ts","sourceRoot":"","sources":["../../src/checks/native-runner.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAI7D,OAAO,KAAK,EAA4B,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAKjF,OAAO,KAAK,EAAE,oCAAoC,EAAE,MAAM,YAAY,CAAC;AAqIvE,iBAAe,4BAA4B,CACzC,WAAW,EAAE,iBAAiB,EAAE,EAChC,OAAO,EAAE,oCAAoC,GAC5C,OAAO,CAAC,uBAAuB,EAAE,CAAC,CAUpC;AAED,OAAO,EAAE,4BAA4B,EAAE,CAAC"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { planTsconfigAliases } from "../imports/aliases.js";
|
|
3
|
+
import { collectPackageJsonImportsSyncState, collectPackageJsonImportsSyncStateFromAliasMap } from "../runtime/imports-sync.js";
|
|
4
|
+
import { filterSourceFilesForRule } from "../shared/rule-exclusions.js";
|
|
5
|
+
import { supportsImports } from "../shared/languages.js";
|
|
6
|
+
import { requireNativeBinding } from "../native/native.js";
|
|
7
|
+
import { shouldRunRule } from "./rule-slugs.js";
|
|
8
|
+
import { buildNormalizedSyncOptions } from "./sync-options.js";
|
|
9
|
+
function createImportSyncViolation(args) {
|
|
10
|
+
const violations = [];
|
|
11
|
+
if (args.aliasesChanged && args.aliasPlan) {
|
|
12
|
+
violations.push({
|
|
13
|
+
rule: "imports",
|
|
14
|
+
fix: true,
|
|
15
|
+
filePath: path.relative(args.normalized.projectRoot, args.normalized.tsconfigPath) || "tsconfig.json",
|
|
16
|
+
message: args.normalized.output.type === "alias-map"
|
|
17
|
+
? "imports folder and generated tsconfig are out of sync"
|
|
18
|
+
: "tsconfig paths are out of sync with the current source tree",
|
|
19
|
+
details: {
|
|
20
|
+
aliasesCount: args.aliasPlan.aliasesCount,
|
|
21
|
+
drift: args.aliasPlan.drift,
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
if (args.packageJsonSyncState?.changed) {
|
|
26
|
+
violations.push({
|
|
27
|
+
rule: "imports",
|
|
28
|
+
fix: true,
|
|
29
|
+
filePath: path.relative(args.normalized.projectRoot, args.packageJsonSyncState.packageJsonPath) || "package.json",
|
|
30
|
+
message: "package.json imports are out of sync with tsconfig paths",
|
|
31
|
+
details: {
|
|
32
|
+
importsCount: args.packageJsonSyncState.importsCount,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return violations;
|
|
37
|
+
}
|
|
38
|
+
async function collectPackageSyncState(normalized, aliasPlan) {
|
|
39
|
+
if (normalized.output.type === "alias-map" && aliasPlan.aliasPathMap) {
|
|
40
|
+
return collectPackageJsonImportsSyncStateFromAliasMap({
|
|
41
|
+
aliasPathMap: aliasPlan.aliasPathMap,
|
|
42
|
+
cleanWhenDisabled: true,
|
|
43
|
+
configPath: normalized.configPath,
|
|
44
|
+
options: {
|
|
45
|
+
...normalized.packageJsonImports,
|
|
46
|
+
enabled: false,
|
|
47
|
+
},
|
|
48
|
+
projectRoot: normalized.projectRoot,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return collectPackageJsonImportsSyncState({
|
|
52
|
+
configPath: normalized.configPath,
|
|
53
|
+
options: normalized.packageJsonImports,
|
|
54
|
+
projectRoot: normalized.projectRoot,
|
|
55
|
+
tsconfigPath: normalized.tsconfigPath,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
async function createNativeImportState(sourceFiles, options) {
|
|
59
|
+
if (!options.rules.imports || !shouldRunRule("imports", options.onlyRules)) {
|
|
60
|
+
return { syncViolations: [] };
|
|
61
|
+
}
|
|
62
|
+
const normalized = await buildNormalizedSyncOptions(options, false);
|
|
63
|
+
if (!normalized)
|
|
64
|
+
return { syncViolations: [] };
|
|
65
|
+
if (!Array.isArray(normalized.allowRelative)) {
|
|
66
|
+
throw new Error("imports.allowRelative functions are not supported by the native check backend");
|
|
67
|
+
}
|
|
68
|
+
const supportedSourceFiles = filterSourceFilesForRule(sourceFiles, options.rules.imports)
|
|
69
|
+
.filter((file) => supportsImports(file.extension));
|
|
70
|
+
const aliasPlan = await planTsconfigAliases(normalized, supportedSourceFiles);
|
|
71
|
+
const packageJsonSyncState = await collectPackageSyncState(normalized, aliasPlan);
|
|
72
|
+
return {
|
|
73
|
+
syncViolations: createImportSyncViolation({
|
|
74
|
+
aliasesChanged: aliasPlan.aliasesChanged,
|
|
75
|
+
aliasPlan,
|
|
76
|
+
normalized,
|
|
77
|
+
packageJsonSyncState,
|
|
78
|
+
}),
|
|
79
|
+
rule: {
|
|
80
|
+
excludeDirs: options.rules.imports.excludeDirs,
|
|
81
|
+
allowRelative: normalized.allowRelative,
|
|
82
|
+
aliasIdsByFilePath: Object.fromEntries(aliasPlan.aliasRecords.map((record) => [path.resolve(record.absolutePath), record.id])),
|
|
83
|
+
removeDeadImports: normalized.removeDeadImports,
|
|
84
|
+
sourceExtensions: normalized.sourceExtensions,
|
|
85
|
+
sourceRoot: normalized.sourceRoot,
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function selectNativeRules(options, importsRule) {
|
|
90
|
+
return {
|
|
91
|
+
bannedPatterns: shouldRunRule("banned-patterns", options.onlyRules) ? options.rules.bannedPatterns : undefined,
|
|
92
|
+
bannedFiles: shouldRunRule("banned-files", options.onlyRules) ? options.rules.bannedFiles : undefined,
|
|
93
|
+
minFileLines: shouldRunRule("min-file-lines", options.onlyRules) ? options.rules.minFileLines : undefined,
|
|
94
|
+
minDeclarationName: shouldRunRule("min-declaration-name", options.onlyRules) ? options.rules.minDeclarationName : undefined,
|
|
95
|
+
maxFileLines: shouldRunRule("max-file-lines", options.onlyRules) ? options.rules.maxFileLines : undefined,
|
|
96
|
+
maxCharactersPerLine: shouldRunRule("max-characters-per-line", options.onlyRules) ? options.rules.maxCharactersPerLine : undefined,
|
|
97
|
+
maxFunctionLines: shouldRunRule("max-function-lines", options.onlyRules) ? options.rules.maxFunctionLines : undefined,
|
|
98
|
+
redundantPathSegments: shouldRunRule("redundant-path-segments", options.onlyRules) ? options.rules.redundantPathSegments : undefined,
|
|
99
|
+
imports: importsRule,
|
|
100
|
+
removeComments: shouldRunRule("remove-comments", options.onlyRules) ? options.rules.removeComments : undefined,
|
|
101
|
+
structuralBlankLines: shouldRunRule("structural-blank-lines", options.onlyRules) ? options.rules.structuralBlankLines : undefined,
|
|
102
|
+
dry: shouldRunRule("dry", options.onlyRules) ? options.rules.dry : undefined,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
async function collectNativeCheckViolations(sourceFiles, options) {
|
|
106
|
+
const importState = await createNativeImportState(sourceFiles, options);
|
|
107
|
+
const response = JSON.parse(requireNativeBinding().runCheckRules(JSON.stringify({
|
|
108
|
+
sourceFiles,
|
|
109
|
+
rules: selectNativeRules(options, importState.rule),
|
|
110
|
+
})));
|
|
111
|
+
return [
|
|
112
|
+
...importState.syncViolations,
|
|
113
|
+
...(Array.isArray(response.violations) ? response.violations : []),
|
|
114
|
+
];
|
|
115
|
+
}
|
|
116
|
+
export { collectNativeCheckViolations };
|
|
117
|
+
//# sourceMappingURL=native-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-runner.js","sourceRoot":"","sources":["../../src/checks/native-runner.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM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OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC,CAAC,SAAS;QACjI,GAAG,EAAE,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS;KAC7E,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,4BAA4B,CACzC,WAAgC,EAChC,OAA6C;IAE7C,MAAM,WAAW,GAAG,MAAM,uBAAuB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IACxE,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,oBAAoB,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC;QACxE,WAAW;QACX,KAAK,EAAE,iBAAiB,CAAC,OAAO,EAAE,WAAW,CAAC,IAAI,CAAC;KAC1D,CAAC,CAAC,CAA6B,CAAC;IACjC,OAAO;QACL,GAAG,WAAW,CAAC,cAAc;QAC7B,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;KACnE,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,4BAA4B,EAAE,CAAC"}
|
package/dist/checks/types.d.ts
CHANGED
|
@@ -22,11 +22,16 @@ type NodeProcessBoundaryPresetOptions = {
|
|
|
22
22
|
envBoundaryFiles?: string[];
|
|
23
23
|
processBoundaryFiles?: string[];
|
|
24
24
|
};
|
|
25
|
-
type CodeDisciplinePresetName = "trebired";
|
|
26
25
|
type CodeDisciplinePresets = {
|
|
27
|
-
use?:
|
|
26
|
+
use?: string | string[];
|
|
27
|
+
};
|
|
28
|
+
type CodeDisciplineHelpers = {
|
|
28
29
|
nodeProcessBoundary?: NodeProcessBoundaryPresetOptions;
|
|
29
30
|
};
|
|
31
|
+
type CodeDisciplinePresetPackage = {
|
|
32
|
+
codeDisciplineVersion: string;
|
|
33
|
+
config: CodeDisciplineConfig;
|
|
34
|
+
};
|
|
30
35
|
type BannedFileRuleEntry = string | {
|
|
31
36
|
glob: string;
|
|
32
37
|
};
|
|
@@ -113,6 +118,7 @@ type CheckCodeDisciplineOptions = {
|
|
|
113
118
|
gitignorePath?: string;
|
|
114
119
|
logging?: LoggingOptions;
|
|
115
120
|
presets?: CodeDisciplinePresets;
|
|
121
|
+
helpers?: CodeDisciplineHelpers;
|
|
116
122
|
rules?: CodeDisciplineRules;
|
|
117
123
|
lifecycle?: CodeDisciplineLifecycleHooks;
|
|
118
124
|
onlyRules?: CodeDisciplineCheckSelectorSlug[];
|
|
@@ -247,5 +253,5 @@ type FixCodeDisciplineResult = CodeDisciplineResult & {
|
|
|
247
253
|
unchanged_files: number;
|
|
248
254
|
ruleResults: Partial<Record<FixableRuleSlug, FixCodeDisciplineRuleResult>>;
|
|
249
255
|
};
|
|
250
|
-
export type { BannedPatternRuleEntry, BannedFileRuleEntry, BannedFilesRuleOptions, BannedPatternsRuleOptions, CheckCodeDisciplineOptions, CheckCodeDisciplineResult, CodeDisciplineConfig, CodeDisciplineLifecycleContext, CodeDisciplineLifecycleHookResult, CodeDisciplineLifecycleHooks, CodeDisciplineMode,
|
|
256
|
+
export type { BannedPatternRuleEntry, BannedFileRuleEntry, BannedFilesRuleOptions, BannedPatternsRuleOptions, CheckCodeDisciplineOptions, CheckCodeDisciplineResult, CodeDisciplineConfig, CodeDisciplineLifecycleContext, CodeDisciplineLifecycleHookResult, CodeDisciplineLifecycleHooks, CodeDisciplineMode, CodeDisciplinePresetPackage, CodeDisciplinePresets, CodeDisciplineHelpers, CodeDisciplineRuleSlug, CodeDisciplineRuleSeverity, CodeDisciplineRuntimeMode, CodeDisciplineCheckSelectorSlug, CodeDisciplineRules, CodeDisciplineImportsRuleOptions, DryRuleOptions, FixableRuleSlug, FixCodeDisciplineOptions, FixCodeDisciplineResult, FixCodeDisciplineRuleResult, RedundantPathSegmentsRuleOptions, FormattingRuleOptions, MaxCharactersPerLineRuleOptions, MaxFileLinesRuleOptions, MaxFunctionLinesRuleOptions, MinDeclarationNameRuleOptions, MinFileLinesRuleOptions, NormalizedCodeFormatter, NormalizedFormattingRule, NormalizedBannedFileRuleEntry, NormalizedBannedFilesRule, NormalizedBannedPatternRuleEntry, NormalizedBannedPatternsRule, RemoveCommentsRuleOptions, RuleExclusionOptions, NormalizedCheckCodeDisciplineOptions, NormalizedDryRule, NormalizedRedundantPathSegmentsRule, NormalizedMaxCharactersPerLineRule, NormalizedMaxFileLinesRule, NormalizedMaxFunctionLinesRule, NormalizedMinDeclarationNameRule, NormalizedMinFileLinesRule, NormalizedRemoveCommentsRule, NodeProcessBoundaryPresetOptions, NormalizedStructuralBlankLinesRule, StructuralBlankLinesRuleOptions, TsconfigPathsNormalizeMode, };
|
|
251
257
|
//# sourceMappingURL=types.d.ts.map
|