Closed brownsugar closed 5 months ago
Any reason to use eslint.config.cjs
instead of eslint.config.mjs
?
Any reason to use
eslint.config.cjs
instead ofeslint.config.mjs
?
When I use eslint.config.mjs
I receive this error:
Cannot write file '/path/to/project/eslint.config.mjs' because it would overwrite input file.ts
@vctrtvfrrr, This is not relevant. Set noEmit: true
in your tsconfig.json
The error mentioned (Cannot write file...
) appears in the server/tsconfig.json
file of any Nuxt project when using the new @nuxt/eslint
module along with the flat config file.
Setting noEmit: true
works, but it would be nice if the module handled this internally.
Can the module add this setting to .nuxt/tsconfig.server.json
?
Maybe by adding the following hook?
nuxt.hook('nitro:config', (config) => {
config.typescript.tsConfig.compilerOptions.noEmit = true;
});
@antfu I was trying to make a minimal shared config without using bundlers so just wrote it in CJS format.
We would suggest always use eslint.config.mjs
as there is almost no reason to not to (it works even in a CJS project). If you absolutely need CJS, I'd suggest you to use dynamic import then.
Environment
Build Modules: -
Package
@nuxt/eslint-config
Reproduction
https://codesandbox.io/p/devbox/nuxt-eslint-xxmhxc
Describe the bug
When using @nuxt/eslint-config package in ESLint with CJS config will throw an error.
Additional context
Logs