This is an ESLint plugin to help suggest alternatives to various dependencies.
Primarily, it will help detect dependency tree bloat and redundant polyfills.
Note
The functionality of this plugin is now available in the @e18e/eslint-plugin, as well as many more performance and quality of life rules.
You can easily migrate by replacing eslint-plugin-depend with @e18e/eslint-plugin in your package.json and updating your ESLint config.
import e18e from '@e18e/eslint-plugin';
import {defineConfig} from 'eslint/config';
export default defineConfig([
e18e.configs.recommended,
]);npm i -D eslint-plugin-dependIf you're using the new flat config files, add to your eslint.config.js:
import depend from 'eslint-plugin-depend';
import {defineConfig} from 'eslint/config';
export default defineConfig([
{
files: ['**/*.js'],
plugins: {
depend
},
extends: ['depend/flat/recommended'],
}
]);For older legacy projects, add to your .eslintrc.json:
{
"extends": [
"plugin:depend/recommended"
]
}Some rules (e.g. ban-dependencies) can be used against your package.json.
You can achieve this by using @eslint/json or jsonc-eslint-parser.
For example, with @eslint/json and eslint.config.js:
import depend from 'eslint-plugin-depend';
import json from '@eslint/json';
import {defineConfig} from 'eslint/config';
export default defineConfig([
{
files: ['package.json'],
language: 'json/json',
plugins: {
depend,
json
},
extends: ['depend/flat/recommended'],
}
]);Or with jsonc-eslint-parser and .eslintrc.json:
{
"overrides": [
{
"files": ["package.json"],
"parser": "jsonc-eslint-parser",
"plugins": ["depend"],
"rules": {
"depend/ban-dependencies": "error"
}
}
]
}Read more at the
@eslint/json docs and
jsonc-eslint-parser docs.
MIT