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

Migrate to ESLint 9 and ESLint flat config #6615

Merged
merged 1 commit into from
Oct 16, 2024
Merged

Conversation

acelaya
Copy link
Contributor

@acelaya acelaya commented Oct 15, 2024

Depends on hypothesis/frontend-toolkit#50

Update project to ESLint 9 and migrate ESlint config to flat format.

This migration is introducing a few side effects:

  • All // eslint-disable comments which do not disable anything have been removed, as they are now reported as warning.
  • Error variable removed from catch blocks where the error is not used, as they are now reported as unused variables.
  • Some eslint plugins needed to be updated:
    • @typescript-eslint/... packages replaced by typescript-eslint and updated to v8
    • eslint-plugin-react-hooks updated to v5
    • eslint-plugin-mocha updated to v10.5
    • eslint-plugin-react updated to v7.37
    • eslint-config-hypothesis updated to v3

eslint.config.js Outdated Show resolved Hide resolved
@acelaya acelaya force-pushed the eslint-flat-config branch 3 times, most recently from b8441d4 to a7c40f2 Compare October 16, 2024 08:10
'**/coverage/**/*',
'docs/_build/*',
'dev-server/static/**/*.js',
],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many of these files are already ignored by .gitignore. Does ESLint not automatically respect that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, doesn't seem to. I even had to add a few more there that were not part of .eslintignore and were getting scanned now (.tox, .yarn and .yalc specifically).

eslint.config.js Outdated Show resolved Hide resolved

// Scripts and configuration files
{
files: ['**/*.js'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would prefer to use an allow-list rather than making these rules apply to all files and then attempting to exclude src/. It depends how cumbersome maintaining the allow-list is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, but for now let's just migrate the config as-is (as much as possible). We can adjust that later.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

package.json Outdated
"eslint-plugin-react": "^7.12.4",
"eslint-plugin-react-hooks": "^4.0.4",
"eslint": "^9.12.0",
"eslint-config-hypothesis": "file:.yalc/eslint-config-hypothesis",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A .yalc reference crept into the package.json file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'll change that once eslint-config-hypothesis v3 is released with support for flat config.

'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-this-alias': 'off',
'@typescript-eslint/consistent-type-assertions': 'error',
'@typescript-eslint/consistent-type-imports': 'error',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we use the same rules in other TS-enabled projects. It would be good to centralize them in eslint-config-hypothesis where appropriate.

@acelaya acelaya marked this pull request as ready for review October 16, 2024 13:24
Copy link

codecov bot commented Oct 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.42%. Comparing base (6a6e3ce) to head (d0df1ca).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6615   +/-   ##
=======================================
  Coverage   99.42%   99.42%           
=======================================
  Files         270      270           
  Lines       10175    10175           
  Branches     2419     2419           
=======================================
  Hits        10117    10117           
  Misses         58       58           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@robertknight robertknight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for this 👍

@acelaya acelaya merged commit d7d77ff into main Oct 16, 2024
4 checks passed
@acelaya acelaya deleted the eslint-flat-config branch October 16, 2024 13:53
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 this pull request may close these issues.

2 participants