0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

eslint9のflat configでsonarjsのエラーが出たのに対応したメモ

Last updated at Posted at 2025-11-06

概要

Sonarjsのeslintプラグインを入れるときに少しハマったのでメモ。
eslint-plugin-sonarjsに記載された書きかただと下記エラーがでて動かない。

Oops! Something went wrong! :(

ESLint: 9.39.0

ConfigError: Config "UserConfig[0][1] > UserConfig[0][0] > ExtendedConfig[6]": Key "plugins": Cannot redefine plugin "sonarjs".

対応後のソース

調査

sonarsourceで下記のやり取りがされていた。

You are correct: our documentation is wrong.
We need to fix our documentation, I created a ticket to make sure that it is handled
ご指摘の通り、弊社のドキュメントは間違っています。
ドキュメントを修正する必要があるため、確実に処理されるようにチケットを作成しました。

待てば、ドキュメントは直るのだろう。

対応

修正した点は下記。

import eslint from '@eslint/js';
import { defineConfig, globalIgnores } from 'eslint/config';
import sonarjs from 'eslint-plugin-sonarjs';
import tseslint from 'typescript-eslint';

export default defineConfig([
  globalIgnores(['node_modules/', '.config/', 'dist/', 'tsconfig.json']),
  {
    extends: [
      eslint.configs.recommended,
      tseslint.configs.recommended,
      sonarjs.configs.recommended,
    ],
-    {
-    "plugins": {
-      sonarjs,
-    }
  }
  },
]);

参考

ESLintはv9に上げてからFlat Configに移行した方がやりやすそう
Fix Usage section of the documentation

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?