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 Object-only config files #38

Closed
nzakas opened this issue Apr 9, 2024 · 1 comment · Fixed by #37
Closed

Support Object-only config files #38

nzakas opened this issue Apr 9, 2024 · 1 comment · Fixed by #37

Comments

@nzakas
Copy link
Member

nzakas commented Apr 9, 2024

Flat config files can export either an array or an object. Right now, config inspector throws an error when attempting to load a config file with an object config like this:

export default {
    rules: {
        "no-undef": "error"
    }
};

Error:

Failed to load `eslint.config.js`.
Note that `@eslint/config-inspector` only works with the flat config format:
https://eslint.org/docs/latest/use/configure/configuration-files-new
TypeError: rawConfigs is not iterable
    at readConfig (file:///C:/Users/nzaka/AppData/Local/npm-cache/_npx/37ca41379bd26461/node_modules/@eslint/config-inspector/dist/cli.mjs:99:22)
    at async Object.getData (file:///C:/Users/nzaka/AppData/Local/npm-cache/_npx/37ca41379bd26461/node_modules/@eslint/config-inspector/dist/cli.mjs:200:16)
    at async Object.handler (file:///C:/Users/nzaka/AppData/Local/npm-cache/_npx/37ca41379bd26461/node_modules/@eslint/config-inspector/dist/cli.mjs:232:46)
    at async Object.handler (file:///C:/Users/nzaka/AppData/Local/npm-cache/_npx/37ca41379bd26461/node_modules/h3/dist/index.mjs:1962:19) 
    at async Server.toNodeHandle (file:///C:/Users/nzaka/AppData/Local/npm-cache/_npx/37ca41379bd26461/node_modules/h3/dist/index.mjs:2249:7)

It probably makes sense to just treat a config file that exports an object as an array with one item?

@antfu antfu closed this as completed in feffffe Apr 9, 2024
@antfu
Copy link
Collaborator

antfu commented Apr 9, 2024

Interesting, I didn't know that. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants