-
Notifications
You must be signed in to change notification settings - Fork 1k
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
chore(linting): Update versions and avoid {}
#10266
Conversation
|
||
type Merge<P1 = {}, P2 = {}> = Omit<P1, keyof P2> & P2 | ||
type Merge<P1 = object, P2 = object> = Omit<P1, keyof P2> & P2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to be overruled on the object
's here
Nice to finally get rid of that warning! v7 doesn't look breaking like you said but for v6 it's not immediately clear. It feels like the Vite and Prettier upgrades where they fixed bugs but if a user could somehow configure Vite or Prettier (they can), then technically it's breaking. Here it's ESLint, or TSLint. We don't ship an "eslintConfig": {
"extends": "@redwoodjs/eslint-config",
"root": true
}, a user is free to add more config here. It feels harmless but I don't want to deal with the collateral if I'm wrong, so I'd say just make it breaking. Unless you want to deal with the collateral. 😉 There's one thing that feels important to have more clarity on though. It looks like TSLint reorganized their configs: https://typescript-eslint.io/blog/announcing-typescript-eslint-v6/#reworked-configuration-names. E.g., this line may not include the same rules between v5 and v6: redwood/packages/eslint-config/shared.js Line 152 in 0e8c0ec
We also may not need to turn off these stylistic rules because they may not be included in the recommended config anymore (if the recommended config still exists; I think they renamed it?): redwood/packages/eslint-config/shared.js Lines 153 to 170 in 0e8c0ec
So maybe we should get more insight into that before proceeding. Thoughts? |
Thanks @jtoar. I've added a small script that collates the rules applied to each file and records them, highlighting differences. I've run that against these changes here and you'll see differences like:
My understanding of the reasons for these changes are:
I agree with what you said and that we should ship this in a major just because it's an underlying major dependency upgrade. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing!
// We support a `--sample` flag to only run on a sample of the files | ||
if (process.argv.includes('--sample')) { | ||
const sampleSize = cpus().length | ||
console.log(`Running on a sample of ${sampleSize} files`) | ||
files.sort(() => Math.random() - 0.5).splice(sampleSize) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to put on my imaginary physicist hat for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put my lazy person hat on for that one because I couldn't be bothered waiting for 138 files every time I was testing this haha.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved! There may be one or two changes to clean up in responding to your last comment:
@typescript-eslint/prefer-namespace-keyword stylistic so it is no longer applied and we don't have to turn it off. This also appears to be redundant because we do have @typescript-eslint/no-namespace enabled as part of 'recommended' and so that is erroring out where the @typescript-eslint/prefer-namespace-keyword would. Shall we disable this @typescript-eslint/no-namespace now?
Not sure I'm following you here; you said @typescript-eslint/prefer-namespace-keyword
no longer applies, and we were turning it off anyway before. So it wouldn't conflict with @typescript-eslint/prefer-namespace-keyword
would it? It looks like we have @typescript-eslint/no-namespace
set to error in both the existing and updated configs already.
@typescript-eslint/no-duplicate-enum-values and @typescript-eslint/no-unsafe-declaration-merging appear to be new rules applied under 'recommended' and so I disabled them to keep some parity with what we already have. I think we should just let them be enabled as this will ship in a major anyway.
I'd probably go with the defaults for these like you're saying since this is breaking anyway.
All in all super impressed with the thoroughness. Very nice! 🚀
Okay updated to allow those new default rules then. I'll fix the conflicts and then merge with the feature-breaking label and the next major milestone. Yeah sorry for being unclear. We used to disable |
Problem
I was getting a little tired of seeing:
when running
yarn lint
on the framework. You also see that firstWARNING: You are currently running...
warning on user apps not just the framework.Changes
eslint
and the@typescript-eslint
packageseslint-plugin
package - lets use the same tool everywherepackages/router/src/skipNav.tsx
to avoid warnings about using{}
as a typeNotes
You can find the v6 upgrade guide I followed here: https://typescript-eslint.io/blog/announcing-typescript-eslint-v6/. This covered all the changes needed, namely:
moduleResolution
changesThe v7 upgrade has no implications for us as far as I can tell: https://typescript-eslint.io/blog/announcing-typescript-eslint-v7/
The conversion to vitest was my own choice but seems like a reasonable one.
Outstanding
object
over{}
but perhaps one of the other possible alternative types is better. I don't know yet but happy to change it if others think there is a better option.