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

Upgrade eslint #224

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Upgrade eslint #224

wants to merge 5 commits into from

Conversation

comunidadio
Copy link
Contributor

@comunidadio comunidadio commented Aug 13, 2024

This PR upgrades prettier and migrates to eslint 9.

The recommended set rules have changed slightly, so this PR also fixes newly triggered (minor) violations.
In our case, recommended rule set had some rules set to "warn" in earlier versions.instead of "error" now (no-unused-vars and no-explicit-any)

Copy link
Contributor

@frankfka frankfka left a comment

Choose a reason for hiding this comment

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

Nice work, leaving a few questions for my own understanding

Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need to be .mjs? The ESLint docs has this just as .js

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ESLint docs also allows mjs and cjs extensions.

Used mjs here to allow modern "import/export" style rather than "require/module.exports", without changing our package.json to type:module (which may have other implications).

ecmaFeatures: { jsx: true },
},
globals: {
/* replacement for env.node:true in eslintrc */
Copy link
Contributor

Choose a reason for hiding this comment

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

Did we actually need this?

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 "env" is not supported anymore so we need to define it in globals

https://eslint.org/docs/latest/use/configure/migration-guide#configuring-language-options

in our case, mostly for "console" and "NodeJS.Timeout" type we use in few places.


export class PerpExecuteAPI extends BaseVertexAPI {
async settlePnl(params: SettlePnlParams) {
async settlePnl(/*params: SettlePnlParams*/) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: We could potentially remove the param for now

import tsParser from '@typescript-eslint/parser';
import tsPlugin from '@typescript-eslint/eslint-plugin';
import reactPlugin from 'eslint-plugin-react';
import reactHooksPlugin from 'eslint-plugin-react-hooks';
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this support eslint v9? facebook/react#28313 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

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

image

We could hold off on this until all dependencies support v9 - not a huge deal. We could potentially upgrade prettier though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

aaah, good catch, support look pretty close as it only fails when an error needs to be reported it seems.

using eslint-plugin-react@canary it reports errors normally if we want to go ahead without waiting a stable version release.
updated.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can probably park this until a stable release is out

@@ -0,0 +1,54 @@
import globals from "globals";
import js from '@eslint/js';
import tsParser from '@typescript-eslint/parser';
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity, typescript-eslint recommends using their own .config fn, would this be useful? https://typescript-eslint.io/getting-started

Copy link
Contributor Author

Choose a reason for hiding this comment

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

doesn't feel especially handy as we also use other rules that do not support this "config fn" construct.

},
rules: {
...js.configs.recommended.rules,
...tsPlugin.configs['eslint-recommended'].rules,
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you know the difference between this & .recommended below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems to be there to adjust core "js" eslint rules above to work better with typescript - eslint-recommended

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