Git Product home page Git Product logo

eslint-plugin-package-json's Introduction

eslint-plugin-package-json

Rules for consistent, readable, and valid package.json files. πŸ—‚οΈ

All Contributors: 13 πŸ‘ͺ Codecov Test Coverage Contributor Covenant License: MIT Style: Prettier npm package version

Installation

This package requires ESLint 8 and jsonc-eslint-parser:

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

Usage

Add an override to your ESLint configuration file that specifies this plugin, jsonc-eslint-parser, and its recommended rules for your package.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. See ESLint's Configure 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 a Prettier plugin that enforces the same package.json keys ordering as the order-properties and sort-collections rules with default options. We recommend using both the Prettier plugin and extends: ["plugin:package-json/recommended"]. 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 the recommended configuration.
πŸ”§ Automatically fixable by the --fix CLI option.
πŸ’‘ Manually fixable by editor suggestions.

NameΒ Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β Β  Description πŸ’Ό πŸ”§ πŸ’‘
order-properties Package properties must be declared in standard order βœ… πŸ”§
prefer-repository-shorthand Enforce shorthand declaration for GitHub repository. βœ… πŸ”§
sort-collections Dependencies, scripts, and configuration values must be declared in alphabetical order. βœ… πŸ”§
unique-dependencies Enforce that if repository directory is specified, it matches the path to the package.json file βœ… πŸ’‘
valid-local-dependency Checks existence of local dependencies in the package.json βœ…
valid-name Enforce that package names are valid npm package names βœ… πŸ’‘
valid-package-def Enforce that package.json has all properties required by the npm spec βœ…
valid-repository-directory Enforce that if repository directory is specified, it matches the path to the package.json file βœ… πŸ’‘
valid-version Enforce that package versions are valid semver specifiers βœ… πŸ’‘

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

Contributors

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

πŸ’»
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 with create-typescript-app.

eslint-plugin-package-json's People

Contributors

joshuakgoldberg avatar renovate[bot] avatar kendallgassner avatar allcontributors[bot] avatar dependabot[bot] avatar azat-io avatar zamiell avatar zetlen avatar piranna avatar kristjanesperanto avatar nschonni avatar sirugh avatar ota-meshi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.