Skip to content

Commit

Permalink
Try out eslint-plugin-depend (#1803)
Browse files Browse the repository at this point in the history
Add `eslint-plugin-depend` as a dependency and use it with ESLint to
suggest alternatives to various dependencies with the goal of preventing
dependency tree bloat.

As of this commit the plugin does not detect any problems, but the idea
is that it would prevent problems from being introduced later OR being
detected as the plugin is updated.

As a testing example, replacing one of the `node:fs` imports as

    - import fs from "node:fs";
    + import fs from "fs-extra";

will cause the plugin to produce a lint error.
  • Loading branch information
ericcornelissen authored Dec 11, 2024
1 parent 99d0125 commit ef8b3e6
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
18 changes: 15 additions & 3 deletions config/eslint.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Check out ESLint at: https://eslint.org/

import ava from "eslint-plugin-ava";
import depend from "eslint-plugin-depend";
import jsdoc from "eslint-plugin-jsdoc";
import json from "@eslint/json";
import regexp from "eslint-plugin-regexp";
Expand Down Expand Up @@ -324,8 +325,11 @@ export default [
{
name: "Source",
files: ["src/**/*.js"],
plugins: { jsdoc, regexp, top },
plugins: { depend, jsdoc, regexp, top },
rules: {
// https://github.com/es-tooling/eslint-plugin-depend#readme
"depend/ban-dependencies": ["error"],

// https://github.com/gajus/eslint-plugin-jsdoc#readme
"jsdoc/check-values": [
"error",
Expand Down Expand Up @@ -549,8 +553,11 @@ export default [
{
name: "Tests",
files: ["test/**/*.js"],
plugins: { ava, jsdoc },
plugins: { ava, depend, jsdoc },
rules: {
// https://github.com/es-tooling/eslint-plugin-depend#readme
"depend/ban-dependencies": ["error"],

// https://github.com/gajus/eslint-plugin-jsdoc#readme
"jsdoc/check-values": [
"error",
Expand Down Expand Up @@ -598,8 +605,11 @@ export default [
{
name: "Scripts",
files: [".github/**/*.js", "script/**/*.js"],
plugins: { jsdoc },
plugins: { depend, jsdoc },
rules: {
// https://github.com/es-tooling/eslint-plugin-depend#readme
"depend/ban-dependencies": ["error"],

// https://github.com/gajus/eslint-plugin-jsdoc#readme
"jsdoc/check-values": [
"error",
Expand Down Expand Up @@ -645,6 +655,8 @@ export default [
// https://github.com/eslint/json/blob/main/README.md#rules
"json/no-duplicate-keys": ["error"],
"json/no-empty-keys": ["error"],
"json/no-unnormalized-keys": ["error"],
"json/no-unsafe-values": ["error"],
},
},
{
Expand Down
30 changes: 30 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"dotenv": "16.3.1",
"eslint": "9.14.0",
"eslint-plugin-ava": "15.0.0",
"eslint-plugin-depend": "0.12.0",
"eslint-plugin-jsdoc": "50.4.1",
"eslint-plugin-regexp": "2.6.0",
"eslint-plugin-yml": "1.14.0",
Expand Down

0 comments on commit ef8b3e6

Please sign in to comment.