# \`eslint-plugin-sonarjs\` doesn’t work with eslint 9.15.0

**URL:** <https://community.sonarsource.com/t/eslint-plugin-sonarjs-doesn-t-work-with-eslint-9-15-0/130771>\
**Category:** SonarQube for IDE\
**Tags:** eslint\
**Created:** [November 20, 2024, 9:21am UTC](https://community.sonarsource.com/t/eslint-plugin-sonarjs-doesn-t-work-with-eslint-9-15-0/130771 "2024-11-20T09:21:42Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adrien-D](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/adrien-d/32/64315_2.png) [@Adrien-D](https://community.sonarsource.com/u/Adrien-D)\
**Post date:** [November 20, 2024, 9:21am UTC](https://community.sonarsource.com/t/eslint-plugin-sonarjs-doesn-t-work-with-eslint-9-15-0/130771/1 "2024-11-20T09:21:42Z")

</div>

Working with

- `eslint 9.15.0`
- `eslint-plugin-sonarjs 2.0.4`

I get this error

```auto
TypeError: Error while loading rule 'sonarjs/no-empty-function': Cannot read properties of undefined (reading 'allow')
Occurred while linting /Users/adrien/dev/myco/mystuff-mono/services/ui/src/test-setup.ts
    at Object.create (/Users/adrien/dev/myco/mystuff-mono/services/ui/node_modules/eslint/lib/rules/no-empty-function.js:125:18)
    at create (/Users/adrien/dev/myco/mystuff-mono/services/ui/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-empty-function.js:55:32)
    at Object.create (/Users/adrien/dev/myco/mystuff-mono/services/ui/node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/utils/dist/eslint-utils/RuleCreator.js:37:20)
    at Object.create (/Users/adrien/dev/myco/mystuff-mono/services/ui/node_modules/eslint-plugin-sonarjs/cjs/typescript-eslint/sanitize.js:36:25)
    at Object.create (/Users/adrien/dev/myco/mystuff-mono/services/ui/node_modules/eslint-plugin-sonarjs/cjs/helpers/decorators/interceptor.js:84:25)
    at createRuleListeners (/Users/adrien/dev/myco/mystuff-mono/services/ui/node_modules/eslint/lib/linter/linter.js:944:21)
    at /Users/adrien/dev/myco/mystuff-mono/services/ui/node_modules/eslint/lib/linter/linter.js:1082:84
    at Array.forEach (<anonymous>)
    at runRules (/Users/adrien/dev/myco/mystuff-mono/services/ui/node_modules/eslint/lib/linter/linter.js:1013:34)
    at #flatVerifyWithoutProcessors (/Users/adrien/dev/myco/mystuff-mono/services/ui/node_modules/eslint/lib/linter/linter.js:1911:31)

```

It looks pretty familiar to [this typescript-eslint issue](https://github.com/typescript-eslint/typescript-eslint/issues/10338) which was fixed by [this PR](https://github.com/typescript-eslint/typescript-eslint/pull/10339)

---

<div class="post-metadata">

**Author:** ![Yassin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/yassin/32/36096_2.png) [@Yassin](https://community.sonarsource.com/u/Yassin)\
**Post date:** [November 21, 2024, 10:39am UTC](https://community.sonarsource.com/t/eslint-plugin-sonarjs-doesn-t-work-with-eslint-9-15-0/130771/3 "2024-11-21T10:39:23Z")

</div>

Hello @Adrien-D,

Welcome to the Sonar community, and thank you for your feedback!

I apologize for the compatibility issue between the SonarJS ESLint plugin and ESLint version 9.15. We are aware of this problem and are actively working on a solution. We plan to release a fixed version of the plugin by the end of next week.

In the meantime, we recommend using ESLint version 9.14 as a temporary workaround.

I hope this helps!

Best regards,  
Yassin

---

<div class="post-metadata">

**Author:** ![David\_Gettins](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/david_gettins/32/62917_2.png) [@David\_Gettins](https://community.sonarsource.com/u/David_Gettins)\
**Post date:** [November 25, 2024, 1:30pm UTC](https://community.sonarsource.com/t/eslint-plugin-sonarjs-doesn-t-work-with-eslint-9-15-0/130771/5 "2024-11-25T13:30:42Z")

</div>

While we wait for a fix, the below patch gets things working for me. My intention is to remove the patch when the sonarjs fix is out.

```auto
diff --git a/node_modules/eslint/lib/.DS_Store b/node_modules/eslint/lib/.DS_Store
new file mode 100644
index 0000000..23bac10
Binary files /dev/null and b/node_modules/eslint/lib/.DS_Store differ
diff --git a/node_modules/eslint/lib/rules/no-empty-function.js b/node_modules/eslint/lib/rules/no-empty-function.js
index 16e611b..665e388 100644
--- a/node_modules/eslint/lib/rules/no-empty-function.js
+++ b/node_modules/eslint/lib/rules/no-empty-function.js
@@ -122,7 +122,8 @@ module.exports = {
     },
 
     create(context) {
- const [{ allow }] = context.options;
+ const [opts] = context.options;
+ const allow = opts?.allow ?? [];
         const sourceCode = context.sourceCode;
 
         /**
diff --git a/node_modules/eslint/lib/rules/no-unused-expressions.js b/node_modules/eslint/lib/rules/no-unused-expressions.js
index fd1437c..2973453 100644
--- a/node_modules/eslint/lib/rules/no-unused-expressions.js
+++ b/node_modules/eslint/lib/rules/no-unused-expressions.js
@@ -71,12 +71,11 @@ module.exports = {
     },
 
     create(context) {
- const [{
- allowShortCircuit,
- allowTernary,
- allowTaggedTemplates,
- enforceForJSX
- }] = context.options;
+ const [opts] = context.options;
+ const allowShortCircuit = opts?.allowShortCircuit ?? false;
+ const allowTernary = opts?.allowTernary ?? false;
+ const allowTaggedTemplates = opts?.allowTaggedTemplates ?? false;
+ const enforceForJSX = opts?.enforceForJSX ?? false;
 
         /**
          * Has AST suggesting a directive.

```

---

<div class="post-metadata">

**Author:** ![szape89](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/szape89/32/64937_2.png) [@szape89](https://community.sonarsource.com/u/szape89)\
**Post date:** [December 10, 2024, 9:32am UTC](https://community.sonarsource.com/t/eslint-plugin-sonarjs-doesn-t-work-with-eslint-9-15-0/130771/6 "2024-12-10T09:32:19Z")

</div>

A more active topic: [Eslint 9.15 breaks the eslint plugin - #9 by szape89](https://community.sonarsource.com/t/eslint-9-15-breaks-the-eslint-plugin/130724/9)

---

<div class="post-metadata">

**Author:** ![victor.diez](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/victor.diez/32/38525_2.png) [@victor.diez](https://community.sonarsource.com/u/victor.diez)\
**Post date:** [December 10, 2024, 9:56am UTC](https://community.sonarsource.com/t/eslint-plugin-sonarjs-doesn-t-work-with-eslint-9-15-0/130771/7 "2024-12-10T09:56:00Z")

</div>

Hello @David_Gettins and @Adrien-D,

can you please try with 3.0.1 and let us know if that fixes the issue, please?

Cheers

---

<div class="post-metadata">

**Author:** ![Adrien-D](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/adrien-d/32/64315_2.png) [@Adrien-D](https://community.sonarsource.com/u/Adrien-D)\
**Post date:** [December 10, 2024, 10:28am UTC](https://community.sonarsource.com/t/eslint-plugin-sonarjs-doesn-t-work-with-eslint-9-15-0/130771/8 "2024-12-10T10:28:03Z")

</div>

Hello Victor,

Thanks for getting back to me, I just tried with

- `eslint 9.16.0`
- `eslint-plugin-sonarjs 3.0.1`

and I get this error :

```auto
ESLint: 9.16.0

TypeError: Key "rules": Key "sonarjs/sonar-max-params": Could not find "sonar-max-params" in plugin "sonarjs".
 
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

```

---

<div class="post-metadata">

**Author:** ![victor.diez](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/victor.diez/32/38525_2.png) [@victor.diez](https://community.sonarsource.com/u/victor.diez)\
**Post date:** [December 10, 2024, 10:34am UTC](https://community.sonarsource.com/t/eslint-plugin-sonarjs-doesn-t-work-with-eslint-9-15-0/130771/9 "2024-12-10T10:34:12Z")

</div>

Hello,

yes, sorry I should have mentioned that since v3.0.0 we decided to drop some rules that were provided by other ESLint plugins. You can find the reasoning in [this other post](https://community.sonarsource.com/t/eslint-plugin-sonarjs-peerdependencies-conflicts/129999/5).

Cheers

---

<div class="post-metadata">

**Author:** ![Adrien-D](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/adrien-d/32/64315_2.png) [@Adrien-D](https://community.sonarsource.com/u/Adrien-D)\
**Post date:** [December 10, 2024, 5:07pm UTC](https://community.sonarsource.com/t/eslint-plugin-sonarjs-doesn-t-work-with-eslint-9-15-0/130771/10 "2024-12-10T17:07:55Z")

</div>

Ok so that fixes the issue, now everything is back to normal. Thanks for your support !
