Skip to content

Commit

Permalink
chore: avoid lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaslovato committed Aug 5, 2024
2 parents dfea9b2 + fc307d6 commit 23b67ed
Show file tree
Hide file tree
Showing 17 changed files with 243 additions and 258 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
},
"scripts": {
"generate-manifest": "node ./source/config/generateManifest.js",
"dev:chrome": "yarn generate-manifest && cross-env NODE_ENV=development cross-env TARGET_BROWSER=chrome webpack --config source/config/webpack/webpack.dev.js --watch",
"build:chrome": "yarn generate-manifest && cross-env NODE_ENV=production cross-env TARGET_BROWSER=chrome webpack --config source/config/webpack/webpack.prod.js",
"dev:chrome": "yarn generate-manifest && cross-env NODE_ENV=development cross-env TARGET_BROWSER=chrome webpack --config source/config/webpack.dev.js --watch",
"build:chrome": "yarn generate-manifest && cross-env NODE_ENV=production cross-env TARGET_BROWSER=chrome webpack --config source/config/webpack.prod.js",
"dev-watch-requests:chrome": "jq '.permissions = if .permissions then (if (.permissions | index(\"webRequest\")) == null then .permissions + [\"webRequest\"] else .permissions end) else [\"webRequest\"] end | .environment = {\"WATCH_REQUESTS\": \"active\"}' manifest.json > modified_manifest.json && mv modified_manifest.json manifest.json && cross-env NODE_ENV=development cross-env TARGET_BROWSER=chrome webpack --watch",
"dev:firefox": "jq '.permissions = if .permissions then (if (.permissions | index(\"webRequest\")) == null then .permissions + [\"webRequest\"] else .permissions end) else [\"webRequest\"] end' manifest.json > modified_manifest.json && mv modified_manifest.json manifest.json && cross-env NODE_ENV=development cross-env TARGET_BROWSER=firefox webpack --watch",
"dev:opera": "jq '.permissions = if .permissions then (if (.permissions | index(\"webRequest\")) == null then .permissions + [\"webRequest\"] else .permissions end) else [\"webRequest\"] end' manifest.json > modified_manifest.json && mv modified_manifest.json manifest.json && cross-env NODE_ENV=development cross-env TARGET_BROWSER=opera webpack --watch",
Expand Down Expand Up @@ -49,7 +49,7 @@
"@babel/runtime": "^7.21.5",
"@headlessui/react": "^1.6.0",
"@heroicons/react": "^1.0.5",
"@pollum-io/sysweb3-keyring": "/Users/lucaslovato/Documents/sysweb3/packages/sysweb3-keyring/dist",
"@pollum-io/sysweb3-keyring": "^1.0.479",
"@pollum-io/sysweb3-network": "^1.0.95",
"@pollum-io/sysweb3-utils": "^1.1.232",
"@reduxjs/toolkit": "^1.4.0",
Expand Down
6 changes: 5 additions & 1 deletion source/components/Header/Menus/NetworkMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ import btcIcon from 'assets/images/btcIcon.svg';
import ethIcon from 'assets/images/ethIcon.svg';
import { Icon } from 'components/index';
import { useUtils } from 'hooks/index';
import { getController } from 'scripts/Background';
import {
dispatchChangeNetworkBgEvent,
getController,
} from 'scripts/Background';
import { FaucetChainIds } from 'scripts/Background/controllers/message-handler/types';
import { RootState } from 'state/store';
import { NetworkType } from 'utils/types';
Expand Down Expand Up @@ -95,6 +98,7 @@ export const NetworkMenu: React.FC<INetworkComponent> = (
return;
}
await wallet.setActiveNetwork(network, chain);
dispatchChangeNetworkBgEvent(network, !!network?.slip44);
} catch (networkError) {
navigate('/home');
}
Expand Down
201 changes: 201 additions & 0 deletions source/config/webpack.common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
/* eslint-disable @typescript-eslint/no-var-requires */

const CopyWebpackPlugin = require('copy-webpack-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');
const { join, resolve } = require('path');
const TerserPlugin = require('terser-webpack-plugin');
const { DefinePlugin } = require('webpack');

const viewsPath = join(__dirname, '../../views');
const sourcePath = join(__dirname, '../../source');
const destPath = join(__dirname, '../../build');
const targetBrowser = process.env.TARGET_BROWSER || 'chrome';

module.exports = {
entry: {
manifest: join(__dirname, '../../manifest.json'),
background: join(sourcePath, 'scripts/Background', 'index.ts'),
inpage: join(sourcePath, 'scripts/ContentScript', 'inject/inpage.ts'),
pali: join(sourcePath, 'scripts/ContentScript', 'inject/pali.ts'),
handleWindowProperties: join(
sourcePath,
'scripts/ContentScript',
'inject/handleWindowProperties.ts'
),
contentScript: join(sourcePath, 'scripts/ContentScript', 'index.ts'),
app: join(sourcePath, 'pages/App', 'index.tsx'),
external: join(sourcePath, 'pages/External', 'index.tsx'),
trezorScript: join(
sourcePath,
'scripts/ContentScript/trezor',
'trezor-content-script.ts'
),
trezorUSB: join(
sourcePath,
'scripts/ContentScript/trezor',
'trezor-usb-permissions.ts'
),
offscreenScript: join(
sourcePath,
'scripts/ContentScript/offscreen',
'index.ts'
),
},
output: {
path: join(destPath, targetBrowser),
filename: 'js/[name].bundle.js',
clean: true,
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.json'],
alias: {
assets: resolve(__dirname, '../../source/assets'),
components: resolve(__dirname, '../../source/components'),
scripts: resolve(__dirname, '../../source/scripts'),
containers: resolve(__dirname, '../../source/containers'),
pages: resolve(__dirname, '../../source/pages'),
routers: resolve(__dirname, '../../source/routers'),
state: resolve(__dirname, '../../source/state'),
constants: resolve(__dirname, '../../source/constants'),
services: resolve(__dirname, '../../source/services'),
hooks: resolve(__dirname, '../../source/hooks'),
utils: resolve(__dirname, '../../source/utils'),
helpers: resolve(__dirname, '../../source/helpers'),
},
fallback: {
fs: false,
},
},
module: {
rules: [
{
test: /\.(jpg|png|xlsx|xls|csv)$/i,
type: 'asset/resource',
generator: {
filename: '[path][name][ext]',
},
exclude: /node_modules/,
},
{
test: /\.(svg)$/i,
type: 'asset/inline',
exclude: /node_modules/,
},
{
test: /\.(js|ts)x?$/,
loader: 'babel-loader',
exclude: /node_modules/,
},
{
test: /\.less$/,
use: [
'style-loader',
'css-loader',
{
loader: 'less-loader',
options: {
lessOptions: {
modifyVars: {
'primary-color': '#1DA57A',
'link-color': '#1DA57A',
'border-radius-base': '2rem',
},
javascriptEnabled: true,
},
},
},
],
},
{
test: /\.(ttf)$/,
type: 'asset/resource',
generator: {
filename: '[path][name][ext]',
},
},
{
test: /\.(sa|sc|c)ss$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'postcss-loader',
'resolve-url-loader',
'sass-loader',
],
},
],
},
plugins: [
new ForkTsCheckerWebpackPlugin(),
new DefinePlugin({
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
TARGET_BROWSER: JSON.stringify(targetBrowser),
}),
new HtmlWebpackPlugin({
template: join(viewsPath, 'app.html'),
inject: 'body',
chunks: ['app'],
hash: true,
filename: 'app.html',
}),
new HtmlWebpackPlugin({
template: join(viewsPath, 'external.html'),
inject: 'body',
chunks: ['external'],
hash: true,
filename: 'external.html',
}),
new HtmlWebpackPlugin({
template: join(viewsPath, 'trezor-usb-permissions.html'),
filename: 'trezor-usb-permissions.html',
inject: 'body',
chunks: ['trezorUSB'],
}),
new HtmlWebpackPlugin({
template: join(viewsPath, 'offscreen.html'),
filename: 'offscreen.html',
inject: 'body',
chunks: ['offscreenScript'],
}),
new MiniCssExtractPlugin({ filename: 'css/[name].css' }),
new CopyWebpackPlugin({
patterns: [{ from: 'source/assets', to: 'assets' }],
}),
new CopyWebpackPlugin({
patterns: [
{
from: './manifest.json',
to: join(__dirname, '../../build/chrome'),
force: true,
transform: function (content) {
return Buffer.from(
JSON.stringify({ ...JSON.parse(content.toString()) })
);
},
},
],
}),
new NodePolyfillPlugin(),
],
optimization: {
minimizer: [
new CssMinimizerPlugin(),
new TerserPlugin({
parallel: true,
terserOptions: {
compress: {
drop_console: true,
},
output: {
comments: false,
},
},
extractComments: false,
}),
],
},
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/* eslint-disable @typescript-eslint/no-var-requires */

const { merge } = require('webpack-merge');

const common = require('./webpack.common');

module.exports = merge(common, {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
const { merge } = require('webpack-merge');
/* eslint-disable @typescript-eslint/no-var-requires */

const path = require('path');
const ZipPlugin = require('zip-webpack-plugin');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const { merge } = require('webpack-merge');
const ZipPlugin = require('zip-webpack-plugin');

const common = require('./webpack.common');
const version = require('../../../package.json').version;

const version = require('../../package.json').version;

const targetBrowser = process.env.TARGET_BROWSER || 'chrome';

Expand All @@ -13,9 +17,7 @@ module.exports = merge(common, {
plugins: [
new ZipPlugin({
filename: `pali-wallet-${targetBrowser}-${version}`,
path: path.resolve(__dirname, '../../../build'),
pathPrefix: `${targetBrowser}`,
include: [/\.js$/, /\.css$/, /\.html$/, /manifest\.json$/],
path: path.join(__dirname, '../../build'),
extension: `${
targetBrowser === 'opera'
? 'crx'
Expand All @@ -29,7 +31,7 @@ module.exports = merge(common, {
openAnalyzer: false,
reportFilename: path.join(
__dirname,
'../../../build',
'../../build',
`${targetBrowser}-report.html`
),
}),
Expand Down
18 changes: 0 additions & 18 deletions source/config/webpack/alias.js

This file was deleted.

34 changes: 0 additions & 34 deletions source/config/webpack/entry.js

This file was deleted.

22 changes: 0 additions & 22 deletions source/config/webpack/optimization.js

This file was deleted.

9 changes: 0 additions & 9 deletions source/config/webpack/paths.js

This file was deleted.

Loading

0 comments on commit 23b67ed

Please sign in to comment.