Add support to new ESLint flat config
Now eslint-nibble finished with error when trying to run with new flat config
"lint": "eslint-nibble --config eslint.config.js . --ext .js,.ts,.vue",
https://eslint.org/docs/latest/use/configure/configuration-files-new
Thanks for the heads-up. I'll try to add support soon, but if anyone wants to submit a PR that would be excellent.
@IanVS any updates?
I haven't had time to dig into it so far. If anyone is interested, please feel free. Or, if you're willing to set up a reproduction repo that I can use as a starting point, that would also be helpful.
To me, it seems like it doesn't work without the flat config. I have an .eslintrc.cjs file with .eslintignore, and get this error:
(node:14980) ESLintIgnoreWarning: The ".eslintignore" file is no longer supported. Switch to using the "ignores" property in "eslint.config.js": https://eslint.org/docs/latest/use/configure/migration-guide#ignoring-files
I'm on eslint v8.56.0
i mean, even in eslintrc, you should really be using ignorePatterns instead of an .eslintignore file - what happens if you make that change?
@ljharb, I forgot to mention: it gave me another error:
throw new ESLintInvalidOptionsError(errors); ^
ESLintInvalidOptionsError: Invalid Options:
- Unknown options: extensions
- 'extensions' has been removed.
I don't have any extension option in my .eslintrc.cjs file, but perhaps it's somewhere in a plugin.
What plugins are you using? not all plugins are compatible yet with flat config.
I disabled all plugins, yet I get the error.
In this package, I am not using a flat config, hence why I didn't really expect and error message around that. I am migrating gradually in a monorepo. eslint-nibble used to work though, and I don't think I changed anything in this workspace
@johannes-lindgren eslint-nibble always sets extensions (until I have time to cut a new version, at least). I think it used to be required when interacting directly with the eslint API, but I could be wrong.
I don't think extensions support was removed until v9 though, so since you mention you've got a monorepo, I wonder if perhaps version 9 of eslint is being pulled in from somewhere. If you're sure it's broken with v8 and standard config files, please create a minimal reproduction so I can investigate.
@IanVS thanks for the swift reply; I was just about to post that I managed to work around the issue, and I think it's exactly what you suggested. In ESLint v9, the flat config file is the default. Though I didn't use ESLint v9 anywhere in the monorepo, when running eslint-nibble with npx, it somehow seems to resolve ESLint to version 9 (that's my guess at least). If I declare eslint-nibble indevDependencies, it works as expected.
I am using esLint v9, does that mean eslint-nibble isn't compatible? I am also getting
throw new ESLintInvalidOptionsError(errors); ^
ESLintInvalidOptionsError: Invalid Options:
Unknown options: extensions 'extensions' has been removed.
I tried adding eslint-nibble as a devDependency but that didn't fix it for me
Currently it's not compatible, no. I probably should have worked on adding this support over the holidays. No promises, but I'll try to take a crack at it before much longer if I can.
There's a merged PR (https://github.com/IanVS/eslint-nibble/pull/117) that will avoid the particular error you're seeing, but it's not released. I was hoping to release it along with support for flat-config, but haven't done that yet. If nothing else, I'll get that released ASAP so that ESLint 9 with legacy config-files should work. Thanks for your patience.
Sounds good! just wanted to make sure I wasn't missing anything. Thanks!
This tool is so very useful, I couldn't resist and just patched out the options extensions, resolvePluginsRelativeTo and rulesDir, which made it work for the time being.
I think the last two options aren't relevant for flat configs anyway, but I haven't looked closer.