I'm trying to upgrade eslint
to v9
for next-json
I followed the official Getting started guideline, but in order to make it work I need to set "type": "module"
in the package.json
file.
Since I'm distributing the package both as CJS and ESM, I'm warried this setting may create issues on the CJS distributed version.
Can I safely distribute the package with this setting as well?
Yes, you can. If you can't set "type": "module"
in your package.json
, you can still either:
eslint.config.mjs
instead of *.cjs
or .js
import
s and export default [ ... ]
, you'd use require
s and module.exports = [ ... ]
:
const eslint = require('eslint');
const tseslint = require('typescript-eslint');
module.exports = [
eslint.configs.recommended,
...tseslint.configs.recommended,
];
This question came up in the typescript-eslint docs: see https://github.com/typescript-eslint/typescript-eslint/pull/927 and its linked issues. Naming the ESLint config file eslint.config.mjs
is what the typescript-eslint docs now do.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With