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 ESLint and related plugins #1250

Merged
merged 3 commits into from
Mar 10, 2023

Conversation

mszabo-wikia
Copy link
Contributor

@mszabo-wikia mszabo-wikia commented Mar 10, 2023

Which problem is this PR solving?

Short description of the changes

Bump ESLint to v7 and update related plugins. Suppress newly introduced or updated rules in a separate config section so that they can be evaluated and enabled later, except for stylistic rules that do not match the existing code style, or where the impact was limited enough to be trivially fixable or suppressable.

@typescript-eslint/eslint-plugin now validates that input files are indeed part of the tsconfig file configured in ESLint options. Since the plugin doesn't understand project references, this requires a small change to specify the package-specific tsconfig files for linting instead.

Also remove eslint-config-react-app (the CRA ESLint config), as it doesn't actually seem to bring much to the table—the Airbnb config seems to overwrite much of the same rules that this config is trying to provide. I ran eslint --print-config packages/jaeger-ui/src/components/App/index.jsx and eslint --print-config packages/jaeger-ui/src/components/App/Page.tsx to dump the active rules for JS and TS files with and without the config loaded, then diffed them:

--- ts-active-rules-cra.json	2023-03-10 21:24:37
+++ ts-active-rules-no-cra.json	2023-03-10 21:25:38
@@ -4,8 +4,7 @@
     "jest": true,
     "jasmine": true,
     "es6": true,
-    "node": true,
-    "commonjs": true
+    "node": true
   },
   "globals": {
     "__REACT_APP_GA_DEBUG__": false,
@@ -27,7 +26,6 @@
     "sourceType": "module"
   },
   "plugins": [
-    "flowtype",
     "import",
     "react",
     "jsx-a11y",
@@ -2850,15 +2848,6 @@
     ],
     "yoda": [
       "error"
-    ],
-    "flowtype/define-flow-type": [
-      "warn"
-    ],
-    "flowtype/require-valid-file-annotation": [
-      "warn"
-    ],
-    "flowtype/use-flow-type": [
-      "warn"
     ]
   },
   "settings": {
--- js-active-rules-cra.json	2023-03-10 21:24:48
+++ js-active-rules-no-cra.json	2023-03-10 21:25:30
@@ -4,15 +4,14 @@
     "jest": true,
     "jasmine": true,
     "es6": true,
-    "node": true,
-    "commonjs": true
+    "node": true
   },
   "globals": {
     "__REACT_APP_GA_DEBUG__": false,
     "__REACT_APP_VSN_STATE__": false,
     "__APP_ENVIRONMENT__": false
   },
-  "parser": "/REDACTED/jaeger-ui/node_modules/babel-eslint/lib/index.js",
+  "parser": null,
   "parserOptions": {
     "ecmaFeatures": {
       "jsx": true,
@@ -23,7 +22,6 @@
     "sourceType": "module"
   },
   "plugins": [
-    "flowtype",
     "import",
     "react",
     "jsx-a11y"
@@ -2830,15 +2828,6 @@
     ],
     "yoda": [
       "error"
-    ],
-    "flowtype/define-flow-type": [
-      "warn"
-    ],
-    "flowtype/require-valid-file-annotation": [
-      "warn"
-    ],
-    "flowtype/use-flow-type": [
-      "warn"
     ]
   },
   "settings": {

So the only things added by the config is Flow support (which the project doesn't use), and extended ES6 support via babel-eslint (which is abandoned in favor of @babel/eslint-parser). As such, remove eslint-plugin-flowtype as well and replace babel-eslint with a simple @babel/eslint-parser config.

Signed-off-by: Máté Szabó <mszabo@fandom.com>
Signed-off-by: Máté Szabó <mszabo@fandom.com>
@mszabo-wikia
Copy link
Contributor Author

[2023-03-10T21:23:30.087Z] ['error'] There was an error running the uploader: Error uploading to [https://codecov.io:](https://codecov.io/) Error: There was an error fetching the storage URL during POST: 503 - upstream connect error or disconnect/reset before headers. reset reason: connection failure

Looks like Codecov runs Envoy.

@codecov
Copy link

codecov bot commented Mar 10, 2023

Codecov Report

Patch coverage has no change and project coverage change: -95.39 ⚠️

Comparison is base (38a0870) 95.38% compared to head (a58fb7a) 0.00%.

❗ Current head a58fb7a differs from pull request most recent head c6f04f9. Consider uploading reports for the commit c6f04f9 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #1250       +/-   ##
==========================================
- Coverage   95.38%       0   -95.39%     
==========================================
  Files         244       0      -244     
  Lines        7750       0     -7750     
  Branches     2017       0     -2017     
==========================================
- Hits         7392       0     -7392     
+ Misses        358       0      -358     

see 244 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@@ -25,25 +25,59 @@ module.exports = {
},
},
},
extends: ['react-app', 'airbnb', 'prettier', 'prettier/react'],
Copy link
Member

Choose a reason for hiding this comment

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

what's the story with 'prettier/react'?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The disparate configs supplied by eslint-config-prettier were merged in v8 of that config, so we no longer need to specify them separately.

@yurishkuro yurishkuro merged commit 9075aa4 into jaegertracing:main Mar 10, 2023
Binrix pushed a commit to Binrix/jaeger-ui that referenced this pull request Apr 18, 2023
## Which problem is this PR solving?
- Contributes towards jaegertracing#1199 

## Short description of the changes
Bump ESLint to v7 and update related plugins. Suppress newly introduced
or updated rules in a separate config section so that they can be
evaluated and enabled later, except for stylistic rules that do not
match the existing code style, or where the impact was limited enough to
be trivially fixable or suppressable.

`@typescript-eslint/eslint-plugin` now validates that input files are
indeed part of the tsconfig file configured in ESLint options. Since the
plugin doesn't understand project references, this requires a small
change to [specify the package-specific tsconfig files for
linting](https://typescript-eslint.io/linting/typed-linting/monorepos#one-tsconfigjson-per-package-and-an-optional-one-in-the-root)
instead.

Also remove `eslint-config-react-app` (the CRA ESLint config), as it
doesn't actually seem to bring much to the table—the Airbnb config seems
to overwrite much of the same rules that this config is trying to
provide. I ran `eslint --print-config
packages/jaeger-ui/src/components/App/index.jsx` and `eslint
--print-config packages/jaeger-ui/src/components/App/Page.tsx` to dump
the active rules for JS and TS files with and without the config loaded,
then diffed them:

```diff
--- ts-active-rules-cra.json	2023-03-10 21:24:37
+++ ts-active-rules-no-cra.json	2023-03-10 21:25:38
@@ -4,8 +4,7 @@
     "jest": true,
     "jasmine": true,
     "es6": true,
-    "node": true,
-    "commonjs": true
+    "node": true
   },
   "globals": {
     "__REACT_APP_GA_DEBUG__": false,
@@ -27,7 +26,6 @@
     "sourceType": "module"
   },
   "plugins": [
-    "flowtype",
     "import",
     "react",
     "jsx-a11y",
@@ -2850,15 +2848,6 @@
     ],
     "yoda": [
       "error"
-    ],
-    "flowtype/define-flow-type": [
-      "warn"
-    ],
-    "flowtype/require-valid-file-annotation": [
-      "warn"
-    ],
-    "flowtype/use-flow-type": [
-      "warn"
     ]
   },
   "settings": {
```

```diff
--- js-active-rules-cra.json	2023-03-10 21:24:48
+++ js-active-rules-no-cra.json	2023-03-10 21:25:30
@@ -4,15 +4,14 @@
     "jest": true,
     "jasmine": true,
     "es6": true,
-    "node": true,
-    "commonjs": true
+    "node": true
   },
   "globals": {
     "__REACT_APP_GA_DEBUG__": false,
     "__REACT_APP_VSN_STATE__": false,
     "__APP_ENVIRONMENT__": false
   },
-  "parser": "/REDACTED/jaeger-ui/node_modules/babel-eslint/lib/index.js",
+  "parser": null,
   "parserOptions": {
     "ecmaFeatures": {
       "jsx": true,
@@ -23,7 +22,6 @@
     "sourceType": "module"
   },
   "plugins": [
-    "flowtype",
     "import",
     "react",
     "jsx-a11y"
@@ -2830,15 +2828,6 @@
     ],
     "yoda": [
       "error"
-    ],
-    "flowtype/define-flow-type": [
-      "warn"
-    ],
-    "flowtype/require-valid-file-annotation": [
-      "warn"
-    ],
-    "flowtype/use-flow-type": [
-      "warn"
     ]
   },
   "settings": {
```

So the only things added by the config is Flow support (which the
project doesn't use), and extended ES6 support via `babel-eslint` (which
is abandoned in favor of `@babel/eslint-parser`). As such, remove
`eslint-plugin-flowtype` as well and replace `babel-eslint` with a
simple `@babel/eslint-parser` config.

---------

Signed-off-by: Máté Szabó <mszabo@fandom.com>
Co-authored-by: Yuri Shkuro <yurishkuro@users.noreply.github.com>
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