JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 97
  • Score
    100M100P100Q95786F
  • License MIT

ESlint plugin for linting package json.

Package Exports

  • @git-validator/eslint-plugin-packagejson

Readme

@git-validator/eslint-plugin-packagejson

PRs Welcome

ESlint plugin for linting package.json.

Features

  • Lint package.jsons in your project.
  • Simple. Tiny. Fast.
  • Zero dependencies.

Usage

Install

pnpm add -D eslint @git-validator/eslint-plugin-packagejson

Config eslint.config.js

import * as packagejsonPlugin from "@git-validator/eslint-plugin-packagejson";

export default [
  {
    files: ["**/package.json"],
    processor: "packagejson/processor",
    plugins: {
      packagejson: packagejsonPlugin,
    },
    rules: {
      /**
       * Force 'default' field on the bottom of 'exports'.
       */
      "packagejson/bottom-default": "error",
      /**
       * `dependencies` and `devDependencies` are expected exact package versions.
       * Versions like`"foo": "^1.0.0"` are not allowed.
       */
      "packagejson/exact-dependency-version": "error",
      /**
       * In monorepo, root 'package.json' should be private.
       */
      "packagejson/private-workspace-root": "error",
      /**
       * The root package.json should specify `engines` field.
       */
      "packagejson/required-engines": "error",
      /**
       * Public package should specify its repository address.
       */
      "packagejson/required-repository": "error",
      /**
       * Force 'types' field on the top of 'exports'.
       */
      "packagejson/top-types": "error",
      /**
       * Force 'type' field to be 'module'. It means your project should be ESM.
       */
      "packagejson/type-module": "warn",
      /**
       * In monorepo, root 'package.json' should not install any packages to 'dependencies'.
       */
      "packagejson/no-dependencies-in-workspace-root": "warn",
    },
  },
];

Config package.json

{
  "scripts": {
    "lint": "eslint .",
    "lint:fix": "eslint . --fix"
  }
}

License

MIT