Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support xo.config.cjs and .xo-config.cjs #561

Merged
merged 1 commit into from
Jun 21, 2021
Merged

Support xo.config.cjs and .xo-config.cjs #561

merged 1 commit into from
Jun 21, 2021

Commits on Jun 21, 2021

  1. Support xo.config.cjs, .xo-config.cjs

    - Fixes `ERR_REQUIRE_ESM` error from `cosmiconfig`.
    - Enables using `xo.config.cjs`/`.xo-config.cjs` in ESM packages with `"type": "module"`.
    
    Fixes #468.
    
    See
    
    - #468
    - https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
    
    Sample error output; problem fixed by this commit.
    
    ```text
    Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /my-code/.xo-config.js
    require() of ES modules is not supported.
    require() of /my-code/.xo-config.js from /my-code/node_modules/cosmiconfig/dist/loaders.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
    Instead rename .xo-config.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /my-code/package.json.
    ```
    joelpurra committed Jun 21, 2021
    Configuration menu
    Copy the full SHA
    75b10b7 View commit details
    Browse the repository at this point in the history