-
-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: re-introduce ESLint for the monorepo
- Loading branch information
1 parent
a6ff7c5
commit 32688ee
Showing
35 changed files
with
2,644 additions
and
296 deletions.
There are no files selected for viewing
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,148 @@ | ||
import path from 'path'; | ||
import { fileURLToPath } from 'url'; | ||
|
||
import globals from 'globals'; | ||
import pluginJs from '@eslint/js'; | ||
import tseslint from 'typescript-eslint'; | ||
import pluginReact from 'eslint-plugin-react'; | ||
import pluginJest from 'eslint-plugin-jest'; | ||
import pluginReactHooks from 'eslint-plugin-react-hooks'; | ||
import importPlugin from 'eslint-plugin-import'; | ||
|
||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = path.dirname(__filename); | ||
|
||
export default [ | ||
{ | ||
ignores: [ | ||
'**/.nx/*', | ||
'**/lib/*', | ||
'**/libDev/*', | ||
'**/dist/*', | ||
'**/coverage/*', | ||
'**/build/*', | ||
'**/build-electron/*', | ||
'**/node_modules/*', | ||
'**/public/*', | ||
'packages/suite-data/files/*', | ||
'packages/protobuf/scripts/protobuf-patches/*', | ||
'packages/address-validator', | ||
'packages/connect-examples', | ||
'**/ci/', | ||
'eslint-local-rules/*', | ||
], | ||
}, | ||
{ files: ['**/*.{js,mjs,cjs,ts,jsx,tsx}'] }, | ||
{ languageOptions: { globals: globals.browser } }, | ||
pluginJs.configs.recommended, | ||
{ | ||
languageOptions: { | ||
...pluginReact.configs.flat.recommended.languageOptions, | ||
globals: { | ||
...globals.serviceworker, | ||
...globals.browser, | ||
}, | ||
}, | ||
rules: { | ||
// Offs | ||
'no-undef': 'off', // Todo: write description | ||
|
||
// Additional rules | ||
'no-console': ['error', { allow: ['warn', 'error'] }], | ||
}, | ||
}, | ||
|
||
// React | ||
pluginReact.configs.flat.recommended, | ||
{ | ||
settings: { react: { version: 'detect' } }, | ||
rules: { | ||
// Offs | ||
'react/react-in-jsx-scope': 'off', // We are not importing React in every file | ||
'react/prop-types': 'off', // This rule is not needed when using TypeScript | ||
'react/display-name': 'off', // This is annoying for stuff like `forwardRef`. Todo: reconsider | ||
'no-prototype-builtins': 'off', // Todo: just temporary, reconsider to remove it | ||
}, | ||
}, | ||
|
||
// React Hooks | ||
{ | ||
plugins: { 'react-hooks': pluginReactHooks }, | ||
rules: pluginReactHooks.configs.recommended.rules, | ||
}, | ||
|
||
// Typescript | ||
...tseslint.configs.recommended, | ||
{ | ||
rules: { | ||
// Offs | ||
'@typescript-eslint/no-require-imports': 'off', // Todo: write description | ||
'@typescript-eslint/no-explicit-any': 'off', // Todo: write description | ||
'@typescript-eslint/ban-ts-comment': 'off', // Todo: just temporary, reconsider to remove it | ||
|
||
// Additional rules | ||
'@typescript-eslint/no-unused-vars': [ | ||
'error', | ||
{ | ||
vars: 'all', | ||
args: 'none', | ||
ignoreRestSiblings: true, | ||
varsIgnorePattern: '^_', | ||
}, | ||
], | ||
'@typescript-eslint/no-use-before-define': ['error'], | ||
}, | ||
}, | ||
|
||
// Import | ||
importPlugin.flatConfigs.recommended, | ||
{ | ||
settings: { | ||
'import/ignore': ['node_modules', '\\.(coffee|scss|css|less|hbs|svg|json)$'], | ||
'import/resolver': { | ||
node: { | ||
paths: [path.resolve(__dirname, 'eslint-rules')], | ||
}, | ||
}, | ||
}, | ||
rules: { | ||
// Offs | ||
'import/no-unresolved': 'off', // Does not work with Babel react-native to react-native-web | ||
}, | ||
}, | ||
// { | ||
// rules: { | ||
// 'import/no-extraneous-dependencies': [ | ||
// 'error', | ||
// { | ||
// devDependencies: [ | ||
// '**/*fixtures*/**', | ||
// '**/*.test.{tsx,ts,js}', | ||
// '**/blockchain-link/tests/**', | ||
// '**/blockchain-link/webpack/**', | ||
// '**/suite-desktop-core/**', | ||
// '**/*e2e/**', | ||
// '**/suite/src/support/tests/**', | ||
// '**/suite-data/**', | ||
// '**/*.stories.*', | ||
// '**/*webpack.config*', | ||
// '**/webpack/**', | ||
// ], | ||
// | ||
// includeTypes: true, | ||
// }, | ||
// ], | ||
// }, | ||
// }, | ||
|
||
// Tests | ||
pluginJest.configs['flat/recommended'], | ||
// { | ||
// files: ['**/*.test.*', '**/__tests__/**/*'], | ||
// rules: { | ||
// 'import/no-extraneous-dependencies': 'off', | ||
// 'import/no-unresolved': 'off', | ||
// 'import/no-default-export': 'off', | ||
// }, | ||
// }, | ||
]; |
Oops, something went wrong.