npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

eslint-plugin-node-dependencies

v0.12.0

Published

ESLint plugin to check Node.js dependencies.

Downloads

40,593

Readme

Introduction

eslint-plugin-node-dependencies is ESLint plugin to check Node.js dependencies.

::: This Plugin is still in an EXPERIMENTAL STATE :::

NPM license NPM version NPM downloads NPM downloads NPM downloads NPM downloads NPM downloads Build Status Coverage Status

:name_badge: Features

This ESLint plugin checks package.json and provides linting rules related to dependencies problems.

:book: Documentation

See documents.

:cd: Installation

npm install --save-dev eslint eslint-plugin-node-dependencies

Requirements

  • ESLint v6.0.0 and above
  • Node.js v14.16.0 and above

:book: Usage

Add node-dependencies to the plugins section of your eslint.config.js or .eslintrc configuration file (you can omit the eslint-plugin- prefix)
and either use one of the two configurations available (recommended) or configure the rules you want:

The recommended configuration (New Config)

The plugin.configs["flat/recommended"] config enables a subset of the rules that should be most useful to most users. See lib/configs/rules/recommended.ts for more details.

// eslint.config.js
import * as nodeDependenciesPlugin from "eslint-plugin-node-dependencies"

export default [
    ...nodeDependenciesPlugin.configs["flat/recommended"],
];

The recommended configuration (Legacy Config)

The plugin:node-dependencies/recommended config enables a subset of the rules that should be most useful to most users. See lib/configs/rules/recommended.ts for more details.

// .eslintrc.js
module.exports = {
    "plugins": [
        "node-dependencies"
    ],
    "extends": [
         // add more generic rulesets here, such as:
         // 'eslint:recommended',
        "plugin:node-dependencies/recommended"
    ]
}

Advanced Configuration

Override/add specific rules configurations. See also: http://eslint.org/docs/user-guide/configuring.

// eslint.config.js
import * as nodeDependenciesPlugin from "eslint-plugin-node-dependencies"

export default [
    {
        plugins: { "node-dependencies": nodeDependenciesPlugin }
        rules: {
            // Override/add rules settings here, such as:
            "node-dependencies/rule-name": "error"
        }
    }
];
// .eslintrc.js
module.exports = {
    "plugins": [
        "node-dependencies"
    ],
    "rules": {
        // Override/add rules settings here, such as:
        "node-dependencies/rule-name": "error"
    }
}

Parser Configuration

If you have specified a parser, you need to configure a parser for .json.

For example, if you are using the "@babel/eslint-parser", configure it as follows:

module.exports = {
  // ...
  extends: [ "plugin:node-dependencies/recommended"],
  // ...
  parser: "@babel/eslint-parser",
  // Add an `overrides` section to add a parser configuration for json.
  overrides: [
    {
      files: ["*.json", "*.json5"],
      parser: "jsonc-eslint-parser",
    },
  ],
  // ...
};

:white_check_mark: Rules

The --fix option on the command line automatically fixes problems reported by rules which have a wrench :wrench: below. The rules with the following star :star: are included in the plugin:node-dependencies/recommended config.

Possible Errors

| Rule ID | Description | | |:--------|:------------|:---| | node-dependencies/compat-engines | enforce the versions of the engines of the dependencies to be compatible. | :star: | | node-dependencies/no-dupe-deps | disallow duplicate dependencies. | :star: | | node-dependencies/valid-semver | enforce versions that is valid as a semantic version. | :star: |

Best Practices

| Rule ID | Description | | |:--------|:------------|:---| | node-dependencies/absolute-version | require or disallow absolute version of dependency. | | | node-dependencies/no-deprecated | disallow having dependencies on deprecate packages. | | | node-dependencies/no-restricted-deps | Disallows dependence on the specified package. | |

Stylistic Issues

| Rule ID | Description | | |:--------|:------------|:---| | node-dependencies/prefer-caret-range-version | require caret(^) version instead of range version. | :wrench: | | node-dependencies/prefer-tilde-range-version | require tilde(~) version instead of range version. | :wrench: |

Deprecated

  • :warning: We're going to remove deprecated rules in the next major release. Please migrate to successor/new rules.
  • :innocent: We don't fix bugs which are in deprecated rules since we don't have enough resources.

| Rule ID | Replaced by | |:--------|:------------| | node-dependencies/valid-engines | node-dependencies/compat-engines |

:rocket: To Do More Verification

Verify JSON

You can verify the JSON files by checking and installing eslint-plugin-jsonc.

Verify using JSON Schema

You can verify using JSON Schema by checking and installing eslint-plugin-json-schema-validator.

:beers: Contributing

Welcome contributing!

Please use GitHub's Issues/PRs.

Development Tools

  • npm test runs tests and measures coverage.
  • npm run update runs in order to update readme and recommended configuration.
  • npm run new [new rule name] runs to create the files needed for the new rule.
  • npm run docs:watch starts the website locally.

:couple: Related Packages

:lock: License

See the LICENSE file for license rights and limitations (MIT).