eslint-plugin-ai-guard 1.4.8 → 1.4.9
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 +18 -5
- package/dist/cli/hook.js +13 -12
- package/dist/cli/index.js +66 -67
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +465 -147
- package/dist/index.mjs +1091 -773
- package/dist/mcp/server.js +15 -14
- package/package.json +9 -4
package/README.md
CHANGED
|
@@ -52,7 +52,7 @@ Measured on 12 November 2026 with 1.4.6. Methods, raw numbers and the commands t
|
|
|
52
52
|
- **0 of 1,361** real dependencies blocked (763 from 15 large open-source projects, 598 from 9 apps)
|
|
53
53
|
- **34 of 36** names from the 2017 crossenv malware campaign blocked
|
|
54
54
|
- **3.0%** of the 5,000 most-downloaded packages had a latest release under a day old, the window the fresh-release check covers
|
|
55
|
-
- **
|
|
55
|
+
- **33 of 33** rules give identical results in ESLint and Oxlint, checked in CI
|
|
56
56
|
|
|
57
57
|
It is engineered to detect reliability bugs, async hazards, security vulnerabilities, and code-scaffolding defects frequently introduced during AI-assisted development (GitHub Copilot, Cursor, Claude Code, Gemini Code Assist, etc.).
|
|
58
58
|
|
|
@@ -168,7 +168,7 @@ AI Guard includes **33 deterministic rules** divided into four specialized categ
|
|
|
168
168
|
| :--- | :---: | :--- | :---: |
|
|
169
169
|
| [`no-floating-promise`](./docs/rules/no-floating-promise.md) | **`error`** | Async function invocations without `await`, `.catch()`, or `return` — leading to silent dropped errors. | No (editor suggestions: `await`, or `void` if intended) |
|
|
170
170
|
| [`no-async-array-callback`](./docs/rules/no-async-array-callback.md) | `warn` | Async callbacks passed to `map()`, `filter()`, `forEach()`, or `reduce()` returning `Promise[]`. | No |
|
|
171
|
-
| [`no-await-in-loop`](./docs/rules/no-await-in-loop.md) | `warn` | Sequential `await` in loops where iterations can be safely executed concurrently with `Promise.all`. |
|
|
171
|
+
| [`no-await-in-loop`](./docs/rules/no-await-in-loop.md) | `warn` | Sequential `await` in loops where iterations can be safely executed concurrently with `Promise.all`. | Suggestion (`Promise.all`) |
|
|
172
172
|
| [`no-async-without-await`](./docs/rules/no-async-without-await.md) | `warn` | Functions declared `async` that never execute an `await` expression, adding unnecessary Promise overhead. | No |
|
|
173
173
|
| [`no-redundant-await`](./docs/rules/no-redundant-await.md) | `off`* | Redundant `return await` statements outside of `try...catch` blocks. | No |
|
|
174
174
|
|
|
@@ -205,6 +205,7 @@ Linting checks the code. These check the agent:
|
|
|
205
205
|
| [Agent hooks: Claude Code, Cursor, Codex](./docs/integrations/agents.md) | `ai-guard init-hooks` sets up every agent a project uses. Findings reach the agent after edits; before it finishes, the whole change is verified once; `git commit --no-verify` and risky installs are caught before they run. |
|
|
206
206
|
| [Pre-commit gate](./docs/integrations/git-hook.md) | `ai-guard init-git-hook` runs `verify --staged` on every commit through husky, lefthook, simple-git-hooks or pre-commit. Only problems the commit introduces block it. |
|
|
207
207
|
| [MCP tools](./docs/mcp-server.md) | `ai_guard_scan_file`, `ai_guard_scan_diff`, `ai_guard_scan_project`, `ai_guard_rules`, `ai_guard_check_integrity`, `ai_guard_verify_change`, `ai_guard_scan_agent_config`, `ai_guard_check_package`, and `ai_guard_fix` (a diff, unless `apply` is set). |
|
|
208
|
+
| [Kits and shared configs](./docs/integrations/kits.md) | Ship AI Guard rules in your own lint kit or preset: version ranges, what stays stable in 1.x, ESLint and Oxlint setup, and which rules to pick. |
|
|
208
209
|
|
|
209
210
|
---
|
|
210
211
|
|
|
@@ -350,7 +351,7 @@ npx eslint-plugin-ai-guard <command> [options] # not installed (first run, one
|
|
|
350
351
|
| `preset` | Interactively select and switch active preset in config | (Interactive prompt with automatic config patch & backup) |
|
|
351
352
|
| `ignore` | Add standard ignore paths (`.next`, `dist`, `build`) to config | (Patches flat config or legacy ignores safely) |
|
|
352
353
|
|
|
353
|
-
**`run` exit codes:** `0` no errors · `1` errors found (or `--max-warnings` exceeded) · `2` scan did not run — the file passed to `--path` matches a built-in ignore pattern (`node_modules/`, `dist/`, `build/`, `generated/`, `vendor/`, …), so nothing was analyzed. Directory scans skip ignored files silently
|
|
354
|
+
**`run` exit codes:** `0` no errors · `1` errors found (or `--max-warnings` exceeded) · `2` scan did not run — the file passed to `--path` matches a built-in ignore pattern (`node_modules/`, `dist/`, `build/`, `generated/`, `vendor/`, …), so nothing was analyzed, or a file could not be parsed and was not checked (install `@typescript-eslint/parser` for TypeScript; `--fail-on none` exits `0`). Directory scans skip ignored files silently.
|
|
354
355
|
|
|
355
356
|
### CLI Usage Examples
|
|
356
357
|
|
|
@@ -617,7 +618,7 @@ async function fetchAllUsers(ids: string[]) {
|
|
|
617
618
|
return users;
|
|
618
619
|
}
|
|
619
620
|
|
|
620
|
-
// ✅ GOOD: Concurrently fetched with Promise.all (
|
|
621
|
+
// ✅ GOOD: Concurrently fetched with Promise.all (editor suggestion)
|
|
621
622
|
async function fetchAllUsers(ids: string[]) {
|
|
622
623
|
return await Promise.all(ids.map((id) => fetchUser(id)));
|
|
623
624
|
}
|
|
@@ -665,7 +666,8 @@ npx eslint . --fix
|
|
|
665
666
|
| Rule | Automatic Fix Behavior |
|
|
666
667
|
| :--- | :--- |
|
|
667
668
|
| `no-hardcoded-secret` | Replaces hardcoded string literal with `process.env.VARIABLE_NAME` |
|
|
668
|
-
|
|
669
|
+
|
|
670
|
+
`no-await-in-loop` offers `await Promise.all(...)` as an editor suggestion only: running iterations in parallel changes their order and concurrency, so `--fix` never applies it.
|
|
669
671
|
|
|
670
672
|
`no-empty-catch` and `no-floating-promise` have no automatic fix on purpose. A fix that inserted a comment or `void` would make the finding disappear without handling the error, and an agent running `--fix` would do exactly that. Editors offer them as suggestions instead (rethrow; `await`, or `void` for an intended fire-and-forget call), which a person applies one at a time.
|
|
671
673
|
|
|
@@ -770,6 +772,10 @@ npx --yes --package eslint-plugin-ai-guard ai-guard-mcp
|
|
|
770
772
|
| `ai_guard_scan_project` | Scan a bounded workspace directory (at most 500 files; fails instead of truncating) |
|
|
771
773
|
| `ai_guard_rules` | List rules and presets, or look up specific rules (`rules: ["no-floating-promise"]`) with remediation and docs link |
|
|
772
774
|
| `ai_guard_check_integrity` | Report checks weakened by current Git changes (new suppressions, skipped/removed tests, lowered configs, removed CI steps), with `tier` and `hasBlockingFindings` |
|
|
775
|
+
| `ai_guard_verify_change` | One verdict before calling work done: introduced lint findings, weakened tests and agent-config issues (`pass`, `blocking`, `disclosures`) |
|
|
776
|
+
| `ai_guard_scan_agent_config` | Check CLAUDE.md, AGENTS.md, skills and MCP config for hidden text and prompt injection |
|
|
777
|
+
| `ai_guard_fix` | Apply deterministic autofixes to one file; returns a diff and writes only with `apply: true` |
|
|
778
|
+
| `ai_guard_check_package` | Check npm packages before installing them: missing names, look-alikes of popular packages, new or rarely used packages, install scripts (the only tool that uses the network: `registry.npmjs.org`) |
|
|
773
779
|
|
|
774
780
|
All tools declare an `outputSchema`; the text content is the same result as compact JSON. Scan tools accept `maxIssues` (default 50, errors first, exact `totalIssues` and `truncated`). The `verify_changes` prompt runs the scan → fix → rescan loop.
|
|
775
781
|
|
|
@@ -790,6 +796,13 @@ All tools declare an `outputSchema`; the text content is the same result as comp
|
|
|
790
796
|
|
|
791
797
|
The SDK in-memory and built STDIO integrations are tested, plus a headless Claude Code CLI smoke test (see the MCP guide for scope). Use the built checkout to test unreleased changes. Scan, fix, then rescan; a partial or failed scan is never clean. For setup, result status, limits, and client verification scope, see [**`docs/mcp-server.md`**](./docs/mcp-server.md).
|
|
792
798
|
|
|
799
|
+
### Glama listing
|
|
800
|
+
|
|
801
|
+
<a href="https://glama.ai/mcp/servers/ai-guard-dev/eslint-plugin-ai-guard"><img width="380" src="https://glama.ai/mcp/servers/ai-guard-dev/eslint-plugin-ai-guard/badge" alt="AI Guard MCP server" /></a>
|
|
802
|
+
|
|
803
|
+
AI Guard is listed on [Glama](https://glama.ai/mcp/servers/ai-guard-dev/eslint-plugin-ai-guard). There you can browse the server's tools, check its quality score, and test it online with [MCP Inspector](https://glama.ai/mcp/inspector).
|
|
804
|
+
|
|
805
|
+
|
|
793
806
|
---
|
|
794
807
|
|
|
795
808
|
## Learn More & Ecosystem
|