Skip to content

docs: incomplete config example#1463

Merged
michaelfaith merged 5 commits intomichaelfaith:mainfrom
OlivierZal:patch-1
Dec 22, 2025
Merged

docs: incomplete config example#1463
michaelfaith merged 5 commits intomichaelfaith:mainfrom
OlivierZal:patch-1

Conversation

@OlivierZal
Copy link
Contributor

PR Checklist

Overview

In the documentation, the following works:

// eslint.config.ts
import packageJson from "eslint-plugin-package-json";

export default [
	// your other ESLint configurations
	packageJson.configs.recommended,
	{
		rules: {
			"package-json/valid-package-definition": "off",
		},
	},
];

But the following:

// eslint.config.ts
import packageJson from "eslint-plugin-package-json";

export default [
	// your other ESLint configurations
	packageJson.configs.recommended,
	{
		rules: {
			"package-json/valid-package-definition": "error", // "error" instead of "off"
		},
	},
];

raises the following error:

Oops! Something went wrong! :(

ESLint: 9.39.2

A configuration object specifies rule "package-json/valid-package-definition", but could not find plugin "package-json".

Common causes of this problem include:

1. The "package-json" plugin is not defined in your configuration file.
2. The "package-json" plugin is not defined within the same configuration object in which the "package-json/valid-package-definition" rule is applied.

To fix it, it should be embedded in eslint's defineConfig method and include the files key:

// eslint.config.ts
import packageJson from "eslint-plugin-package-json";
import { defineConfig } from "eslint/config";

export default defineConfig(
	// your other ESLint configurations
	{
		extends: [packageJson.configs.recommended],
		files: ["package.json"],
		rules: {
			"package-json/valid-package-definition": "error",
		},
	},
);

Copilot AI review requested due to automatic review settings December 22, 2025 15:14
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR attempts to fix an incomplete configuration example in the documentation for overriding recommended rules. The author identified that the original example only worked when setting rules to "off" but not when setting them to "error". However, the proposed solution introduces unnecessary complexity and deviates from standard ESLint flat config patterns.

Key Changes:

  • Adds import for defineConfig from "eslint/config"
  • Changes configuration structure from array to single object wrapped in defineConfig
  • Uses extends property to extend the recommended config with overridden files and rules

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@michaelfaith
Copy link
Owner

Didn't realize we had Copilot enabled. That must be new. Though it was 0 for 3 this round 😆

@codecov
Copy link

codecov bot commented Dec 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.39%. Comparing base (5ecf56a) to head (de57dbc).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1463   +/-   ##
=======================================
  Coverage   97.39%   97.39%           
=======================================
  Files          28       28           
  Lines         575      575           
  Branches      169      169           
=======================================
  Hits          560      560           
  Misses          1        1           
  Partials       14       14           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Owner

@michaelfaith michaelfaith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks for taking this up.

As I mentioned in #1451 (comment), I'd like to include defineConfig in all of our examples for consistency. Let me know if you're planning to update this PR to include, and if not, I'll add it on top of your changes. I'll wait to hear back before making the update.

@michaelfaith
Copy link
Owner

@all-contributors please add @OlivierZal for docs

@allcontributors
Copy link
Contributor

@michaelfaith

I've put up a pull request to add @OlivierZal! 🎉

michaelfaith pushed a commit that referenced this pull request Dec 22, 2025
Adds @OlivierZal as a contributor for doc.

This was requested by michaelfaith [in this
comment](#1463 (comment))

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
@OlivierZal
Copy link
Contributor Author

Sure, @michaelfaith. Updated accordingly.

Copy link
Owner

@michaelfaith michaelfaith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome. Thanks again! 🚀

@michaelfaith michaelfaith changed the title fix(docs): incomplete config example docs: incomplete config example Dec 22, 2025
@michaelfaith michaelfaith enabled auto-merge (squash) December 22, 2025 22:53
@michaelfaith michaelfaith merged commit b0acd58 into michaelfaith:main Dec 22, 2025
15 checks passed
@OlivierZal OlivierZal deleted the patch-1 branch December 22, 2025 22:59
@github-actions
Copy link
Contributor

🎉 This is included in version v0.86.0 🎉

The release is available on:

Cheers! 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

📝 Documentation: misleading config example

3 participants