Skip to content

Upgrade eslint and eslint-related packages - #51059

Merged
molly-moen merged 28 commits into
stagingfrom
molly/update-linting
Apr 7, 2023
Merged

Upgrade eslint and eslint-related packages#51059
molly-moen merged 28 commits into
stagingfrom
molly/update-linting

Conversation

@molly-moen

@molly-moen molly-moen commented Mar 31, 2023

Copy link
Copy Markdown
Contributor

Upgrade of various linting packages:

  • upgrade from babel-eslint to @babel/eslint-parser (package name changed)
  • eslint
  • eslint-config-prettier
  • eslint-plugin-babel
  • eslint-plugin-mocha
  • eslint-plugin-prettier
  • eslint-plugin-react-hooks

I also added linting packages for typescript, and set up configurations for typescript files in .eslintrc.js, but have not adding typescript linting to yarn lint yet. That will be done as a follow-up so this PR stays scoped to the various upgrades.

I kept our non-typescript files linted with the babel parser, and we will use @typescript-eslint/parser for our typescript files. There were a few discrepancies between the two parsers that made it hard to do an easy swap out, and it made sense to me to have typescript-specific parsing for typescript files only. However, we could revisit this if we find it confusing to have two linters (or at least unify rules if we discover major differences).

I fixed a few new linter errors that were obviously safe to fix (such as 3 global variables that were not used, and one case of a react hook dependency array that was safe). For the rest, I either added ignores for rules that would need many ignore comments, or adding ignore comments to relevant lines. We will follow up with fixes/investigations for these violations. The categories of violations are:

  • no-prototype-builtins. This seems to be a new rule, that I am currently ignoring because we had many violations. The fix here seems straightforward, so I created a task on student learning to update our usage here.
  • no-redeclare. I needed to add an exception for builtInGlobals to this rule. I made a task on Student Learning to start investigating this and determine whether to follow the new rule or not.
  • react-hooks/exhaustive-deps seems to have become more strict (there is no official documentation for this rule, the best I rule itself links to this github issue, and now alarms on nested objects and functions that are not in the array. This one needs to be resolved on a case-by-case basis. Here is a ticket for the student learning violations and a thread with teacher tools about fixing their violations.
  • There was one case of needing to ignore no-async-promise-executor. I think this is a student learning component, here's the follow-up ticket.

As part of working on this I ended up linting .eslintrc.js with prettier. We actually don't need prettier on that root level, but I left it as-is because it is more consistent with our other javascript files.

Links

Testing story

I mostly used drone to validate these changes.

Follow-up work

See the list above for various follow-ups

PR Checklist:

  • Tests provide adequate coverage
  • Privacy and Security impacts have been assessed
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

@molly-moen molly-moen changed the title Molly/update linting Upgrade eslint and eslint-related packages Apr 6, 2023
@molly-moen
molly-moen marked this pull request as ready for review April 6, 2023 21:48
@molly-moen
molly-moen requested a review from a team April 6, 2023 21:48
Comment thread apps/.eslintrc.js
"react/no-danger": "error",
}
'babel/semi': 'error', // autofixable
'cdo-custom-rules/style-blocks-below-class': 'error',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see a few rules like this one moved into apps, did that happen as part of the linting or was a conscious choice (I think this one in particular makes sense here b/c its react-specific)?

@molly-moen molly-moen Apr 7, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Conscious choice I forgot to include in the PR description! 2 reasons: they are all specific to apps (react, babel, mocha tests), and now eslint does package resolution slightly differently, so us referencing the rules in a folder where the packages did not exist (all the eslint packages are installed to /apps) was causing some inconsistent behavior.

@sanchitmalhotra126 sanchitmalhotra126 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Awesome! Thanks for documenting all the follow-up tasks!

@molly-moen
molly-moen merged commit 7f4e695 into staging Apr 7, 2023
@molly-moen
molly-moen deleted the molly/update-linting branch April 7, 2023 18:59
@fisher-alice

Copy link
Copy Markdown
Contributor

Awesome! Thanks for documenting all the follow-up tasks!

+1 on the documentation for the follow-up tasks and preliminary investigation into these! Thanks Molly!

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.

4 participants