-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(refactor): Migrate to ESLint 9 (#2342)
- Loading branch information
Showing
51 changed files
with
493 additions
and
501 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
}, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.