Skip to content

Development

After forking the repo from GitHub and installing pnpm, run the following:

Terminal window
git clone https://github.com/(your-name-here)/eslint-plugin-package-json
cd eslint-plugin-package-json
pnpm install

Run tsdown locally to build source files from src/ into output files in lib/:

Terminal window
pnpm build

Add --watch to run the builder in watch mode that continuously cleans and recreates lib/ as you save files:

Terminal window
pnpm build --watch

Run eslint-doc-generator to generate new skeleton doc pages for new rules or to update existing doc pages for updated rules:

Terminal window
pnpm docs:generate

Prettier is used to format code. It should be applied automatically when you save files in VS Code or make a Git commit.

To manually reformat all files, you can run:

Terminal window
pnpm format --write

This package includes a couple forms of linting to enforce consistent code quality and styling. Each will run at CI time, and can be run manually on the command-line:

  • pnpm lint (ESLint): Lints all source files
  • pnpm lint:knip (knip): Detects unused files, dependencies, and code exports

Read the individual documentation for each tool to understand how it can be configured and used best.

For example, ESLint can be run with --fix to auto-fix some lint rule violations:

Terminal window
pnpm lint --fix

Vitest is used for tests. You can run it locally on the command-line:

Terminal window
pnpm test

Add the --coverage flag to compute test coverage and place reports in the coverage/ directory:

Terminal window
pnpm test --coverage

Note that console-fail-test is enabled for all test runs. Calls to console.log, console.warn, and other console methods will cause a test to fail.

We recommend using the official Vitest VSCode extension to run and / or debug individual tests (or entire test suites).

You should be able to see suggestions from TypeScript in your editor for all open files.

However, it can be useful to run the TypeScript command-line (tsc) to type check all files in src/:

Terminal window
pnpm typecheck

Add --watch to keep the type checker running in a watch mode that updates the display as you save files:

Terminal window
pnpm typecheck --watch

If you’d like to work on aspects of the website, these commands might come in helpful. The site is built using ✨Starlight for Astro.

You can spin up a local instance of the server by running astro dev. This will serve the site in “watch” mode, so that updates you make will reflect in the site as you make them. This will serve the site on http://localhost:3000/.

Terminal window
pnpm site:dev

To create a production build for testing, you can run a combination of the “build” and “preview” commands. This will create a production build of the site, and serve the statically generated assets locally on the dev server. This, importantly, is not running in “watch” mode, and won’t react to changes to the source files.

Terminal window
pnpm site:build
pnpm site:preview