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 and all plugis & revalidate the config and ALL of the rules #15285

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
63c83e2
chore: add recommanded checks from eslint-plugin-jest
peter-sanderson Oct 31, 2024
8a1bd6d
chore: add 'import/no-duplicates' ESLint rule
peter-sanderson Oct 31, 2024
971c795
chore: remove ESLint so we can upgrade by installing fresh version
peter-sanderson Oct 30, 2024
a40831d
chore: re-introduce ESLint for the monorepo
peter-sanderson Oct 31, 2024
b4905e8
chore: fix code style
peter-sanderson Oct 31, 2024
90f9db4
fix: format
peter-sanderson Nov 1, 2024
433c237
chore: implement ESLint rulset as a package in the workspace
peter-sanderson Nov 1, 2024
eb3bc40
chore: re-add all our custom eslint rules
peter-sanderson Nov 4, 2024
8ccd2f8
chore: add no-prototype-builtins ESLint rule as it became part of rec…
peter-sanderson Nov 4, 2024
617332f
chore: progress
peter-sanderson Nov 4, 2024
b59cba5
fix: duplicate key
peter-sanderson Nov 4, 2024
29d7c93
fix: missing devDependency
peter-sanderson Nov 5, 2024
5db0276
chore: more ESLint fixies
peter-sanderson Nov 5, 2024
c431d00
fix: wip
peter-sanderson Nov 5, 2024
08de135
fix: local-rules/no-override-ds-component were not riggered correcly …
peter-sanderson Nov 5, 2024
ec1be25
chore: enable no-constant-binary-expression as it becames recommanded…
peter-sanderson Nov 5, 2024
087b74a
chore: wip
peter-sanderson Nov 6, 2024
e5240ca
chore: enable no-extra-boolean-cast as it becames recomended
peter-sanderson Nov 6, 2024
1d0e9e8
chore: wip
peter-sanderson Nov 6, 2024
180670a
chore: add no-async-promise-executor as it becames recommanded
peter-sanderson Nov 6, 2024
c37c9e2
chore: remove all import/order offs
peter-sanderson Nov 6, 2024
6fde233
chore: ignore some rules in packages
peter-sanderson Nov 6, 2024
2bfdbbb
chore: wip
peter-sanderson Nov 6, 2024
7490906
chore: wip
peter-sanderson Nov 6, 2024
3691858
chore: wip2
peter-sanderson Nov 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
399 changes: 0 additions & 399 deletions .eslintrc.js

This file was deleted.

3 changes: 3 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { eslint } from '@trezor/eslint';

export default [...eslint];
15 changes: 3 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"type-check": "yarn nx run-many --target=type-check",
"type-check:force": "rimraf -rf -- **/libDev && yarn type-check",
"test:unit": "yarn nx run-many --target=test:unit",
"lint:js": "eslint . --cache --cache-strategy content --ignore-path .gitignore",
"lint:js": "eslint . --cache --cache-strategy content --flag unstable_config_lookup_from_file",
"lint:styles": "yarn nx run-many --target=lint:styles",
"lint": "yarn lint:styles && yarn lint:js",
"lint-staged": "npx lint-staged",
Expand Down Expand Up @@ -121,24 +121,15 @@
"@babel/preset-typescript": "^7.24.7",
"@babel/runtime": "^7.23.9",
"@suite-common/wallet-types": "workspace:*",
"@trezor/eslint": "workspace:*",
"@types/jest": "29.5.12",
"@types/node": "20.12.7",
"@types/prettier": "^3.0.0",
"@types/semver": "^7.5.6",
"@types/tar": "^6.1.11",
"@typescript-eslint/eslint-plugin": "^8.8.1",
"@typescript-eslint/parser": "^8.8.1",
"babel-jest": "29.7.0",
"depcheck": "^1.4.7",
"eslint": "^8.57.1",
"eslint-plugin-chai-friendly": "^1.0.1",
"eslint-plugin-cypress": "^3.5.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jest": "^28.8.3",
"eslint-plugin-jsx-a11y": "^6.10.0",
"eslint-plugin-local-rules": "^3.0.2",
"eslint-plugin-react": "^7.37.1",
"eslint-plugin-react-hooks": "^4.6.2",
"globals": "^15.11.0",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"jest-expo": "^50.0.2",
Expand Down
5 changes: 0 additions & 5 deletions packages/blockchain-link-utils/.eslintrc.js

This file was deleted.

15 changes: 15 additions & 0 deletions packages/blockchain-link-utils/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { eslint } from '@trezor/eslint';

export default [
...eslint,
{
rules: {
'import/no-extraneous-dependencies': [
'error',
{
includeTypes: true,
},
],
},
},
];
1 change: 1 addition & 0 deletions packages/blockchain-link-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
},
"devDependencies": {
"@trezor/blockchain-link-types": "workspace:*",
"@trezor/eslint": "workspace:*",
"@trezor/type-utils": "workspace:*",
"tsx": "^4.16.3"
},
Expand Down
7 changes: 0 additions & 7 deletions packages/blockchain-link/.eslintrc.js

This file was deleted.

12 changes: 12 additions & 0 deletions packages/blockchain-link/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { eslint } from '@trezor/eslint';

export default [
...eslint,
{
rules: {
camelcase: 'off',
'no-underscore-dangle': 'off',
'no-console': 'warn',
},
},
];
1 change: 1 addition & 0 deletions packages/blockchain-link/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
},
"devDependencies": {
"@trezor/e2e-utils": "workspace:*",
"@trezor/eslint": "workspace:*",
"@trezor/type-utils": "workspace:*",
"fs-extra": "^11.2.0",
"html-webpack-plugin": "^5.6.0",
Expand Down
6 changes: 0 additions & 6 deletions packages/coinjoin/.eslintrc.js

This file was deleted.

11 changes: 11 additions & 0 deletions packages/coinjoin/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { eslint } from '@trezor/eslint';

export default [
...eslint,
{
rules: {
'no-bitwise': 'off',
'no-console': 'warn',
},
},
];
1 change: 1 addition & 0 deletions packages/coinjoin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@trezor/blockchain-link": "workspace:*",
"@trezor/blockchain-link-types": "workspace:*",
"@trezor/blockchain-link-utils": "workspace:*",
"@trezor/eslint": "workspace:*",
"@trezor/utils": "workspace:*",
"@trezor/utxo-lib": "workspace:*",
"cross-fetch": "^4.0.0",
Expand Down
18 changes: 10 additions & 8 deletions packages/components/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import { dirname, join } from 'path';

/**
* This function is used to resolve the absolute path of a package.
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
*/
function getAbsolutePath(value) {
return dirname(require.resolve(join(value, 'package.json')));
}

module.exports = {
stories: ['../src/**/*.stories.*'],
logLevel: 'debug',
Expand All @@ -14,18 +22,12 @@ module.exports = {
name: getAbsolutePath('@storybook/react-webpack5'),
options: {},
},
babel: async options => {
babel: options => {
options.presets.push('@babel/preset-typescript');

return options;
},
features: {
storyStoreV7: false, // Remove this line when storiesOf is not used anymore
},
};
/**
* This function is used to resolve the absolute path of a package.
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
*/
function getAbsolutePath(value) {
return dirname(require.resolve(join(value, 'package.json')));
}
11 changes: 11 additions & 0 deletions packages/components/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { eslint } from '@trezor/eslint';

export default [
...eslint,
{
files: ['**/*.stories.tsx'],
rules: {
'import/no-default-export': 'off',
},
},
];
7 changes: 0 additions & 7 deletions packages/connect-examples/webextension-mv2/.eslintrc.js

This file was deleted.

15 changes: 15 additions & 0 deletions packages/connect-examples/webextension-mv2/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Todo: figure out the better way, if this would be package, we would use "@trezor/eslint": "workspace:*" in package.json
import parentConfig from '../../../eslint.config.mjs';

export default [
...parentConfig,
{
ignores: ['**/vendor*/'],
},
{
rules: {
'no-underscore-dangle': 'off',
camelcase: 'off',
},
},
];
19 changes: 0 additions & 19 deletions packages/connect-explorer/.eslintrc.js

This file was deleted.

43 changes: 43 additions & 0 deletions packages/connect-explorer/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import * as mdx from 'eslint-plugin-mdx';

import { eslint } from '@trezor/eslint';

export default [
...eslint,
{
ignores: ['.next/**/*'],
},

// Mdx
{
...mdx.flat,
rules: {
'jsx-a11y/click-events-have-key-events': 'off',
'jsx-a11y/no-static-element-interactions': 'off',
'import/no-default-export': 'off',
'no-console': 'off',
'no-restricted-syntax': 'off',
},
},
{
files: ['**/*.mdx'],
rules: {
'react/no-unescaped-entities': 'off',
},
},
{
rules: {
'no-console': 'off',
'import/no-default-export': 'off', // Todo: shall be fixed
'no-restricted-syntax': 'off', // Todo: shall be fixed
'@typescript-eslint/no-restricted-imports': 'off',
'@typescript-eslint/no-shadow': 'off',
'react/jsx-filename-extension': [
'error',
{
extensions: ['.tsx', '.mdx'],
},
],
},
},
];
1 change: 1 addition & 0 deletions packages/connect-explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"swr": "^2.2.5"
},
"devDependencies": {
"@trezor/eslint": "workspace:*",
"@types/redux-logger": "^3.0.11",
"babel-plugin-styled-components": "^2.1.4",
"concurrently": "^8.2.2",
Expand Down
10 changes: 10 additions & 0 deletions packages/connect-iframe/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { eslint } from '@trezor/eslint';

export default [
...eslint,
{
rules: {
'import/no-default-export': 'off', // Todo: shall be fixed
},
},
];
1 change: 1 addition & 0 deletions packages/connect-iframe/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"devDependencies": {
"@babel/preset-typescript": "^7.24.7",
"@trezor/env-utils": "workspace:*",
"@trezor/eslint": "workspace:*",
"babel-loader": "^9.1.3",
"copy-webpack-plugin": "^12.0.2",
"es6-promise": "^4.2.8",
Expand Down
10 changes: 10 additions & 0 deletions packages/connect-plugin-stellar/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { eslint } from '@trezor/eslint';

export default [
...eslint,
{
rules: {
'import/no-default-export': 'off', // Todo: fix and solve
},
},
];
3 changes: 2 additions & 1 deletion packages/connect-plugin-stellar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"tslib": "^2.6.2"
},
"devDependencies": {
"@stellar/stellar-sdk": "^12.1.3"
"@stellar/stellar-sdk": "^12.1.3",
"@trezor/eslint": "workspace:*"
},
"dependencies": {
"@trezor/utils": "workspace:*"
Expand Down
2 changes: 2 additions & 0 deletions packages/connect-popup/e2e/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ const config: PlaywrightTestConfig = {
...devices[process.env.MOBILE ? 'Pixel 7' : 'Desktop Chrome'],
},
};

// eslint-disable-next-line import/no-default-export
export default config;
1 change: 1 addition & 0 deletions packages/connect-popup/e2e/tests/methods.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ filteredFixtures.forEach(f => {
// - fixture require different device than prev fixture, or
// - fixture is retried
// FIXME: always reset for now, due to flaky tests with bridge bug
// eslint-disable-next-line no-constant-binary-expression
if (true || JSON.stringify(device) !== JSON.stringify(f.device) || retry) {
device = f.device;
await TrezorUserEnvLink.stopBridge();
Expand Down
11 changes: 11 additions & 0 deletions packages/connect-popup/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { eslint } from '@trezor/eslint';

export default [
...eslint,
{
rules: {
'no-console': 'off',
'no-restricted-syntax': 'off', // Todo: fix and solve
},
},
];
1 change: 1 addition & 0 deletions packages/connect-popup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"@playwright/browser-firefox": "^1.46.1",
"@playwright/browser-webkit": "^1.46.1",
"@playwright/test": "^1.46.1",
"@trezor/eslint": "workspace:*",
"@trezor/node-utils": "workspace:*",
"@trezor/trezor-user-env-link": "workspace:*",
"@trezor/utils": "workspace:*",
Expand Down
6 changes: 0 additions & 6 deletions packages/connect-web/.eslintrc.js

This file was deleted.

13 changes: 13 additions & 0 deletions packages/connect-web/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { eslint } from '@trezor/eslint';

export default [
...eslint,
{
rules: {
'no-underscore-dangle': 'off', // underscore is used
camelcase: 'off', // camelcase is used
'jest/valid-expect': 'off', // because of cypress tests
'import/no-default-export': 'off', // Todo: shall be fixed
},
},
];
1 change: 1 addition & 0 deletions packages/connect-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"@playwright/browser-firefox": "^1.46.1",
"@playwright/browser-webkit": "^1.46.1",
"@playwright/test": "^1.46.1",
"@trezor/eslint": "workspace:*",
"@types/chrome": "^0.0.278",
"@types/w3c-web-usb": "^1.0.10",
"babel-loader": "^9.1.3",
Expand Down
5 changes: 0 additions & 5 deletions packages/connect-webextension/.eslintrc.js

This file was deleted.

10 changes: 10 additions & 0 deletions packages/connect-webextension/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { eslint } from '@trezor/eslint';

export default [
...eslint,
{
rules: {
'no-underscore-dangle': 'off', // underscore is used
},
},
];
1 change: 1 addition & 0 deletions packages/connect-webextension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
},
"devDependencies": {
"@babel/preset-typescript": "^7.24.7",
"@trezor/eslint": "workspace:*",
"@trezor/node-utils": "workspace:*",
"@trezor/trezor-user-env-link": "workspace:*",
"@types/chrome": "^0.0.278",
Expand Down
Loading