From 0f668f249956d5a0fbc3838557816e773b2ba0df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20Holm=20Gj=C3=B8rup?= Date: Wed, 31 Jan 2024 13:41:04 +0100 Subject: [PATCH] Address review comments --- .github/workflows/format-lint-build-test.yml | 251 ++++++++----------- frontend/.prettierignore | 4 - frontend/README.md | 58 ----- frontend/package.json | 5 +- frontend/tsconfig.json | 2 - frontend/vite.config.ts | 3 - 6 files changed, 101 insertions(+), 222 deletions(-) delete mode 100644 frontend/.prettierignore delete mode 100644 frontend/README.md diff --git a/.github/workflows/format-lint-build-test.yml b/.github/workflows/format-lint-build-test.yml index eb09c8a..23367ae 100644 --- a/.github/workflows/format-lint-build-test.yml +++ b/.github/workflows/format-lint-build-test.yml @@ -1,158 +1,103 @@ name: Format, Lint, Build and Test on: - push: - branches: - - main - pull_request: - branches: - - main - types: - - opened - - reopened - - synchronize - - ready_for_review + push: + branches: + - main + pull_request: + branches: + - main + types: + - opened + - reopened + - synchronize + - ready_for_review env: - NODE_VERSION: 'lts/*' - RUST_VERSION: "1.75" - CARGO_CONCORDIUM_VERSION: "3.2" - MY_CONTRACT_PATH: contracts/my-contract - MY_CONTRACT_DEPLOY_SCRIPT_PATH: contracts/my-contract/deploy-scripts + NODE_VERSION: "lts/*" + RUST_VERSION: "1.75" + CARGO_CONCORDIUM_VERSION: "3.2" + MY_CONTRACT_PATH: contracts/my-contract + MY_CONTRACT_DEPLOY_SCRIPT_PATH: contracts/my-contract/deploy-scripts jobs: - rustfmt-my-contract: - name: Check formatting smart contracts - runs-on: ubuntu-latest - steps: - - name: Checkout project - uses: actions/checkout@v4 - - name: Install Rust toolchain with rustfmt available - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - toolchain: ${{ env.RUST_VERSION }} - components: rustfmt - - name: Run cargo fmt - working-directory: ${{ env.MY_CONTRACT_PATH }} - run: cargo fmt --check - rustfmt-my-contract-deploy-scripts: - name: Check formatting smart contract deploy scripts - runs-on: ubuntu-latest - steps: - - name: Checkout project - uses: actions/checkout@v4 - - name: Install Rust toolchain with rustfmt available - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - toolchain: ${{ env.RUST_VERSION }} - components: rustfmt - - name: Run cargo fmt - working-directory: ${{ env.MY_CONTRACT_DEPLOY_SCRIPT_PATH }} - run: cargo fmt --check - clippy-my-contract: - name: Run linter on smart contracts - runs-on: ubuntu-latest - steps: - - name: Checkout project - uses: actions/checkout@v4 - - name: Install Rust toolchain with clippy available - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - uses: actions-rust-lang/setup-rust-toolchain@v1 - toolchain: ${{ env.RUST_VERSION }} - target: wasm32-unknown-unknown - components: clippy - - name: Run cargo clippy - working-directory: ${{ env.MY_CONTRACT_PATH }} - run: cargo clippy --locked -- -D warnings - clippy-my-contract-deploy-scripts: - name: Run linter on smart contract deploy scripts - runs-on: ubuntu-latest - steps: - - name: Checkout project - uses: actions/checkout@v4 - - name: Install Rust toolchain with clippy available - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - toolchain: ${{ env.RUST_VERSION }} - target: wasm32-unknown-unknown - components: clippy - - name: Run cargo clippy - working-directory: ${{ env.MY_CONTRACT_DEPLOY_SCRIPT_PATH }} - run: cargo clippy --locked -- -D warnings - prettier: - name: Check formatting frontend - runs-on: ubuntu-latest - steps: - - name: Checkout project - uses: actions/checkout@v4 - - name: Setup Node for frontend - uses: actions/setup-node@v4 - with: - node-version: ${{env.NODE_VERSION}} - cache: 'npm' - cache-dependency-path: frontend/package-lock.json - - name: Install NPM dependencies - working-directory: frontend - run: npm clean-install - - name: Run prettier - working-directory: frontend - run: npm run format - eslint: - name: Run linter on frontend - runs-on: ubuntu-latest - steps: - - name: Checkout project - uses: actions/checkout@v4 - - name: Setup Node for frontend - uses: actions/setup-node@v4 - with: - node-version: ${{env.NODE_VERSION}} - cache: 'npm' - cache-dependency-path: frontend/package-lock.json - - name: Install NPM dependencies - working-directory: frontend - run: npm clean-install - - name: Run linter - working-directory: frontend - run: npm run lint - build-and-test: - needs: [rustfmt-my-contract, rustfmt-my-contract-deploy-scripts, clippy-my-contract, clippy-my-contract-deploy-scripts, prettier, eslint] - runs-on: ubuntu-latest - name: Build and test everything - steps: - - name: Checkout project - uses: actions/checkout@v4 - - name: Install Rust toolchain - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - target: wasm32-unknown-unknown - toolchain: ${{ env.RUST_VERSION }} + rustfmt-clippy: + name: Check formatting smart contracts + runs-on: ubuntu-latest + steps: + - name: Checkout project + uses: actions/checkout@v4 + - name: Install Rust toolchain with rustfmt available + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: ${{ env.RUST_VERSION }} + target: wasm32-unknown-unknown + components: rustfmt, clippy + - name: Run cargo fmt + working-directory: ${{ env.MY_CONTRACT_PATH }} + run: cargo fmt --check + - name: Run cargo fmt + working-directory: ${{ env.MY_CONTRACT_DEPLOY_SCRIPT_PATH }} + run: cargo fmt --check + - name: Run cargo clippy + working-directory: ${{ env.MY_CONTRACT_PATH }} + run: cargo clippy --locked -- -D warnings + - name: Run cargo clippy + working-directory: ${{ env.MY_CONTRACT_DEPLOY_SCRIPT_PATH }} + run: cargo clippy --locked -- -D warnings + prettier-eslint: + name: Check formatting frontend + runs-on: ubuntu-latest + steps: + - name: Checkout project + uses: actions/checkout@v4 + - name: Setup Node for frontend + uses: actions/setup-node@v4 + with: + node-version: ${{env.NODE_VERSION}} + cache: "npm" + cache-dependency-path: frontend/package-lock.json + - name: Install NPM dependencies + working-directory: frontend + run: npm clean-install + - name: Run prettier + working-directory: frontend + run: npm run format-check + - name: Run eslint + working-directory: frontend + run: npm run lint-check + build-and-test: + name: Build and test everything + needs: [rustfmt-clippy, prettier-eslint] + runs-on: ubuntu-latest + steps: + - name: Checkout project + uses: actions/checkout@v4 + - name: Install Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + target: wasm32-unknown-unknown + toolchain: ${{ env.RUST_VERSION }} + - name: Install cargo-concordium from crates.io + uses: baptiste0928/cargo-install@v2 + with: + crate: cargo-concordium + version: ${{env.CARGO_CONCORDIUM_VERSION}} + - name: Build and test smart contract + working-directory: ${{ env.MY_CONTRACT_PATH }} + run: cargo concordium test --out "./concordium-out/module.wasm.v1" - - name: Install cargo-concordium from crates.io - uses: baptiste0928/cargo-install@v2 - with: - crate: cargo-concordium - version: ${{env.CARGO_CONCORDIUM_VERSION}} - - - name: Build and test smart contract - working-directory: ${{ env.MY_CONTRACT_PATH }} - run: cargo concordium test --out "./concordium-out/module.wasm.v1" - - # Frontend build and test - - name: Setup Node for frontend - uses: actions/setup-node@v4 - with: - node-version: ${{env.NODE_VERSION}} - cache: 'npm' - cache-dependency-path: frontend/package-lock.json - - - name: Install NPM dependencies - working-directory: frontend - run: npm clean-install - - # This must be run after building the smart contracts. - - name: Generate smart contract clients - working-directory: frontend - run: npm run generate - - - name: Build all libraries and samples - working-directory: frontend - run: npm run build + # Frontend build and test + - name: Setup Node for frontend + uses: actions/setup-node@v4 + with: + node-version: ${{env.NODE_VERSION}} + cache: "npm" + cache-dependency-path: frontend/package-lock.json + - name: Install NPM dependencies + working-directory: frontend + run: npm clean-install + # This must be run after building the smart contracts. + - name: Generate smart contract clients + working-directory: frontend + run: npm run generate + - name: Build all libraries and samples + working-directory: frontend + run: npm run build diff --git a/frontend/.prettierignore b/frontend/.prettierignore deleted file mode 100644 index 3fcc459..0000000 --- a/frontend/.prettierignore +++ /dev/null @@ -1,4 +0,0 @@ -.yarn/ -node_modules/ -dist/ -generated/ diff --git a/frontend/README.md b/frontend/README.md deleted file mode 100644 index e02a038..0000000 --- a/frontend/README.md +++ /dev/null @@ -1,58 +0,0 @@ -# Frontend - -This template provides a starting setup to get React working in Vite with HMR and some ESLint rules. - -## Getting started - -Install dependencies: - -```bash -npm install -``` - -Start dev server: - -```bash -yarn dev -``` - -Build for production: - -```bash -yarn build -``` - -## Development - -### Styling - -The template uses bootstrap, which is themed in the scss files placed in `src/scss`. More information about customizing bootstrap can be found [here](https://getbootstrap.com/docs/5.0/customize/overview/). -Bootstrap components can be used by importing components from [`react-boostrap`](https://react-bootstrap.netlify.app/). -When a new bootstrap component is used, the corresponding bootstrap component scss file should be imported and (ideally) themed. - -#### Example: Using a bootstrap card - -```ts -// src/components/SomeComponent.tsx -import { Card } from 'react-bootstrap'; - -export default function SomeComponent() { - return ...; -} -``` - -```scss -// src/scss/layout/_card.scss -@import "bootstrap/scss/card"; - -// Theming by overriding -.card { - ... -} -``` - -```scss -// src/scss/_layout.scss -... -@import "layout/card"; -``` diff --git a/frontend/package.json b/frontend/package.json index ab5c499..7fdd452 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -6,8 +6,9 @@ "scripts": { "dev": "vite", "build": "tsc && vite build", - "lint": "eslint src", - "format": "prettier --check src", + "lint-check": "eslint", + "format-check": "prettier --check .", + "format-fix": "prettier --write .", "preview": "vite preview", "generate": "ccd-js-gen --module ../contracts/my-contract/concordium-out/module.wasm.v1 --out-dir ./generated --output-type TypeScript --ts-nocheck" }, diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json index a7fc6fb..9995662 100644 --- a/frontend/tsconfig.json +++ b/frontend/tsconfig.json @@ -16,8 +16,6 @@ /* Linting */ "strict": true, - "noUnusedLocals": true, - "noUnusedParameters": true, "noFallthroughCasesInSwitch": true }, "include": ["src"], diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 5a7360d..16e7b92 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -14,7 +14,4 @@ export default defineConfig({ wasm(), topLevelAwait(), // For legacy browser compatibility ], - define: { - global: "globalThis", - }, });