Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Rules for consistent, readable, and valid package.json files. 🗂️

License

NotificationsYou must be signed in to change notification settings

chandu/eslint-plugin-package-json

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Rules for consistent, readable, and valid package.json files. 🗂️

All Contributors: 15 👪Codecov Test CoverageContributor CovenantLicense: MITStyle: Prettiernpm package version

Installation

This package requiresESLint 8 andjsonc-eslint-parser:

npm install eslint eslint-plugin-package-json jsonc-eslint-parser --save-dev

Usage

Flat Config

This plugin's recommended configuration enables its rules on**/package.json files, parsing them withjsonc-eslint-parser:

In your ESLint configuration file:

importpackageJsonfrom"eslint-plugin-package-json/configs/recommended";exportdefault[// your other ESLint configurationspackageJson,];

If you want to override the recommended rules:

importpackageJsonfrom"eslint-plugin-package-json/configs/recommended";exportdefault[// your other ESLint configurations{...packageJson,rules:{...packageJson.rules,"package-json/valid-package-def":"off",},},];

SeeESLint'sConfiguration Files guide for details on how to customize your rules and other config settings.

Legacy Config

Add an override to your ESLint configuration file that specifies this plugin,jsonc-eslint-parser, and its recommended rules for yourpackage.json file:

module.exports={overrides:[{extends:["plugin:package-json/recommended"],files:["package.json"],parser:"jsonc-eslint-parser",plugins:["package-json"],},],};

You may also want to individually configure rules.SeeESLint'sConfigure Rules guide for details on how to customize your rules.

module.exports={overrides:[{extends:["plugin:package-json/recommended"],files:["package.json"],parser:"jsonc-eslint-parser",plugins:["package-json"],rules:{"package-json/valid-package-def":"error",},},],};

Usage Alongside Prettier

prettier-plugin-packagejson is aPrettier plugin that enforces the samepackage.json keys ordering as theorder-properties andsort-collections rules with default options.We recommend using both the Prettier plugin andeslint-plugin-package-json's recommended configuration.The default settings don't conflict, and Prettier plugins can quickly fix up ordering in your editor on save and/or as a Git hook.

Supported Rules

💼 Configurations enabled in.
✅ Set in therecommended configuration.
🔧 Automatically fixable by the--fix CLI option.
💡 Manually fixable byeditor suggestions.

Name                      Description💼🔧💡
order-propertiesPackage properties must be declared in standard order🔧
repository-shorthandEnforce either object or shorthand declaration for repository.🔧
sort-collectionsDependencies, scripts, and configuration values must be declared in alphabetical order.🔧
unique-dependenciesEnforce that if repository directory is specified, it matches the path to the package.json file💡
valid-local-dependencyChecks existence of local dependencies in the package.json
valid-nameEnforce that package names are valid npm package names
valid-package-defEnforce that package.json has all properties required by the npm spec
valid-repository-directoryEnforce that if repository directory is specified, it matches the path to the package.json file💡
valid-versionEnforce that package versions are valid semver specifiers

These rules only run onpackage.json files; they will ignore all other files being linted.They can lintpackage.json files at project root and in any subfolder of the project, making this plugin great for monorepos.

Contributors

Alan
Alan

🐛💻
Andreas Lindberg
Andreas Lindberg

🐛
Anton Khitrenovich
Anton Khitrenovich

🤔
Azat S.
Azat S.

🤔💻
James
James

💻
James Zetlen
James Zetlen

💻🐛📖🚇🚧🔧
Jesús Leganés-Combarro
Jesús Leganés-Combarro

💻
Josh Goldberg ✨
Josh Goldberg ✨

🔧🐛💻🚇📖🚧🤔
Kendall Gassner
Kendall Gassner

💻🚧
Kristjan ESPERANTO
Kristjan ESPERANTO

🤔🐛💻
Nick Schonning
Nick Schonning

💻
Stephen
Stephen

💻
Stephen Zhou
Stephen Zhou

🐛💻🤔📖
Yosuke Ota
Yosuke Ota

🐛💻
b3rnhard
b3rnhard

🐛

Appreciation

Many thanks to@zetlen for creating the initial version and core infrastructure of this package! 💖

💙 This package was templated withcreate-typescript-app.

About

Rules for consistent, readable, and valid package.json files. 🗂️

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript92.2%
  • JavaScript7.7%
  • Shell0.1%

[8]ページ先頭

©2009-2025 Movatter.jp