antfu / eslint-flat-config-viewer

A visual tool to help you view and understand your ESLint Flat config.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot resolve CJS ESLint config

PinkChampagne17 opened this issue · comments

Describe the bug

The viewer page always shows a white screen.

The browser console print:

FetchError: [GET] "/api/get": 500 Internal Server Error
    at async s (entry.c4bc8f9a.js:1:81738)
    at async i (entry.c4bc8f9a.js:1:81791)
    at async setup (entry.c4bc8f9a.js:5:88858)

The terminal print:

[nuxt] [request error] [unhandled] [500] raw is not iterable
  at processConfig (/C:/Users/username/AppData/Local/pnpm/global/5/.pnpm/eslint-flat-config-viewer@0.0.8/node_modules/eslint-flat-config-viewer/dist/server/chunks/get.mjs:91:24)
  at readConfig (/C:/Users/username/AppData/Local/pnpm/global/5/.pnpm/eslint-flat-config-viewer@0.0.8/node_modules/eslint-flat-config-viewer/dist/server/chunks/get.mjs:73:15)
  at /C:/Users/username/AppData/Local/pnpm/global/5/.pnpm/eslint-flat-config-viewer@0.0.8/node_modules/eslint-flat-config-viewer/dist/server/chunks/get.mjs:126:7
  at /C:/Users/username/AppData/Local/pnpm/global/5/.pnpm/eslint-flat-config-viewer@0.0.8/node_modules/eslint-flat-config-viewer/dist/server/chunks/nitro/node-server.mjs:2051:14
  at /C:/Users/username/AppData/Local/pnpm/global/5/.pnpm/eslint-flat-config-viewer@0.0.8/node_modules/eslint-flat-config-viewer/dist/server/chunks/nitro/node-server.mjs:2051:14
  at Object.handler (/C:/Users/username/AppData/Local/pnpm/global/5/.pnpm/eslint-flat-config-viewer@0.0.8/node_modules/eslint-flat-config-viewer/dist/server/chunks/nitro/node-server.mjs:2291:28)
  at Object.handler (/C:/Users/username/AppData/Local/pnpm/global/5/.pnpm/eslint-flat-config-viewer@0.0.8/node_modules/eslint-flat-config-viewer/dist/server/chunks/nitro/node-server.mjs:2115:31)
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  at async Server.toNodeHandle (/C:/Users/username/AppData/Local/pnpm/global/5/.pnpm/eslint-flat-config-viewer@0.0.8/node_modules/eslint-flat-config-viewer/dist/server/chunks/nitro/node-server.mjs:2304:7)

I found that rawConfigs is undefined due to the ESLint config is a CJS module without default property.

rawConfigs = jiti(configPath).default as FlatESLintConfigItem[]

Reproduction

https://github.com/p-dustbin/eslint-flat-config-viewer-cjs-issue

System Info

I think this info is not needed.

Used Package Manager

pnpm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.