Skip to content

Commit

Permalink
chore: re-introduce ESLint for the monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-sanderson committed Oct 31, 2024
1 parent a6ff7c5 commit 32688ee
Show file tree
Hide file tree
Showing 35 changed files with 2,644 additions and 296 deletions.
148 changes: 148 additions & 0 deletions eslint.config.mjs
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',
// },
// },
];
Loading

0 comments on commit 32688ee

Please sign in to comment.