@blundergoat/gruff-ts 0.4.0 → 0.6.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.
- package/CHANGELOG.md +123 -1
- package/CONTRIBUTING.md +32 -25
- package/README.md +55 -46
- package/SECURITY.md +18 -30
- package/UPGRADING.md +101 -0
- package/bin/gruff-ts +3 -0
- package/docs/README.md +11 -13
- package/docs/agent-hook.md +33 -24
- package/docs/ci-integration.md +38 -24
- package/docs/configuration.md +173 -71
- package/docs/dashboard.md +12 -13
- package/docs/output-formats.md +100 -25
- package/docs/philosophy.md +2 -2
- package/docs/reports-and-ci.md +14 -157
- package/docs/rules.md +140 -106
- package/package.json +10 -8
- package/src/analyser.ts +886 -282
- package/src/baseline-file.ts +867 -0
- package/src/baseline-identity.ts +463 -0
- package/src/baseline-options.ts +139 -34
- package/src/baseline.ts +85 -55
- package/src/blocks.ts +579 -364
- package/src/changed-regions.ts +414 -65
- package/src/check-ignore.ts +28 -13
- package/src/class-rules.ts +461 -302
- package/src/cli-program.ts +956 -166
- package/src/cli.ts +9 -2
- package/src/comment-rules.ts +277 -414
- package/src/comment-scanner.ts +363 -44
- package/src/complexity-metrics.ts +320 -0
- package/src/config-load-error.ts +17 -8
- package/src/config-parse.ts +291 -98
- package/src/config-preservation.ts +81 -26
- package/src/config.ts +778 -210
- package/src/constants.ts +7 -6
- package/src/context-doc-rules.ts +188 -61
- package/src/dashboard.ts +88 -23
- package/src/dead-code-rules.ts +153 -74
- package/src/discovery.ts +521 -148
- package/src/doc-rules.ts +592 -147
- package/src/duplicate-test-group-rules.ts +359 -0
- package/src/findings-helpers.ts +240 -89
- package/src/findings.ts +48 -24
- package/src/fixture-purpose-rules.ts +226 -48
- package/src/github-actions-event-guards.ts +331 -0
- package/src/github-actions-rules.ts +336 -106
- package/src/hook-contract.ts +708 -211
- package/src/init-config.ts +169 -114
- package/src/inline-suppressions.ts +340 -0
- package/src/limit-band.ts +56 -0
- package/src/line-rules.ts +331 -419
- package/src/migrate-config.ts +670 -0
- package/src/naming-pushers.ts +33 -107
- package/src/parsed-script.ts +1206 -0
- package/src/pillar-summary.ts +56 -40
- package/src/profiles.ts +97 -71
- package/src/project-config-rules.ts +335 -146
- package/src/project-rules.ts +237 -115
- package/src/public-exports.ts +284 -0
- package/src/report-html.ts +217 -85
- package/src/report-renderers.ts +864 -195
- package/src/rule-list.ts +166 -46
- package/src/rules.ts +100 -104
- package/src/safety-rules.ts +191 -132
- package/src/scoring.ts +255 -52
- package/src/security-flow-rules.ts +930 -109
- package/src/selectors.ts +169 -0
- package/src/sensitive-data-rules.ts +502 -375
- package/src/sensitive-exclusions.ts +435 -0
- package/src/source-text.ts +380 -148
- package/src/static-analysis-redundant-rules.ts +298 -41
- package/src/test-block-rules.ts +422 -228
- package/src/text-scans.ts +67 -9
- package/src/types.ts +222 -71
- package/tsconfig.json +2 -1
- package/src/process-exec-metadata.ts +0 -153
- package/src/test-fixtures.ts +0 -668
package/src/check-ignore.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
// `check-ignore
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
1
|
+
// Powers `gruff-ts check-ignore`, answering whether gruff would skip each path without running analysis.
|
|
2
|
+
//
|
|
3
|
+
// Reuses `classifyPathIgnore` from `discovery.ts` so `check-ignore` and `analyse` never disagree:
|
|
4
|
+
// - mirrors `git check-ignore` exit codes (0 = at least one ignored, 1 = none ignored, 2 = config error);
|
|
5
|
+
// - lets coding-agent hooks and CI scripts check ignore policy in O(1) per path before scanning.
|
|
6
6
|
import { cwd } from "node:process";
|
|
7
7
|
import { loadConfig } from "./config.ts";
|
|
8
8
|
import { classifyPathIgnore, type PathIgnoreClassification } from "./discovery.ts";
|
|
@@ -11,24 +11,39 @@ import type { AnalysisOptions } from "./types.ts";
|
|
|
11
11
|
/** Output encodings supported by the `check-ignore` command. */
|
|
12
12
|
export type CheckIgnoreFormat = "text" | "json";
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Reads config using the current working directory and classifies each path through discovery ignore rules.
|
|
16
|
+
* Config paths.ignore takes precedence over other ignore sources.
|
|
17
|
+
*
|
|
18
|
+
* @param inputs - File or directory paths to classify against the ignore rules.
|
|
19
|
+
* @param options - Analysis options that select config and control whether ordinary ignore rules are bypassed.
|
|
20
|
+
* @returns One classification per input path in input order, reporting the matching source and pattern when ignored.
|
|
21
|
+
*/
|
|
17
22
|
export function checkIgnore(inputs: string[], options: AnalysisOptions): PathIgnoreClassification[] {
|
|
18
23
|
const projectRoot = cwd();
|
|
19
24
|
const config = loadConfig(projectRoot, options);
|
|
20
25
|
return inputs.map((input) => classifyPathIgnore(projectRoot, input, options, config));
|
|
21
26
|
}
|
|
22
27
|
|
|
23
|
-
|
|
24
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Converts path classifications to the `git check-ignore` exit status.
|
|
30
|
+
* The CLI's `runWithConfigErrorHandling` assigns exit 2 for configuration failures.
|
|
31
|
+
*
|
|
32
|
+
* @param results - Path ignore classifications produced by `checkIgnore`.
|
|
33
|
+
* @returns `0` if any path in `results` is ignored, and `1` otherwise, including for an empty list.
|
|
34
|
+
*/
|
|
25
35
|
export function checkIgnoreExitCode(results: PathIgnoreClassification[]): number {
|
|
26
36
|
return results.some((result) => result.isIgnored) ? 0 : 1;
|
|
27
37
|
}
|
|
28
38
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Formats path classifications as JSON or tab-delimited text.
|
|
41
|
+
* JSON includes every path with `null` for missing match details; text lists ignored paths with a tab before `source:pattern`.
|
|
42
|
+
*
|
|
43
|
+
* @param results - Path ignore classifications to format.
|
|
44
|
+
* @param format - Output format (`"json"` for all paths, `"text"` for ignored paths only).
|
|
45
|
+
* @returns Formatted classification output, or an empty string in `"text"` format when no path is ignored.
|
|
46
|
+
*/
|
|
32
47
|
export function renderCheckIgnore(results: PathIgnoreClassification[], format: CheckIgnoreFormat): string {
|
|
33
48
|
if (format === "json") {
|
|
34
49
|
return JSON.stringify(
|