I am writing a eslint-9 sharable-config that uses eslint-plugin-sonarjs
.
Hereβs my eslint config:
// index.js
import js from "@eslint/js";
import prettierConfig from "eslint-config-prettier";
import * as typescriptEslintPlugin from "@typescript-eslint/eslint-plugin";
import sonarjs from "eslint-plugin-sonarjs";
export default [
js.configs.recommended,
sonarjs.configs.recommended,
prettierConfig,
{
files: ["**/*.{js,ts,jsx,tsx}"],
languageOptions: {
globals: {
Atomics: "readonly",
SharedArrayBuffer: "readonly",
es6: true,
node: true,
},
parser: typescriptEslintPlugin.parser,
parserOptions: {
ecmaVersion: 2018,
sourceType: "module",
},
},
plugins: {
"@typescript-eslint": typescriptEslintPlugin,
sonarjs,
},
rules: {
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/consistent-type-assertions": [
"error",
{ assertionStyle: "angle-bracket" },
],
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/explicit-function-return-type": "off",
},
},
{
files: ["**/*(specs|tests)/**", "**/*.spec.ts"],
rules: {
"@typescript-eslint/no-empty-function": "off",
},
},
];
And hereβs the package.json for that sharable config:
{
"name": "@myscope/eslint-config",
"version": "2.1.3",
"main": "index.js",
"type": "module",
"license": "ISC",
"peerDependencies": {
"eslint": ">= 9"
},
"dependencies": {
"@eslint/js": "^9.14.0",
"@types/eslint__js": "^8.42.3",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-sonarjs": "^2.0.4",
"typescript-eslint": "^8.13.0"
}
}
I am getting conflicting peer dependencies with eslint-plugin-sonarjs
package:
$ npm i
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: @typescript-eslint/eslint-plugin@7.16.1
npm WARN Found: eslint@9.14.0
npm WARN node_modules/eslint
npm WARN peer eslint@">= 9" from the root project
npm WARN 10 more (@babel/eslint-parser, ...)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer eslint@"^8.56.0" from @typescript-eslint/eslint-plugin@7.16.1
npm WARN node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/eslint-plugin
npm WARN @typescript-eslint/eslint-plugin@"7.16.1" from eslint-plugin-sonarjs@2.0.4
npm WARN node_modules/eslint-plugin-sonarjs
npm WARN
npm WARN Conflicting peer dependency: eslint@8.57.1
npm WARN node_modules/eslint
npm WARN peer eslint@"^8.56.0" from @typescript-eslint/eslint-plugin@7.16.1
npm WARN node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/eslint-plugin
npm WARN @typescript-eslint/eslint-plugin@"7.16.1" from eslint-plugin-sonarjs@2.0.4
npm WARN node_modules/eslint-plugin-sonarjs
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: @typescript-eslint/parser@7.18.0
npm WARN Found: eslint@9.14.0
npm WARN node_modules/eslint
npm WARN peer eslint@">= 9" from the root project
npm WARN 10 more (@babel/eslint-parser, ...)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer eslint@"^8.56.0" from @typescript-eslint/parser@7.18.0
npm WARN node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/parser
npm WARN peer @typescript-eslint/parser@"^7.0.0" from @typescript-eslint/eslint-plugin@7.16.1
npm WARN node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/eslint-plugin
npm WARN
npm WARN Conflicting peer dependency: eslint@8.57.1
npm WARN node_modules/eslint
npm WARN peer eslint@"^8.56.0" from @typescript-eslint/parser@7.18.0
npm WARN node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/parser
npm WARN peer @typescript-eslint/parser@"^7.0.0" from @typescript-eslint/eslint-plugin@7.16.1
npm WARN node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/eslint-plugin
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: @typescript-eslint/utils@7.16.1
npm WARN Found: eslint@9.14.0
npm WARN node_modules/eslint
npm WARN peer eslint@">= 9" from the root project
npm WARN 10 more (@babel/eslint-parser, ...)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer eslint@"^8.56.0" from @typescript-eslint/utils@7.16.1
npm WARN node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/utils
npm WARN @typescript-eslint/utils@"7.16.1" from eslint-plugin-sonarjs@2.0.4
npm WARN node_modules/eslint-plugin-sonarjs
npm WARN 2 more (@typescript-eslint/eslint-plugin, @typescript-eslint/type-utils)
npm WARN
npm WARN Conflicting peer dependency: eslint@8.57.1
npm WARN node_modules/eslint
npm WARN peer eslint@"^8.56.0" from @typescript-eslint/utils@7.16.1
npm WARN node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/utils
npm WARN @typescript-eslint/utils@"7.16.1" from eslint-plugin-sonarjs@2.0.4
npm WARN node_modules/eslint-plugin-sonarjs
npm WARN 2 more (@typescript-eslint/eslint-plugin, @typescript-eslint/type-utils)
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: eslint-plugin-import@2.30.0
npm WARN Found: eslint@9.14.0
npm WARN node_modules/eslint
npm WARN peer eslint@">= 9" from the root project
npm WARN 10 more (@babel/eslint-parser, ...)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer eslint@"^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8" from eslint-plugin-import@2.30.0
npm WARN node_modules/eslint-plugin-sonarjs/node_modules/eslint-plugin-import
npm WARN eslint-plugin-import@"2.30.0" from eslint-plugin-sonarjs@2.0.4
npm WARN node_modules/eslint-plugin-sonarjs
npm WARN
npm WARN Conflicting peer dependency: eslint@8.57.1
npm WARN node_modules/eslint
npm WARN peer eslint@"^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8" from eslint-plugin-import@2.30.0
npm WARN node_modules/eslint-plugin-sonarjs/node_modules/eslint-plugin-import
npm WARN eslint-plugin-import@"2.30.0" from eslint-plugin-sonarjs@2.0.4
npm WARN node_modules/eslint-plugin-sonarjs
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: eslint-plugin-react-hooks@4.6.2
npm WARN Found: eslint@9.14.0
npm WARN node_modules/eslint
npm WARN peer eslint@">= 9" from the root project
npm WARN 10 more (@babel/eslint-parser, ...)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer eslint@"^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0" from eslint-plugin-react-hooks@4.6.2
npm WARN node_modules/eslint-plugin-sonarjs/node_modules/eslint-plugin-react-hooks
npm WARN eslint-plugin-react-hooks@"4.6.2" from eslint-plugin-sonarjs@2.0.4
npm WARN node_modules/eslint-plugin-sonarjs
npm WARN
npm WARN Conflicting peer dependency: eslint@8.57.1
npm WARN node_modules/eslint
npm WARN peer eslint@"^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0" from eslint-plugin-react-hooks@4.6.2
npm WARN node_modules/eslint-plugin-sonarjs/node_modules/eslint-plugin-react-hooks
npm WARN eslint-plugin-react-hooks@"4.6.2" from eslint-plugin-sonarjs@2.0.4
npm WARN node_modules/eslint-plugin-sonarjs
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: @typescript-eslint/type-utils@7.16.1
npm WARN Found: eslint@9.14.0
npm WARN node_modules/eslint
npm WARN peer eslint@">= 9" from the root project
npm WARN 10 more (@babel/eslint-parser, ...)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer eslint@"^8.56.0" from @typescript-eslint/type-utils@7.16.1
npm WARN node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/type-utils
npm WARN @typescript-eslint/type-utils@"7.16.1" from @typescript-eslint/eslint-plugin@7.16.1
npm WARN node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/eslint-plugin
npm WARN
npm WARN Conflicting peer dependency: eslint@8.57.1
npm WARN node_modules/eslint
npm WARN peer eslint@"^8.56.0" from @typescript-eslint/type-utils@7.16.1
npm WARN node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/type-utils
npm WARN @typescript-eslint/type-utils@"7.16.1" from @typescript-eslint/eslint-plugin@7.16.1
npm WARN node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/eslint-plugin
Additional information:
$ npm ls eslint
npm ERR! code ELSPROBLEMS
npm ERR! invalid: eslint@9.14.0 /home/me/github/eslint-config/node_modules/eslint
@myscope/eslint-config@2.1.3 /home/me//github/eslint-config
βββ¬ eslint-config-prettier@9.1.0
β βββ eslint@9.14.0 deduped
βββ¬ eslint-plugin-sonarjs@2.0.4
β βββ¬ @babel/eslint-parser@7.25.1
β β βββ eslint@9.14.0 deduped
β βββ¬ @typescript-eslint/eslint-plugin@7.16.1
β β βββ¬ @typescript-eslint/parser@7.18.0
β β β βββ eslint@9.14.0 deduped invalid: "^8.56.0" from node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/eslint-plugin, "^8.56.0" from node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/utils, "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8" from node_modules/eslint-plugin-sonarjs/node_modules/eslint-plugin-import, "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0" from node_modules/eslint-plugin-sonarjs/node_modules/eslint-plugin-react-hooks, "^8.56.0" from node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/parser
β β βββ¬ @typescript-eslint/type-utils@7.16.1
β β β βββ eslint@9.14.0 deduped invalid: "^8.56.0" from node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/eslint-plugin, "^8.56.0" from node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/utils, "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8" from node_modules/eslint-plugin-sonarjs/node_modules/eslint-plugin-import, "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0" from node_modules/eslint-plugin-sonarjs/node_modules/eslint-plugin-react-hooks, "^8.56.0" from node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/parser, "^8.56.0" from node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/type-utils
β β βββ eslint@9.14.0 deduped invalid: "^8.56.0" from node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/eslint-plugin
β βββ¬ @typescript-eslint/utils@7.16.1
β β βββ eslint@9.14.0 deduped invalid: "^8.56.0" from node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/eslint-plugin, "^8.56.0" from node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/utils
β βββ¬ eslint-plugin-import@2.30.0
β β βββ eslint@9.14.0 deduped invalid: "^8.56.0" from node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/eslint-plugin, "^8.56.0" from node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/utils, "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8" from node_modules/eslint-plugin-sonarjs/node_modules/eslint-plugin-import
β βββ¬ eslint-plugin-jsx-a11y@6.10.0
β β βββ eslint@9.14.0 deduped invalid: "^8.56.0" from node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/eslint-plugin, "^8.56.0" from node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/utils, "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8" from node_modules/eslint-plugin-sonarjs/node_modules/eslint-plugin-import
β βββ¬ eslint-plugin-react-hooks@4.6.2
β β βββ eslint@9.14.0 deduped invalid: "^8.56.0" from node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/eslint-plugin, "^8.56.0" from node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/utils, "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8" from node_modules/eslint-plugin-sonarjs/node_modules/eslint-plugin-import, "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0" from node_modules/eslint-plugin-sonarjs/node_modules/eslint-plugin-react-hooks
β βββ¬ eslint-plugin-react@7.36.1
β β βββ eslint@9.14.0 deduped invalid: "^8.56.0" from node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/eslint-plugin, "^8.56.0" from node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/utils, "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8" from node_modules/eslint-plugin-sonarjs/node_modules/eslint-plugin-import, "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0" from node_modules/eslint-plugin-sonarjs/node_modules/eslint-plugin-react-hooks
β βββ eslint@9.14.0 deduped
β βββ¬ vue-eslint-parser@9.4.3
β βββ eslint@9.14.0 deduped invalid: "^8.56.0" from node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/eslint-plugin, "^8.56.0" from node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/utils, "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8" from node_modules/eslint-plugin-sonarjs/node_modules/eslint-plugin-import, "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0" from node_modules/eslint-plugin-sonarjs/node_modules/eslint-plugin-react-hooks
βββ¬ eslint@9.14.0
β βββ¬ @eslint-community/eslint-utils@4.4.0
β βββ eslint@9.14.0 deduped invalid: "^8.56.0" from node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/eslint-plugin, "^8.56.0" from node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/utils, "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8" from node_modules/eslint-plugin-sonarjs/node_modules/eslint-plugin-import, "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0" from node_modules/eslint-plugin-sonarjs/node_modules/eslint-plugin-react-hooks
βββ¬ typescript-eslint@8.13.0
βββ¬ @typescript-eslint/eslint-plugin@8.13.0
β βββ eslint@9.14.0 deduped invalid: "^8.56.0" from node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/eslint-plugin, "^8.56.0" from node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/utils, "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8" from node_modules/eslint-plugin-sonarjs/node_modules/eslint-plugin-import, "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0" from node_modules/eslint-plugin-sonarjs/node_modules/eslint-plugin-react-hooks
βββ¬ @typescript-eslint/parser@8.13.0
β βββ eslint@9.14.0 deduped invalid: "^8.56.0" from node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/eslint-plugin, "^8.56.0" from node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/utils, "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8" from node_modules/eslint-plugin-sonarjs/node_modules/eslint-plugin-import, "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0" from node_modules/eslint-plugin-sonarjs/node_modules/eslint-plugin-react-hooks
βββ¬ @typescript-eslint/utils@8.13.0
βββ eslint@9.14.0 deduped invalid: "^8.56.0" from node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/eslint-plugin, "^8.56.0" from node_modules/eslint-plugin-sonarjs/node_modules/@typescript-eslint/utils, "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8" from node_modules/eslint-plugin-sonarjs/node_modules/eslint-plugin-import, "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0" from node_modules/eslint-plugin-sonarjs/node_modules/eslint-plugin-react-hooks