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

[static-site] we're not linting TS files #905

Closed
Tracked by #871
jameshadfield opened this issue Jun 6, 2024 · 6 comments
Closed
Tracked by #871

[static-site] we're not linting TS files #905

jameshadfield opened this issue Jun 6, 2024 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@jameshadfield
Copy link
Member

Our static-site linting rule needs to consider ts and tsx files:

"lint:static-site": "cd static-site && DEBUG=eslint:cli-engine npx eslint --ext .js,.jsx .",

Observed because the nextjs build failed (due to linting errors) in #904

@jameshadfield jameshadfield added the bug Something isn't working label Jun 6, 2024
@genehack genehack self-assigned this Jun 6, 2024
@genehack
Copy link
Contributor

genehack commented Jun 6, 2024

Note: this is also going to require extending/upgrading the ESLint ecosystem to get it to be able to parse Typescript ...

@jameshadfield
Copy link
Member Author

Here's how auspice does it - not saying nextstrain.org has to do the same, but if there's no objectively better way then it'd be nice to have consistency.

@genehack
Copy link
Contributor

genehack commented Jun 7, 2024

Okay, there's a bit of yak shaving potential here...

Installing @typescript-eslint/eslint-plugin fails due to ...some sort of tangled conflict between peer deps and eslint-config-next (which is a regular dependency, not a devDep, for some reason. We're also installing eslint-plugin-jest but don't seem to be loading/using that anywhere. Finally, we've got a lot of things that are fairly out of date and probably contributing to the kinda high number of audit warnings (currently: 44 vulnerabilities (1 low, 20 moderate, 18 high, 5 critical)):

Package Installed Current
eslint 8.23.1 9.4.0
@babel/eslint-parser 7.19.1 7.24.7
eslint-config-next 14.2.3 14.2.3
eslint-plugin-jest 27.0.4 28.6.0

Due to eslint-config-next lacking ESLint v9 support, we need to stay with ESLint v8, but we could bump to v8.57.0.

I propose to do the following:

1. remove eslint-plugin-jest
2. Update eslint to v8.57.0
3. install @typescript-eslint/eslint-plugin and @typescript-eslint/parser (I think this will work once the jest plugin is removed, I think it is actually the source of the failing peer dep, because it wants an older version of the typescript parser than eslint-config-next allows for)
4. update static-site/.eslintrc.yaml to load the TS parser, the TS plugin, and add the @typescript-eslint/recommended ruleset to the extends list
5. evaluate the linting and see what rules we might want to bring over from nextstrain/auspice (linked above by James)

Potentially a scope expansion, but if we want to push for standardization across nextstrain.org, auspice, and other Nextstrain projects using Typescript, I think the right way to do that is to do the extra work to publish a @nextstrain/nextstrain-eslint-config package on NPM, rather than depending on copypasta to keep files sync'd.

I'm very much on the fence about the value of 100% sync of linting rules across these two projects at this point in time.

I would LOVE to hear opinions and feedback about the above!

@tsibley
Copy link
Member

tsibley commented Jun 7, 2024

I'm very much on the fence about the value of 100% sync of linting rules across these two projects at this point in time.

I would LOVE to hear opinions and feedback about the above!

I don't think our different projects have to have exactly the same linting/setups/whatever. I'm not going to stand in the way of it if folks think it's valuable, but personally I think effort spent to make everything the same in those regards is needless work. I think copying as a starting point is fine, and I think they'll likely diverge over time and that's also fine.

@victorlin victorlin mentioned this issue Jun 7, 2024
6 tasks
@victorlin
Copy link
Member

Thanks for catching this, should've been a part of #877!

Figuring out the right versions of packages that work together is a struggle. Your proposal sounds good.

[eslint-config-next] is a regular dependency, not a devDep, for some reason

This is noted in vercel/next.js#50731 (comment). I think we can manually move it over the devDependencies and things will continue to work fine.

genehack added a commit that referenced this issue Jun 7, 2024
As far as I can tell, this plugin is not being used.
genehack added a commit that referenced this issue Jun 7, 2024
Also manually updated the version in package.json
genehack added a commit that referenced this issue Jun 7, 2024
genehack added a commit that referenced this issue Jun 7, 2024
…everywhere we're currently violating it.
genehack added a commit that referenced this issue Jun 7, 2024
…to make the linter happy
genehack added a commit that referenced this issue Jun 7, 2024
genehack added a commit that referenced this issue Jun 7, 2024
Load up required bits of ESLint machinery; update the
`lint:static-site` script to also look at *.tsx? files.
genehack added a commit that referenced this issue Jun 7, 2024
Also manually updated the version in package.json
genehack added a commit that referenced this issue Jun 7, 2024
genehack added a commit that referenced this issue Jun 7, 2024
…everywhere we're currently violating it.
genehack added a commit that referenced this issue Jun 7, 2024
…to make the linter happy
genehack added a commit that referenced this issue Jun 7, 2024
genehack added a commit that referenced this issue Jun 7, 2024
Load up required bits of ESLint machinery; update the
`lint:static-site` script to also look at *.tsx? files.
@genehack
Copy link
Contributor

genehack commented Jun 7, 2024

Update: eslint-plugin-jest is used, by the ESLint config in the repo root. Plan above updated accordingly.

genehack added a commit that referenced this issue Jun 7, 2024
genehack added a commit that referenced this issue Jun 7, 2024
Per [install instructions](https://typescript-eslint.io/getting-started/).

Note: also update `eslint-plugin-jest` to 28.6.0, in order to allow v7
of the typescript-eslint packages to be installed (previous version
only peerDep'd with ^5.0.0 version).
genehack added a commit that referenced this issue Jun 7, 2024
…everywhere we're currently violating it.
genehack added a commit that referenced this issue Jun 7, 2024
…to make the linter happy
genehack added a commit that referenced this issue Jun 7, 2024
genehack added a commit that referenced this issue Jun 7, 2024
Load up required bits of ESLint machinery; update the
`lint:static-site` script to also look at *.tsx? files.
genehack added a commit that referenced this issue Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants