Skip to content

Commit

Permalink
feat: onboard eslint-plugin-package-json (#1269)
Browse files Browse the repository at this point in the history
## PR Checklist

- [x] Addresses an existing open issue: fixes #839
- [x] That issue was marked as [`status: accepting
prs`](https://github.com/JoshuaKGoldberg/create-typescript-app/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22)
- [x] Steps in
[CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/create-typescript-app/blob/main/.github/CONTRIBUTING.md)
were taken

## Overview

Directly swaps from the standalone `npm-package-json-lint` linter to
using `eslint-plugin-package-json` in the existing ESLint config. Fewer
tools, yay!
  • Loading branch information
JoshuaKGoldberg authored Jan 20, 2024
1 parent 25fb5e5 commit 592b0c8
Show file tree
Hide file tree
Showing 27 changed files with 131 additions and 363 deletions.
6 changes: 6 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ module.exports = {
"jsonc/no-comments": "off",
},
},
{
extends: ["plugin:package-json/recommended"],
files: ["package.json"],
parser: "jsonc-eslint-parser",
plugins: ["package-json"],
},
{
files: "**/*.test.ts",
rules: {
Expand Down
1 change: 0 additions & 1 deletion .github/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ Each should be shown in VS Code, and can be run manually on the command-line:
- `pnpm lint` ([ESLint](https://eslint.org) with [typescript-eslint](https://typescript-eslint.io)): Lints JavaScript and TypeScript source files
- `pnpm lint:knip` ([knip](https://github.com/webpro/knip)): Detects unused files, dependencies, and code exports
- `pnpm lint:md` ([Markdownlint](https://github.com/DavidAnson/markdownlint)): Checks Markdown source files
- `pnpm lint:package-json` ([npm-package-json-lint](https://npmpackagejsonlint.org/)): Lints the `package.json` file
- `pnpm lint:packages` ([pnpm dedupe --check](https://pnpm.io/cli/dedupe)): Checks for unnecessarily duplicated packages in the `pnpm-lock.yml` file
- `pnpm lint:spelling` ([cspell](https://cspell.org)): Spell checks across all source files

Expand Down
15 changes: 0 additions & 15 deletions .github/workflows/lint-package-json.yml

This file was deleted.

4 changes: 0 additions & 4 deletions .npmpackagejsonlintrc.json

This file was deleted.

2 changes: 1 addition & 1 deletion docs/Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Alternately, you can bypass that prompt by providing any number of the following
- `--exclude-lint-json`: Don't apply linting and sorting to `*.json` and `*.jsonc` files.
- `--exclude-lint-knip`: Don't add Knip to detect unused files, dependencies, and code exports.
- `--exclude-lint-md`: Don't apply linting to `*.md` files.
- `--exclude-lint-package-json`: Don't add npm-package-json-lint to lint for package.json correctness.
- `--exclude-lint-package-json`: Don't add eslint-plugin-package-json to lint for package.json correctness.
- `--exclude-lint-deprecation`: Don't use eslint-plugin-deprecation to report on usage of code marked as `@deprecated`.
- `--exclude-lint-eslint`: Don't use eslint-plugin-eslint-comment to enforce good practices around ESLint comment directives.
- `--exclude-lint-jsdoc`: Don't use eslint-plugin-jsdoc to enforce good practices around JSDoc comments.
Expand Down
8 changes: 1 addition & 7 deletions docs/Tooling.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,7 @@ pnpm lint:md
### Lint Package JSON

[`npm-package-json-lint`](https://github.com/tclindner/npm-package-json-lint): Linting for `package.json` files.

```shell
pnpm lint:package-json
```

> This is a separate linter from ESLint, but will likely eventually be switched to an ESLint plugin ([#839](https://github.com/JoshuaKGoldberg/create-typescript-app/issues/839)).
[`eslint-plugin-package-json`](https://github.com/JoshuaKGoldberg/eslint-plugin-package-json): Linting for `package.json` files.

### Lint Packages

Expand Down
9 changes: 2 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
"name": "create-typescript-app",
"version": "1.55.0",
"description": "Quickstart-friendly TypeScript template with comprehensive, configurable, opinionated tooling. 💝",
"repository": {
"type": "git",
"url": "https://github.com/JoshuaKGoldberg/create-typescript-app"
},
"repository": "JoshuaKGoldberg/create-typescript-app",
"license": "MIT",
"author": {
"name": "Josh Goldberg",
Expand All @@ -28,7 +25,6 @@
"lint": "eslint . .*js --max-warnings 0",
"lint:knip": "knip",
"lint:md": "markdownlint \"**/*.md\" \".github/**/*.md\" --rules sentences-per-line",
"lint:package-json": "npmPkgJsonLint .",
"lint:packages": "pnpm dedupe --check",
"lint:spelling": "cspell \"**\" \".github/**/*\"",
"prepare": "husky install",
Expand Down Expand Up @@ -84,6 +80,7 @@
"eslint-plugin-markdown": "^3.0.1",
"eslint-plugin-n": "^16.3.1",
"eslint-plugin-no-only-tests": "^3.1.0",
"eslint-plugin-package-json": "^0.10.0",
"eslint-plugin-perfectionist": "^2.5.0",
"eslint-plugin-regexp": "^2.1.2",
"eslint-plugin-vitest": "^0.3.10",
Expand All @@ -95,8 +92,6 @@
"lint-staged": "^15.2.0",
"markdownlint": "^0.33.0",
"markdownlint-cli": "^0.38.0",
"npm-package-json-lint": "^7.1.0",
"npm-package-json-lint-config-default": "^6.0.0",
"prettier-plugin-curly": "^0.1.3",
"prettier-plugin-packagejson": "^2.4.7",
"release-it": "^17.0.0",
Expand Down
Loading

0 comments on commit 592b0c8

Please sign in to comment.