I’ve created a starter project for open source projects that includes features like commitlint, release-it, etc.
https://github.com/fireflysemantics/fs-github-flow-docs-starter
If we clone it down like this:
git clone https://github.com/fireflysemantics/fs-github-flow-docs-starter
And add "type": "module"
to package.json
and try to do a commit like this:
git add package.json
git commit -m "fail"
Instead of the normal commitlint message that looks something like this:
⧗ input: fail
✖ subject may not be empty [subject-empty]
✖ type may not be empty [type-empty]
✖ found 2 problems, 0 warnings
We get:
ReferenceError: module is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '/Users/oleersoy/Github/RM1/fs-github-flow-docs-starter/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
at file:///Users/oleersoy/Github/RM1/fs-github-flow-docs-starter/commitlint.config.js:1:1
at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
at async loadJs (/Users/oleersoy/Github/RM1/fs-github-flow-docs-starter/node_modules/cosmiconfig/dist/loaders.js:23:17)
at async #loadConfiguration (/Users/oleersoy/Github/RM1/fs-github-flow-docs-starter/node_modules/cosmiconfig/dist/Explorer.js:116:36)
at async #loadConfigFileWithImports (/Users/oleersoy/Github/RM1/fs-github-flow-docs-starter/node_modules/cosmiconfig/dist/Explorer.js:87:31)
at async #readConfiguration (/Users/oleersoy/Github/RM1/fs-github-flow-docs-starter/node_modules/cosmiconfig/dist/Explorer.js:84:51)
at async search (/Users/oleersoy/Github/RM1/fs-github-flow-docs-starter/node_modules/cosmiconfig/dist/Explorer.js:50:40)
at async Explorer.search (/Users/oleersoy/Github/RM1/fs-github-flow-docs-starter/node_modules/cosmiconfig/dist/Explorer.js:78:20)
at async loadConfig (file:///Users/oleersoy/Github/RM1/fs-github-flow-docs-starter/node_modules/@commitlint/load/lib/utils/load-config.js:53:19) {
filepath: '/Users/oleersoy/Github/RM1/fs-github-flow-docs-starter/commitlint.config.js'
}
Any ideas on why this is?