@blundergoat/gruff-ts 0.1.0 → 0.1.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 +14 -2
- package/CONTRIBUTING.md +3 -3
- package/README.md +140 -182
- package/docs/README.md +23 -0
- package/docs/ci-integration.md +63 -0
- package/docs/{CONFIGURATION.md → configuration.md} +2 -19
- package/docs/dashboard.md +29 -0
- package/docs/output-formats.md +65 -0
- package/docs/{RELEASING.md → releasing.md} +12 -10
- package/docs/rules.md +177 -0
- package/package.json +2 -2
- package/scripts/bump-version.sh +67 -18
- package/scripts/dependency-install.sh +96 -0
- package/scripts/dependency-update.sh +177 -0
- package/scripts/preflight-checks.sh +75 -0
- package/src/analyser.ts +5 -20
- package/src/blocks.ts +4 -4
- package/src/class-rules.ts +5 -6
- package/src/cli-program.ts +125 -12
- package/src/cli.ts +4 -1
- package/src/comment-rules.ts +2 -0
- package/src/config.ts +2 -4
- package/src/constants.ts +1 -1
- package/src/dead-code-rules.ts +2 -2
- package/src/init-config.ts +248 -0
- package/src/line-rules.ts +6 -8
- package/src/naming-pushers.ts +0 -31
- package/src/project-config-rules.ts +1 -1
- package/src/report-renderers.ts +60 -11
- package/src/rule-list.ts +1 -0
- package/src/rules.ts +14 -16
- package/src/safety-rules.ts +3 -3
- package/src/scoring.ts +4 -4
- package/src/test-fixtures.ts +0 -2
- package/src/text-scans.ts +1 -152
- package/src/types.ts +1 -2
- /package/docs/{REPORTS_AND_CI.md → reports-and-ci.md} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.1.1] - 2026-05-24
|
|
4
|
+
|
|
5
|
+
Onboarding flow, machine-readable summaries, and a `waste` → `maintainability` pillar rename. Catalogue is now 119 rules across 11 pillars.
|
|
6
|
+
|
|
7
|
+
- **Breaking**: pillar `waste` renamed to `maintainability` — rule IDs unchanged, but text/JSON/SARIF parsers, dashboard nav, and the `Pillar` TypeScript union must update. Rules `docs.todo-density` and `naming.abbreviation` removed (both opt-in advisories), along with the now-unused `allowlists.abbreviationDenylist` config key; stale entries are silently ignored.
|
|
8
|
+
- **Added**: `gruff-ts init` writes the default `.gruff-ts.yaml`, refusing to overwrite any supported config name without `--force` (which preserves existing `paths.ignore` entries). `analyse`, `summary`, `report`, and `dashboard` auto-prompt for `init` when no config is found, gated by `--no-interaction`, `--silent`/`--quiet`, and TTY checks so it never fires in CI.
|
|
9
|
+
- **Added**: `summary --format=json` emits the new `gruff.summary.v1` schema; `summary --top <n>` controls digest size; a baseline status line surfaces source and suppression count. `dashboard --project-root <path>` sets the default scan root.
|
|
10
|
+
- **Added**: docs index (`docs/README.md`) plus `ci-integration.md`, `dashboard.md`, `output-formats.md`, `rules.md`; CI now runs `npm audit --audit-level=moderate`.
|
|
11
|
+
- **Fixed**: `summary`/`list-rules` `--format` rejects unsupported values via Commander instead of coercing to `text`; CLI switched to `parseAsync` so async handler rejections exit with the correct code.
|
|
12
|
+
- **Fixed**: `summary --top <n>` now actually controls file-offender count beyond 10. `gruff.analysis.v1` `score.topOffenders` is now the full sorted file list (was capped at 10); HTML report and `--format=hotspot` still cap their own output at 10 rows. `init --force` help text now reflects that it also overrides the refusal triggered by non-canonical configs (`.gruff.yaml`/`.yml`/`.json`). `--top` added to the known-CLI-flag list so comments documenting it no longer trip `docs.stale-comment`.
|
|
13
|
+
- **Changed**: docs filenames lowercased (`CONFIGURATION.md` → `configuration.md`, `RELEASING.md` → `releasing.md`, `REPORTS_AND_CI.md` → `reports-and-ci.md`).
|
|
14
|
+
|
|
3
15
|
## [0.1.0] - 2026-05-23
|
|
4
16
|
|
|
5
17
|
Initial public release of the `@blundergoat/gruff-ts` npm package.
|
|
6
18
|
|
|
7
19
|
- TypeScript/JavaScript code quality scanner: 121 rules across 11 pillars
|
|
8
|
-
(complexity, dead-code, design, documentation,
|
|
9
|
-
security, sensitive-data, size, test-quality
|
|
20
|
+
(complexity, dead-code, design, documentation, maintainability,
|
|
21
|
+
modernisation, naming, security, sensitive-data, size, test-quality).
|
|
10
22
|
- CLI commands: `analyse`, `summary`, `report`, `list-rules`, `dashboard`,
|
|
11
23
|
`completion`.
|
|
12
24
|
- Output formats: `text`, `json`, `html`, `markdown`, `github`, `hotspot`,
|
package/CONTRIBUTING.md
CHANGED
|
@@ -68,9 +68,9 @@ Update docs when behavior changes:
|
|
|
68
68
|
|
|
69
69
|
- `README.md` for user-facing workflow changes.
|
|
70
70
|
- `CHANGELOG.md` for release-visible changes.
|
|
71
|
-
- `docs/
|
|
72
|
-
- `docs/
|
|
73
|
-
- `docs/
|
|
71
|
+
- `docs/configuration.md` for config shape or threshold changes.
|
|
72
|
+
- `docs/reports-and-ci.md` for output, CI, dashboard, or baseline changes.
|
|
73
|
+
- `docs/releasing.md` for release process changes.
|
|
74
74
|
|
|
75
75
|
## Pull Request Checklist
|
|
76
76
|
|
package/README.md
CHANGED
|
@@ -1,23 +1,38 @@
|
|
|
1
1
|
# gruff-ts
|
|
2
2
|
|
|
3
|
-
`gruff-ts` is
|
|
4
|
-
dependency-light Node.js CLI scans source, tests, package metadata, and
|
|
5
|
-
common config files, then reports quality findings across 11 pillars with
|
|
6
|
-
stable fingerprints for baselines and repeatable machine output.
|
|
3
|
+
`gruff-ts` is an opinionated static analyzer for TypeScript and JavaScript projects. The dependency-light Node.js CLI scans source, tests, package metadata, and common config files, then emits reports for terminals, CI annotations, SARIF consumers, static HTML, and a local dashboard. It is heuristic static analysis; run it beside `tsc`, ESLint, tests, dependency scanners, and code review, not instead of them.
|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
## Status At A Glance
|
|
6
|
+
|
|
7
|
+
| Field | Value |
|
|
8
|
+
| --- | --- |
|
|
9
|
+
| Release line | Published `0.1.0` package line |
|
|
10
|
+
| Runtime | Node.js `22+` |
|
|
11
|
+
| Package | `@blundergoat/gruff-ts` |
|
|
12
|
+
| Binary | `gruff-ts` |
|
|
13
|
+
| Rule catalogue | 119 rules across 11 pillars |
|
|
14
|
+
| Primary config | `.gruff-ts.yaml`; `.gruff.json`, `.gruff.yaml`, and `.gruff.yml` are fallback files |
|
|
15
|
+
| Analysis schema | `gruff.analysis.v1` |
|
|
16
|
+
| Baseline schema | `gruff.baseline.v1` |
|
|
17
|
+
| Severity gate | `--fail-on` with `none`, `advisory`, `warning`, `error` |
|
|
18
|
+
| Dashboard | `127.0.0.1:8767` by default |
|
|
19
|
+
|
|
20
|
+
Scanned file types include TypeScript, JavaScript, CSS, JSON, YAML, TOML, INI, XML, and `.env*`.
|
|
21
|
+
|
|
22
|
+
## Requirements
|
|
23
|
+
|
|
24
|
+
- Node.js `22+`, matching [`package.json`](package.json).
|
|
25
|
+
- npm for source-checkout development.
|
|
26
|
+
- Git only for diff modes.
|
|
13
27
|
|
|
14
28
|
## Install
|
|
15
29
|
|
|
16
|
-
Install
|
|
30
|
+
Install as a project dev dependency:
|
|
17
31
|
|
|
18
32
|
```bash
|
|
19
33
|
npm install --save-dev @blundergoat/gruff-ts
|
|
20
|
-
|
|
34
|
+
./node_modules/.bin/gruff-ts init
|
|
35
|
+
./node_modules/.bin/gruff-ts summary
|
|
21
36
|
```
|
|
22
37
|
|
|
23
38
|
From this checkout:
|
|
@@ -29,170 +44,90 @@ npm install
|
|
|
29
44
|
|
|
30
45
|
## Quick Start
|
|
31
46
|
|
|
32
|
-
Run an exploratory scan without failing the shell on findings:
|
|
33
|
-
|
|
34
47
|
```bash
|
|
35
|
-
|
|
36
|
-
|
|
48
|
+
# Create the project config.
|
|
49
|
+
./node_modules/.bin/gruff-ts init
|
|
37
50
|
|
|
38
|
-
|
|
51
|
+
# Review the current finding mix.
|
|
52
|
+
./node_modules/.bin/gruff-ts summary
|
|
39
53
|
|
|
40
|
-
|
|
41
|
-
gruff-ts analyse
|
|
42
|
-
```
|
|
54
|
+
# Explore without failing because of findings.
|
|
55
|
+
./node_modules/.bin/gruff-ts analyse . --fail-on=none
|
|
43
56
|
|
|
44
|
-
|
|
57
|
+
# Gate on warning and error findings.
|
|
58
|
+
./node_modules/.bin/gruff-ts analyse . --fail-on=warning
|
|
45
59
|
|
|
46
|
-
|
|
47
|
-
gruff-ts
|
|
48
|
-
```
|
|
60
|
+
# Emit SARIF for code scanning.
|
|
61
|
+
./node_modules/.bin/gruff-ts analyse . --format=sarif --fail-on=none > gruff-ts.sarif
|
|
49
62
|
|
|
50
|
-
|
|
63
|
+
# Generate a fresh-start baseline.
|
|
64
|
+
./node_modules/.bin/gruff-ts analyse . --generate-baseline gruff-baseline.json --fail-on=none
|
|
51
65
|
|
|
52
|
-
|
|
53
|
-
gruff-ts dashboard
|
|
66
|
+
# Start the local dashboard.
|
|
67
|
+
./node_modules/.bin/gruff-ts dashboard
|
|
54
68
|
```
|
|
55
69
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
## What It Checks
|
|
59
|
-
|
|
60
|
-
Findings are grouped into 11 public pillars:
|
|
61
|
-
|
|
62
|
-
- `size`
|
|
63
|
-
- `complexity`
|
|
64
|
-
- `dead-code`
|
|
65
|
-
- `waste`
|
|
66
|
-
- `naming`
|
|
67
|
-
- `documentation`
|
|
68
|
-
- `modernisation`
|
|
69
|
-
- `security`
|
|
70
|
-
- `sensitive-data`
|
|
71
|
-
- `test-quality`
|
|
72
|
-
- `design`
|
|
73
|
-
|
|
74
|
-
Inspect the exact rule ids, severities, confidence levels, remediation text,
|
|
75
|
-
threshold values, and options:
|
|
76
|
-
|
|
77
|
-
```bash
|
|
78
|
-
gruff-ts list-rules
|
|
79
|
-
gruff-ts list-rules --format=json
|
|
80
|
-
```
|
|
70
|
+
Open `http://127.0.0.1:8767/` for the dashboard.
|
|
81
71
|
|
|
82
72
|
## Commands
|
|
83
73
|
|
|
84
74
|
| Command | Purpose |
|
|
85
75
|
| --- | --- |
|
|
86
|
-
| `analyse [paths...]` | Run the
|
|
87
|
-
| `summary [paths...]` | Print
|
|
88
|
-
| `report [paths...]` | Render an HTML or JSON report
|
|
89
|
-
| `
|
|
90
|
-
| `
|
|
76
|
+
| `analyse [paths...]` | Run the analyzer and print findings. |
|
|
77
|
+
| `summary [paths...]` | Print compact score, pillar, rule, and file summaries. |
|
|
78
|
+
| `report [paths...]` | Render an HTML or JSON report to stdout or `--output`. |
|
|
79
|
+
| `init` | Write the default `.gruff-ts.yaml` to the current directory (`--force` to overwrite). |
|
|
80
|
+
| `list-rules` | Print rule metadata as text or JSON. |
|
|
81
|
+
| `dashboard` | Serve the local browser dashboard. |
|
|
91
82
|
| `completion [shell]` | Print a shell completion script for `bash`, `zsh`, or `fish`. |
|
|
92
|
-
| `list` |
|
|
83
|
+
| `list`, `help` | Show command lists and command-specific help. |
|
|
93
84
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
```bash
|
|
97
|
-
gruff-ts --help
|
|
98
|
-
gruff-ts list
|
|
99
|
-
gruff-ts analyse --help
|
|
100
|
-
gruff-ts summary --help
|
|
101
|
-
gruff-ts report --help
|
|
102
|
-
gruff-ts dashboard --help
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
Global console options match the `gruff` PHP CLI surface: `--silent`,
|
|
106
|
-
`--quiet`, `--ansi` / `--no-ansi`, `--no-interaction`, and `-v` / `-vv` /
|
|
107
|
-
`-vvv`. The command menu uses the same ANSI colour treatment as `gruff` when
|
|
108
|
-
stdout is a TTY; `--ansi` forces colour and `--no-ansi` disables it.
|
|
85
|
+
Global console options match the broader gruff CLI surface: `--silent`, `--quiet`, `--ansi` / `--no-ansi`, `--no-interaction`, and `-v` / `-vv` / `-vvv`.
|
|
109
86
|
|
|
110
87
|
## Output Formats
|
|
111
88
|
|
|
112
|
-
`analyse
|
|
89
|
+
`analyse --format <fmt>` accepts:
|
|
113
90
|
|
|
114
|
-
| Format | Use
|
|
91
|
+
| Format | Use it for |
|
|
115
92
|
| --- | --- |
|
|
116
93
|
| `text` | Human terminal output. |
|
|
117
|
-
| `json` | Full
|
|
118
|
-
| `html` | Self-contained
|
|
119
|
-
| `markdown` |
|
|
120
|
-
| `github` | GitHub Actions
|
|
121
|
-
| `hotspot` |
|
|
122
|
-
| `sarif` | SARIF 2.1.0 code
|
|
123
|
-
|
|
124
|
-
Examples:
|
|
125
|
-
|
|
126
|
-
```bash
|
|
127
|
-
gruff-ts analyse . --format=json --fail-on=none
|
|
128
|
-
gruff-ts analyse . --format=github --fail-on=warning
|
|
129
|
-
gruff-ts analyse . --format=hotspot --fail-on=none
|
|
130
|
-
gruff-ts analyse . --format=sarif --fail-on=none > gruff.sarif
|
|
131
|
-
```
|
|
94
|
+
| `json` | Full `gruff.analysis.v1` report. |
|
|
95
|
+
| `html` | Self-contained inspection report. |
|
|
96
|
+
| `markdown` | Pull-request or issue comment summary. |
|
|
97
|
+
| `github` | GitHub Actions workflow annotations. |
|
|
98
|
+
| `hotspot` | `gruff.hotspot.v1` file-offender JSON. |
|
|
99
|
+
| `sarif` | SARIF 2.1.0 for code scanning. |
|
|
132
100
|
|
|
133
|
-
`report
|
|
101
|
+
`report --format <fmt>` accepts `html` and `json`.
|
|
134
102
|
|
|
135
|
-
|
|
136
|
-
gruff-ts report . --format=json --output gruff-report.json
|
|
137
|
-
```
|
|
103
|
+
## Exit Codes
|
|
138
104
|
|
|
139
|
-
|
|
105
|
+
| Code | Meaning |
|
|
106
|
+
| --- | --- |
|
|
107
|
+
| `0` | Run completed and no finding met `--fail-on`. |
|
|
108
|
+
| `1` | At least one finding met `--fail-on`. |
|
|
109
|
+
| `2` | Fatal diagnostic such as missing input, parse error, config error, diff failure, baseline failure, or invalid input. |
|
|
140
110
|
|
|
141
111
|
`analyse` defaults to `--fail-on error`.
|
|
142
112
|
|
|
143
|
-
|
|
144
|
-
# Exploratory scan: never fail because of findings.
|
|
145
|
-
gruff-ts analyse . --fail-on=none
|
|
146
|
-
|
|
147
|
-
# CI gate only on error findings.
|
|
148
|
-
gruff-ts analyse . --fail-on=error
|
|
149
|
-
|
|
150
|
-
# Stricter CI gate on warnings and errors.
|
|
151
|
-
gruff-ts analyse . --fail-on=warning
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
Exit codes:
|
|
113
|
+
## CI Usage
|
|
155
114
|
|
|
156
|
-
|
|
157
|
-
- `1`: scan completed and at least one finding met `--fail-on`.
|
|
158
|
-
- `2`: scan produced diagnostics such as missing inputs or parse/config errors.
|
|
159
|
-
|
|
160
|
-
Changed-file scans:
|
|
115
|
+
Generic CI command:
|
|
161
116
|
|
|
162
117
|
```bash
|
|
163
|
-
gruff-ts analyse . --
|
|
164
|
-
gruff-ts analyse . --diff=staged --format=json --fail-on=none
|
|
118
|
+
./node_modules/.bin/gruff-ts analyse . --format=github --fail-on=warning
|
|
165
119
|
```
|
|
166
120
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
Security-focused CI can run without baseline suppression so new error-severity
|
|
170
|
-
security or sensitive-data findings cannot be hidden by an adoption baseline:
|
|
121
|
+
SARIF jobs can write an artifact for code scanning:
|
|
171
122
|
|
|
172
123
|
```bash
|
|
173
|
-
gruff-ts analyse . --
|
|
124
|
+
./node_modules/.bin/gruff-ts analyse . --format=sarif --fail-on=none > gruff-ts.sarif
|
|
174
125
|
```
|
|
175
126
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
Baselines suppress existing findings by stable fingerprint so teams can adopt
|
|
179
|
-
the tool without fixing every current issue first.
|
|
127
|
+
Security-focused gates can bypass adoption baselines:
|
|
180
128
|
|
|
181
129
|
```bash
|
|
182
|
-
gruff-ts analyse . --
|
|
183
|
-
gruff-ts analyse . --baseline gruff-baseline.json --fail-on=warning
|
|
184
|
-
gruff-ts analyse . --no-baseline --fail-on=none
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
Baseline files use `schemaVersion: "gruff.baseline.v1"`.
|
|
188
|
-
|
|
189
|
-
`report` is intended for raw inspection output and does not accept
|
|
190
|
-
`--baseline`; use `analyse` when you need baseline suppression in CI.
|
|
191
|
-
|
|
192
|
-
Append local score history:
|
|
193
|
-
|
|
194
|
-
```bash
|
|
195
|
-
gruff-ts analyse . --history-file .gruff-history.json --fail-on=none
|
|
130
|
+
./node_modules/.bin/gruff-ts analyse . --no-baseline --fail-on=error
|
|
196
131
|
```
|
|
197
132
|
|
|
198
133
|
## Configuration
|
|
@@ -204,18 +139,7 @@ gruff-ts analyse . --history-file .gruff-history.json --fail-on=none
|
|
|
204
139
|
3. `.gruff.yaml`
|
|
205
140
|
4. `.gruff.yml`
|
|
206
141
|
|
|
207
|
-
Use an explicit
|
|
208
|
-
|
|
209
|
-
```bash
|
|
210
|
-
gruff-ts analyse . --config .gruff-ts.yaml
|
|
211
|
-
gruff-ts analyse . --no-config
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
Recursive scans respect root and nested `.gitignore` files. Use
|
|
215
|
-
`--include-ignored` to include default and Git-ignored paths for a run;
|
|
216
|
-
`paths.ignore` entries still apply as project policy.
|
|
217
|
-
|
|
218
|
-
Minimal YAML example:
|
|
142
|
+
Use `--config <path>` for an explicit file or `--no-config` to skip config loading. Recursive scans respect root and nested `.gitignore` files; `--include-ignored` includes default and Git-ignored paths for one run, but `paths.ignore` entries still apply as project policy.
|
|
219
143
|
|
|
220
144
|
```yaml
|
|
221
145
|
paths:
|
|
@@ -237,41 +161,74 @@ rules:
|
|
|
237
161
|
severity: warning
|
|
238
162
|
```
|
|
239
163
|
|
|
240
|
-
See [Configuration](docs/
|
|
241
|
-
examples.
|
|
164
|
+
See [Configuration](docs/configuration.md) for the full config shape.
|
|
242
165
|
|
|
243
|
-
##
|
|
166
|
+
## Rules And Pillars
|
|
167
|
+
|
|
168
|
+
The v0.1 catalogue contains 119 rules:
|
|
169
|
+
|
|
170
|
+
| Pillar | Rules |
|
|
171
|
+
| --- | ---: |
|
|
172
|
+
| `complexity` | 3 |
|
|
173
|
+
| `dead-code` | 1 |
|
|
174
|
+
| `design` | 6 |
|
|
175
|
+
| `documentation` | 17 |
|
|
176
|
+
| `maintainability` | 14 |
|
|
177
|
+
| `modernisation` | 14 |
|
|
178
|
+
| `naming` | 10 |
|
|
179
|
+
| `security` | 27 |
|
|
180
|
+
| `sensitive-data` | 8 |
|
|
181
|
+
| `size` | 4 |
|
|
182
|
+
| `test-quality` | 15 |
|
|
183
|
+
|
|
184
|
+
Use `./node_modules/.bin/gruff-ts list-rules --format=json` for exact rule IDs, severities, confidence levels, remediation text, thresholds, and options.
|
|
185
|
+
|
|
186
|
+
## Baselines And Changed-Code Scans
|
|
244
187
|
|
|
245
|
-
|
|
188
|
+
Baselines suppress reviewed findings by stable fingerprint:
|
|
246
189
|
|
|
247
190
|
```bash
|
|
248
|
-
gruff-ts
|
|
191
|
+
./node_modules/.bin/gruff-ts analyse . --generate-baseline gruff-baseline.json --fail-on=none
|
|
192
|
+
./node_modules/.bin/gruff-ts analyse . --baseline gruff-baseline.json --fail-on=warning
|
|
193
|
+
./node_modules/.bin/gruff-ts analyse . --no-baseline --fail-on=none
|
|
249
194
|
```
|
|
250
195
|
|
|
251
|
-
|
|
252
|
-
the default loopback bind unless the network is trusted. The `/scan` endpoint
|
|
253
|
-
analyses filesystem paths from request parameters, so the bind address is the
|
|
254
|
-
main safety boundary.
|
|
196
|
+
Changed-file scans use Git only when requested:
|
|
255
197
|
|
|
256
|
-
|
|
198
|
+
```bash
|
|
199
|
+
./node_modules/.bin/gruff-ts analyse . --diff=working-tree --format=github --fail-on=warning
|
|
200
|
+
./node_modules/.bin/gruff-ts analyse . --diff=staged --format=json --fail-on=none
|
|
201
|
+
```
|
|
257
202
|
|
|
258
|
-
|
|
259
|
-
appear in findings or rendered output.
|
|
260
|
-
- The scanner is heuristic. It is not a TypeScript compiler, type checker, or
|
|
261
|
-
full JavaScript parser.
|
|
262
|
-
- Rule confidence is included in the rule catalogue and each finding. Treat low
|
|
263
|
-
and medium confidence findings as review prompts.
|
|
264
|
-
- Baselines suppress matching fingerprints. Review baseline diffs carefully so
|
|
265
|
-
new findings are not hidden by accident.
|
|
203
|
+
`--diff` accepts `working-tree`, `staged`, `unstaged`, or a base ref. `report` renders raw inspection output and does not accept `--baseline`; use `analyse` when baseline suppression matters.
|
|
266
204
|
|
|
267
|
-
##
|
|
205
|
+
## Dashboard
|
|
268
206
|
|
|
269
|
-
|
|
270
|
-
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
207
|
+
```bash
|
|
208
|
+
./node_modules/.bin/gruff-ts dashboard --host 127.0.0.1 --port 8767 --project-root .
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
The dashboard serves a local iframe report and compact controls panel. It has no authentication; keep the default loopback bind unless the network is trusted. The `/scan` endpoint analyses filesystem paths from request parameters, so the bind address is the main safety boundary.
|
|
212
|
+
|
|
213
|
+
In polyglot repositories, `gruff-ts` defaults to port `8767`, `gruff-rs` defaults to `8766`, and `gruff-go`, `gruff-php`, and `gruff-py` default to `8765`; use `--port` when running multiple dashboards at the same time.
|
|
214
|
+
|
|
215
|
+
## Trust Boundary
|
|
216
|
+
|
|
217
|
+
Default scans are local source inspections. `gruff-ts` parses supported source, config, and package metadata files; it does not execute target application code, run tests, invoke the TypeScript compiler, query package registries, or read vulnerability feeds. Git is used only for explicit diff modes. Secret-like findings use redacted previews; raw secret values should not appear in terminal, JSON, SARIF, GitHub, Markdown, hotspot, or HTML output.
|
|
218
|
+
|
|
219
|
+
## Stability Contract
|
|
220
|
+
|
|
221
|
+
The `0.1.x` line treats rule IDs, finding fingerprints, baseline identity, `gruff.analysis.v1`, `gruff.baseline.v1`, `gruff.hotspot.v1`, SARIF rendering, and CLI exit semantics as compatibility-sensitive. Breaking changes should be tagged as a future minor release and recorded in [`CHANGELOG.md`](CHANGELOG.md).
|
|
222
|
+
|
|
223
|
+
## How It Compares
|
|
224
|
+
|
|
225
|
+
| Tool | Relationship |
|
|
226
|
+
| --- | --- |
|
|
227
|
+
| `tsc` | Type checking. `gruff-ts` does not prove type correctness or replace compiler diagnostics. |
|
|
228
|
+
| ESLint | Rule-driven linting. `gruff-ts` adds scoring, baselines, reports, dashboard, and cross-file/project-quality signals. |
|
|
229
|
+
| Prettier / formatters | Formatting only. `gruff-ts` does not format code. |
|
|
230
|
+
| Knip / ts-prune | Focused unused export/dead-code tools. `gruff-ts` includes broader quality and security-oriented heuristics. |
|
|
231
|
+
| `npm audit` / dependency scanners | Advisory-backed dependency checks. `gruff-ts` reports local static signals and does not replace advisory feeds. |
|
|
275
232
|
|
|
276
233
|
## Development
|
|
277
234
|
|
|
@@ -283,16 +240,17 @@ npm run start-dev
|
|
|
283
240
|
./bin/gruff-ts analyse . --fail-on=none
|
|
284
241
|
```
|
|
285
242
|
|
|
286
|
-
Source lives under `src/`: `src/cli.ts` is the
|
|
287
|
-
`src/cli-program.ts` owns Commander wiring, `src/analyser.ts` orchestrates the
|
|
288
|
-
scan, `src/rules.ts` holds the descriptor catalogue, and focused sibling
|
|
289
|
-
modules own rule packs and renderers. Tests live in focused `src/*.test.ts`
|
|
290
|
-
files.
|
|
243
|
+
Source lives under `src/`: `src/cli.ts` is the bootstrap, `src/cli-program.ts` owns Commander wiring, `src/analyser.ts` orchestrates scans, and focused sibling modules own rules and renderers.
|
|
291
244
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
245
|
+
## Documentation
|
|
246
|
+
|
|
247
|
+
- [Changelog](CHANGELOG.md)
|
|
248
|
+
- [Configuration](docs/configuration.md)
|
|
249
|
+
- [Rules catalogue](docs/rules.md)
|
|
250
|
+
- [Reports and CI](docs/reports-and-ci.md)
|
|
251
|
+
- [Release checklist](docs/releasing.md)
|
|
252
|
+
- [Contributing](CONTRIBUTING.md)
|
|
253
|
+
- [Security](SECURITY.md)
|
|
296
254
|
|
|
297
255
|
## Author
|
|
298
256
|
|
package/docs/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# gruff-ts docs
|
|
2
|
+
|
|
3
|
+
Use these docs with the top-level README for the stable user-facing surface.
|
|
4
|
+
|
|
5
|
+
## Core Docs
|
|
6
|
+
|
|
7
|
+
- [Configuration](configuration.md) - config discovery, schema, allowlists, and rule overrides.
|
|
8
|
+
- [Rules](rules.md) - rule IDs, severities, thresholds, and remediation guidance.
|
|
9
|
+
- [Output Formats](output-formats.md) - text, JSON, HTML, Markdown, GitHub annotations, hotspot, and SARIF.
|
|
10
|
+
- [CI Integration](ci-integration.md) - GitHub Actions, SARIF upload, baselines, and diff scans.
|
|
11
|
+
- [Dashboard](dashboard.md) - local dashboard flags and safety model.
|
|
12
|
+
- [Releasing](releasing.md) - release checks and packaging notes.
|
|
13
|
+
|
|
14
|
+
## Extra Docs
|
|
15
|
+
|
|
16
|
+
- [Reports And CI](reports-and-ci.md) - combined reporting and CI details retained for existing links.
|
|
17
|
+
|
|
18
|
+
## Shared Contract
|
|
19
|
+
|
|
20
|
+
Cross-language naming and CLI expectations live in
|
|
21
|
+
[`../../CONTRACT.md`](../../CONTRACT.md). TypeScript keeps `summary` analysis
|
|
22
|
+
flags as documented extensions while also supporting the common `--format` and
|
|
23
|
+
`--top` summary surface.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# CI Integration
|
|
2
|
+
|
|
3
|
+
gruff-ts is designed to run as a deterministic CI quality gate.
|
|
4
|
+
|
|
5
|
+
## GitHub Actions
|
|
6
|
+
|
|
7
|
+
```yaml
|
|
8
|
+
name: gruff-ts
|
|
9
|
+
|
|
10
|
+
on: [push, pull_request]
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
analyse:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
- uses: actions/setup-node@v4
|
|
18
|
+
with:
|
|
19
|
+
node-version: "22"
|
|
20
|
+
- run: npm ci
|
|
21
|
+
- run: ./bin/gruff-ts analyse src --format=sarif --fail-on=none > gruff-ts.sarif
|
|
22
|
+
- uses: github/codeql-action/upload-sarif@v3
|
|
23
|
+
with:
|
|
24
|
+
sarif_file: gruff-ts.sarif
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Quality Gate
|
|
28
|
+
|
|
29
|
+
For blocking jobs, choose the lowest severity that should fail the build:
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
./bin/gruff-ts analyse src --fail-on=warning
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Use `--fail-on=none` when the job should only publish reports.
|
|
36
|
+
|
|
37
|
+
## Baselines
|
|
38
|
+
|
|
39
|
+
Generate an adoption baseline after reviewing current findings:
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
./bin/gruff-ts analyse src --generate-baseline gruff-baseline.json --fail-on=none
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Future scans auto-apply `gruff-baseline.json` when present. Use
|
|
46
|
+
`--no-baseline` to audit the full unsuppressed result.
|
|
47
|
+
|
|
48
|
+
## Diff Scans
|
|
49
|
+
|
|
50
|
+
TypeScript supports working-tree, staged, unstaged, and base-ref diff scans:
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
./bin/gruff-ts analyse src --diff=working-tree --format=github --fail-on=warning
|
|
54
|
+
./bin/gruff-ts analyse src --diff=origin/main --format=json --fail-on=none
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Check
|
|
58
|
+
|
|
59
|
+
Run the local TypeScript gate before release:
|
|
60
|
+
|
|
61
|
+
```sh
|
|
62
|
+
npm run check
|
|
63
|
+
```
|
|
@@ -41,7 +41,6 @@ allowlists:
|
|
|
41
41
|
booleanPrefixes: [is, has, can, should, does, did, was, will, may, in, scan, supports, requires]
|
|
42
42
|
hungarianPrefixes: [str, obj, arr, bool, int, num]
|
|
43
43
|
placeholderNames: [foo, bar, baz, tmp, temp, thing, stuff, data, value, item]
|
|
44
|
-
abbreviationDenylist: [ctx, pkg, opts, fn, idx, cb]
|
|
45
44
|
negativeBooleanAllowed: [nostore, nofollow, noreferrer, noscript, noindex]
|
|
46
45
|
knownAcronyms: [url, http, https, id, xml, json, html, css, api, sql, db, io, ui, uuid, ip, tcp, udp, ast, cli, npm]
|
|
47
46
|
|
|
@@ -116,7 +115,6 @@ fingerprints:
|
|
|
116
115
|
| `booleanPrefixes` | `naming.boolean-prefix` | Replaces the accepted boolean-name prefixes such as `is`, `has`, `should`, `may`, `supports`, and `requires`. |
|
|
117
116
|
| `hungarianPrefixes` | `naming.hungarian-notation` | Replaces type-style prefixes to flag. |
|
|
118
117
|
| `placeholderNames` | `naming.identifier-quality`, `naming.generic-parameter` | Replaces placeholder words; numbered suffix checks stay active. |
|
|
119
|
-
| `abbreviationDenylist` | `naming.abbreviation` | Replaces the opt-in abbreviation denylist. |
|
|
120
118
|
| `negativeBooleanAllowed` | `naming.negative-boolean` | Replaces domain terms allowed to start with `no`. |
|
|
121
119
|
| `knownAcronyms` | `naming.acronym-case` | Replaces acronyms checked for mixed casing. |
|
|
122
120
|
|
|
@@ -165,6 +163,8 @@ gruff-ts list-rules
|
|
|
165
163
|
gruff-ts list-rules --format=json
|
|
166
164
|
```
|
|
167
165
|
|
|
166
|
+
See [Rules](./rules.md) for the full rule catalogue grouped by pillar.
|
|
167
|
+
|
|
168
168
|
## Example Project Config
|
|
169
169
|
|
|
170
170
|
```yaml
|
|
@@ -201,20 +201,3 @@ rules:
|
|
|
201
201
|
threshold: 12
|
|
202
202
|
severity: advisory
|
|
203
203
|
```
|
|
204
|
-
|
|
205
|
-
## Adoption Defaults
|
|
206
|
-
|
|
207
|
-
Two noisy-by-nature rules are present in the public catalogue but disabled by
|
|
208
|
-
default in this repo config:
|
|
209
|
-
|
|
210
|
-
```yaml
|
|
211
|
-
rules:
|
|
212
|
-
docs.todo-density:
|
|
213
|
-
enabled: false
|
|
214
|
-
naming.abbreviation:
|
|
215
|
-
enabled: false
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
`docs.todo-without-tracking` remains enabled because it checks whether a TODO
|
|
219
|
-
has owner, issue, date, ADR, or task context instead of counting raw TODO
|
|
220
|
-
markers.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Dashboard
|
|
2
|
+
|
|
3
|
+
`gruff-ts dashboard` serves a local browser dashboard for repeated analysis.
|
|
4
|
+
|
|
5
|
+
## Start
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
./bin/gruff-ts dashboard --host 127.0.0.1 --port 8767 --project-root .
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Options
|
|
12
|
+
|
|
13
|
+
| Option | Default | Purpose |
|
|
14
|
+
| --- | --- | --- |
|
|
15
|
+
| `--host` | `127.0.0.1` | Bind host. |
|
|
16
|
+
| `--port` | `8767` | Bind port. |
|
|
17
|
+
| `--project-root` | current directory | Initial project root. |
|
|
18
|
+
|
|
19
|
+
## Safety
|
|
20
|
+
|
|
21
|
+
The dashboard has no authentication and should stay bound to loopback unless the
|
|
22
|
+
network is trusted. The `/scan` endpoint analyses filesystem paths from request
|
|
23
|
+
parameters, so the bind address is the safety boundary.
|
|
24
|
+
|
|
25
|
+
## Polyglot Repos
|
|
26
|
+
|
|
27
|
+
`gruff-ts` defaults to port `8767`, `gruff-rs` defaults to `8766`, and Go, PHP,
|
|
28
|
+
and Python default to `8765`. Use `--port` when running multiple dashboards at
|
|
29
|
+
once.
|