0.1.1 • Published 6 months ago

@muangchu/eslint-plugin-no-secrets v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

@muangchu/eslint-plugin-no-secrets

Disallow logging of sensitive information (PII) such as emails and phone numbers.

Installation

npm install eslint @eslint/js @muangchu/eslint-plugin-no-secrets --save-dev

Usage

Configuration (ESLint v9+)

//eslint.config.mjs file

import { defineConfig } from "eslint/config";
import js from "@eslint/js";

import noSecrets from "@muangchu/eslint-plugin-no-secrets";

export default defineConfig([
  {
    files: ["**/*.js"],
    plugins: {
      js,
      "no-secrets": noSecrets,
    },
    extends: ["js/recommended"],
    rules: {
      "no-unused-vars": "off",
      "no-undef": "off",
      "no-console": "off",
      "no-secrets/no-pii-logging": error,
      "no-secrets/no-sensitive-object-logging": error,
    },
  },
]);

For custom fields, objects and override default

//eslint.config.mjs file

import { defineConfig } from "eslint/config";
import js from "@eslint/js";

import noSecrets from "@muangchu/eslint-plugin-no-secrets";

export default defineConfig([
  {
    files: ["**/*.js"],
    plugins: {
      js,
      "no-secrets": noSecrets,
    },
    extends: ["js/recommended"],
    rules: {
      "no-secrets/no-pii-logging": [
        "error",
        {
          fields: ["foo", "_80001"], // add custom fields
		      override: true, //override default fields
        },
      ],
      "no-secrets/no-sensitive-object-logging": [
        "error",
        {
          objects: ["session", "authToken"], // add custom objects
		      override: true, //override default objects
        },
      ],
    },
  },
]);

Run

npx eslint .

Generate report

npx eslint . -f json -o eslint-report.json

Development

Run unit test

npm run test

Local development (using npm link)

In your plugin directory:

npm link

In your Express.js project:

npm link @muangchu/eslint-plugin-no-secrets
0.1.1

6 months ago

0.1.0

6 months ago

0.0.1

6 months ago