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

Update to eslint flat config and yea/nay all rules #3240

Merged
merged 76 commits into from
Jul 17, 2024

Commits on Jul 16, 2024

  1. Moving eslint config to flat config system

    This is the default for eslint 9 and will be the only option
    in eslint 10.
    
    See https://eslint.org/docs/latest/use/configure/migration-guide
    
    There's apparently a bug with the globals release we had
    automatically installed and eslint flat config, so just updated
    to the latest version manually since that one is fixed.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    c02e844 View commit details
    Browse the repository at this point in the history
  2. Fix previously undetected eslint issues

    For some reason (.mjs differences?) these two files
    had eslint issues that were not reported with the old config.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    7e75318 View commit details
    Browse the repository at this point in the history
  3. Move unfixed rules into the flat eslint config

    Rather than having a convoluted system to check unfixed rules,
    this just has them apply to all files, and only selectively
    disables them for files we know to be unfixed.
    This helps us not introduce more issues in the meantime.
    I did generalize a bit for release-editor and similar folders
    where we don't expect to fix the files but convert them entirely,
    so there's no point fixing them file by file.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    30ab720 View commit details
    Browse the repository at this point in the history
  4. Fix previously undetected eslint issues

    For some reason (.mjs differences?) these files
    had eslint issues that were not reported with the old config.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    490f177 View commit details
    Browse the repository at this point in the history
  5. Add no-constant-binary-expression rule

    This is a new recommended rule in eslint 9:
    https://eslint.org/docs/latest/use/migrate-to-9.0.0
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    42bd47a View commit details
    Browse the repository at this point in the history
  6. Use @Stylistic JS eslint plugin

    Most stylistic rules have been split from the eslint package
    and moved to a separate one - the eslint ones still work but
    are officially deprecated, so we might as well update before
    they break.
    I'll move these to a separate block in a second commit to make it easier to review.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    55299d4 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    7bc2043 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    3044041 View commit details
    Browse the repository at this point in the history
  9. Add eslint dot-location rule

    https://eslint.style/rules/js/dot-location
    
    We consistently use the property dot location position.
    Especially given how that's not even the eslint default,
    it seems worth enforcing with a rule.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    0a5f600 View commit details
    Browse the repository at this point in the history
  10. Add eslint generator-star-spacing rule

    https://eslint.style/rules/js/generator-star-spacing
    
    We consistently use the 'after' style.
    Especially given how that's not even the eslint default,
    it seems worth enforcing with a rule.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    36580f9 View commit details
    Browse the repository at this point in the history
  11. Use stylistic plugin no-extra-semi

    This was listed under errors, but it's a stylistic rule.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    fb7d769 View commit details
    Browse the repository at this point in the history
  12. Use stylistic plugin no-floating-decimal

    This was listed under best practices, but it's a stylistic rule.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    917e7e5 View commit details
    Browse the repository at this point in the history
  13. Use stylistic plugin no-multi-spaces

    This was listed under best practices, but it's a stylistic rule.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    65ba677 View commit details
    Browse the repository at this point in the history
  14. Use stylistic plugin rest-spread-spacing

    This was listed under ECMAScript 6, but it's a stylistic rule.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    23f8f88 View commit details
    Browse the repository at this point in the history
  15. Use stylistic plugin template-curly-spacing

    This was listed under ECMAScript 6, but it's a stylistic rule.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    401adb0 View commit details
    Browse the repository at this point in the history
  16. Add eslint yield-star-spacing rule

    https://eslint.style/rules/js/yield-star-spacing
    
    We were inconsistent here, but I talked to mwiencek and we both
    prefer the 'after' default.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    948b84c View commit details
    Browse the repository at this point in the history
  17. Use @Stylistic JSX eslint plugin

    Most stylistic React rules have been split from the react package
    and moved to a separate one - the react ones still work but
    are officially deprecated, so we might as well update before
    they break.
    I'll move these to a separate block in a second commit to make it easier to review.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    1eb74d0 View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    5a3c942 View commit details
    Browse the repository at this point in the history
  19. Add eslint jsx-curly-newline rule

    https://eslint.style/rules/jsx/jsx-curly-newline
    
    We were inconsistent here, but not horribly so.
    Auto --fix'ed 38 issues.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    82c98b0 View commit details
    Browse the repository at this point in the history
  20. Update no-new-symbol to no-new-native-nonconstructor

    The old rule is deprecated in 9.0.0 and replaced with
    the new one, which is already available, so making
    the change in preparation.
    
    We don't have any clashes with the new rule, it seems.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    1c18fe1 View commit details
    Browse the repository at this point in the history
  21. Configuration menu
    Copy the full SHA
    829a6fd View commit details
    Browse the repository at this point in the history
  22. Configuration menu
    Copy the full SHA
    7ea7c67 View commit details
    Browse the repository at this point in the history
  23. Apply or actively reject eslint problem solving rules

    We already intentionally clarified we did not use a lot of rules.
    This is the first step into making that more generalized,
    plus it applies a bunch of newer rules we already followed
    but might actually want to enforce.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    cfd0af6 View commit details
    Browse the repository at this point in the history
  24. Organize rules like eslint does

    This was fairly arbitrary anyway, and this makes it easier
    to compare with the eslint rule docs.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    8d1d1a7 View commit details
    Browse the repository at this point in the history
  25. Add eslint default-case-last rule

    https://eslint.org/docs/latest/rules/default-case-last
    
    We have one use which kinda makes sense, but is also confusing.
    There's no reason we cannot put case 0 and default last, and
    we don't actually have a type 0,
    so it's already a default anyway.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    5a001f0 View commit details
    Browse the repository at this point in the history
  26. Add eslint default-param-last rule

    https://eslint.org/docs/latest/rules/default-param-last
    
    We have three cases where it seems to be needed to flout the rule
    (two seem to just be because the rule doesn't understand that
    ? means the param is optional anyway).
    Added eslint-disable comments for those.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    3485cf4 View commit details
    Browse the repository at this point in the history
  27. Add eslint no-case-declarations rule

    https://eslint.org/docs/latest/rules/no-case-declarations
    
    None of our few hits seem intentional (they all end in break;),
    so just added brackets as suggested by the rule.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    5be4506 View commit details
    Browse the repository at this point in the history
  28. Add eslint no-useless-concat rule

    https://eslint.org/docs/latest/rules/no-useless-concat
    
    The two places where we hit this do not seem more clear for having
    two separate strings.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    1520d50 View commit details
    Browse the repository at this point in the history
  29. Add eslint no-useless-escape rule

    https://eslint.org/docs/latest/rules/no-useless-escape
    
    We had a somewhat embarrassing amount of hits here,
    including a few where we were escaping *too little*.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    4540077 View commit details
    Browse the repository at this point in the history
  30. Add eslint no-redeclare rule

    https://eslint.org/docs/latest/rules/no-redeclare
    
    We had one hit, where the redeclared param seems useless
    anyway.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    27fc678 View commit details
    Browse the repository at this point in the history
  31. Add eslint no-return-assign rule

    https://eslint.org/docs/latest/rules/no-return-assign
    
    Couple of places where we didn't want to return anything
    anyway, so just doing { }.
    In URLCleanup, all we gained was one line, so eh.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    8a0e808 View commit details
    Browse the repository at this point in the history
  32. Add eslint no-loop-func rule

    https://eslint.org/docs/latest/rules/no-loop-func
    
    The only place where we hit this is actually fine
    because it's executed immediately but in general this is
    a good thing to keep in mind.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    6fcf118 View commit details
    Browse the repository at this point in the history
  33. Add eslint logical-assignment-operators rule

    https://eslint.org/docs/latest/rules/logical-assignment-operators
    
    We weren't using these at all, but it actually seems quite nice
    and avoids a lot of repetition.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    dea9185 View commit details
    Browse the repository at this point in the history
  34. Add eslint no-implicit-coercion rule

    https://eslint.org/docs/latest/rules/no-implicit-coercion
    
    In many cases, especially when we have Flow types, it's
    a lot better to just do the actual check that makes sense
    based on the data instead of having boolean coercion.
    For places where we don't have Flow, or coercion to
    string or number, it's probably sensible to just do
    the coercion explicitly.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    956ebd2 View commit details
    Browse the repository at this point in the history
  35. Add eslint func-style rule

    https://eslint.org/docs/latest/rules/func-style
    
    By far most of our (non-arrow) functions were already using
    the declaration style, so this just standardises the last few cases
    for consistency.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    5eaad03 View commit details
    Browse the repository at this point in the history
  36. Configuration menu
    Copy the full SHA
    40e1ee6 View commit details
    Browse the repository at this point in the history
  37. Configuration menu
    Copy the full SHA
    49f8952 View commit details
    Browse the repository at this point in the history
  38. Add eslint object-shorthand rule

    https://eslint.org/docs/latest/rules/object-shorthand
    
    All --fix'ed. In TagEditor Flow was worried but it seems to be
    a false positive for object-this-reference.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    7683cba View commit details
    Browse the repository at this point in the history
  39. Add eslint prefer-object-has-own rule

    https://eslint.org/docs/latest/rules/prefer-object-has-own
    
    Using this means we no longer seem to have a need
    for our own function hasOwnProp.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    2a3a774 View commit details
    Browse the repository at this point in the history
  40. Add eslint prefer-regex-literals rule

    https://eslint.org/docs/latest/rules/prefer-regex-literals
    
    Almost all changes are in the match section of URLCleanup.
    Honestly, I'm not sure what the original reason was for that part
    to be a string regex - there was a slight benefit, in that it allowed
    having the regex in several lines to make it a bit more readable.
    That said, there were so many cases where we were over-escaping
    and, a lot worse, a bunch where we were *under-escaping*, leading
    to actually incorrect regexes.
    This way is a lot easier to get the escapes right.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    5d0cd29 View commit details
    Browse the repository at this point in the history
  41. Configuration menu
    Copy the full SHA
    fa9b4bb View commit details
    Browse the repository at this point in the history
  42. Add eslint prefer-spread rule

    https://eslint.org/docs/latest/rules/prefer-spread
    
    GuessCase/Main was messy enough that this refactors it a bit
    to make Flow less angry.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    da08136 View commit details
    Browse the repository at this point in the history
  43. Add eslint require-await rule

    https://eslint.org/docs/latest/rules/require-await
    
    This mostly hit cases where we didn't actually need async
    since they return Promises. There was one case where we needed to wrap some returns
    in Promise wrappers, but that's about it.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    9ec526c View commit details
    Browse the repository at this point in the history
  44. Activate the eslint strict rule

    We don't need this to remind us to use strict, but it did warn me
    of one unnecessary use of it! So worth having on for that.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    00a4ecb View commit details
    Browse the repository at this point in the history
  45. yoda eslint rule add

    https://eslint.org/docs/latest/rules/yoda
    
    Three cases of this we had, a bit stupid it looked.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    3d0531c View commit details
    Browse the repository at this point in the history
  46. Add other Suggestions rules from eslint

    This adds some rules that seem useful as warn, and lists all others
    as off, so we know we looked at them and decided against them
    rather than not having decided yet.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    1b9374a View commit details
    Browse the repository at this point in the history
  47. Configuration menu
    Copy the full SHA
    77f247e View commit details
    Browse the repository at this point in the history
  48. Add eslint no-extraneous-dependencies rule

    https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-extraneous-dependencies.md
    
    We only had one of this, defined in selenium.mjs... which seems
    to be pretty useless anyway, so just replacing it with a simpler
    option (we shouldn't really care if the message is '' or undefined).
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    a622e58 View commit details
    Browse the repository at this point in the history
  49. Add eslint prefer-default-export rule

    https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/prefer-default-export.md
    
    There's no good reason anymore to not have a default export
    for manifest (we used to have two exports but we no longer do).
    Other files were a lot more trivial.
    tableColumns is clearly meant as something that might eventually
    have more exports, and so is report/constants,
    so I disabled the rule there. Same for i18n/history.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    7987429 View commit details
    Browse the repository at this point in the history
  50. Document eslint-plugin-import rule usage

    This activates a few more rules and specifies the ones we do not want
    are intentionally off. There's a few rules that do not currently
    work with a flat config setup but we probably do want;
    I commented those out for now.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    f8c485b View commit details
    Browse the repository at this point in the history
  51. Configuration menu
    Copy the full SHA
    f468b36 View commit details
    Browse the repository at this point in the history
  52. Configuration menu
    Copy the full SHA
    6c3448e View commit details
    Browse the repository at this point in the history
  53. Document eslint-plugin-js rule usage

    This activates a few more rules and specifies the ones we do not want
    are intentionally off.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    ec1b295 View commit details
    Browse the repository at this point in the history
  54. Document eslint-jsx stylistic rule usage

    This activates a few more rules and specifies the ones we do not want
    are intentionally off.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    300f3d8 View commit details
    Browse the repository at this point in the history
  55. Configuration menu
    Copy the full SHA
    f84795a View commit details
    Browse the repository at this point in the history
  56. Configuration menu
    Copy the full SHA
    6886150 View commit details
    Browse the repository at this point in the history
  57. Configuration menu
    Copy the full SHA
    7072352 View commit details
    Browse the repository at this point in the history
  58. Document eslint-plugin-react rule usage

    This activates a few more rules and specifies the ones we do not want
    are intentionally off.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    c85e89c View commit details
    Browse the repository at this point in the history
  59. Add eslint ft-flow/enforce-suppression-code rule

    https://github.com/flow-typed/eslint-plugin-ft-flow?tab=readme-ov-file#enforce-suppression-code
    
    Our Multiselect typing is a horrible mess that we will fix
    in a separate PR, for now this disables the rule there
    since we have to ignore *four* Flow rules for them.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    d5ed41b View commit details
    Browse the repository at this point in the history
  60. Configuration menu
    Copy the full SHA
    f875680 View commit details
    Browse the repository at this point in the history
  61. Configuration menu
    Copy the full SHA
    736134f View commit details
    Browse the repository at this point in the history
  62. Add eslint ft-flow/no-internal-flow-type rule

    https://github.com/flow-typed/eslint-plugin-ft-flow?tab=readme-ov-file#no-internal-flow-type
    
    We were using these to avoid importing React all the time,
    but a recent Flow version made it so that it's no longer needed,
    so we might as well return to the standard types.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    5a64d78 View commit details
    Browse the repository at this point in the history
  63. Document eslint-plugin-ft-flow rule usage

    This activates a few more rules and specifies the ones we do not want
    are intentionally off.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    7a5bc2c View commit details
    Browse the repository at this point in the history
  64. Configuration menu
    Copy the full SHA
    73fae4c View commit details
    Browse the repository at this point in the history
  65. Configuration menu
    Copy the full SHA
    04a0b7c View commit details
    Browse the repository at this point in the history
  66. Document eslint-plugin-fb-flow rule usage

    This activates a few more rules and specifies the ones we do not want
    are intentionally off.
    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    0d75ce9 View commit details
    Browse the repository at this point in the history
  67. Configuration menu
    Copy the full SHA
    cbc62c9 View commit details
    Browse the repository at this point in the history
  68. Remove unneded void

    reosarevok committed Jul 16, 2024
    Configuration menu
    Copy the full SHA
    504d5ce View commit details
    Browse the repository at this point in the history
  69. Configuration menu
    Copy the full SHA
    12dc0eb View commit details
    Browse the repository at this point in the history

Commits on Jul 17, 2024

  1. Update eslint-plugin-ft-flow to v3.0.9

    This fixes a bug where flow annotations were not seen
    when in multiline comments - so most of our files...
    
    A lot of issues came up that were previously hidden for
    'no-flow-suppressions-in-strict-files'.
    reosarevok committed Jul 17, 2024
    Configuration menu
    Copy the full SHA
    9f7822e View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    1eb0401 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    7022a20 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    5c6cbd5 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    ff02e28 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    a7fe8c3 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    8e33e64 View commit details
    Browse the repository at this point in the history