npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

eslint-plugin-ai-guardrail

v0.1.0

Published

AI生成コードの典型的なミスを検出するESLintプラグイン

Readme

eslint-plugin-ai-guardrail

npm version License: MIT

AI生成コードの典型的なミスを検出するESLintプラグイン。

LLMが生成するコードに頻出する問題パターン(存在しないパッケージのimport、非推奨API使用、セキュリティリスクなど)を自動検出します。

Installation

npm install -D eslint-plugin-ai-guardrail

Usage

ESLint設定(flat config)

eslint.config.js に recommended 設定を追加:

import aiGuardrail from "eslint-plugin-ai-guardrail";

export default [
  aiGuardrail.configs.recommended,
  // ... 他の設定
];

個別にルールを設定する場合:

import aiGuardrail from "eslint-plugin-ai-guardrail";

export default [
  {
    plugins: {
      "ai-guardrail": aiGuardrail,
    },
    rules: {
      "ai-guardrail/no-hallucinated-imports": "error",
      "ai-guardrail/no-deprecated-api": "warn",
      "ai-guardrail/no-insecure-eval": "error",
      "ai-guardrail/no-unused-catch": "warn",
      "ai-guardrail/no-console-in-prod": "warn",
    },
  },
];

CLI

ESLint設定なしで直接実行:

npx ai-guardrail check src/
npx ai-guardrail check .

Rules

no-hallucinated-imports

package.json の dependencies に登録されていないパッケージの import を検出します。AIが存在しないパッケージ名を「幻覚」するケースに対応。

// NG: package.json に登録されていない
import foo from "nonexistent-package";
const bar = require("imaginary-lib");

// OK: 登録済みのパッケージ
import express from "express";

// OK: Node.js 組み込みモジュール
import fs from "node:fs";

// OK: 相対パス
import utils from "./utils";

no-deprecated-api

Node.js / React / Next.js の非推奨APIの使用を警告し、代替APIを提案します。

// NG: 非推奨API
url.parse("http://example.com");      // → new URL()
ReactDOM.render(<App />, root);        // → ReactDOM.createRoot().render()
util.isArray([1, 2]);                  // → Array.isArray()

// OK: 推奨API
const u = new URL("http://example.com");
ReactDOM.createRoot(root).render(<App />);
Array.isArray([1, 2]);

no-insecure-eval

eval()new Function() の使用を検出します。これらはコードインジェクション攻撃のリスクがあります。

// NG: セキュリティリスク
eval("alert(1)");
new Function("a", "return a + 1");
window.eval("code");

// OK: 安全な代替
JSON.parse('{"a":1}');

no-unused-catch

catch ブロックでエラーを適切に処理していないパターンを検出します。空の catch や console.log のみのケースを警告。

// NG: エラーを無視
try { foo(); } catch (e) { }
try { foo(); } catch (e) { console.log(e); }

// OK: 適切なエラーハンドリング
try { foo(); } catch (e) { throw e; }
try { foo(); } catch (e) { handleError(e); }
try { foo(); } catch (e) { console.error(e); reportError(e); }

no-console-in-prod

console.log / console.warn / console.error の残存を検出します。

// NG: 本番コードに残すべきでない
console.log("debug");
console.warn("warning");

// OK: allow オプションで許可
// ルール設定: ["warn", { "allow": ["error"] }]
console.error("critical error");

Development

# 依存パッケージのインストール
npm install

# ビルド
npm run build

# テスト
npm test

# テスト(watchモード)
npm run test:watch

Publishing to npm (for maintainers)

Prerequisites

  1. Create GitHub repository: https://github.com/imudak/ai-code-guardrail
  2. Push code to GitHub:
    git remote add origin https://github.com/imudak/ai-code-guardrail.git
    git push -u origin main
  3. Login to npm:
    npm login

Publish steps

  1. Update version in package.json (follow Semantic Versioning):

    npm version patch  # 0.1.0 → 0.1.1 (bug fixes)
    npm version minor  # 0.1.0 → 0.2.0 (new features, backward compatible)
    npm version major  # 0.1.0 → 1.0.0 (breaking changes)
  2. Update CHANGELOG.md with release notes

  3. Verify package contents:

    npm pack --dry-run
  4. Build before publishing (automatic via prepublishOnly script):

    npm run build
  5. Publish to npm:

    npm publish
  6. Create GitHub release:

    • Go to https://github.com/imudak/ai-code-guardrail/releases/new
    • Tag: v0.1.0 (match package.json version)
    • Title: v0.1.0
    • Description: Copy from CHANGELOG.md

Verify installation

After publishing, test installation:

mkdir test-install
cd test-install
npm init -y
npm install eslint-plugin-ai-guardrail

License

MIT