From 6f174c6e0cb34a363e602e5528615807d99848a8 Mon Sep 17 00:00:00 2001 From: Nabarun Date: Thu, 8 Aug 2024 10:39:02 +0000 Subject: [PATCH] Add loader at app start and configure eslint (#10) Part of [laconicd testnet validator enrollment](https://www.notion.so/laconicd-testnet-validator-enrollment-6fc1d3cafcc64fef8c5ed3affa27c675) Co-authored-by: IshaVenikar Reviewed-on: https://git.vdb.to/cerc-io/laconic-wallet-web/pulls/10 Co-authored-by: Nabarun Co-committed-by: Nabarun --- .eslintrc.json | 17 ++ .husky/pre-commit | 1 + config-overrides.js | 86 +++++------ package.json | 9 ++ public/index.html | 42 ++++- src/App.tsx | 6 +- src/components/HDPath.tsx | 2 +- src/context/AccountsContext.tsx | 12 +- src/context/NetworksContext.tsx | 16 +- src/utils/accounts.ts | 16 +- src/utils/key-store.ts | 12 +- .../wallet-connect/wallet-connect-requests.ts | 22 +-- yarn.lock | 146 ++++++++++++++++-- 13 files changed, 291 insertions(+), 96 deletions(-) create mode 100644 .eslintrc.json create mode 100644 .husky/pre-commit diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..98c2686 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,17 @@ +{ + "parser": "@typescript-eslint/parser", + "plugins": ["react"], + "extends": [ + "react-app", + "react-app/jest", + "plugin:react/recommended" + ], + "settings": { + "react": { + "version": "detect" + } + }, + "rules": { + "indent": ["error", 2, { "SwitchCase": 1 }] + } +} diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 0000000..39abe4d --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1 @@ +yarn lint diff --git a/config-overrides.js b/config-overrides.js index d10f3ea..af26d75 100644 --- a/config-overrides.js +++ b/config-overrides.js @@ -2,52 +2,52 @@ const webpack = require('webpack') module.exports = function override(config, env) { - config.module.rules.push({ - test: /\.js$/, - exclude: /node_modules[/\\](?!react-native-vector-icons)/, - use: { - loader: "babel-loader", - options: { - // Disable reading babel configuration - babelrc: false, - configFile: false, + config.module.rules.push({ + test: /\.js$/, + exclude: /node_modules[/\\](?!react-native-vector-icons)/, + use: { + loader: "babel-loader", + options: { + // Disable reading babel configuration + babelrc: false, + configFile: false, - // The configuration for compilation - presets: [ - ["@babel/preset-env", { useBuiltIns: "usage", "corejs": "3" }], - "@babel/preset-react", - "@babel/preset-flow", - "@babel/preset-typescript", - ], - plugins: [ - "@babel/plugin-proposal-class-properties", - "@babel/plugin-proposal-object-rest-spread", - "@babel/plugin-transform-modules-commonjs" - ] - } + // The configuration for compilation + presets: [ + ["@babel/preset-env", { useBuiltIns: "usage", "corejs": "3" }], + "@babel/preset-react", + "@babel/preset-flow", + "@babel/preset-typescript", + ], + plugins: [ + "@babel/plugin-proposal-class-properties", + "@babel/plugin-proposal-object-rest-spread", + "@babel/plugin-transform-modules-commonjs" + ] } - }); - - config.plugins.push( - new webpack.ProvidePlugin({ - Buffer: ["buffer", "Buffer"], - }) - ) - - config.module.rules.push({ - test: /\.(jpg|png|woff|woff2|eot|ttf|svg)$/, - type: 'asset/resource' - }) - - config.resolve.fallback = { - crypto: require.resolve("crypto-browserify"), - stream: require.resolve("stream-browserify"), - http: require.resolve('stream-http'), - https: require.resolve('https-browserify'), - url: false } + }); - config.resolve.alias['react-native$'] = require.resolve('react-native-web'); + config.plugins.push( + new webpack.ProvidePlugin({ + Buffer: ["buffer", "Buffer"], + }) + ) - return config; + config.module.rules.push({ + test: /\.(jpg|png|woff|woff2|eot|ttf|svg)$/, + type: 'asset/resource' + }) + + config.resolve.fallback = { + crypto: require.resolve("crypto-browserify"), + stream: require.resolve("stream-browserify"), + http: require.resolve('stream-http'), + https: require.resolve('https-browserify'), + url: false + } + + config.resolve.alias['react-native$'] = require.resolve('react-native-web'); + + return config; }; diff --git a/package.json b/package.json index 6574ed6..91e19c9 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,8 @@ "start": "react-app-rewired start", "build": "react-app-rewired build", "test": "react-app-rewired test", + "lint": "eslint .", + "prepare": "husky", "eject": "react-scripts eject" }, "eslintConfig": { @@ -75,7 +77,14 @@ "@types/node": "^16.7.13", "@types/react": "^18.0.0", "@types/react-dom": "^18.0.0", + "@typescript-eslint/eslint-plugin": "^6.13.2", + "@typescript-eslint/parser": "^6.13.2", "crypto-browserify": "^3.12.0", + "eslint": "^8.3.0", + "eslint-config-react-app": "^7.0.1", + "eslint-plugin-react": "^7.33.2", + "eslint-webpack-plugin": "^3.1.1", + "husky": "^9.0.11", "react-app-rewired": "^2.2.1", "stream-browserify": "^3.0.0" } diff --git a/public/index.html b/public/index.html index 1a6d95a..1e28cec 100644 --- a/public/index.html +++ b/public/index.html @@ -25,10 +25,50 @@ Learn how to configure a non-root public URL by running `npm run build`. --> Laconic Wallet + -
+
+
+
+
+