Skip to content

Commit

Permalink
feat(refactor): Migrate to ESLint 9 (#2342)
Browse files Browse the repository at this point in the history
  • Loading branch information
rossbulat authored Nov 26, 2024
1 parent a03169b commit 43db0c0
Show file tree
Hide file tree
Showing 51 changed files with 493 additions and 501 deletions.
25 changes: 0 additions & 25 deletions .eslintignore

This file was deleted.

100 changes: 0 additions & 100 deletions .eslintrc.json

This file was deleted.

147 changes: 147 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
// Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors
// SPDX-License-Identifier: GPL-3.0-only

import pluginJs from '@eslint/js';
import importPlugin from 'eslint-plugin-import';
import preferArrowFunctions from 'eslint-plugin-prefer-arrow-functions';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import react from 'eslint-plugin-react';
import reactHooks from 'eslint-plugin-react-hooks';
import unusedImports from 'eslint-plugin-unused-imports';
import globals from 'globals';
import tseslint from 'typescript-eslint';

/** @type {import('eslint').Linter.Config[]} */
export default [
{
files: ['**/*.{js,mjs,ts,jsx,tsx}'],
},
{
ignores: [
'**/*.css',
'**/*.scss',
'**/*.lottie',
'**/*.woff2',
'**/*.svg',
'**/*.png',
'**/*.json',
'**/*.log',
'**/*.lock',
'**/*.md',
'**/*.ico',
'**/*.ttf',
'**/*.xml',
'**/*.txt',
'**/*.html',
'**/*.cjs',
'**/*.webmanifest',
'**/LICENSE',
'**/node_modules/',
'**/dist/',
'**/build/',
'**/CHANGELOG.md',
'**/.yarn',
'**/.licenserc.json',
'**/lottie/',
'**/vite.config.ts',
],
},
pluginJs.configs.recommended,
importPlugin.flatConfigs.recommended,
...tseslint.configs.recommended,
eslintPluginPrettierRecommended,
{
plugins: {
react,
'prefer-arrow-functions': preferArrowFunctions,
'unused-imports': unusedImports,
'react-hooks': reactHooks,
},
languageOptions: {
globals: {
...globals.browser,
},
parserOptions: {
ecmaFeatures: {
jsx: true,
arrowFunctions: true,
},
ecmaVersion: 'latest',
sourceType: 'module',
project: './tsconfig.json',
},
},
settings: {
react: {
version: 'detect',
},
'import/resolver': {
typescript: {
alwaysTryTypes: true,
project: ['tsconfig.json', 'packages/*/tsconfig.json'],
},
},
},
rules: {
// Stylistic
curly: 'error',
'arrow-body-style': ['error', 'as-needed'],
'comma-dangle': [
'error',
{
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
functions: 'never',
},
],
'object-shorthand': 'error',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
caughtErrors: 'none',
},
],
semi: [2, 'always'],
'import/extensions': [
'error',
'ignorePackages',
{
ts: 'never',
tsx: 'never',
},
],
// React
// "@typescript-eslint/no-unnecessary-condition": "error", // in progress
'prefer-arrow-functions/prefer-arrow-functions': [
'warn',
{
classPropertiesAllowed: false,
disallowPrototype: false,
returnStyle: 'unchanged',
singleReturnOnly: false,
},
],
'react/react-in-jsx-scope': 'off',
'react-hooks/rules-of-hooks': 'error',
'react/jsx-no-useless-fragment': 'error',
'react/jsx-filename-extension': [
'warn',
{
extensions: ['.tsx'],
},
],
// Typescript
'@typescript-eslint/consistent-type-imports': [
'error',
{
prefer: 'type-imports',
fixStyle: 'separate-type-imports',
},
],
'@typescript-eslint/no-shadow': 'error',
},
},
];
27 changes: 15 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,32 @@
"test": "npm run test --workspaces --if-present"
},
"devDependencies": {
"@eslint/js": "^9.15.0",
"@ledgerhq/logs": "^6.12.0",
"@types/chroma-js": "^2.4.4",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.2.25",
"@types/react-helmet": "^6.1.11",
"@types/react-scroll": "^1.8.10",
"@typescript-eslint/eslint-plugin": "^7.12.0",
"@typescript-eslint/parser": "^7.12.0",
"@typescript-eslint/parser": "^8.16.0",
"@vitejs/plugin-react-swc": "^3.7.0",
"@w3ux/types": "0.2.1-beta.1",
"eslint": "8.57.0",
"eslint": "^9.15.0",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.3",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prefer-arrow-functions": "^3.3.2",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-react": "^7.34.2",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-unused-imports": "3.2.0",
"prettier": "^3.3.1",
"prettier-plugin-organize-imports": "^4.0.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-prefer-arrow-functions": "^3.4.1",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-unused-imports": "^4.1.4",
"globals": "^15.12.0",
"prettier": "^3.4.0",
"prettier ": "^3.3.1",
"prettier-plugin-organize-imports": "^4.1.0",
"sass": "1.77.6",
"typescript": "^5.4.3"
"typescript": "^5.7.2",
"typescript-eslint": "^8.16.0"
},
"dependencies": {
"classnames": "^2.5.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/contexts/ActiveAccounts/defaults.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors
// SPDX-License-Identifier: GPL-3.0-only
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function */
/* eslint-disable @typescript-eslint/no-unused-vars */

import type { ActiveAccountsContextInterface } from './types';

Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/contexts/Api/defaults.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors
// SPDX-License-Identifier: GPL-3.0-only
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function */
/* eslint-disable @typescript-eslint/no-unused-vars */

import { stringToU8a } from '@polkadot/util';
import BigNumber from 'bignumber.js';
Expand Down
1 change: 0 additions & 1 deletion packages/app/src/contexts/Community/defaults.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors
// SPDX-License-Identifier: GPL-3.0-only
/* eslint-disable @typescript-eslint/no-unused-vars */

import type { CommunityContextInterface } from './types';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors
// SPDX-License-Identifier: GPL-3.0-only
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function */
/* eslint-disable @typescript-eslint/no-unused-vars */

import type { ExternalAccountsContextInterface } from './types';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors
// SPDX-License-Identifier: GPL-3.0-only
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function */
/* eslint-disable @typescript-eslint/no-unused-vars */

import type { OtherAccountsContextInterface } from './types';

Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/contexts/Filters/defaults.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors
// SPDX-License-Identifier: GPL-3.0-only
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function */
/* eslint-disable @typescript-eslint/no-unused-vars */

import type { FilterItem, FiltersContextInterface } from './types';

Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/contexts/Help/defaults.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors
// SPDX-License-Identifier: GPL-3.0-only
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function */
/* eslint-disable @typescript-eslint/no-unused-vars */

import type { HelpContextInterface } from './types';

Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/contexts/LedgerHardware/defaults.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors
// SPDX-License-Identifier: GPL-3.0-only
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function */
/* eslint-disable @typescript-eslint/no-unused-vars */

import type { LedgerHardwareContextInterface } from './types';

Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/contexts/Menu/defaults.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors
// SPDX-License-Identifier: GPL-3.0-only
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function */
/* eslint-disable @typescript-eslint/no-unused-vars */

import type { MenuContextInterface } from './types';

Expand Down
1 change: 0 additions & 1 deletion packages/app/src/contexts/Network/defaults.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors
// SPDX-License-Identifier: GPL-3.0-only
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function */

import { NetworkList } from 'config/networks';

Expand Down
Loading

0 comments on commit 43db0c0

Please sign in to comment.