From ea9f1fd32f4122e11df63c174b59f7082e2bddc7 Mon Sep 17 00:00:00 2001 From: CodeDead Date: Thu, 17 Apr 2025 16:48:11 +0200 Subject: [PATCH 1/2] feat: eslint upgrade, formatting, improved test and build process, dependency upgrades --- .eslintignore | 10 - .eslintrc.json | 22 - .github/workflows/release.yml | 38 +- .github/workflows/test.yml | 35 +- .prettierignore | 9 + .prettierrc | 7 + eslint.config.js | 92 + index.html | 18 +- package.json | 23 +- src-tauri/Cargo.lock | 132 +- src-tauri/Cargo.toml | 4 +- src-tauri/tauri.conf.json | 2 +- src/components/AlertDialog/index.jsx | 23 +- src/components/App/index.jsx | 5 +- src/components/GridList/index.jsx | 5 +- src/components/Layout/index.jsx | 28 +- src/components/LoadingBar/index.jsx | 11 +- src/components/PortInput/index.jsx | 4 +- src/components/Theme/index.jsx | 4 +- src/components/TopBar/index.jsx | 96 +- src/components/UpdateDialog/index.jsx | 24 +- src/contexts/MainContextProvider/index.jsx | 55 +- src/main.css | 16 +- src/main.jsx | 16 +- src/reducers/MainReducer/Actions/index.js | 17 +- src/routes/About/index.jsx | 11 +- src/routes/Home/index.jsx | 162 +- src/routes/Settings/index.jsx | 113 +- src/utils/Updater/index.js | 12 +- vite.config.js | 8 +- yarn.lock | 2570 ++++++++++++++++---- 31 files changed, 2750 insertions(+), 822 deletions(-) delete mode 100644 .eslintignore delete mode 100644 .eslintrc.json create mode 100644 .prettierignore create mode 100644 .prettierrc create mode 100644 eslint.config.js diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index fc383f6..0000000 --- a/.eslintignore +++ /dev/null @@ -1,10 +0,0 @@ -src/setupTests.js -src-tauri/ -src-tauri/* -.github/* -.yarn/* -node_modules/* -build/* -dist/* -vite.config.js -src/languages/* diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index d0b44c1..0000000 --- a/.eslintrc.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "env": { - "browser": true, - "es2021": true - }, - "extends": "airbnb", - "parserOptions": { - "ecmaVersion": "latest", - "sourceType": "module" - }, - "rules": { - "react/function-component-definition": [ - 2, - { - "namedComponents": "arrow-function", - "unnamedComponents": "arrow-function" - } - ], - "react/prop-types": 0, - "linebreak-style": 0 - } -} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 080db66..978db27 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,49 +7,59 @@ on: workflow_dispatch: jobs: - release: + publish-tauri: permissions: contents: write strategy: fail-fast: false matrix: - platform: [ macos-latest, ubuntu-latest, windows-latest ] + include: + - platform: 'macos-latest' + args: '--target aarch64-apple-darwin' + - platform: 'macos-latest' + args: '--target x86_64-apple-darwin' + - platform: 'ubuntu-22.04' + args: '' + - platform: 'windows-latest' + args: '' + runs-on: ${{ matrix.platform }} steps: - - name: Checkout repository - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - - name: Install dependencies (ubuntu only) - if: matrix.platform == 'ubuntu-latest' + - name: install dependencies (ubuntu only) + if: matrix.platform == 'ubuntu-22.04' run: | sudo apt-get update sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf - - name: Node.js setup + - name: setup node uses: actions/setup-node@v4 with: - node-version: 'lts/*' + node-version: lts/* cache: 'yarn' - - name: Rust setup + - name: install Rust stable uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }} - name: Rust cache uses: swatinem/rust-cache@v2 with: workspaces: './src-tauri -> target' - - name: Install app dependencies and build web - run: yarn && yarn build + - name: Install frontend dependencies + run: yarn install - name: Build the app uses: tauri-apps/tauri-action@v0 - env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - tagName: ${{ github.ref_name }} + tagName: app-v__VERSION__ releaseName: 'Advanced PortChecker v__VERSION__' - releaseBody: 'See the assets to download and install this version.' + releaseBody: 'See the assets to download this version and install.' releaseDraft: true prerelease: false + args: ${{ matrix.args }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 12eb6a3..6203fb8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,21 +15,31 @@ jobs: run: yarn - name: Run ESLint - run: yarn run eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0 + run: yarn lint + + - name: Run Prettier + run: yarn format test-tauri: strategy: fail-fast: false matrix: - platform: [ macos-latest, ubuntu-latest, windows-latest ] + include: + - platform: 'macos-latest' + args: '--target aarch64-apple-darwin' + - platform: 'macos-latest' + args: '--target x86_64-apple-darwin' + - platform: 'ubuntu-22.04' + args: '' + - platform: 'windows-latest' + args: '' runs-on: ${{ matrix.platform }} steps: - - name: Checkout repository - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - - name: Install dependencies (ubuntu only) - if: matrix.platform == 'ubuntu-latest' + - name: install dependencies (ubuntu only) + if: matrix.platform == 'ubuntu-22.04' run: | sudo apt-get update sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf @@ -37,20 +47,23 @@ jobs: - name: Setup node uses: actions/setup-node@v4 with: - node-version: 'lts/*' + node-version: lts/* cache: 'yarn' - - name: Rust setup + - name: Install Rust stable uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }} - name: Rust cache uses: swatinem/rust-cache@v2 with: workspaces: './src-tauri -> target' - - name: Install app dependencies and build it - run: yarn && yarn build + - name: Install frontend dependencies + run: yarn install - - uses: tauri-apps/tauri-action@v0 + - name: Build the app + uses: tauri-apps/tauri-action@v0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..bb51e5a --- /dev/null +++ b/.prettierignore @@ -0,0 +1,9 @@ +dist +.yarn +dist +node_modules +nginx +.idea +README.md +src-tauri +.github diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..51110b0 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,7 @@ +{ + "singleQuote": true, + "trailingComma": "all", + "tabWidth": 2, + "semi": true, + "arrowParens": "always" +} diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..dcc022f --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,92 @@ +import js from '@eslint/js'; +import importPlugin from 'eslint-plugin-import'; +import react from 'eslint-plugin-react'; +import reactHooks from 'eslint-plugin-react-hooks'; +import reactRefresh from 'eslint-plugin-react-refresh'; +import globals from 'globals'; + +export default [ + importPlugin.flatConfigs.recommended, + { + ignores: [ + 'dist', + '.yarn', + 'dist', + 'node_modules', + 'nginx', + '.idea', + 'src-tauri', + '.github', + ], + }, + { + files: ['**/*.{js,jsx}'], + languageOptions: { + ecmaVersion: 'latest', + globals: globals.browser, + parserOptions: { + ecmaVersion: 'latest', + ecmaFeatures: { jsx: true }, + sourceType: 'module', + }, + }, + settings: { + react: { version: '19.0' }, + 'import/resolver': { + node: { + extensions: ['.js', '.jsx', '.ts', '.tsx'], + }, + }, + }, + plugins: { + react, + 'react-hooks': reactHooks, + 'react-refresh': reactRefresh, + }, + rules: { + ...js.configs.recommended.rules, + ...react.configs.recommended.rules, + ...react.configs['jsx-runtime'].rules, + ...reactHooks.configs.recommended.rules, + 'no-multi-spaces': ['error', { ignoreEOLComments: false }], + 'no-trailing-spaces': ['error', { skipBlankLines: false }], + 'no-use-before-define': ['error', { functions: true }], + 'react/jsx-no-target-blank': 'off', + 'react-refresh/only-export-components': [ + 'warn', + { allowConstantExport: true }, + ], + 'react/function-component-definition': [ + 2, + { + namedComponents: 'arrow-function', + unnamedComponents: 'arrow-function', + }, + ], + 'react/prop-types': 0, + 'react/jsx-uses-vars': 'error', + 'react/jsx-uses-react': 'error', + semi: [2, 'always'], + quotes: [2, 'single'], + 'import/order': [ + 'error', + { + groups: ['builtin', 'external', 'internal', ['parent', 'sibling']], + pathGroups: [ + { + pattern: 'react', + group: 'external', + position: 'before', + }, + ], + pathGroupsExcludedImportTypes: ['react'], + 'newlines-between': 'never', + alphabetize: { + order: 'asc', + caseInsensitive: true, + }, + }, + ], + }, + }, +]; diff --git a/index.html b/index.html index 083ea95..63963ef 100644 --- a/index.html +++ b/index.html @@ -1,13 +1,13 @@ - - - - + + + + Advanced PortChecker - - -
- - + + +
+ + diff --git a/package.json b/package.json index dfa968d..2d47b1c 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "scripts": { "dev": "vite", "build": "vite build", - "lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0", + "lint": "eslint .", + "format": "prettier --check .", "preview": "vite preview", "tdev": "yarn tauri dev", "tbuild": "yarn tauri build" @@ -17,8 +18,8 @@ "@fontsource/roboto": "^5.2.5", "@mui/icons-material": "^7.0.2", "@mui/material": "^7.0.2", - "@mui/x-data-grid": "^7.28.3", - "@tauri-apps/api": "^2.4.1", + "@mui/x-data-grid": "^8.0.0", + "@tauri-apps/api": "^2.5.0", "@tauri-apps/plugin-dialog": "^2.2.1", "@tauri-apps/plugin-os": "^2.2.1", "react": "^19.1.0", @@ -26,18 +27,20 @@ "react-router-dom": "^7.5.0" }, "devDependencies": { - "@tauri-apps/cli": "^2.4.1", - "@types/react": "^19.1.1", + "@eslint/js": "^9.24.0", + "@tauri-apps/cli": "^2.5.0", + "@types/react": "^19.1.2", "@types/react-dom": "^19.1.2", - "@vitejs/plugin-react": "^4.3.4", - "eslint": "^8.57.1", - "eslint-config-airbnb": "^19.0.4", + "@vitejs/plugin-react": "^4.4.0", + "eslint": "^9.24.0", + "eslint-config-react-app": "^7.0.1", "eslint-plugin-import": "^2.31.0", - "eslint-plugin-jsx-a11y": "^6.10.2", "eslint-plugin-react": "^7.37.5", "eslint-plugin-react-hooks": "^5.2.0", "eslint-plugin-react-refresh": "^0.4.19", - "vite": "^6.2.6", + "globals": "^16.0.0", + "prettier": "^3.5.3", + "vite": "^6.3.1", "vite-plugin-eslint": "^1.8.1", "vite-plugin-svgr": "^4.3.0" }, diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 5292df2..53dc021 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -72,9 +72,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.97" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f" +checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" [[package]] name = "ashpd" @@ -85,7 +85,7 @@ dependencies = [ "enumflags2", "futures-channel", "futures-util", - "rand 0.9.0", + "rand 0.9.1", "raw-window-handle", "serde", "serde_repr", @@ -1453,7 +1453,7 @@ dependencies = [ "js-sys", "log", "wasm-bindgen", - "windows-core 0.61.0", + "windows-core", ] [[package]] @@ -1821,9 +1821,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.171" +version = "0.2.172" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" +checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" [[package]] name = "libloading" @@ -2643,9 +2643,9 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" [[package]] name = "proc-macro2" -version = "1.0.94" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" dependencies = [ "unicode-ident", ] @@ -2701,13 +2701,12 @@ dependencies = [ [[package]] name = "rand" -version = "0.9.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" +checksum = "9fbfd9d094a40bf3ae768db9361049ace4c0e04a4fd6b359518bd7b73a73dd97" dependencies = [ "rand_chacha 0.9.0", "rand_core 0.9.3", - "zerocopy", ] [[package]] @@ -3399,9 +3398,9 @@ dependencies = [ [[package]] name = "tao" -version = "0.32.8" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63c8b1020610b9138dd7b1e06cf259ae91aa05c30f3bd0d6b42a03997b92dec1" +checksum = "1e59c1f38e657351a2e822eadf40d6a2ad4627b9c25557bc1180ec1b3295ef82" dependencies = [ "bitflags 2.9.0", "core-foundation", @@ -3431,7 +3430,7 @@ dependencies = [ "unicode-segmentation", "url", "windows", - "windows-core 0.60.1", + "windows-core", "windows-version", "x11-dl", ] @@ -3455,9 +3454,9 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "tauri" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d08db1ff9e011e04014e737ec022610d756c0eae0b3b3a9037bccaf3003173a" +checksum = "be03adf68fba02f87c4653da7bd73f40b0ecf9c6b7c2c39830f6981d0651912f" dependencies = [ "anyhow", "bytes", @@ -3478,6 +3477,7 @@ dependencies = [ "objc2 0.6.0", "objc2-app-kit", "objc2-foundation 0.3.0", + "objc2-ui-kit", "percent-encoding", "plist", "raw-window-handle", @@ -3505,9 +3505,9 @@ dependencies = [ [[package]] name = "tauri-build" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fd20e4661c2cce65343319e6e8da256958f5af958cafc47c0d0af66a55dcd17" +checksum = "d7a0350f0df1db385ca5c02888a83e0e66655c245b7443db8b78a70da7d7f8fc" dependencies = [ "anyhow", "cargo_toml", @@ -3527,9 +3527,9 @@ dependencies = [ [[package]] name = "tauri-codegen" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "458258b19032450ccf975840116ecf013e539eadbb74420bd890e8c56ab2b1a4" +checksum = "f93f035551bf7b11b3f51ad9bc231ebbe5e085565527991c16cf326aa38cdf47" dependencies = [ "base64 0.22.1", "brotli", @@ -3554,9 +3554,9 @@ dependencies = [ [[package]] name = "tauri-macros" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d402813d3b9c773a0fa58697c457c771f10e735498fdcb7b343264d18e5a601f" +checksum = "8db4df25e2d9d45de0c4c910da61cd5500190da14ae4830749fee3466dddd112" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -3568,9 +3568,9 @@ dependencies = [ [[package]] name = "tauri-plugin" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4190775d6ff73fe66d9af44c012739a2659720efd9c0e1e56a918678038699d" +checksum = "37a5ebe6a610d1b78a94650896e6f7c9796323f408800cef436e0fa0539de601" dependencies = [ "anyhow", "glob", @@ -3644,15 +3644,17 @@ dependencies = [ [[package]] name = "tauri-runtime" -version = "2.5.1" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00ada7ac2f9276f09b8c3afffd3215fd5d9bff23c22df8a7c70e7ef67cacd532" +checksum = "00f004905d549854069e6774533d742b03cacfd6f03deb08940a8677586cbe39" dependencies = [ "cookie", "dpi", "gtk", "http", "jni", + "objc2 0.6.0", + "objc2-ui-kit", "raw-window-handle", "serde", "serde_json", @@ -3664,9 +3666,9 @@ dependencies = [ [[package]] name = "tauri-runtime-wry" -version = "2.5.1" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf2e5842c57e154af43a20a49c7efee0ce2578c20b4c2bdf266852b422d2e421" +checksum = "f85d056f4d4b014fe874814034f3416d57114b617a493a4fe552580851a3f3a2" dependencies = [ "gtk", "http", @@ -3691,9 +3693,9 @@ dependencies = [ [[package]] name = "tauri-utils" -version = "2.3.1" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f037e66c7638cc0a2213f61566932b9a06882b8346486579c90e4b019bac447" +checksum = "b2900399c239a471bcff7f15c4399eb1a8c4fe511ba2853e07c996d771a5e0a4" dependencies = [ "anyhow", "brotli", @@ -4360,15 +4362,15 @@ dependencies = [ [[package]] name = "webview2-com" -version = "0.36.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0d606f600e5272b514dbb66539dd068211cc20155be8d3958201b4b5bd79ed3" +checksum = "b542b5cfbd9618c46c2784e4d41ba218c336ac70d44c55e47b251033e7d85601" dependencies = [ "webview2-com-macros", "webview2-com-sys", "windows", - "windows-core 0.60.1", - "windows-implement 0.59.0", + "windows-core", + "windows-implement", "windows-interface", ] @@ -4385,13 +4387,13 @@ dependencies = [ [[package]] name = "webview2-com-sys" -version = "0.36.0" +version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfb27fccd3c27f68e9a6af1bcf48c2d82534b8675b83608a4d81446d095a17ac" +checksum = "8ae2d11c4a686e4409659d7891791254cf9286d3cfe0eef54df1523533d22295" dependencies = [ "thiserror 2.0.12", "windows", - "windows-core 0.60.1", + "windows-core", ] [[package]] @@ -4442,12 +4444,12 @@ dependencies = [ [[package]] name = "windows" -version = "0.60.0" +version = "0.61.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddf874e74c7a99773e62b1c671427abf01a425e77c3d3fb9fb1e4883ea934529" +checksum = "c5ee8f3d025738cb02bad7868bbb5f8a6327501e870bf51f1b455b0a2454a419" dependencies = [ "windows-collections", - "windows-core 0.60.1", + "windows-core", "windows-future", "windows-link", "windows-numerics", @@ -4455,24 +4457,11 @@ dependencies = [ [[package]] name = "windows-collections" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5467f79cc1ba3f52ebb2ed41dbb459b8e7db636cc3429458d9a852e15bc24dec" +checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8" dependencies = [ - "windows-core 0.60.1", -] - -[[package]] -name = "windows-core" -version = "0.60.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca21a92a9cae9bf4ccae5cf8368dce0837100ddf6e6d57936749e85f152f6247" -dependencies = [ - "windows-implement 0.59.0", - "windows-interface", - "windows-link", - "windows-result", - "windows-strings 0.3.1", + "windows-core", ] [[package]] @@ -4481,7 +4470,7 @@ version = "0.61.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4763c1de310c86d75a878046489e2e5ba02c649d185f21c67d4cf8a56d098980" dependencies = [ - "windows-implement 0.60.0", + "windows-implement", "windows-interface", "windows-link", "windows-result", @@ -4490,25 +4479,14 @@ dependencies = [ [[package]] name = "windows-future" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a787db4595e7eb80239b74ce8babfb1363d8e343ab072f2ffe901400c03349f0" +checksum = "7a1d6bbefcb7b60acd19828e1bc965da6fcf18a7e39490c5f8be71e54a19ba32" dependencies = [ - "windows-core 0.60.1", + "windows-core", "windows-link", ] -[[package]] -name = "windows-implement" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83577b051e2f49a058c308f17f273b570a6a758386fc291b5f6a934dd84e48c1" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.100", -] - [[package]] name = "windows-implement" version = "0.60.0" @@ -4539,11 +4517,11 @@ checksum = "76840935b766e1b0a05c0066835fb9ec80071d4c09a16f6bd5f7e655e3c14c38" [[package]] name = "windows-numerics" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "005dea54e2f6499f2cee279b8f703b3cf3b5734a2d8d21867c8f44003182eeed" +checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1" dependencies = [ - "windows-core 0.60.1", + "windows-core", "windows-link", ] @@ -4923,9 +4901,9 @@ checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" [[package]] name = "wry" -version = "0.50.5" +version = "0.51.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b19b78efae8b853c6c817e8752fc1dbf9cab8a8ffe9c30f399bd750ccf0f0730" +checksum = "c886a0a9d2a94fd90cfa1d929629b79cfefb1546e2c7430c63a47f0664c0e4e2" dependencies = [ "base64 0.22.1", "block2 0.6.0", @@ -4960,7 +4938,7 @@ dependencies = [ "webkit2gtk-sys", "webview2-com", "windows", - "windows-core 0.60.1", + "windows-core", "windows-version", "x11-dl", ] diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 23258d5..77f5398 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -12,12 +12,12 @@ rust-version = "1.86.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [build-dependencies] -tauri-build = { version = "2.1.1", features = [] } +tauri-build = { version = "2.2.0", features = [] } [dependencies] serde_json = "1.0" serde = { version = "1.0", features = ["derive"] } -tauri = { version = "2.4.1", features = [] } +tauri = { version = "2.5.0", features = [] } open = "5.3.2" chrono = "0.4.40" tauri-plugin-dialog = "2.2.1" diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 0c6860d..ff9a16a 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -9,7 +9,7 @@ "bundle": { "active": true, "category": "Utility", - "copyright": "Copyright © 2024 CodeDead", + "copyright": "Copyright © 2025 CodeDead", "targets": "all", "externalBin": [], "icon": [ diff --git a/src/components/AlertDialog/index.jsx b/src/components/AlertDialog/index.jsx index 4c90778..9896c6b 100644 --- a/src/components/AlertDialog/index.jsx +++ b/src/components/AlertDialog/index.jsx @@ -1,13 +1,20 @@ import React from 'react'; +import Button from '@mui/material/Button'; import Dialog from '@mui/material/Dialog'; import DialogActions from '@mui/material/DialogActions'; import DialogContent from '@mui/material/DialogContent'; import DialogContentText from '@mui/material/DialogContentText'; import DialogTitle from '@mui/material/DialogTitle'; -import Button from '@mui/material/Button'; const AlertDialog = ({ - open, title, content, onOk, onCancel, onClose, agreeLabel, cancelLabel, + open, + title, + content, + onOk, + onCancel, + onClose, + agreeLabel, + cancelLabel, }) => { /** * Cancel action @@ -41,7 +48,6 @@ const AlertDialog = ({ const splitContent = content.split('\n').map((item, idx) => { if (idx === 0) { return ( - // eslint-disable-next-line react/no-array-index-key {item} {content.split('\n').length > 1 ?
: null} @@ -49,7 +55,6 @@ const AlertDialog = ({ ); } return ( - // eslint-disable-next-line react/no-array-index-key {item.charAt(0).toUpperCase() + item.slice(1)}
@@ -64,20 +69,14 @@ const AlertDialog = ({ aria-labelledby="alert-dialog-title" aria-describedby="alert-dialog-description" > - - {title} - + {title} {splitContent} - {onCancel ? ( - - ) : null} + {onCancel ? : null} {onOk ? ( - + + diff --git a/src/contexts/MainContextProvider/index.jsx b/src/contexts/MainContextProvider/index.jsx index 95335af..f663e81 100644 --- a/src/contexts/MainContextProvider/index.jsx +++ b/src/contexts/MainContextProvider/index.jsx @@ -1,38 +1,49 @@ import React, { createContext, useReducer } from 'react'; -import MainReducer from '../../reducers/MainReducer'; import enUs from '../../languages/en_us.json'; import esEs from '../../languages/es_es.json'; -import nlNl from '../../languages/nl_nl.json'; import frFr from '../../languages/fr_fr.json'; -import zhCn from '../../languages/zh_cn.json'; import itIt from '../../languages/it_it.json'; +import nlNl from '../../languages/nl_nl.json'; +import zhCn from '../../languages/zh_cn.json'; +import MainReducer from '../../reducers/MainReducer'; -const languageIndex = localStorage.languageIndex ? parseFloat(localStorage.languageIndex) : 0; -const themeIndex = localStorage.themeIndex ? parseFloat(localStorage.themeIndex) : 0; +const languageIndex = localStorage.languageIndex + ? parseFloat(localStorage.languageIndex) + : 0; +const themeIndex = localStorage.themeIndex + ? parseFloat(localStorage.themeIndex) + : 0; const themeType = localStorage.themeType ? localStorage.themeType : 'light'; -const autoUpdate = localStorage.autoUpdate ? (localStorage.autoUpdate === 'true') : true; -const colorOnDark = localStorage.colorOnDark ? (localStorage.colorOnDark === 'true') : false; +const autoUpdate = localStorage.autoUpdate + ? localStorage.autoUpdate === 'true' + : true; +const colorOnDark = localStorage.colorOnDark + ? localStorage.colorOnDark === 'true' + : false; const threads = localStorage.threads ? parseFloat(localStorage.threads) : 1; const timeout = localStorage.timeout ? parseFloat(localStorage.timeout) : 250; -const noClosed = localStorage.noClosed ? (localStorage.noClosed === 'true') : false; -const noUnknown = localStorage.noUnknown ? (localStorage.noUnknown === 'true') : false; -const exportNoClosed = localStorage.exportNoClosed ? (localStorage.exportNoClosed === 'true') : true; -const exportNoUnknown = localStorage.exportNoUnknown ? (localStorage.exportNoUnknown === 'true') : true; -const sort = localStorage.sort ? (localStorage.sort === 'true') : true; -const themeToggle = localStorage.themeToggle ? (localStorage.themeToggle === 'true') : true; +const noClosed = localStorage.noClosed + ? localStorage.noClosed === 'true' + : false; +const noUnknown = localStorage.noUnknown + ? localStorage.noUnknown === 'true' + : false; +const exportNoClosed = localStorage.exportNoClosed + ? localStorage.exportNoClosed === 'true' + : true; +const exportNoUnknown = localStorage.exportNoUnknown + ? localStorage.exportNoUnknown === 'true' + : true; +const sort = localStorage.sort ? localStorage.sort === 'true' : true; +const themeToggle = localStorage.themeToggle + ? localStorage.themeToggle === 'true' + : true; const initState = { autoUpdate, languageIndex, - languages: [ - enUs, - esEs, - frFr, - itIt, - nlNl, - zhCn, - ], + languages: [enUs, esEs, frFr, itIt, nlNl, zhCn], themeIndex, themeType, pageIndex: 0, @@ -57,13 +68,13 @@ const initState = { themeToggle, }; +// eslint-disable-next-line react-refresh/only-export-components export const MainContext = createContext(initState); const MainContextProvider = ({ children }) => { const [state, dispatch] = useReducer(MainReducer, initState); return ( - // eslint-disable-next-line react/jsx-no-constructed-context-values {children} diff --git a/src/main.css b/src/main.css index da92873..8464098 100644 --- a/src/main.css +++ b/src/main.css @@ -1,13 +1,13 @@ body { - margin: 0; - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', - 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', - sans-serif; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; + margin: 0; + font-family: + -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', + 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; } code { - font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', - monospace; + font-family: + source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace; } diff --git a/src/main.jsx b/src/main.jsx index 93e1782..7b7773b 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -8,12 +8,10 @@ import '@fontsource/roboto/500.css'; import '@fontsource/roboto/700.css'; import MainContextProvider from './contexts/MainContextProvider'; -ReactDOM - .createRoot(document.getElementById('root')) - .render( - - - - - , - ); +ReactDOM.createRoot(document.getElementById('root')).render( + + + + + , +); diff --git a/src/reducers/MainReducer/Actions/index.js b/src/reducers/MainReducer/Actions/index.js index 6a97b3c..f723e9f 100644 --- a/src/reducers/MainReducer/Actions/index.js +++ b/src/reducers/MainReducer/Actions/index.js @@ -57,14 +57,19 @@ export const setAutoUpdate = (value) => ({ }); export const openWebSite = (website) => { - invoke('open_website', { website }) - .catch((e) => { - // eslint-disable-next-line no-console - console.error(e); - }); + invoke('open_website', { website }).catch((e) => { + console.error(e); + }); }; -export const scanAddresses = (addresses, startPort, endPort, timeout, threads, sort) => { +export const scanAddresses = ( + addresses, + startPort, + endPort, + timeout, + threads, + sort, +) => { const cmd = { addresses, startPort: parseInt(startPort, 10), diff --git a/src/routes/About/index.jsx b/src/routes/About/index.jsx index 313ead6..af451c5 100644 --- a/src/routes/About/index.jsx +++ b/src/routes/About/index.jsx @@ -1,12 +1,12 @@ import React, { useContext, useEffect } from 'react'; -import Container from '@mui/material/Container'; +import Button from '@mui/material/Button'; import Card from '@mui/material/Card'; import CardContent from '@mui/material/CardContent'; +import Container from '@mui/material/Container'; import Typography from '@mui/material/Typography'; -import Button from '@mui/material/Button'; +import packageJson from '../../../package.json'; import { MainContext } from '../../contexts/MainContextProvider'; import { openWebSite, setPageIndex } from '../../reducers/MainReducer/Actions'; -import packageJson from '../../../package.json'; const About = () => { const [state, d1] = useContext(MainContext); @@ -29,6 +29,7 @@ const About = () => { useEffect(() => { d1(setPageIndex(2)); + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); return ( @@ -39,7 +40,9 @@ const About = () => { - {language.aboutText.replace('{x}', packageJson.version).replace('{year}', new Date().getFullYear())} + {language.aboutText + .replace('{x}', packageJson.version) + .replace('{year}', new Date().getFullYear())} diff --git a/src/routes/Home/index.jsx b/src/routes/Home/index.jsx index a3e65fa..3e5ae47 100644 --- a/src/routes/Home/index.jsx +++ b/src/routes/Home/index.jsx @@ -1,24 +1,26 @@ import React, { useContext, useEffect, useState } from 'react'; +import AddIcon from '@mui/icons-material/Add'; +import RemoveIcon from '@mui/icons-material/Remove'; +import Alert from '@mui/material/Alert'; +import Button from '@mui/material/Button'; import Card from '@mui/material/Card'; import CardContent from '@mui/material/CardContent'; -import Grid from '@mui/material/Grid'; -import TextField from '@mui/material/TextField'; import Container from '@mui/material/Container'; -import Paper from '@mui/material/Paper'; -import { DataGrid } from '@mui/x-data-grid'; -import Button from '@mui/material/Button'; -import { save } from '@tauri-apps/plugin-dialog'; -import { invoke } from '@tauri-apps/api/core'; import FormControl from '@mui/material/FormControl'; +import Grid from '@mui/material/Grid'; +import IconButton from '@mui/material/IconButton'; import InputLabel from '@mui/material/InputLabel'; -import Select from '@mui/material/Select'; +import LinearProgress from '@mui/material/LinearProgress'; import MenuItem from '@mui/material/MenuItem'; -import Alert from '@mui/material/Alert'; +import Paper from '@mui/material/Paper'; +import Select from '@mui/material/Select'; import Snackbar from '@mui/material/Snackbar'; -import AddIcon from '@mui/icons-material/Add'; -import RemoveIcon from '@mui/icons-material/Remove'; -import IconButton from '@mui/material/IconButton'; -import LinearProgress from '@mui/material/LinearProgress'; +import TextField from '@mui/material/TextField'; +import { DataGrid } from '@mui/x-data-grid'; +import { invoke } from '@tauri-apps/api/core'; +import { save } from '@tauri-apps/plugin-dialog'; +import PortInput from '../../components/PortInput'; +import { MainContext } from '../../contexts/MainContextProvider'; import { cancelScan, scanAddresses, @@ -31,16 +33,26 @@ import { setScanResults, setStartPort, } from '../../reducers/MainReducer/Actions'; -import { MainContext } from '../../contexts/MainContextProvider'; -import PortInput from '../../components/PortInput'; const Home = () => { const [state, d1] = useContext(MainContext); const { - languages, languageIndex, addresses, startPort, endPort, timeout, - threads, noClosed, sort, isScanning, scanResults, exportNoClosed, - isCancelling, noUnknown, exportNoUnknown, + languages, + languageIndex, + addresses, + startPort, + endPort, + timeout, + threads, + noClosed, + sort, + isScanning, + scanResults, + exportNoClosed, + isCancelling, + noUnknown, + exportNoUnknown, } = state; const language = languages[languageIndex]; @@ -76,7 +88,9 @@ const Home = () => { * @param indexToRemove The index of the address to remove */ const removeAddress = (indexToRemove) => { - const newAddresses = addresses.filter((address, index) => index !== indexToRemove); + const newAddresses = addresses.filter( + (address, index) => index !== indexToRemove, + ); d1(setAddresses(newAddresses)); }; @@ -117,18 +131,21 @@ const Home = () => { const startStopScan = () => { if (isScanning) { d1(setIsCancelling(true)); - cancelScan() - .catch((err) => { - d1(setError(err)); - d1(setIsCancelling(false)); - }); + cancelScan().catch((err) => { + d1(setError(err)); + d1(setIsCancelling(false)); + }); } else { for (let i = 0; i < addresses.length; i += 1) { - if (addresses[i] === '' || startPort < 0 - || startPort > 65535 - || endPort < 0 - || endPort > 65535 - || startPort > endPort) return; + if ( + addresses[i] === '' || + startPort < 0 || + startPort > 65535 || + endPort < 0 || + endPort > 65535 || + startPort > endPort + ) + return; } d1(setIsScanning(true)); @@ -191,7 +208,11 @@ const Home = () => { if (type === 'text/plain') { res.forEach((e) => { - if ((!exportNoClosed && e.portStatus === 'Closed') || (!exportNoUnknown && e.portStatus === 'Unknown')) return; + if ( + (!exportNoClosed && e.portStatus === 'Closed') || + (!exportNoUnknown && e.portStatus === 'Unknown') + ) + return; toExport += `${e.address} ${e.port} ${e.hostName} ${e.portStatus} ${e.scanDate}\n`; }); } else if (type === 'application/json') { @@ -205,13 +226,22 @@ const Home = () => { toExport = JSON.stringify(exportJson, null, 2); } else if (type === 'text/csv') { res.forEach((e) => { - if ((!exportNoClosed && e.portStatus === 'Closed') || (!exportNoUnknown && e.portStatus === 'Unknown')) return; + if ( + (!exportNoClosed && e.portStatus === 'Closed') || + (!exportNoUnknown && e.portStatus === 'Unknown') + ) + return; toExport += `"${e.address.replaceAll('"', '""')}","${e.port}","${e.hostName.replaceAll('"', '""')}","${e.portStatus.replaceAll('"', '""')}","${e.scanDate.replaceAll('"', '""')}",\n`; }); } else if (type === 'text/html') { - toExport = 'Advanced PortChecker'; + toExport = + 'Advanced PortChecker
AddressPortHost NamePort StatusScan Date
'; res.forEach((e) => { - if ((!exportNoClosed && e.portStatus === 'Closed') || (!exportNoUnknown && e.portStatus === 'Unknown')) return; + if ( + (!exportNoClosed && e.portStatus === 'Closed') || + (!exportNoUnknown && e.portStatus === 'Unknown') + ) + return; toExport += ``; }); toExport += '
AddressPortHost NamePort StatusScan Date
${e.address}${e.port}${e.hostName}${e.portStatus}${e.scanDate}
'; @@ -241,17 +271,21 @@ const Home = () => { } save({ multiple: false, - filters: [{ - name: exportType, - extensions: [ext], - }], + filters: [ + { + name: exportType, + extensions: [ext], + }, + ], }) .then((res) => { if (res && res.length > 0) { - // eslint-disable-next-line no-bitwise - const resExt = res.slice((res.lastIndexOf('.') - 1 >>> 0) + 2); + const resExt = res.slice(((res.lastIndexOf('.') - 1) >>> 0) + 2); const path = resExt && resExt.length > 0 ? res : `${res}.${ext}`; - invoke('save_string_to_disk', { content: getExportData(scanResults, exportType), path }) + invoke('save_string_to_disk', { + content: getExportData(scanResults, exportType), + path, + }) .then(() => { setSnackOpen(true); }) @@ -275,11 +309,14 @@ const Home = () => { * @param scanDate The scan date * @returns {{hostName, portType, address, port, scanDate}} */ - const createData = (id, addr, port, hostName, portStatus, scanDate) => ( - { - id, address: addr, port, hostName, portStatus, scanDate, - } - ); + const createData = (id, addr, port, hostName, portStatus, scanDate) => ({ + id, + address: addr, + port, + hostName, + portStatus, + scanDate, + }); const columns = [ { @@ -316,10 +353,11 @@ const Home = () => { const scanResultRows = []; if (scanResults && scanResults.length > 0) { - // eslint-disable-next-line no-restricted-syntax for (const res of scanResults) { - if ((noClosed && res.portStatus === 'Closed') || (noUnknown && res.portStatus === 'Unknown')) { - // eslint-disable-next-line no-continue + if ( + (noClosed && res.portStatus === 'Closed') || + (noUnknown && res.portStatus === 'Unknown') + ) { continue; } @@ -347,7 +385,6 @@ const Home = () => { const canAdd = i === addresses.length - 1; return ( - // eslint-disable-next-line react/no-array-index-key 0 ? 1 : 0 }}> { {canAdd ? ( - + ) : ( - removeAddress(i)} disabled={isScanning}> + removeAddress(i)} + disabled={isScanning} + > @@ -381,6 +428,7 @@ const Home = () => { useEffect(() => { d1(setPageIndex(0)); + // eslint-disable-next-line react-hooks/exhaustive-deps }, []); return ( @@ -442,15 +490,17 @@ const Home = () => { color="primary" onClick={onExport} sx={{ mt: 2, ml: 2, mr: 2 }} - disabled={!scanResults || scanResults.length === 0 || exportType === null || isScanning} + disabled={ + !scanResults || + scanResults.length === 0 || + exportType === null || + isScanning + } style={{ float: 'right' }} > {language.export} - + {language.exportType}