Repository: un-ts/eslint-plugin-import-x
Pull request #360: fix: try/catch `enumerator.iterateFiles` gracefully
Author: login: JounQin
Labels: name: bug
description: Something isn't working
Created: 2025-05-30T23:36:51Z | Merged: 2025-05-31T00:41:31Z


<!-- ELLIPSIS_HIDDEN -->


> [!IMPORTANT]
> Improve error handling for `enumerator.iterateFiles` in `no-unused-modules.ts` with try/catch and update documentation for flat config compatibility.
> 
>   - **Error Handling**:
>     - Add try/catch block in `listFilesUsingFileEnumerator()` in `no-unused-modules.ts` to handle errors from `enumerator.iterateFiles`.
>     - Throws specific error if using flat config without `.eslintrc`.
>   - **Documentation**:
>     - Update `no-unused-modules.md` to clarify rule compatibility with flat config.
>   - **Dependencies**:
>     - Add `@types/tmp` and `tmp` to `package.json`.
>   - **Testing**:
>     - Add tests in `no-unused-modules.spec.ts` to verify error handling with ESLint v9.
> 
> <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=un-ts%2Feslint-plugin-import-x&utm_source=github&utm_medium=referral)<sup> for 1e09f8bc4e81969431c4211e8e4e8bf08fd20dbb. You can [customize](https://app.ellipsis.dev/un-ts/settings/summaries) this summary. It will automatically update as commits are pushed.</sup>

----


<!-- ELLIPSIS_HIDDEN -->

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **Bug Fixes**
  - Enhanced error handling during file processing to prevent crashes and deliver clearer messages when ESLint flat config is detected.
- **Documentation**
  - Clarified compatibility notes for the no-unused-modules rule regarding legacy and flat ESLint configurations.
- **Chores**
  - Added new test fixtures and configurations to support ESLint version 9 testing scenarios.
  - Updated development dependencies and test utilities to improve ESLint version detection and testing reliability.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->


Diff:
diff --git a/.changeset/curvy-swans-ring.md b/.changeset/curvy-swans-ring.md
new file mode 100644
index 00000000..2d667ac1
--- /dev/null
+++ b/.changeset/curvy-swans-ring.md
@@ -0,0 +1,5 @@
+---
+"eslint-plugin-import-x": patch
+---
+
+fix: try/catch `enumerator.iterateFiles` gracefully
diff --git a/.eslintrc.cjs b/.eslintrc.cjs
index 37b22a8d..2ca81d76 100644
--- a/.eslintrc.cjs
+++ b/.eslintrc.cjs
@@ -1,155 +1,3 @@
 // ! This file is here for testing `no-unused-modules` rule for eslintrc
 
-const { version } = require('eslint/package.json')
-
-const noEslintrc = +version.split('.')[0] > 8
-
-const testCompiled = process.env.TEST_COMPILED === '1'
-
-/** @type {import('eslint').Linter.Config} */
-module.exports = {
-  root: true,
-  reportUnusedDisableDirectives: true,
-  extends: [
-    'eslint:recommended',
-    'plugin:@typescript-eslint/recommended',
-    'plugin:eslint-plugin/recommended',
-    testCompiled && 'plugin:import-x/recommended',
-    'plugin:json/recommended-legacy',
-    'plugin:mdx/recommended',
-    'plugin:n/recommended',
-    !noEslintrc && 'plugin:unicorn/recommended',
-    'plugin:yml/standard',
-    'plugin:yml/prettier',
-    'plugin:prettier/recommended',
-  ].filter(Boolean),
-  env: {
-    node: true,
-    es6: true,
-    es2017: true,
-  },
-  parserOptions: {
-    sourceType: 'module',
-    ecmaVersion: 2020,
-  },
-  rules: {
-    '@typescript-eslint/no-non-null-assertion': 'off',
-    '@typescript-eslint/no-require-imports': 'off',
-
-    'no-constant-condition': noEslintrc ? 'error' : 'off',
-
-    'eslint-plugin/consistent-output': ['error', 'always'],
-    'eslint-plugin/meta-property-ordering': 'error',
-    'eslint-plugin/no-deprecated-context-methods': 'error',
-    'eslint-plugin/no-deprecated-report-api': 'off',
-    'eslint-plugin/prefer-replace-text': 'error',
-    'eslint-plugin/report-message-format': 'error',
-    'eslint-plugin/require-meta-docs-description': [
-      'error',
-      { pattern: String.raw`^(Enforce|Ensure|Prefer|Forbid).+\.$` },
-    ],
-    'eslint-plugin/require-meta-schema': 'error',
-    'eslint-plugin/require-meta-type': 'error',
-    'n/no-extraneous-require': 'off',
-    'n/no-missing-import': 'off',
-    'n/no-missing-require': 'off',
-    'n/no-unsupported-features/es-syntax': 'off',
-    ...(noEslintrc || {
-      'unicorn/filename-case': [
-        'error',
-        {
-          case: 'kebabCase',
-          ignore: [String.raw`^(CONTRIBUTING|README)\.md$`],
-        },
-      ],
-    }),
-    'unicorn/no-array-callback-reference': 'off',
-    'unicorn/no-array-reduce': 'off',
-    'unicorn/no-null': 'off',
-    'unicorn/prefer-module': 'off',
-    'unicorn/prevent-abbreviations': 'off',
-    'unicorn/prefer-at': 'off',
-    'unicorn/prefer-export-from': ['error', { ignoreUsedVariables: true }],
-
-    // dog fooding
-    ...(testCompiled && {
-      'import-x/no-extraneous-dependencies': [
-        'error',
-        {
-          devDependencies: ['test/**'],
-          optionalDependencies: false,
-          peerDependencies: true,
-          bundledDependencies: false,
-        },
-      ],
-      'import-x/unambiguous': 'off',
-    }),
-  },
-
-  overrides: [
-    {
-      files: ['*.ts'],
-      excludedFiles: ['test/fixtures'],
-      rules: {
-        '@typescript-eslint/array-type': [
-          2,
-          {
-            default: 'array-simple',
-          },
-        ],
-        '@typescript-eslint/consistent-type-definitions': ['error', 'type'],
-        '@typescript-eslint/consistent-type-imports': [
-          'error',
-          {
-            fixStyle: 'inline-type-imports',
-          },
-        ],
-        '@typescript-eslint/no-unused-vars': [
-          'error',
-          {
-            argsIgnorePattern: '^_',
-            varsIgnorePattern: '^_',
-          },
-        ],
-        ...(testCompiled && {
-          'import-x/consistent-type-specifier-style': 'error',
-          'import-x/order': [
-            'error',
-            {
-              alphabetize: {
-                order: 'asc',
-              },
-              'newlines-between': 'always',
-            },
-          ],
-        }),
-      },
-      settings: {
-        'import-x/resolver': {
-          typescript: {
-            project: 'tsconfig.base.json',
-          },
-        },
-      },
-    },
-    {
-      files: 'test/**',
-      env: {
-        jest: true,
-      },
-    },
-    {
-      files: 'global.d.ts',
-      rules: {
-        'import-x/no-extraneous-dependencies': 'off',
-      },
-    },
-    {
-      files: 'README.md',
-      rules: {
-        // https://github.com/bmish/eslint-doc-generator/issues/655
-        'no-irregular-whitespace': 'off',
-      },
-    },
-  ],
-}
+module.exports = {}
diff --git a/docs/rules/no-unused-modules.md b/docs/rules/no-unused-modules.md
index ea3ea21b..0dbc4b13 100644
--- a/docs/rules/no-unused-modules.md
+++ b/docs/rules/no-unused-modules.md
@@ -9,7 +9,7 @@ Reports:
 - dynamic imports are supported if argument is a literal string
 
 > [!IMPORTANT]
-> This rule is only compatible with legacy configs. If you make use of the new flat config, either do not enable this rule, or provide a legacy eslintrc config at the same time together for this rule to be functional.
+> This rule is only compatible with legacy configs. If you make use of the new flat config, either do not enable this rule, or provide a legacy eslintrc config (even empty) at the same time together for this rule to be functional.
 
 ## Rule Details
 
diff --git a/package.json b/package.json
index d9ff0d54..ab21c190 100644
--- a/package.json
+++ b/package.json
@@ -119,6 +119,7 @@
     "@types/klaw-sync": "^6.0.5",
     "@types/node": "^22.15.27",
     "@types/pnpapi": "^0.0.5",
+    "@types/tmp": "^0.2.6",
     "@typescript-eslint/eslint-plugin": "^8.33.0",
     "@typescript-eslint/parser": "^8.33.0",
     "@typescript-eslint/rule-tester": "^8.33.0",
@@ -153,6 +154,7 @@
     "redux": "^5.0.1",
     "simple-git-hooks": "^2.13.0",
     "tinyexec": "^1.0.1",
+    "tmp": "^0.2.3",
     "ts-node": "^10.9.2",
     "tsdown": "^0.12.5",
     "type-fest": "^4.41.0",
diff --git a/src/rules/no-unused-modules.ts b/src/rules/no-unused-modules.ts
index 9ed0533b..ae44a360 100644
--- a/src/rules/no-unused-modules.ts
+++ b/src/rules/no-unused-modules.ts
@@ -23,17 +23,62 @@ import {
 } from '../utils/index.js'
 
 // eslint-disable-next-line import-x/no-named-as-default-member -- incorrect types , commonjs actually
-const { FileEnumerator } = eslintUnsupportedApi
+const { FileEnumerator, shouldUseFlatConfig } = eslintUnsupportedApi
 
-function listFilesToProcess(src: string[], extensions: FileExtension[]) {
-  const enumerator = new FileEnumerator({
-    extensions,
-  })
+function listFilesUsingFileEnumerator(
+  src: string[],
+  extensions: FileExtension[],
+) {
+  // We need to know whether this is being run with flat config in order to
+  // determine how to report errors if FileEnumerator throws due to a lack of eslintrc.
+
+  const { ESLINT_USE_FLAT_CONFIG } = process.env
+
+  // This condition is sufficient to test in v8, since the environment variable is necessary to turn on flat config
+  let isUsingFlatConfig: boolean
+
+  // In the case of using v9, we can check the `shouldUseFlatConfig` function
+  // If this function is present, then we assume it's v9
+  try {
+    isUsingFlatConfig =
+      // @ts-expect-error -- only available in ESLint v9
+      shouldUseFlatConfig && ESLINT_USE_FLAT_CONFIG !== 'false'
+  } catch {
+    // We don't want to throw here, since we only want to init the
+    // boolean if the function is available.
+    isUsingFlatConfig =
+      !!ESLINT_USE_FLAT_CONFIG && ESLINT_USE_FLAT_CONFIG !== 'false'
+  }
+
+  const enumerator = new FileEnumerator({ extensions })
 
-  return Array.from(enumerator.iterateFiles(src), ({ filePath, ignored }) => ({
-    ignored,
-    filename: filePath,
-  }))
+  try {
+    return Array.from(
+      enumerator.iterateFiles(src),
+      ({ filePath, ignored }) => ({ filename: filePath, ignored }),
+    )
+  } catch (error) {
+    // If we're using flat config, and FileEnumerator throws due to a lack of eslintrc,
+    // then we want to throw an error so that the user knows about this rule's reliance on
+    // the legacy config.
+    if (
+      isUsingFlatConfig &&
+      (error as Error).message.includes('No ESLint configuration found')
+    ) {
+      throw new Error(`
+Due to the exclusion of certain internal ESLint APIs when using flat config,
+the import-x/no-unused-modules rule requires an .eslintrc file (even empty) to know which
+files to ignore (even when using flat config).
+The .eslintrc file only needs to contain "ignorePatterns", or can be empty if
+you do not want to ignore any files.
+
+See https://github.com/import-js/eslint-plugin-import/issues/3079
+for additional context.
+`)
+    }
+    // If this isn't the case, then we'll just let the error bubble up
+    throw error
+  }
 }
 
 const DEFAULT = 'default'
@@ -141,10 +186,13 @@ const resolveFiles = (
 ) => {
   const extensions = [...getFileExtensions(context.settings)]
 
-  const srcFileList = listFilesToProcess(src, extensions)
+  const srcFileList = listFilesUsingFileEnumerator(src, extensions)
 
   // prepare list of ignored files
-  const ignoredFilesList = listFilesToProcess(ignoreExports, extensions)
+  const ignoredFilesList = listFilesUsingFileEnumerator(
+    ignoreExports,
+    extensions,
+  )
   for (const { filename } of ignoredFilesList) ignoredFiles.add(filename)
 
   // prepare list of source files, don't consider files from node_modules
diff --git a/test/fixtures/eslint-v9/.gitignore b/test/fixtures/eslint-v9/.gitignore
new file mode 100644
index 00000000..3c3629e6
--- /dev/null
+++ b/test/fixtures/eslint-v9/.gitignore
@@ -0,0 +1 @@
+node_modules
diff --git a/test/fixtures/eslint-v9/.npmrc b/test/fixtures/eslint-v9/.npmrc
new file mode 100644
index 00000000..43c97e71
--- /dev/null
+++ b/test/fixtures/eslint-v9/.npmrc
@@ -0,0 +1 @@
+package-lock=false
diff --git a/test/fixtures/eslint-v9/eslint.config.mjs b/test/fixtures/eslint-v9/eslint.config.mjs
new file mode 100644
index 00000000..234dd455
--- /dev/null
+++ b/test/fixtures/eslint-v9/eslint.config.mjs
@@ -0,0 +1,22 @@
+import { importX } from 'eslint-plugin-import-x'
+import js from '@eslint/js'
+
+export default [
+  js.configs.recommended,
+  importX.flatConfigs.recommended,
+  {
+    files: ['**/*.{js,mjs,cjs}'],
+    languageOptions: {
+      ecmaVersion: 'latest',
+      sourceType: 'module',
+    },
+    ignores: ['eslint.config.mjs', 'node_modules/*'],
+    rules: {
+      'no-unused-vars': 'off',
+      'import-x/no-dynamic-require': 'warn',
+      'import-x/no-nodejs-modules': 'warn',
+      'import-x/no-unused-modules': ['warn', { unusedExports: true }],
+      'import-x/no-cycle': 'warn',
+    },
+  },
+]
diff --git a/test/fixtures/eslint-v9/package.json b/test/fixtures/eslint-v9/package.json
new file mode 100644
index 00000000..e6c57123
--- /dev/null
+++ b/test/fixtures/eslint-v9/package.json
@@ -0,0 +1,14 @@
+{
+  "name": "eslint-v9",
+  "version": "1.0.0",
+  "type": "module",
+  "main": "index.js",
+  "scripts": {
+    "lint": "eslint src --report-unused-disable-directives"
+  },
+  "devDependencies": {
+    "@eslint/js": "^9.17.0",
+    "eslint": "^9.17.0",
+    "eslint-plugin-import-x": "file:../../.."
+  }
+}
diff --git a/test/fixtures/eslint-v9/src/depth-zero.js b/test/fixtures/eslint-v9/src/depth-zero.js
new file mode 100644
index 00000000..09909817
--- /dev/null
+++ b/test/fixtures/eslint-v9/src/depth-zero.js
@@ -0,0 +1,3 @@
+import { foo } from './es6/depth-one-dynamic'
+
+foo()
diff --git a/test/fixtures/eslint-v9/src/exports.js b/test/fixtures/eslint-v9/src/exports.js
new file mode 100644
index 00000000..273385ec
--- /dev/null
+++ b/test/fixtures/eslint-v9/src/exports.js
@@ -0,0 +1,6 @@
+//import c from './exports';
+import { a, b } from './exports'
+
+import path from 'path'
+import fs from 'node:fs'
+import console from 'console'
diff --git a/test/rules/no-unused-modules.spec.ts b/test/rules/no-unused-modules.spec.ts
index 1395baef..6c161494 100644
--- a/test/rules/no-unused-modules.spec.ts
+++ b/test/rules/no-unused-modules.spec.ts
@@ -1,3 +1,5 @@
+import { execSync } from 'node:child_process'
+import type { ChildProcess } from 'node:child_process'
 import fs from 'node:fs'
 
 import { jest } from '@jest/globals'
@@ -7,8 +9,14 @@ import type { TSESLint } from '@typescript-eslint/utils'
 // eslint-disable-next-line import-x/default -- incorrect types
 import eslint8UnsupportedApi from 'eslint8.56/use-at-your-own-risk'
 import { RuleTester as ESLint9_FlatRuleTester } from 'eslint9'
+import { dirSync } from 'tmp'
 
-import { createRuleTestCaseFunctions, testFilePath, parsers } from '../utils.js'
+import {
+  createRuleTestCaseFunctions,
+  testFilePath,
+  parsers,
+  isESLint9,
+} from '../utils.js'
 import type { GetRuleModuleOptions, GetRuleModuleMessageIds } from '../utils.js'
 
 import { cjsRequire as require } from 'eslint-plugin-import-x'
@@ -1560,3 +1568,40 @@ for (const [name, FlatRuleTester] of [
     })
   })
 }
+
+;(isESLint9 ? describe : describe.skip)('with eslint 9+', () => {
+  it('provides meaningful error when eslintrc is not present', () => {
+    // Create temp directory outside of project root
+    const { name: tempDir, removeCallback } = dirSync({
+      unsafeCleanup: true,
+    })
+
+    // Copy example project to temp directory
+    // eslint-disable-next-line n/no-unsupported-features/node-builtins -- false positive
+    fs.cpSync(testFilePath('eslint-v9'), tempDir, {
+      recursive: true,
+    })
+
+    let errorMessage = ''
+
+    // We run `test-compiled` first, so that the plugin is already built
+    // But don't forget to run `yarn build` first if you're developing the rule or test case
+
+    // Install the plugin and run the lint command in the temp directory
+    try {
+      execSync(`npm install -D ${process.cwd()} && npm run lint`, {
+        cwd: tempDir,
+      })
+    } catch (error) {
+      errorMessage = (error as ChildProcess).stderr!.toString()
+    }
+
+    // Verify that the error message is as expected
+    expect(errorMessage).toContain(
+      'the import-x/no-unused-modules rule requires an .eslintrc file (even empty)',
+    )
+
+    // Cleanup
+    removeCallback()
+  }, 100_000)
+})
diff --git a/test/utils.ts b/test/utils.ts
index 34c4749d..7e02aa57 100644
--- a/test/utils.ts
+++ b/test/utils.ts
@@ -6,6 +6,7 @@ import type {
   RunTests as TSESLintRunTests,
 } from '@typescript-eslint/rule-tester'
 import type { RuleModule } from '@typescript-eslint/utils/ts-eslint'
+import eslintPkg from 'eslint/package.json'
 import * as semver from 'semver'
 import typescriptPkg from 'typescript/package.json'
 
@@ -22,6 +23,8 @@ export const parsers = {
   HERMES: require.resolve('hermes-eslint'),
 }
 
+export const isESLint9 = semver.satisfies(eslintPkg.version, '>=9')
+
 export function tsVersionSatisfies(specifier: string) {
   return semver.satisfies(typescriptPkg.version, specifier)
 }
diff --git a/yarn.lock b/yarn.lock
index 1a9ab993..194812d8 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3913,6 +3913,13 @@ __metadata:
   languageName: node
   linkType: hard
 
+"@types/tmp@npm:^0.2.6":
+  version: 0.2.6
+  resolution: "@types/tmp@npm:0.2.6"
+  checksum: 10c0/a11bfa2cd8eaa6c5d62f62a3569192d7a2c28efdc5c17af0b0551db85816b2afc8156f3ca15ac76f0b142ae1403f04f44279871424233a1f3390b2e5fc828cd0
+  languageName: node
+  linkType: hard
+
 "@types/treeify@npm:^1.0.0":
   version: 1.0.3
   resolution: "@types/treeify@npm:1.0.3"
@@ -5951,6 +5958,7 @@ __metadata:
     "@types/klaw-sync": "npm:^6.0.5"
     "@types/node": "npm:^22.15.27"
     "@types/pnpapi": "npm:^0.0.5"
+    "@types/tmp": "npm:^0.2.6"
     "@typescript-eslint/eslint-plugin": "npm:^8.33.0"
     "@typescript-eslint/parser": "npm:^8.33.0"
     "@typescript-eslint/rule-tester": "npm:^8.33.0"
@@ -5993,6 +6001,7 @@ __metadata:
     simple-git-hooks: "npm:^2.13.0"
     stable-hash: "npm:^0.0.5"
     tinyexec: "npm:^1.0.1"
+    tmp: "npm:^0.2.3"
     ts-node: "npm:^10.9.2"
     tsdown: "npm:^0.12.5"
     type-fest: "npm:^4.41.0"
@@ -12348,6 +12357,13 @@ __metadata:
   languageName: node
   linkType: hard
 
+"tmp@npm:^0.2.3":
+  version: 0.2.3
+  resolution: "tmp@npm:0.2.3"
+  checksum: 10c0/3e809d9c2f46817475b452725c2aaa5d11985cf18d32a7a970ff25b568438e2c076c2e8609224feef3b7923fa9749b74428e3e634f6b8e520c534eef2fd24125
+  languageName: node
+  linkType: hard
+
 "tmpl@npm:1.0.5":
   version: 1.0.5
   resolution: "tmpl@npm:1.0.5"


Reviews:
user: login: petercat-assistant[bot]
state: COMMENTED
author_association: NONE
submitted_at: 2025-05-30T23:37:07Z
user: login: copilot-pull-request-reviewer[bot]
body: ## Pull Request Overview

This PR updates the file enumeration logic in the `no-unused-modules` rule to handle errors from `FileEnumerator.iterateFiles` more gracefully under ESLint flat config.

- Added detection for flat config via `shouldUseFlatConfig` and `ESLINT_USE_FLAT_CONFIG`
- Wrapped `iterateFiles` calls in try/catch to rethrow a clearer error when no configuration is found
- Renamed `listFilesToProcess` to `listFilesUsingFileEnumerator` for clarity

### Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

| File                                 | Description                                                  |
| ------------------------------------ | ------------------------------------------------------------ |
| src/rules/no-unused-modules.ts       | Enhanced file enumeration with flat config detection and improved error handling |
| .changeset/curvy-swans-ring.md       | Added changelog entry for the new graceful error handling   |


<details>
<summary>Comments suppressed due to low confidence (1)</summary>

**src/rules/no-unused-modules.ts:55**
* This new try/catch branch for `iterateFiles` should have accompanying unit tests covering both the flat-config error path and the normal path to ensure correct behavior.
```
  try {
```
</details>


state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-30T23:37:28Z
user: login: ellipsis-dev[bot]
body: > [!IMPORTANT]
> **Looks good to me!  :+1:**
> <details>
> <summary>Reviewed everything up to 666a0ab46a7a8d824910291da4dadf1c1f516e9c in <ellipsistime>1 minute and 47 seconds</ellipsistime>. Click for details.</summary> 
> 
> - Reviewed `103` lines of code in `2` files
> - Skipped `0` files when reviewing.
> - Skipped posting `4` draft comments. View those below.
> - Modify your [settings](https://app.ellipsis.dev/un-ts/settings/code-review) and [rules](https://app.ellipsis.dev/un-ts/code-review/rules) to customize what types of comments Ellipsis leaves. And don't forget to react with :+1: or :-1: to teach Ellipsis.
> 
> <details>
> <summary>1. <code>.changeset/curvy-swans-ring.md:5</code></summary>
> 
> - **Draft comment:** 
> Changeset message is clear and concise.
> - **Reason this comment was not posted:**
> Confidence changes required: `0%` <= threshold `50%` None
> 
> 
> </details>
> 
> <details>
> <summary>2. <code>src/rules/no-unused-modules.ts:26</code></summary>
> 
> - **Draft comment:** 
> Destructure 'shouldUseFlatConfig' along with 'FileEnumerator'. Ensure its API is used correctly—if it's a function in ESLint v9, consider invoking it (e.g. shouldUseFlatConfig()) rather than using it directly.
> - **Reason this comment was not posted:**
> Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50% The code already destructures shouldUseFlatConfig correctly. The comment suggests using it as a function call, but looking at lines 43-45, it's clear the code intentionally uses it as a boolean check with a ts-expect-error comment indicating this is the correct usage for ESLint v9. The comment seems to misunderstand the intended usage. Could there be documentation or ESLint v9 API specs that show shouldUseFlatConfig should be used as a function? Could the ts-expect-error be masking a real type issue? The code's usage matches the comments around it explaining ESLint v9 compatibility. The ts-expect-error is explicitly explained as handling the v9-only API. The boolean usage appears intentional and correct. The comment should be deleted as it incorrectly suggests changing working code that is already handling the API correctly for both v8 and v9 compatibility.
> 
> 
> </details>
> 
> <details>
> <summary>3. <code>src/rules/no-unused-modules.ts:42</code></summary>
> 
> - **Draft comment:** 
> The try/catch block initializing 'isUsingFlatConfig' safely handles potential issues. Verify whether 'shouldUseFlatConfig' should be invoked as a function (e.g. shouldUseFlatConfig()) in ESLint v9 rather than accessed directly.
> - **Reason this comment was not posted:**
> Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 0% vs. threshold = 50% The code is specifically handling ESLint v9 compatibility. The comment suggests a potential bug where shouldUseFlatConfig might be a function rather than a property in v9. However, without being able to verify the ESLint v9 API directly, I can't be 100% certain if shouldUseFlatConfig is meant to be a function or property. The code has a @ts-expect-error suggesting some uncertainty about the types. I don't have direct access to ESLint v9's API documentation or source code to verify if shouldUseFlatConfig is definitely a function. The existing code may already be correct. While the comment raises a valid question about the API usage, without clear evidence that shouldUseFlatConfig is definitely a function in v9, we can't be certain the current code is wrong. Since we don't have strong evidence that the current code is incorrect, and the comment is speculative about how the API should be used, we should remove this comment.
> 
> 
> </details>
> 
> <details>
> <summary>4. <code>src/rules/no-unused-modules.ts:68</code></summary>
> 
> - **Draft comment:** 
> The multi-line error message template includes a leading newline. Consider trimming it to avoid unintended formatting in the error output.
> - **Reason this comment was not posted:**
> Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 10% vs. threshold = 50% The leading newline is likely intentional to ensure the error message displays cleanly in the terminal. Error messages often benefit from starting on a new line for readability. The current format makes the message more readable and easier to distinguish from the stack trace. Removing the newline could make the error harder to read. The comment could be right that the newline is unintended. Maybe there are ESLint error message formatting conventions I'm not aware of. Even if there are conventions, the readability benefit of the newline likely outweighs strict adherence to a format. The current format serves a clear purpose in making the error more readable. The comment should be deleted. The leading newline appears intentional and beneficial for error message readability. This is a matter of style preference rather than a clear improvement.
> 
> 
> </details>
> 
> 
> Workflow ID: <workflowid>`wflow_FwQtzr8LVeg163Jo`</workflowid>
> </details>
> 
> <sup>You can customize </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=un-ts%2Feslint-plugin-import-x&utm_source=github&utm_medium=referral)<sup> by changing your [verbosity settings](https://app.ellipsis.dev/un-ts/settings/code-review), reacting with :+1: or :-1:, [replying to comments](https://docs.ellipsis.dev/features/code-review#teaching-ellipsis), or adding [code review rules](https://app.ellipsis.dev/un-ts/code-review/rules).</sup>
state: COMMENTED
author_association: NONE
submitted_at: 2025-05-30T23:38:42Z
user: login: coderabbitai[bot]
body: **Actionable comments posted: 2**

<details>
<summary>📜 Review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**
**Plan: Pro**


<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between dfcbe2ca40f6faaec80e0abb93e58a0cf8347a06 and 666a0ab46a7a8d824910291da4dadf1c1f516e9c.

</details>

<details>
<summary>📒 Files selected for processing (2)</summary>

* `.changeset/curvy-swans-ring.md` (1 hunks)
* `src/rules/no-unused-modules.ts` (2 hunks)

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🪛 GitHub Check: codecov/patch</summary>

<details>
<summary>src/rules/no-unused-modules.ts</summary>

[warning] 49-49: src/rules/no-unused-modules.ts#L49
Added line #L49 was not covered by tests

---

[warning] 66-66: src/rules/no-unused-modules.ts#L66
Added line #L66 was not covered by tests

---

[warning] 68-68: src/rules/no-unused-modules.ts#L68
Added line #L68 was not covered by tests

---

[warning] 80-80: src/rules/no-unused-modules.ts#L80
Added line #L80 was not covered by tests

</details>

</details>

</details>

<details>
<summary>⏰ Context from checks skipped due to timeout of 90000ms (172)</summary>

* GitHub Check: Codacy Static Code Analysis
* GitHub Check: Lint and Test with Node.js 18 and ESLint 9 on ubuntu-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8 on ubuntu-latest
* GitHub Check: autofix
* GitHub Check: Analyze (actions)
* GitHub Check: Analyze (javascript-typescript)
* GitHub Check: Lint and Test with Node.js 22 and ESLint 8 on windows-latest
* GitHub Check: Lint and Test with Node.js 22 and ESLint 9 on windows-latest
* GitHub Check: Lint and Test with Node.js 24 and ESLint 8.56 on windows-latest
* GitHub Check: Lint and Test with Node.js 20 and ESLint 8 on windows-latest
* GitHub Check: Lint and Test with Node.js 20 and ESLint 9 on windows-latest
* GitHub Check: Lint and Test with Node.js 20 and ESLint 8.56 on windows-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8.56 on windows-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 9 on windows-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8 on windows-latest
* GitHub Check: Lint and Test with Node.js 24 and ESLint 8 on ubuntu-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8.56 on ubuntu-latest
* GitHub Check: Codacy Static Code Analysis
* GitHub Check: Lint and Test with Node.js 18 and ESLint 9 on ubuntu-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8 on ubuntu-latest
* GitHub Check: autofix
* GitHub Check: Analyze (actions)
* GitHub Check: Analyze (javascript-typescript)
* GitHub Check: Lint and Test with Node.js 22 and ESLint 8 on windows-latest
* GitHub Check: Lint and Test with Node.js 22 and ESLint 9 on windows-latest
* GitHub Check: Lint and Test with Node.js 24 and ESLint 8.56 on windows-latest
* GitHub Check: Lint and Test with Node.js 20 and ESLint 8 on windows-latest
* GitHub Check: Lint and Test with Node.js 20 and ESLint 9 on windows-latest
* GitHub Check: Lint and Test with Node.js 20 and ESLint 8.56 on windows-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8.56 on windows-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 9 on windows-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8 on windows-latest
* GitHub Check: Lint and Test with Node.js 24 and ESLint 8 on ubuntu-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8.56 on ubuntu-latest
* GitHub Check: Codacy Static Code Analysis
* GitHub Check: Lint and Test with Node.js 18 and ESLint 9 on ubuntu-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8 on ubuntu-latest
* GitHub Check: autofix
* GitHub Check: Analyze (actions)
* GitHub Check: Analyze (javascript-typescript)
* GitHub Check: Lint and Test with Node.js 22 and ESLint 8 on windows-latest
* GitHub Check: Lint and Test with Node.js 22 and ESLint 9 on windows-latest
* GitHub Check: Lint and Test with Node.js 24 and ESLint 8.56 on windows-latest
* GitHub Check: Lint and Test with Node.js 20 and ESLint 8 on windows-latest
* GitHub Check: Lint and Test with Node.js 20 and ESLint 9 on windows-latest
* GitHub Check: Lint and Test with Node.js 20 and ESLint 8.56 on windows-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8.56 on windows-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 9 on windows-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8 on windows-latest
* GitHub Check: Lint and Test with Node.js 24 and ESLint 8 on ubuntu-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8.56 on ubuntu-latest
* GitHub Check: Codacy Static Code Analysis
* GitHub Check: Lint and Test with Node.js 18 and ESLint 9 on ubuntu-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8 on ubuntu-latest
* GitHub Check: autofix
* GitHub Check: Analyze (actions)
* GitHub Check: Analyze (javascript-typescript)
* GitHub Check: Lint and Test with Node.js 22 and ESLint 8 on windows-latest
* GitHub Check: Lint and Test with Node.js 22 and ESLint 9 on windows-latest
* GitHub Check: Lint and Test with Node.js 24 and ESLint 8.56 on windows-latest
* GitHub Check: Lint and Test with Node.js 20 and ESLint 8 on windows-latest
* GitHub Check: Lint and Test with Node.js 20 and ESLint 9 on windows-latest
* GitHub Check: Lint and Test with Node.js 20 and ESLint 8.56 on windows-latest
* GitHub Check: Lint and Test with Node.js 24 and ESLint 9 on ubuntu-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8.56 on windows-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 9 on windows-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8 on windows-latest
* GitHub Check: Lint and Test with Node.js 24 and ESLint 8 on ubuntu-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8.56 on ubuntu-latest
* GitHub Check: Codacy Static Code Analysis
* GitHub Check: Lint and Test with Node.js 18 and ESLint 9 on ubuntu-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8 on ubuntu-latest
* GitHub Check: autofix
* GitHub Check: Analyze (actions)
* GitHub Check: Analyze (javascript-typescript)
* GitHub Check: Lint and Test with Node.js 22 and ESLint 8 on windows-latest
* GitHub Check: Lint and Test with Node.js 22 and ESLint 9 on windows-latest
* GitHub Check: Lint and Test with Node.js 24 and ESLint 8.56 on windows-latest
* GitHub Check: Lint and Test with Node.js 20 and ESLint 8 on windows-latest
* GitHub Check: Lint and Test with Node.js 20 and ESLint 9 on windows-latest
* GitHub Check: Lint and Test with Node.js 20 and ESLint 8.56 on windows-latest
* GitHub Check: Lint and Test with Node.js 24 and ESLint 9 on ubuntu-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8.56 on windows-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 9 on windows-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8 on windows-latest
* GitHub Check: Lint and Test with Node.js 24 and ESLint 8 on ubuntu-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8.56 on ubuntu-latest
* GitHub Check: Codacy Static Code Analysis
* GitHub Check: Lint and Test with Node.js 18 and ESLint 9 on ubuntu-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8 on ubuntu-latest
* GitHub Check: Analyze (actions)
* GitHub Check: Analyze (javascript-typescript)
* GitHub Check: Lint and Test with Node.js 22 and ESLint 8 on windows-latest
* GitHub Check: Lint and Test with Node.js 22 and ESLint 9 on windows-latest
* GitHub Check: Lint and Test with Node.js 24 and ESLint 8.56 on windows-latest
* GitHub Check: Lint and Test with Node.js 20 and ESLint 8 on windows-latest
* GitHub Check: Lint and Test with Node.js 20 and ESLint 9 on windows-latest
* GitHub Check: Lint and Test with Node.js 20 and ESLint 8.56 on windows-latest
* GitHub Check: Lint and Test with Node.js 24 and ESLint 9 on ubuntu-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8.56 on windows-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 9 on windows-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8 on windows-latest
* GitHub Check: Lint and Test with Node.js 24 and ESLint 8 on ubuntu-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8.56 on ubuntu-latest
* GitHub Check: Codacy Static Code Analysis
* GitHub Check: Lint and Test with Node.js 18 and ESLint 9 on ubuntu-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8 on ubuntu-latest
* GitHub Check: Analyze (actions)
* GitHub Check: Analyze (javascript-typescript)
* GitHub Check: Lint and Test with Node.js 22 and ESLint 8 on windows-latest
* GitHub Check: Lint and Test with Node.js 22 and ESLint 9 on windows-latest
* GitHub Check: Lint and Test with Node.js 24 and ESLint 8.56 on windows-latest
* GitHub Check: Lint and Test with Node.js 20 and ESLint 8 on windows-latest
* GitHub Check: Lint and Test with Node.js 20 and ESLint 9 on windows-latest
* GitHub Check: Lint and Test with Node.js 20 and ESLint 8.56 on windows-latest
* GitHub Check: Lint and Test with Node.js 24 and ESLint 9 on ubuntu-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8.56 on windows-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 9 on windows-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8 on windows-latest
* GitHub Check: Lint and Test with Node.js 24 and ESLint 8 on ubuntu-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8.56 on ubuntu-latest
* GitHub Check: Codacy Static Code Analysis
* GitHub Check: Lint and Test with Node.js 18 and ESLint 9 on ubuntu-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8 on ubuntu-latest
* GitHub Check: Analyze (actions)
* GitHub Check: Analyze (javascript-typescript)
* GitHub Check: Lint and Test with Node.js 22 and ESLint 8 on windows-latest
* GitHub Check: Lint and Test with Node.js 22 and ESLint 9 on windows-latest
* GitHub Check: Lint and Test with Node.js 24 and ESLint 8.56 on windows-latest
* GitHub Check: Lint and Test with Node.js 20 and ESLint 8 on windows-latest
* GitHub Check: Lint and Test with Node.js 20 and ESLint 9 on windows-latest
* GitHub Check: Lint and Test with Node.js 20 and ESLint 8.56 on windows-latest
* GitHub Check: Lint and Test with Node.js 24 and ESLint 9 on ubuntu-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8.56 on windows-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 9 on windows-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8 on windows-latest
* GitHub Check: Lint and Test with Node.js 24 and ESLint 8 on ubuntu-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8.56 on ubuntu-latest
* GitHub Check: Codacy Static Code Analysis
* GitHub Check: Lint and Test with Node.js 18 and ESLint 9 on ubuntu-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8 on ubuntu-latest
* GitHub Check: Analyze (actions)
* GitHub Check: Analyze (javascript-typescript)
* GitHub Check: Lint and Test with Node.js 22 and ESLint 8 on windows-latest
* GitHub Check: Lint and Test with Node.js 22 and ESLint 9 on windows-latest
* GitHub Check: Lint and Test with Node.js 24 and ESLint 8.56 on windows-latest
* GitHub Check: Lint and Test with Node.js 20 and ESLint 8 on windows-latest
* GitHub Check: Lint and Test with Node.js 20 and ESLint 9 on windows-latest
* GitHub Check: Lint and Test with Node.js 20 and ESLint 8.56 on windows-latest
* GitHub Check: Lint and Test with Node.js 24 and ESLint 9 on ubuntu-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8.56 on windows-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 9 on windows-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8 on windows-latest
* GitHub Check: Lint and Test with Node.js 24 and ESLint 8 on ubuntu-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8.56 on ubuntu-latest
* GitHub Check: Codacy Static Code Analysis
* GitHub Check: Lint and Test with Node.js 18 and ESLint 9 on ubuntu-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8 on ubuntu-latest
* GitHub Check: Analyze (actions)
* GitHub Check: Analyze (javascript-typescript)
* GitHub Check: Lint and Test with Node.js 22 and ESLint 8 on windows-latest
* GitHub Check: Lint and Test with Node.js 22 and ESLint 9 on windows-latest
* GitHub Check: Lint and Test with Node.js 24 and ESLint 8.56 on windows-latest
* GitHub Check: Lint and Test with Node.js 20 and ESLint 8 on windows-latest
* GitHub Check: Lint and Test with Node.js 20 and ESLint 9 on windows-latest
* GitHub Check: Lint and Test with Node.js 20 and ESLint 8.56 on windows-latest
* GitHub Check: Lint and Test with Node.js 24 and ESLint 9 on ubuntu-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8.56 on windows-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 9 on windows-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8 on windows-latest
* GitHub Check: Lint and Test with Node.js 24 and ESLint 8 on ubuntu-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8.56 on ubuntu-latest

</details>

<details>
<summary>🔇 Additional comments (5)</summary><blockquote>

<details>
<summary>src/rules/no-unused-modules.ts (4)</summary>

`26-26`: **LGTM - Good addition of `shouldUseFlatConfig` import.**

The destructuring of `shouldUseFlatConfig` from `eslintUnsupportedApi` is correctly added to support the flat config detection logic.

---

`28-31`: **Clear function naming and parameter documentation.**

The function renaming from `listFilesToProcess` to `listFilesUsingFileEnumerator` is more descriptive and accurately reflects its implementation using FileEnumerator.

---

`189-189`: **Function call correctly updated.**

The call to `listFilesUsingFileEnumerator` correctly replaces the old function name for source files enumeration.

---

`192-195`: **Function call correctly updated for ignored files.**

The call to `listFilesUsingFileEnumerator` correctly replaces the old function name for ignored files enumeration, maintaining the same parameter structure.

</details>
<details>
<summary>.changeset/curvy-swans-ring.md (1)</summary>

`1-6`: **Well-documented changeset for the error handling improvement.**

The changeset correctly documents this as a patch-level change and accurately describes the fix for graceful error handling around `enumerator.iterateFiles`. The title aligns with the PR objective and the implementation changes.

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-05-30T23:40:07Z
user: login: ellipsis-dev[bot]
body: > [!IMPORTANT]
> **Looks good to me!  :+1:**
> <details>
> <summary>Reviewed 1e09f8bc4e81969431c4211e8e4e8bf08fd20dbb in <ellipsistime>1 minute and 27 seconds</ellipsistime>. Click for details.</summary> 
> 
> - Reviewed `378` lines of code in `12` files
> - Skipped `1` files when reviewing.
> - Skipped posting `5` draft comments. View those below.
> - Modify your [settings](https://app.ellipsis.dev/un-ts/settings/code-review) and [rules](https://app.ellipsis.dev/un-ts/code-review/rules) to customize what types of comments Ellipsis leaves. And don't forget to react with :+1: or :-1: to teach Ellipsis.
> 
> <details>
> <summary>1. <code>test/utils.ts:63</code></summary>
> 
> - **Draft comment:** 
> The default parserOptions set ecmaVersion to 9 which may be outdated for modern syntax. Consider updating it to a more recent ECMAScript version (e.g. 2018+) to support newer language features.
> - **Reason this comment was not posted:**
> Comment was not on a location in the diff, so it can't be submitted as a review comment.
> 
> 
> </details>
> 
> <details>
> <summary>2. <code>test/utils.ts:152</code></summary>
> 
> - **Draft comment:** 
> Avoid using the 'as never' cast when merging test case options. Using such a cast can mask type errors; prefer a more precise type assertion to maintain type safety.
> - **Reason this comment was not posted:**
> Comment was not on a location in the diff, so it can't be submitted as a review comment.
> 
> 
> </details>
> 
> <details>
> <summary>3. <code>test/utils.ts:32</code></summary>
> 
> - **Draft comment:** 
> Consider caching the result of requiring '@typescript-eslint/parser/package.json' to avoid repeated file system accesses if this function is called multiple times.
> - **Reason this comment was not posted:**
> Comment was not on a location in the diff, so it can't be submitted as a review comment.
> 
> 
> </details>
> 
> <details>
> <summary>4. <code>test/utils.ts:28</code></summary>
> 
> - **Draft comment:** 
> Consider adding explicit return types for exported functions (e.g. tsVersionSatisfies) to improve readability and maintainability.
> - **Reason this comment was not posted:**
> Comment was on unchanged code.
> 
> 
> </details>
> 
> <details>
> <summary>5. <code>package.json:126</code></summary>
> 
> - **Draft comment:** 
> There appears to be a typographical error in the dependency name on line 126. It is written as "@unts/patch-package"; please double-check if this should be "@un-ts/patch-package" or the intended name.
> - **Reason this comment was not posted:**
> Comment was not on a location in the diff, so it can't be submitted as a review comment.
> 
> 
> </details>
> 
> 
> Workflow ID: <workflowid>`wflow_Oqhgh3TBFMRUGaiC`</workflowid>
> </details>
> 
> <sup>You can customize </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=un-ts%2Feslint-plugin-import-x&utm_source=github&utm_medium=referral)<sup> by changing your [verbosity settings](https://app.ellipsis.dev/un-ts/settings/code-review), reacting with :+1: or :-1:, [replying to comments](https://docs.ellipsis.dev/features/code-review#teaching-ellipsis), or adding [code review rules](https://app.ellipsis.dev/un-ts/code-review/rules).</sup>
state: COMMENTED
author_association: NONE
submitted_at: 2025-05-31T00:28:35Z
user: login: github-advanced-security[bot]
state: COMMENTED
author_association: NONE
submitted_at: 2025-05-31T00:31:19Z

Review comments:
diff_hunk: @@ -23,17 +23,62 @@ import {
 } from '../utils/index.js'
 
 // eslint-disable-next-line import-x/no-named-as-default-member -- incorrect types , commonjs actually
-const { FileEnumerator } = eslintUnsupportedApi
+const { FileEnumerator, shouldUseFlatConfig } = eslintUnsupportedApi
 
-function listFilesToProcess(src: string[], extensions: FileExtension[]) {
-  const enumerator = new FileEnumerator({
-    extensions,
-  })
+function listFilesUsingFileEnumerator(
+  src: string[],
+  extensions: FileExtension[],
+) {
+  // We need to know whether this is being run with flat config in order to
+  // determine how to report errors if FileEnumerator throws due to a lack of eslintrc.
+
+  const { ESLINT_USE_FLAT_CONFIG } = process.env
+
+  // This condition is sufficient to test in v8, since the environment variable is necessary to turn on flat config
+  let isUsingFlatConfig: boolean
+
+  // In the case of using v9, we can check the `shouldUseFlatConfig` function
+  // If this function is present, then we assume it's v9
+  try {
+    isUsingFlatConfig =
+      // @ts-expect-error -- only available in ESLint v9
+      shouldUseFlatConfig && ESLINT_USE_FLAT_CONFIG !== 'false'
+  } catch {
+    // We don't want to throw here, since we only want to init the
+    // boolean if the function is available.
+    isUsingFlatConfig =
+      !!ESLINT_USE_FLAT_CONFIG && ESLINT_USE_FLAT_CONFIG !== 'false'
+  }
+
+  const enumerator = new FileEnumerator({ extensions })
 
-  return Array.from(enumerator.iterateFiles(src), ({ filePath, ignored }) => ({
-    ignored,
-    filename: filePath,
-  }))
+  try {
+    return Array.from(
+      enumerator.iterateFiles(src),
+      ({ filePath, ignored }) => ({ filename: filePath, ignored }),
+    )
+  } catch (error) {
+    // If we're using flat config, and FileEnumerator throws due to a lack of eslintrc,
+    // then we want to throw an error so that the user knows about this rule's reliance on
+    // the legacy config.
+    if (
+      isUsingFlatConfig &&
+      (error as Error).message.includes('No ESLint configuration found')
path: src/rules/no-unused-modules.ts
user: login: petercat-assistant[bot]
body: The error message check for 'No ESLint configuration found' is crucial for users to understand the dependency on legacy config when using flat config. Ensure this message is accurate and informative.
created_at: 2025-05-30T23:37:07Z
author_association: NONE
diff_hunk: @@ -23,17 +23,62 @@ import {
 } from '../utils/index.js'
 
 // eslint-disable-next-line import-x/no-named-as-default-member -- incorrect types , commonjs actually
-const { FileEnumerator } = eslintUnsupportedApi
+const { FileEnumerator, shouldUseFlatConfig } = eslintUnsupportedApi
 
-function listFilesToProcess(src: string[], extensions: FileExtension[]) {
-  const enumerator = new FileEnumerator({
-    extensions,
-  })
+function listFilesUsingFileEnumerator(
+  src: string[],
+  extensions: FileExtension[],
+) {
+  // We need to know whether this is being run with flat config in order to
+  // determine how to report errors if FileEnumerator throws due to a lack of eslintrc.
+
+  const { ESLINT_USE_FLAT_CONFIG } = process.env
+
+  // This condition is sufficient to test in v8, since the environment variable is necessary to turn on flat config
+  let isUsingFlatConfig: boolean
+
+  // In the case of using v9, we can check the `shouldUseFlatConfig` function
+  // If this function is present, then we assume it's v9
+  try {
+    isUsingFlatConfig =
+      // @ts-expect-error -- only available in ESLint v9
+      shouldUseFlatConfig && ESLINT_USE_FLAT_CONFIG !== 'false'
path: src/rules/no-unused-modules.ts
user: login: Copilot
body: You're checking `shouldUseFlatConfig` without invoking it. Since it's a function in ESLint v9, it should be called (e.g., `shouldUseFlatConfig()`) to get the actual flat config status.
```suggestion
      (typeof shouldUseFlatConfig === 'function' && shouldUseFlatConfig()) && ESLINT_USE_FLAT_CONFIG !== 'false'
```
created_at: 2025-05-30T23:37:28Z
author_association: CONTRIBUTOR
diff_hunk: @@ -23,17 +23,62 @@ import {
 } from '../utils/index.js'
 
 // eslint-disable-next-line import-x/no-named-as-default-member -- incorrect types , commonjs actually
-const { FileEnumerator } = eslintUnsupportedApi
+const { FileEnumerator, shouldUseFlatConfig } = eslintUnsupportedApi
 
-function listFilesToProcess(src: string[], extensions: FileExtension[]) {
-  const enumerator = new FileEnumerator({
-    extensions,
-  })
+function listFilesUsingFileEnumerator(
+  src: string[],
+  extensions: FileExtension[],
+) {
+  // We need to know whether this is being run with flat config in order to
+  // determine how to report errors if FileEnumerator throws due to a lack of eslintrc.
+
+  const { ESLINT_USE_FLAT_CONFIG } = process.env
+
+  // This condition is sufficient to test in v8, since the environment variable is necessary to turn on flat config
+  let isUsingFlatConfig: boolean
+
+  // In the case of using v9, we can check the `shouldUseFlatConfig` function
+  // If this function is present, then we assume it's v9
+  try {
+    isUsingFlatConfig =
+      // @ts-expect-error -- only available in ESLint v9
+      shouldUseFlatConfig && ESLINT_USE_FLAT_CONFIG !== 'false'
+  } catch {
+    // We don't want to throw here, since we only want to init the
+    // boolean if the function is available.
+    isUsingFlatConfig =
+      !!ESLINT_USE_FLAT_CONFIG && ESLINT_USE_FLAT_CONFIG !== 'false'
+  }
+
+  const enumerator = new FileEnumerator({ extensions })
 
-  return Array.from(enumerator.iterateFiles(src), ({ filePath, ignored }) => ({
-    ignored,
-    filename: filePath,
-  }))
+  try {
+    return Array.from(
+      enumerator.iterateFiles(src),
+      ({ filePath, ignored }) => ({ filename: filePath, ignored }),
+    )
+  } catch (error) {
+    // If we're using flat config, and FileEnumerator throws due to a lack of eslintrc,
+    // then we want to throw an error so that the user knows about this rule's reliance on
+    // the legacy config.
+    if (
+      isUsingFlatConfig &&
+      (error as Error).message.includes('No ESLint configuration found')
path: src/rules/no-unused-modules.ts
user: login: Copilot
body: [nitpick] Relying on a hardcoded substring to detect this error can break if ESLint changes its message. Consider using an error code or a more robust detection (e.g., checking a specific error property).
```suggestion
      (error as any).code === 'NO_ESLINT_CONFIG'
```
created_at: 2025-05-30T23:37:28Z
author_association: CONTRIBUTOR
diff_hunk: @@ -23,17 +23,62 @@
 } from '../utils/index.js'
 
 // eslint-disable-next-line import-x/no-named-as-default-member -- incorrect types , commonjs actually
-const { FileEnumerator } = eslintUnsupportedApi
+const { FileEnumerator, shouldUseFlatConfig } = eslintUnsupportedApi
 
-function listFilesToProcess(src: string[], extensions: FileExtension[]) {
-  const enumerator = new FileEnumerator({
-    extensions,
-  })
+function listFilesUsingFileEnumerator(
+  src: string[],
+  extensions: FileExtension[],
+) {
+  // We need to know whether this is being run with flat config in order to
+  // determine how to report errors if FileEnumerator throws due to a lack of eslintrc.
+
+  const { ESLINT_USE_FLAT_CONFIG } = process.env
+
+  // This condition is sufficient to test in v8, since the environment variable is necessary to turn on flat config
+  let isUsingFlatConfig: boolean
+
+  // In the case of using v9, we can check the `shouldUseFlatConfig` function
+  // If this function is present, then we assume it's v9
+  try {
+    isUsingFlatConfig =
+      // @ts-expect-error -- only available in ESLint v9
+      shouldUseFlatConfig && ESLINT_USE_FLAT_CONFIG !== 'false'
+  } catch {
+    // We don't want to throw here, since we only want to init the
+    // boolean if the function is available.
+    isUsingFlatConfig =
+      !!ESLINT_USE_FLAT_CONFIG && ESLINT_USE_FLAT_CONFIG !== 'false'
+  }
path: src/rules/no-unused-modules.ts
user: login: coderabbitai[bot]
body: _💡 Verification agent_

<details>
<summary>🧩 Analysis chain</summary>

**Robust flat config detection logic with proper fallbacks.**

The implementation correctly handles both ESLint v8 and v9 scenarios:
- v8: Relies on `ESLINT_USE_FLAT_CONFIG` environment variable
- v9: Uses `shouldUseFlatConfig` function when available
- Proper fallback to environment variable when the function isn't available

The try-catch around `shouldUseFlatConfig` is necessary since it's only available in v9.



However, the catch block on line 49 lacks test coverage. Consider adding tests to verify the fallback behavior when `shouldUseFlatConfig` is not available:

---

🏁 Script executed:

```shell
#!/bin/bash
# Verify if there are existing tests for the flat config detection logic
rg -A 10 -B 5 "listFilesUsingFileEnumerator|shouldUseFlatConfig|ESLINT_USE_FLAT_CONFIG" --type ts
```

Length of output: 3914

---



</details>

**Add tests for flat‐config fallback detection**

There’s currently no coverage for the `catch` block in `src/rules/no-unused-modules.ts` (lines 32–51), which handles the case when `shouldUseFlatConfig` isn’t available. Please add unit tests that:

- Mock or stub `eslintUnsupportedApi.shouldUseFlatConfig` to throw or be `undefined`
- Verify that `isUsingFlatConfig` correctly falls back to using `ESLINT_USE_FLAT_CONFIG`
- Cover both truthy and falsy values of `ESLINT_USE_FLAT_CONFIG`

Suggested location:  
• `tests/src/rules/no-unused-modules.test.ts` (or your project’s standard test directory)

<details>
<summary>🧰 Tools</summary>

<details>
<summary>🪛 GitHub Check: codecov/patch</summary>

[warning] 49-49: src/rules/no-unused-modules.ts#L49
Added line #L49 was not covered by tests

</details>

</details>

<details>
<summary>🤖 Prompt for AI Agents</summary>

```
In src/rules/no-unused-modules.ts around lines 32 to 51, the catch block
handling the absence of shouldUseFlatConfig lacks test coverage. Add unit tests
in tests/src/rules/no-unused-modules.test.ts that mock or stub
eslintUnsupportedApi.shouldUseFlatConfig to throw an error or be undefined, then
verify that isUsingFlatConfig falls back to using the ESLINT_USE_FLAT_CONFIG
environment variable correctly. Include tests for both truthy and falsy values
of ESLINT_USE_FLAT_CONFIG to ensure full coverage of the fallback logic.
```

</details>

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-30T23:40:06Z
author_association: CONTRIBUTOR
diff_hunk: @@ -23,17 +23,62 @@
 } from '../utils/index.js'
 
 // eslint-disable-next-line import-x/no-named-as-default-member -- incorrect types , commonjs actually
-const { FileEnumerator } = eslintUnsupportedApi
+const { FileEnumerator, shouldUseFlatConfig } = eslintUnsupportedApi
 
-function listFilesToProcess(src: string[], extensions: FileExtension[]) {
-  const enumerator = new FileEnumerator({
-    extensions,
-  })
+function listFilesUsingFileEnumerator(
+  src: string[],
+  extensions: FileExtension[],
+) {
+  // We need to know whether this is being run with flat config in order to
+  // determine how to report errors if FileEnumerator throws due to a lack of eslintrc.
+
+  const { ESLINT_USE_FLAT_CONFIG } = process.env
+
+  // This condition is sufficient to test in v8, since the environment variable is necessary to turn on flat config
+  let isUsingFlatConfig: boolean
+
+  // In the case of using v9, we can check the `shouldUseFlatConfig` function
+  // If this function is present, then we assume it's v9
+  try {
+    isUsingFlatConfig =
+      // @ts-expect-error -- only available in ESLint v9
+      shouldUseFlatConfig && ESLINT_USE_FLAT_CONFIG !== 'false'
+  } catch {
+    // We don't want to throw here, since we only want to init the
+    // boolean if the function is available.
+    isUsingFlatConfig =
+      !!ESLINT_USE_FLAT_CONFIG && ESLINT_USE_FLAT_CONFIG !== 'false'
+  }
+
+  const enumerator = new FileEnumerator({ extensions })
 
-  return Array.from(enumerator.iterateFiles(src), ({ filePath, ignored }) => ({
-    ignored,
-    filename: filePath,
-  }))
+  try {
+    return Array.from(
+      enumerator.iterateFiles(src),
+      ({ filePath, ignored }) => ({ filename: filePath, ignored }),
+    )
+  } catch (error) {
+    // If we're using flat config, and FileEnumerator throws due to a lack of eslintrc,
+    // then we want to throw an error so that the user knows about this rule's reliance on
+    // the legacy config.
+    if (
+      isUsingFlatConfig &&
+      (error as Error).message.includes('No ESLint configuration found')
+    ) {
+      throw new Error(`
+Due to the exclusion of certain internal ESLint APIs when using flat config,
+the import/no-unused-modules rule requires an .eslintrc file to know which
+files to ignore (even when using flat config).
+The .eslintrc file only needs to contain "ignorePatterns", or can be empty if
+you do not want to ignore any files.
+
+See https://github.com/import-js/eslint-plugin-import/issues/3079
+for additional context.
+`)
+    }
+    // If this isn't the case, then we'll just let the error bubble up
+    throw error
+  }
 }
path: src/rules/no-unused-modules.ts
user: login: coderabbitai[bot]
body: _💡 Verification agent_

<details>
<summary>🧩 Analysis chain</summary>

**Excellent error handling for flat config scenarios.**

The try-catch wrapper around `enumerator.iterateFiles` provides graceful error handling with these benefits:

1. **Specific flat config error**: When ESLint flat config is detected and configuration is missing, it provides a clear, actionable error message with a GitHub issue link.
2. **Preserves original errors**: For other scenarios, the original error is re-thrown.
3. **User-friendly guidance**: The error message explains the workaround (creating .eslintrc file) even when using flat config.




The static analysis indicates lines 66, 68, and 80 lack test coverage. Consider adding tests to cover these error scenarios:

---

🏁 Script executed:

```shell
#!/bin/bash
# Check for existing tests covering the error handling scenarios
rg -A 20 -B 5 "No ESLint configuration found|import/no-unused-modules.*eslintrc" --type ts
```

Length of output: 2069

---

🏁 Script executed:

```shell
#!/bin/bash
# Search for tests covering the no-unused-modules error-handling scenarios
rg 'import/no-unused-modules' --glob '*.test.ts' --glob '*.spec.ts' -A 5 -B 3
rg 'No ESLint configuration found' --glob '*.test.ts' --glob '*.spec.ts' -A 5 -B 3
```

Length of output: 162

---



</details>

**Add tests for flat-config error handling in no-unused-modules**

It looks like we don’t have any existing tests covering the `isUsingFlatConfig` + missing `.eslintrc` scenario (or the fallback re-throw path). Please add tests to exercise:

- The specific error message when `enumerator.iterateFiles` throws “No ESLint configuration found” under flat config  
- The default behavior of re-throwing non–flat-config errors  

Suggested locations:  
- `src/rules/no-unused-modules.ts` lines 55–82

<details>
<summary>🧰 Tools</summary>

<details>
<summary>🪛 GitHub Check: codecov/patch</summary>

[warning] 66-66: src/rules/no-unused-modules.ts#L66
Added line #L66 was not covered by tests

---

[warning] 68-68: src/rules/no-unused-modules.ts#L68
Added line #L68 was not covered by tests

---

[warning] 80-80: src/rules/no-unused-modules.ts#L80
Added line #L80 was not covered by tests

</details>

</details>

<details>
<summary>🤖 Prompt for AI Agents</summary>

```
In src/rules/no-unused-modules.ts around lines 55 to 82, add unit tests to cover
the error handling logic for flat config scenarios. Specifically, create a test
that mocks enumerator.iterateFiles to throw an error with the message "No ESLint
configuration found" while isUsingFlatConfig is true, and verify that the custom
error with the detailed message is thrown. Also, add a test where
enumerator.iterateFiles throws a different error or isUsingFlatConfig is false,
and confirm that the original error is re-thrown. Place these tests in the
appropriate test file for no-unused-modules to ensure full coverage of these
branches.
```

</details>

<!-- This is an auto-generated comment by CodeRabbit -->
created_at: 2025-05-30T23:40:06Z
author_association: CONTRIBUTOR
diff_hunk: @@ -1560,3 +1568,40 @@
     })
   })
 }
+
+;(isESLint9 ? describe : describe.skip)('with eslint 9+', () => {
+  it('provides meaningful error when eslintrc is not present', () => {
+    // Create temp directory outside of project root
+    const { name: tempDir, removeCallback } = dirSync({
+      unsafeCleanup: true,
+    })
+
+    // Copy example project to temp directory
+    // eslint-disable-next-line n/no-unsupported-features/node-builtins -- false positive
+    fs.cpSync(testFilePath('eslint-v9'), tempDir, {
+      recursive: true,
+    })
+
+    let errorMessage = ''
+
+    // We run `test-compiled` first, so that the plugin is already built
+    // But don't forget to run `yarn build` first if you're developing the rule or test case
+
+    // Install the plugin and run the lint command in the temp directory
+    try {
+      execSync(`npm install -D ${process.cwd()} && npm run lint`, {
path: test/rules/no-unused-modules.spec.ts
user: login: github-advanced-security[bot]
body: ## Shell command built from environment values

This shell command depends on an uncontrolled [absolute path](1).

[Show more details](https://github.com/un-ts/eslint-plugin-import-x/security/code-scanning/108)
created_at: 2025-05-31T00:31:19Z
author_association: NONE

PR comments:
user: login: changeset-bot[bot]
created_at: 2025-05-30T23:36:55Z
body: ###  🦋  Changeset detected

Latest commit: 1e09f8bc4e81969431c4211e8e4e8bf08fd20dbb

**The changes in this PR will be included in the next version bump.**

<details><summary>This PR includes changesets to release 1 package</summary>

  | Name                   | Type  |
| ---------------------- | ----- |
| eslint-plugin-import-x | Patch |

</details>

Not sure what this means? [Click here  to learn what changesets are](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md).

[Click here if you're a maintainer who wants to add another changeset to this PR](https://github.com/un-ts/eslint-plugin-import-x/new/fix/no-unused-modules?filename=.changeset/weak-boxes-begin.md&value=---%0A%22eslint-plugin-import-x%22%3A%20patch%0A---%0A%0Afix%3A%20try%2Fcatch%20%60enumerator.iterateFiles%60%20gracefully%0A)


author_association: NONE
user: login: coderabbitai[bot]
created_at: 2025-05-30T23:36:58Z
body: <!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- walkthrough_start -->

## Walkthrough

A new changeset was added documenting a patch for the "eslint-plugin-import-x" package. In the code, the function for listing files was renamed and enhanced to detect ESLint's flat config mode, improving error handling during file enumeration. Calls to the old function were updated to use the new implementation. Additionally, the comprehensive ESLint configuration file was removed and replaced with an empty config. New test fixtures and tests for ESLint v9 compatibility were added, along with updated documentation and dev dependencies.

## Changes

| File(s)                                      | Change Summary                                                                                                                      |
|----------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|
| .changeset/curvy-swans-ring.md                | Added a changeset documenting a patch for improved error handling in file iteration for "eslint-plugin-import-x".                   |
| src/rules/no-unused-modules.ts                 | Renamed and enhanced file listing function to detect flat config, added robust error handling, and updated function usage accordingly.|
| .eslintrc.cjs                                 | Removed detailed ESLint configuration, replaced with an empty export object.                                                        |
| docs/rules/no-unused-modules.md                | Updated rule documentation to clarify compatibility with flat config and allowance of empty legacy config.                         |
| package.json                                  | Added "tmp" package and its type definitions to devDependencies.                                                                     |
| test/fixtures/eslint-v9/*                      | Added new ESLint v9 test fixture files including config, package.json, source files, .gitignore, and .npmrc.                         |
| test/rules/no-unused-modules.spec.ts           | Added ESLint v9 conditional test verifying error thrown when no .eslintrc is present with the rule enabled.                          |
| test/utils.ts                                 | Added exported constant `isESLint9` to detect ESLint version 9 or higher.                                                           |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant User
    participant Rule as no-unused-modules Rule
    participant Enumerator as FileEnumerator
    participant ESLint

    User->>Rule: Invoke rule (resolveFiles)
    Rule->>Rule: listFilesUsingFileEnumerator(src, extensions)
    Rule->>ESLint: Check flat config (env var/API)
    Rule->>Enumerator: Iterate files (try/catch)
    alt Success
        Enumerator-->>Rule: Return files
    else Error (flat config detected)
        Rule-->>User: Throw detailed flat config error
    else Other error
        Rule-->>User: Rethrow original error
    end
```

## Possibly related PRs

- un-ts/eslint-plugin-import-x#358: Originally added the compatibility note for the `no-unused-modules` rule regarding legacy config and flat config coexistence, closely related to the documentation update in this PR.

## Poem

> In the warren of code, a patch hops in,  
> With careful paws, it guards where errors begin.  
> Flat configs detected, exceptions now tamed,  
> Files enumerated, no more rules blamed!  
> A rabbit’s delight in code that won’t fall,  
> Hopping ahead, outsmarting them all! 🐇

<!-- walkthrough_end -->
<!-- This is an auto-generated comment: all tool run failures by coderabbit.ai -->

> [!WARNING]
> There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.
> 
> <details>
> <summary>🔧 ESLint</summary>
> 
> > If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.
> 
> <details>
> <summary>test/fixtures/eslint-v9/src/depth-zero.js</summary>
> 
> 
> Oops! Something went wrong! :(
> 
> ESLint: 9.28.0
> 
> Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/lib/index.js' imported from /eslint.config.js
>     at finalizeResolution (node:internal/modules/esm/resolve:274:11)
>     at moduleResolve (node:internal/modules/esm/resolve:859:10)
>     at defaultResolve (node:internal/modules/esm/resolve:983:11)
>     at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:799:12)
>     at #cachedDefaultResolve (node:internal/modules/esm/loader:723:25)
>     at ModuleLoader.resolve (node:internal/modules/esm/loader:706:38)
>     at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:307:38)
>     at #link (node:internal/modules/esm/module_job:170:49)
> 
> </details>
> 
> <details>
> <summary>.eslintrc.cjs</summary>
> 
> 
> Oops! Something went wrong! :(
> 
> ESLint: 9.28.0
> 
> Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/lib/index.js' imported from /eslint.config.js
>     at finalizeResolution (node:internal/modules/esm/resolve:274:11)
>     at moduleResolve (node:internal/modules/esm/resolve:859:10)
>     at defaultResolve (node:internal/modules/esm/resolve:983:11)
>     at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:799:12)
>     at #cachedDefaultResolve (node:internal/modules/esm/loader:723:25)
>     at ModuleLoader.resolve (node:internal/modules/esm/loader:706:38)
>     at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:307:38)
>     at #link (node:internal/modules/esm/module_job:170:49)
> 
> </details>
> 
> <details>
> <summary>src/rules/no-unused-modules.ts</summary>
> 
> 
> Oops! Something went wrong! :(
> 
> ESLint: 9.28.0
> 
> Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/lib/index.js' imported from /eslint.config.js
>     at finalizeResolution (node:internal/modules/esm/resolve:274:11)
>     at moduleResolve (node:internal/modules/esm/resolve:859:10)
>     at defaultResolve (node:internal/modules/esm/resolve:983:11)
>     at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:799:12)
>     at #cachedDefaultResolve (node:internal/modules/esm/loader:723:25)
>     at ModuleLoader.resolve (node:internal/modules/esm/loader:706:38)
>     at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:307:38)
>     at #link (node:internal/modules/esm/module_job:170:49)
> 
> </details>
> 
> + 4 others
> 
> </details>

<!-- end of auto-generated comment: all tool run failures by coderabbit.ai -->


---

<details>
<summary>📜 Recent review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**
**Plan: Pro**


<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 666a0ab46a7a8d824910291da4dadf1c1f516e9c and 1e09f8bc4e81969431c4211e8e4e8bf08fd20dbb.

</details>

<details>
<summary>⛔ Files ignored due to path filters (1)</summary>

* `yarn.lock` is excluded by `!**/yarn.lock`, `!**/*.lock`

</details>

<details>
<summary>📒 Files selected for processing (12)</summary>

* `.eslintrc.cjs` (1 hunks)
* `docs/rules/no-unused-modules.md` (1 hunks)
* `package.json` (2 hunks)
* `src/rules/no-unused-modules.ts` (2 hunks)
* `test/fixtures/eslint-v9/.gitignore` (1 hunks)
* `test/fixtures/eslint-v9/.npmrc` (1 hunks)
* `test/fixtures/eslint-v9/eslint.config.mjs` (1 hunks)
* `test/fixtures/eslint-v9/package.json` (1 hunks)
* `test/fixtures/eslint-v9/src/depth-zero.js` (1 hunks)
* `test/fixtures/eslint-v9/src/exports.js` (1 hunks)
* `test/rules/no-unused-modules.spec.ts` (3 hunks)
* `test/utils.ts` (2 hunks)

</details>

<details>
<summary>✅ Files skipped from review due to trivial changes (8)</summary>

* test/fixtures/eslint-v9/.npmrc
* package.json
* test/fixtures/eslint-v9/.gitignore
* test/fixtures/eslint-v9/src/depth-zero.js
* test/utils.ts
* test/fixtures/eslint-v9/src/exports.js
* test/fixtures/eslint-v9/package.json
* test/fixtures/eslint-v9/eslint.config.mjs

</details>

<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (1)</summary>

* src/rules/no-unused-modules.ts

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🧬 Code Graph Analysis (1)</summary>

<details>
<summary>test/rules/no-unused-modules.spec.ts (1)</summary><blockquote>

<details>
<summary>test/utils.ts (2)</summary>

* `isESLint9` (26-26)
* `testFilePath` (42-44)

</details>

</blockquote></details>

</details>

</details>

<details>
<summary>⏰ Context from checks skipped due to timeout of 90000ms (21)</summary>

* GitHub Check: Codacy Static Code Analysis
* GitHub Check: Lint and Test with Node.js 22 and ESLint 9 on windows-latest
* GitHub Check: Lint and Test with Node.js 24 and ESLint 8 on windows-latest
* GitHub Check: Lint and Test with Node.js 20 and ESLint 8.56 on windows-latest
* GitHub Check: Lint and Test with Node.js 22 and ESLint 8 on ubuntu-latest
* GitHub Check: Lint and Test with Node.js 22 and ESLint 8 on windows-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8.56 on windows-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 9 on windows-latest
* GitHub Check: Lint and Test with Node.js 22 and ESLint 8.56 on windows-latest
* GitHub Check: Lint and Test with Node.js 20 and ESLint 8.56 on ubuntu-latest
* GitHub Check: Lint and Test with Node.js 24 and ESLint 9 on ubuntu-latest
* GitHub Check: Lint and Test with Node.js 20 and ESLint 9 on windows-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8 on windows-latest
* GitHub Check: Lint and Test with Node.js 20 and ESLint 9 on ubuntu-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8.56 on ubuntu-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 8 on ubuntu-latest
* GitHub Check: Lint and Test with Node.js 20 and ESLint 9 on macos-latest
* GitHub Check: Lint and Test with Node.js 24 and ESLint 9 on macos-latest
* GitHub Check: Lint and Test with Node.js 22 and ESLint 9 on macos-latest
* GitHub Check: Lint and Test with Node.js 18 and ESLint 9 on macos-latest
* GitHub Check: Lint and Test with Node.js 20 and ESLint 8 on macos-latest

</details>

<details>
<summary>🔇 Additional comments (4)</summary><blockquote>

<details>
<summary>.eslintrc.cjs (1)</summary>

`1-3`: **LGTM! The empty config aligns with the PR objectives.**

This change correctly provides a minimal `.eslintrc` file to satisfy the `no-unused-modules` rule requirement when testing with flat config, as documented in the updated rule documentation.

</details>
<details>
<summary>docs/rules/no-unused-modules.md (1)</summary>

`12-12`: **Documentation accurately reflects the implementation.**

The clarification that the legacy eslintrc config can be empty is helpful and consistent with the error message in the code implementation.

</details>
<details>
<summary>test/rules/no-unused-modules.spec.ts (2)</summary>

`1-2`: **Imports are appropriate for the new test functionality.**

The added imports for `execSync`, `ChildProcess`, and `dirSync` are necessary for the new ESLint 9+ test suite that creates temporary directories and executes npm commands.



Also applies to: 12-12

---

`1572-1607`: **Well-structured test for the new error handling functionality.**

The test effectively verifies that the `no-unused-modules` rule produces a meaningful error message when used with ESLint flat config without an `.eslintrc` file. The implementation is clean with proper:
- Conditional execution for ESLint 9+
- Temporary directory handling with cleanup
- Error message verification
- Reasonable timeout for npm operations

</details>

</blockquote></details>

</details>
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNxU3bABsvkCiQBHbGlcABpIcVwvOkgAIgAzeAAPLlwXAHoGagZYSAADMkdlAgoNdWKSADF4aMQ8yCIqBhJ47y9ZUNj7bAFmdRp6OUhsREpIACl8bAwARXgsNGRbSAxHATGAZgA2AAZw+bTFbGbkSgp8PlhMWi95ohRmXnwpNgxcZHmI2BJ8jEJpkZ0MDMI61DTveqJaL8eJfH7SW5vMDcLzYIjzMDwR4XXBgJI8c4iMQaGDfSDMbRYHKYUgoZC4MloWi0dTwfBYfCwtARDJZXA5SACLz4BgAa3Q52m9AZPwKqzYVBKZRoiqqNWk9SyPkgAHd1AgsDL8rdELhqrUAKqIO7mkgAUXlxQuAAoAJSQ6ZiNmG/CQK4YG7wijnCjIEH+BpNFptWQk9wfZDcZziBjeZztdBYmLUYajUOQEiPYWyO6QO0AZQAMgcAOTIeJeHNMDCJIjhHXfCNGlSjDDNGHofIaBEHCgMSHqhTeei8EgSNkjDNZQHDDD+wP0M4XRBxsnLNBeRC++YMVFKZDC9EMCK+pQ0MQoWENpvs1t0lBYFdDHKiUWlo15BWlYAJIAHLQAA+ha5Z2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LuoJLeSFuc4xo0HUC4P8bUz014tmhZofP+Vs64cirID9Yo6iAJPATwLcpbVV6JXaKiM14KSgFc+s4iQ2YU9/Mka1bJRVWyZFxA2GeIFUaiMY/R+li4RlxVk6VALytvegf1Sl2zPqsnOHKw6ULMXx9qBanYHYQLZsWgFTFaC+/FJR42nm3w/2olgoJIUQcsRS8cX7ZCBABiFeZSHHGhMuzBEtvsPIV0ALbkPAGoRyTVe4HixAE9GaryVNpZjMABL1kIZ/LJvymIjWkB3/EKnWoAvW6BiuEx30fGa2Od0Mhd0p97GsPJmd/lUIpkIWDrTN41ZwD8rEcoPSCIWzKaQY/UD4sVWzY50C7230bPCdWKeQTAL9Dd3FP5ROFlxsC1syspN4SgFUk4cOhneBpE9tw8FpjBnMpq5onO1q0kvAskDGPvNNsnbhgcG8rRERa2uq8kW7HXbkS+F+6FwcVFMBhhyONhkRHtvttuoNxOJj4iQELu5hQsHRJp3fRINXS/N8t+FUPocgR8aiEUthnwbrIjl8lm1y5ATZ2ybZzsRwxlFw5JvgTZc4TlYUQ6aqNwoTpGny/+md3J6d+I4K8E4prdiKpd6Ko2+jzbP3N4GUpAPtrgFBV5Gl22nKuD8QBD6dSp26e6FqGhdqVRzqLOjOLxjzvwNAQ6Fq7WO9maNQK6BacLpaJ09QCCcKRACCfwecXGOgCCP3dyxqAwXLrYOrtAHYFQAAFi2DQBJrQAAA5aAOvGCmvRFE3GD+vA0mvA1aB4gFqGAFr4gABWBarYEgURa8RaZqSABakgHYUReIDrgQBgJrkgDrha0RLYURJrjYCbprxghatbjrkgPb7b+IHYDr+IWgRgnYWgVQG6O6XL1s/Lwr4rwDMr2gCCVqT7oAA=== -->

<!-- internal state end -->
<!-- finishing_touch_checkbox_start -->

<details open="true">
<summary>✨ Finishing Touches</summary>

- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

<details>
<summary>❤️ Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=un-ts/eslint-plugin-import-x&utm_content=360):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Explain this complex logic.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai explain this code block.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and explain its main purpose.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

### Support

Need help? Create a ticket on our [support page](https://www.coderabbit.ai/contact-us/support) for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### CodeRabbit Configuration File (`.coderabbit.yaml`)

- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.
- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->
author_association: CONTRIBUTOR
user: login: petercat-assistant[bot]
created_at: 2025-05-30T23:37:04Z
body: ### Walkthrough
This pull request introduces a try/catch mechanism around the `enumerator.iterateFiles` function to handle errors gracefully, especially when using ESLint's flat config. It modifies the logic to detect the use of flat config and throws a specific error message if the configuration is missing.

### Changes
| File | Summary |
|------|---------|
| .changeset/curvy-swans-ring.md | Added a changeset file for the patch fix. |
| src/rules/no-unused-modules.ts | Refactored the file processing function to include error handling for missing ESLint configuration when using flat config. |
author_association: NONE
user: login: codesandbox-ci[bot]
created_at: 2025-05-30T23:37:36Z
body: This pull request is automatically built and testable in [CodeSandbox](https://codesandbox.io).

  To see build info of the built libraries, click [here](https://ci.codesandbox.io/status/un-ts/eslint-plugin-import-x/pr/360/builds/621370) or the icon next to each commit SHA.
author_association: NONE
user: login: codacy-production[bot]
created_at: 2025-05-30T23:37:48Z
body: ## Coverage summary from Codacy
### [See diff coverage on Codacy](https://app.codacy.com/gh/un-ts/eslint-plugin-import-x/pull-requests/360/coverage?utm_source=github.com&utm_medium=coverageSummary&utm_campaign=coverageSummaryPullRequest)

 | Coverage variation | Diff coverage | 
 | ------------- | ------------- |
 | :white_check_mark: **-0.10%** (target: -1.00%) | :white_check_mark: **75.00%** |

<details>
<summary>Coverage variation details</summary>

| | Coverable lines | Covered lines | Coverage |
| ------------- | ------------- | ------------- | ------------- |
| Common ancestor commit (dfcbe2ca40f6faaec80e0abb93e58a0cf8347a06) | 3669 | 3510 | 95.67% | |
| Head commit (1e09f8bc4e81969431c4211e8e4e8bf08fd20dbb) | 3676 (+7) | 3513 (+3) | 95.57% (**-0.10%**) |

**Coverage variation** is the difference between the coverage for the head and common ancestor commits of the pull request branch: `<coverage of head commit> - <coverage of common ancestor commit>`
</details>

<details>
<summary>Diff coverage details</summary>

| | Coverable lines | Covered lines | Diff coverage |
| ------------- | ------------- | ------------- | ------------- |
| Pull request (#360) | 16 | 12 | **75.00%** |

**Diff coverage** is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: `<covered lines added or modified>/<coverable lines added or modified> * 100%`
</details>

#### [See your quality gate settings](https://app.codacy.com/gh/un-ts/eslint-plugin-import-x/settings/quality?utm_source=github.com&utm_medium=coverageSummary&utm_campaign=coverageSummaryGates)&nbsp;&nbsp;&nbsp;&nbsp;[Change summary preferences](https://app.codacy.com/gh/un-ts/eslint-plugin-import-x/settings/integrations?utm_source=github.com&utm_medium=coverageSummary&utm_campaign=coverageSummarySettings)

<!-- 108f945d-e553-4918-8ccf-027c6d4acc2c -->
author_association: NONE
user: login: codecov[bot]
created_at: 2025-05-30T23:37:52Z
body: ## [Codecov](https://app.codecov.io/gh/un-ts/eslint-plugin-import-x/pull/360?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=un-ts) Report
Attention: Patch coverage is `66.66667%` with `7 lines` in your changes missing coverage. Please review.
> Project coverage is 96.02%. Comparing base [(`dfcbe2c`)](https://app.codecov.io/gh/un-ts/eslint-plugin-import-x/commit/dfcbe2ca40f6faaec80e0abb93e58a0cf8347a06?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=un-ts) to head [(`1e09f8b`)](https://app.codecov.io/gh/un-ts/eslint-plugin-import-x/commit/1e09f8bc4e81969431c4211e8e4e8bf08fd20dbb?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=un-ts).
> Report is 1 commits behind head on master.

| [Files with missing lines](https://app.codecov.io/gh/un-ts/eslint-plugin-import-x/pull/360?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=un-ts) | Patch % | Lines |
|---|---|---|
| [src/rules/no-unused-modules.ts](https://app.codecov.io/gh/un-ts/eslint-plugin-import-x/pull/360?src=pr&el=tree&filepath=src%2Frules%2Fno-unused-modules.ts&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=un-ts#diff-c3JjL3J1bGVzL25vLXVudXNlZC1tb2R1bGVzLnRz) | 63.15% | [7 Missing :warning: ](https://app.codecov.io/gh/un-ts/eslint-plugin-import-x/pull/360?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=un-ts) |

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##           master     #360      +/-   ##
==========================================
- Coverage   96.16%   96.02%   -0.14%     
==========================================
  Files          93       93              
  Lines        4879     4884       +5     
  Branches     1814     1834      +20     
==========================================
- Hits         4692     4690       -2     
- Misses        186      193       +7     
  Partials        1        1              
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/un-ts/eslint-plugin-import-x/pull/360?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=un-ts).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=un-ts).

<details><summary> :rocket: New features to boost your workflow: </summary>

- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
author_association: NONE
user: login: pkg-pr-new[bot]
created_at: 2025-05-30T23:38:27Z
body: 
[Open in StackBlitz](https://pkg.pr.new/template/92c98865-bb6f-4611-8abe-c5107adbf807)


```
npm i https://pkg.pr.new/eslint-plugin-import-x@360
```


_commit: <a href="https://github.com/un-ts/eslint-plugin-import-x/runs/43221199330"><code>1e09f8b</code></a>_

author_association: NONE
user: login: socket-security[bot]
created_at: 2025-05-31T00:27:34Z
body: **Review the following changes in direct dependencies.** Learn more about [Socket for GitHub](https://socket.dev?utm_medium=gh).

<table>
<thead>
<tr>
<th>Diff</th>
<th width="200px">Package</th>
<th align="center" width="100px">Supply Chain<br/>Security</th>
<th align="center" width="100px">Vulnerability</th>
<th align="center" width="100px">Quality</th>
<th align="center" width="100px">Maintenance</th>
<th align="center" width="100px">License</th>
</tr>
</thead>
<tbody>
<tr><td align="center"><a href="https://socket.dev/dashboard/org/un-ts/diff/045ae372-73bb-445f-87c7-d50049588e17/d42e1d8f-e261-4f69-b865-6cda61d88485?tab=dependencies&dependency_item_key=56355647"><img src="https://github-app-statics.socket.dev/diff-added.svg" title="Added" alt="Added" width="20" height="20"></a></td><td><a href="https://socket.dev/dashboard/org/un-ts/diff/045ae372-73bb-445f-87c7-d50049588e17/d42e1d8f-e261-4f69-b865-6cda61d88485?tab=dependencies&dependency_item_key=56355647">@​types/​tmp@​0.2.6</a></td><td align="center"><a href="https://socket.dev/dashboard/org/un-ts/diff/045ae372-73bb-445f-87c7-d50049588e17/d42e1d8f-e261-4f69-b865-6cda61d88485?tab=dependencies&dependency_item_key=56355647"><img src="https://github-app-statics.socket.dev/score-100.svg" title="Supply Chain Security" width="40" height="40" alt="100"></a></td><td align="center"><a href="https://socket.dev/dashboard/org/un-ts/diff/045ae372-73bb-445f-87c7-d50049588e17/d42e1d8f-e261-4f69-b865-6cda61d88485?tab=dependencies&dependency_item_key=56355647"><img src="https://github-app-statics.socket.dev/score-100.svg" title="Vulnerability" width="40" height="40" alt="100"></a></td><td align="center"><a href="https://socket.dev/dashboard/org/un-ts/diff/045ae372-73bb-445f-87c7-d50049588e17/d42e1d8f-e261-4f69-b865-6cda61d88485?tab=dependencies&dependency_item_key=56355647"><img src="https://github-app-statics.socket.dev/score-70.svg" title="Quality" width="40" height="40" alt="70"></a></td><td align="center"><a href="https://socket.dev/dashboard/org/un-ts/diff/045ae372-73bb-445f-87c7-d50049588e17/d42e1d8f-e261-4f69-b865-6cda61d88485?tab=dependencies&dependency_item_key=56355647"><img src="https://github-app-statics.socket.dev/score-76.svg" title="Maintenance" width="40" height="40" alt="76"></a></td><td align="center"><a href="https://socket.dev/dashboard/org/un-ts/diff/045ae372-73bb-445f-87c7-d50049588e17/d42e1d8f-e261-4f69-b865-6cda61d88485?tab=dependencies&dependency_item_key=56355647"><img src="https://github-app-statics.socket.dev/score-100.svg" title="License" width="40" height="40" alt="100"></a></td></tr>
</tbody>
</table>

[View full report](https://socket.dev/dashboard/org/un-ts/diff/045ae372-73bb-445f-87c7-d50049588e17/d42e1d8f-e261-4f69-b865-6cda61d88485?tab=dependencies)

<!-- overview-comment -->
author_association: NONE