react-native icon indicating copy to clipboard operation
react-native copied to clipboard

Updating eslint packages to flat config file

Open MCanhisares opened this issue 10 months ago • 8 comments

Summary:

Implements eslint flat config file support

Changelog:

[GENERAL] [ADDED] - Adding support for Flat Config files

Test Plan:

Run lint on a reproducer with the eslint config changes Reproducer example: https://github.com/MCanhisares/eslint-flat-upgrade

MCanhisares avatar Apr 08 '24 03:04 MCanhisares

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 19,558,636 +0
android hermes armeabi-v7a n/a --
android hermes x86 n/a --
android hermes x86_64 n/a --
android jsc arm64-v8a 22,928,758 -4
android jsc armeabi-v7a n/a --
android jsc x86 n/a --
android jsc x86_64 n/a --

Base commit: 3f17c8b5f04cd80517d7ba3943745f37dce7f5dd Branch: main

analysis-bot avatar Apr 08 '24 03:04 analysis-bot

@MCanhisares Is there any chance that this will be merged soon ?

jafar-jabr avatar May 01 '24 11:05 jafar-jabr

@cortinico what do we have to do to get this ready for merge?

Edit: To add more context, the JS tasks are failing because the eslint server is using the latest version of this package which should be ready for the new config format. Should we fix these issues in this PR? Or open another PR to handle the changes to the main proj?

MCanhisares avatar May 11 '24 23:05 MCanhisares

Any update on this?

Jonnboy91 avatar Jun 12 '24 12:06 Jonnboy91

LGTM on the face of it, importing to test inside the FB monorepo.

We should bump the template devDependency to ^8.23.0 as well though - I'll add that.

robhogan avatar Jun 12 '24 16:06 robhogan

@robhogan has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

facebook-github-bot avatar Jun 12 '24 16:06 facebook-github-bot

Hi @MCanhisares - thanks for this and sorry it's been in review for so long. Having had a closer look, this seems to break support for legacy config - this is actually the error CI is correctly reporting, and also came up importing to the internal monorepo - it requires users to update their projects to use flat config.

I think that's too much upgrade friction, and also presumably unintentional from the PR description - we should be able to support flat config without breaking legacy just yet, as eg jsx-eslint/eslint-plugin-react#3429 did.

Hi @robhogan, sorry this took a while to get back to, but I made the changes to support both legacy and new flat config formats

In order for this to work though, we need to change our approach for the configs, and export one that supports legacy .eslintrc projects and one for projects that use the new format (confirmed by one of the core eslint maintainers ).

Another problem arises from this, where eslint reads the package name to create an alias to the config itself, so we have two alternatives:

  1. Move away from the current package structure, and distribute the configs on the react-native-eslint-plugin package (seems like the better option, and is what the react, angular, solid and many others do)
  2. Create a new package eslint-config-react-native-flat and publish it so other projects can use the new config format.

The current code is uses approach 1, but I can easily migrate to 2 if you think it makes more sense

Let me know what you think, and also the tests might need to be updated to correctly read the new eslint configs. Where should I make those changes?

MCanhisares avatar Aug 15 '24 05:08 MCanhisares