eslint-nibble icon indicating copy to clipboard operation
eslint-nibble copied to clipboard

Add support to new ESLint flat config

Open Alex-Sokolov opened this issue 2 years ago • 14 comments

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

Alex-Sokolov avatar Sep 01 '23 08:09 Alex-Sokolov

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 avatar Sep 01 '23 12:09 IanVS

@IanVS any updates?

kobizz avatar Sep 19 '24 08:09 kobizz

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.

IanVS avatar Sep 19 '24 13:09 IanVS

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

johannes-lindgren avatar Sep 23 '24 17:09 johannes-lindgren

i mean, even in eslintrc, you should really be using ignorePatterns instead of an .eslintignore file - what happens if you make that change?

ljharb avatar Sep 23 '24 17:09 ljharb

@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.

johannes-lindgren avatar Sep 23 '24 17:09 johannes-lindgren

What plugins are you using? not all plugins are compatible yet with flat config.

ljharb avatar Sep 23 '24 17:09 ljharb

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 avatar Sep 23 '24 17:09 johannes-lindgren

@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 avatar Sep 23 '24 18:09 IanVS

@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.

johannes-lindgren avatar Sep 23 '24 19:09 johannes-lindgren

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

rainagalbiati-turngate avatar Jan 02 '25 22:01 rainagalbiati-turngate

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.

IanVS avatar Jan 03 '25 16:01 IanVS

Sounds good! just wanted to make sure I wasn't missing anything. Thanks!

rainagalbiati-turngate avatar Jan 03 '25 16:01 rainagalbiati-turngate

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.

davidenke avatar May 20 '25 20:05 davidenke