Skip to content

Commit 5713f1f

Browse files
djangolivogiorgis
andauthored
Upgrade lint libs (#8493)
* feat: upgrade prettier * perf: use moment-locales-webpack-plugin This plugin doesnt install useless locales files * perf: lazy load of redoc app * feat: upgrade some libs * feat: upgrade eslint --------- Co-authored-by: Olivier Giorgis <[email protected]>
1 parent 6de9353 commit 5713f1f

File tree

9 files changed

+1954
-3277
lines changed

9 files changed

+1954
-3277
lines changed

Diff for: .eslintrc.js

-65
This file was deleted.

Diff for: eslint.config.mjs

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import globals from 'globals';
2+
import babelParser from '@babel/eslint-parser';
3+
import path from 'node:path';
4+
import { fileURLToPath } from 'node:url';
5+
import js from '@eslint/js';
6+
import { FlatCompat } from '@eslint/eslintrc';
7+
8+
const __filename = fileURLToPath(import.meta.url);
9+
const __dirname = path.dirname(__filename);
10+
const compat = new FlatCompat({
11+
baseDirectory: __dirname,
12+
recommendedConfig: js.configs.recommended,
13+
allConfig: js.configs.all,
14+
});
15+
16+
export default [
17+
...compat.extends(
18+
'eslint-config-airbnb',
19+
'plugin:prettier/recommended',
20+
'prettier',
21+
'plugin:jest/recommended',
22+
'plugin:jest/style',
23+
),
24+
{
25+
languageOptions: {
26+
globals: {
27+
...globals.browser,
28+
page: true,
29+
browser: true,
30+
jestPuppeteer: true,
31+
},
32+
33+
parser: babelParser,
34+
},
35+
files: ['**/*.js', '**/*.jsx'],
36+
rules: {
37+
'class-methods-use-this': 'off',
38+
'consistent-return': 'off',
39+
'default-case': 'off',
40+
'default-param-last': 'off',
41+
'import/extensions': 'off',
42+
'jsx-a11y/click-events-have-key-events': 'off',
43+
'no-alert': 'off',
44+
'no-continue': 'off',
45+
'no-param-reassign': 'off',
46+
'no-plusplus': 'off',
47+
'no-restricted-syntax': 'off',
48+
'no-shadow': 'off',
49+
'no-underscore-dangle': 'off',
50+
'prefer-promise-reject-errors': 'off',
51+
'react/destructuring-assignment': 'off',
52+
'react/function-component-definition': 'off',
53+
'react/jsx-fragments': 'off',
54+
'react/jsx-no-constructed-context-values': 'off',
55+
'react/jsx-no-script-url': 'off',
56+
'react/jsx-no-useless-fragment': 'off',
57+
'react/jsx-props-no-spreading': 'off',
58+
'react/no-arrow-function-lifecycle': 'off',
59+
'react/no-invalid-html-attribute': 'off',
60+
'react/no-namespace': 'off',
61+
'react/no-unstable-nested-components': 'off',
62+
'react/no-unused-class-component-methods': 'off',
63+
'react/prefer-exact-props': 'off',
64+
'react/prop-types': 'off',
65+
'react/sort-comp': [0, {}],
66+
67+
'import/order': [
68+
'error',
69+
{
70+
'newlines-between': 'always',
71+
},
72+
],
73+
},
74+
},
75+
];

Diff for: package.json

+17-14
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"yarn": "1.22.22"
1212
},
1313
"dependencies": {
14-
"@fortawesome/fontawesome-svg-core": "6.2.1",
14+
"@fortawesome/fontawesome-svg-core": "6.7.2",
1515
"@fortawesome/free-brands-svg-icons": "6.7.2",
1616
"@fortawesome/free-regular-svg-icons": "6.7.2",
1717
"@fortawesome/free-solid-svg-icons": "6.7.2",
@@ -29,6 +29,7 @@
2929
"d3-scale": "4.0.2",
3030
"eslint-formatter-codeframe": "7.32.1",
3131
"fuse.js": "6.0.4",
32+
"globals": "15.15.0",
3233
"history": "4.10.1",
3334
"js-cookie": "3.0.5",
3435
"js-yaml": "4.1.0",
@@ -46,7 +47,7 @@
4647
"react-dom": "18.3.1",
4748
"react-helmet": "6.1.0",
4849
"react-highlight-words": "0.20.0",
49-
"react-hot-keys": "2.6.2",
50+
"react-hot-keys": "2.7.3",
5051
"react-hot-loader": "4.13.1",
5152
"react-lazylog": "4.5.3",
5253
"react-linkify": "0.2.2",
@@ -57,13 +58,13 @@
5758
"react-table-6": "6.11.0",
5859
"react-tabs": "6.1.0",
5960
"reactstrap": "8.10.1",
60-
"redoc": "2.2.0",
61+
"redoc": "2.4.0",
6162
"redux": "4.2.1",
6263
"redux-debounce": "1.0.1",
6364
"redux-mock-store": "1.5.5",
6465
"redux-thunk": "2.4.2",
6566
"stream-browserify": "3.0.0",
66-
"styled-components": "6.1.14",
67+
"styled-components": "6.1.15",
6768
"taskcluster-client-web": "77.0.0",
6869
"taskcluster-lib-scopes": "11.0.0",
6970
"taskcluster-lib-urls": "13.0.1",
@@ -74,13 +75,14 @@
7475
"devDependencies": {
7576
"@babel/core": "7.26.10",
7677
"@babel/eslint-parser": "7.25.9",
78+
"@babel/eslint-parser": "7.26.8",
7779
"@babel/plugin-proposal-class-properties": "7.18.6",
7880
"@babel/plugin-syntax-dynamic-import": "7.8.3",
7981
"@babel/preset-env": "7.26.9",
8082
"@babel/preset-react": "7.26.3",
8183
"@pollyjs/adapter-fetch": "6.0.6",
8284
"@pollyjs/adapter-node-http": "6.0.6",
83-
"@pollyjs/adapter-puppeteer": "5.1.1",
85+
"@pollyjs/adapter-puppeteer": "6.0.6",
8486
"@pollyjs/core": "6.0.6",
8587
"@pollyjs/persister-fs": "6.0.6",
8688
"@testing-library/dom": "10.4.0",
@@ -91,13 +93,13 @@
9193
"clean-webpack-plugin": "4.0.0",
9294
"copy-webpack-plugin": "12.0.2",
9395
"css-loader": "7.1.2",
94-
"eslint": "8.21.0",
96+
"eslint": "9.20.1",
9597
"eslint-config-airbnb": "19.0.4",
96-
"eslint-config-prettier": "9.0.0",
98+
"eslint-config-prettier": "^10.0.1",
9799
"eslint-plugin-import": "2.31.0",
98-
"eslint-plugin-jest": "27.1.7",
100+
"eslint-plugin-jest": "28.11.0",
99101
"eslint-plugin-jsx-a11y": "6.10.2",
100-
"eslint-plugin-prettier": "4.2.1",
102+
"eslint-plugin-prettier": "^4.2.1",
101103
"eslint-plugin-react": "7.37.4",
102104
"fetch-mock": "9.4.0",
103105
"html-loader": "5.1.0",
@@ -108,23 +110,24 @@
108110
"jest-puppeteer": "11.0.0",
109111
"markdownlint-cli": "0.43.0",
110112
"mini-css-extract-plugin": "2.9.2",
113+
"moment-locales-webpack-plugin": "1.2.0",
111114
"path": "0.12.7",
112-
"prettier": "2.0.5",
113-
"puppeteer": "24.1.1",
115+
"prettier": "2.2.1",
116+
"puppeteer": "24.2.0",
114117
"setup-polly-jest": "0.11.0",
115118
"style-loader": "4.0.0",
116119
"webpack": "5.97.1",
117120
"webpack-cli": "6.0.1",
118121
"webpack-dev-server": "5.2.0",
119-
"webpack-merge": "5.8.0"
122+
"webpack-merge": "6.0.1"
120123
},
121124
"scripts": {
122125
"build": "node ./node_modules/webpack/bin/webpack.js --mode production",
123126
"build:dev": "node ./node_modules/webpack/bin/webpack.js --mode development",
124127
"format": "node ./node_modules/prettier/bin-prettier.js --write \"**/*.{css,html,js,jsx,json,md,yaml,yml}\"",
125128
"format:check": "node ./node_modules/prettier/bin-prettier.js --check \"**/*.{css,html,js,jsx,json,md,yaml,yml}\"",
126-
"lint": "node ./node_modules/eslint/bin/eslint.js --report-unused-disable-directives --max-warnings 0 --format codeframe --ext js,jsx \".*.js\" \"*.js\" ui/ tests/ui/",
127-
"lint-with-cache": "node ./node_modules/eslint/bin/eslint.js --cache --report-unused-disable-directives --max-warnings 0 --format codeframe --ext js,jsx \".*.js\" \"*.js\" ui/ tests/ui/",
129+
"lint": "node ./node_modules/eslint/bin/eslint.js --report-unused-disable-directives --max-warnings 0 --format codeframe ui/ tests/ui/",
130+
"lint-with-cache": "node ./node_modules/eslint/bin/eslint.js --cache --report-unused-disable-directives --max-warnings 0 --format codeframe ui/ tests/ui/",
128131
"markdownlint": "node ./node_modules/markdownlint-cli/markdownlint.js -c .markdownlint.json -p .markdownlintignore .",
129132
"prettier": "npx prettier --check .",
130133
"start": "node ./node_modules/webpack/bin/webpack.js serve --mode development",

Diff for: ui/App.jsx

+3-10
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { Route, Switch } from 'react-router-dom';
33
import { hot } from 'react-hot-loader/root';
44
import { ConnectedRouter } from 'connected-react-router';
55
import { Provider } from 'react-redux';
6-
import { RedocStandalone } from 'redoc';
76

87
import { permaLinkPrefix } from './perfherder/perf-helpers/constants';
98
import { configureStore, history } from './job-view/redux/configureStore';
@@ -27,6 +26,8 @@ const JobsViewApp = lazy(() => import('./job-view/App'));
2726

2827
const LogviewerApp = lazy(() => import('./logviewer/App'));
2928

29+
const RedocApp = lazy(() => import('./RedocApp'));
30+
3031
// backwards compatibility for routes like this: treeherder.mozilla.org/perf.html#/alerts?id=26622&hideDwnToInv=0
3132
const updateOldUrls = () => {
3233
const { pathname, hash, search } = history.location;
@@ -176,15 +177,7 @@ const App = () => {
176177
withFavicon(<PerfherderApp {...props} />, '/perfherder')
177178
}
178179
/>
179-
<Route
180-
path="/docs"
181-
render={(props) => (
182-
<RedocStandalone
183-
specUrl="/api/schema/?format=openapi-json"
184-
{...props}
185-
/>
186-
)}
187-
/>
180+
<Route path="/docs" render={(props) => <RedocApp {...props} />} />
188181
</Switch>
189182
</Suspense>
190183
</ConnectedRouter>

Diff for: ui/RedocApp.jsx

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from 'react';
2+
import { RedocStandalone } from 'redoc';
3+
4+
const App = (props) => {
5+
return (
6+
<RedocStandalone specUrl="/api/schema/?format=openapi-json" {...props} />
7+
);
8+
};
9+
10+
export default App;

Diff for: ui/job-view/headerbars/SecondaryNavBar.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ class SecondaryNavBar extends React.PureComponent {
181181

182182
// Re-save the list, in case it has now changed
183183
this.saveWatchedRepos(watchedRepoNames);
184-
} catch (e) {
184+
} catch {
185185
// localStorage is disabled/not supported.
186186
return [];
187187
}
@@ -191,7 +191,7 @@ class SecondaryNavBar extends React.PureComponent {
191191
this.setState({ watchedRepoNames: repos });
192192
try {
193193
localStorage.setItem(WATCHED_REPOS_STORAGE_KEY, JSON.stringify(repos));
194-
} catch (e) {
194+
} catch {
195195
// localStorage is disabled/not supported.
196196
}
197197
}

Diff for: ui/models/job.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ export default class JobModel {
257257
/* eslint-enable no-await-in-loop */
258258

259259
notify(`Request sent to cancel ${jobTerm} via action.json`, 'success');
260-
} catch (e) {
260+
} catch {
261261
notify(`Unable to cancel ${jobTerm}`, 'danger', { sticky: true });
262262
}
263263
}

Diff for: webpack.config.js

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const CopyWebpackPlugin = require('copy-webpack-plugin');
88
const { ProvidePlugin } = require('webpack');
99
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
1010
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
11+
const MomentLocalesPlugin = require('moment-locales-webpack-plugin');
1112

1213
const commonConfig = {
1314
target: 'web',
@@ -43,6 +44,7 @@ const commonConfig = {
4344
vm: require.resolve('vm-browserify'),
4445
fs: false,
4546
tls: false,
47+
vm: false,
4648
},
4749
},
4850
module: {
@@ -104,6 +106,7 @@ const commonConfig = {
104106
jQuery: 'jquery',
105107
'window.jQuery': 'jquery',
106108
}),
109+
new MomentLocalesPlugin(),
107110
],
108111
entry: {
109112
index: ['./ui/index'],

0 commit comments

Comments
 (0)