Skip to content

Commit

Permalink
Merge pull request #265 from 0x4007/chore/sync-card-branch-to-template
Browse files Browse the repository at this point in the history
  • Loading branch information
0x4007 authored Jul 22, 2024
2 parents 54474af + e6f334a commit acae5b2
Show file tree
Hide file tree
Showing 33 changed files with 1,912 additions and 903 deletions.
32 changes: 25 additions & 7 deletions .cspell.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
{
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
"version": "0.2",
"ignorePaths": ["**/*.json", "**/*.css", "node_modules", "**/*.log", "/lib"],
"ignorePaths": [
"**/*.json",
"**/*.css",
"node_modules",
"**/*.log",
"/lib"
],
"useGitignore": true,
"language": "en",
"words": [
"blockscan",
"funder",
"Funder",
"binkey",
"binsec",
"blockscan",
Expand All @@ -20,13 +23,17 @@
"fract",
"giftcards",
"gnosischain",
"funder",
"Funder",
"gnosisscan",
"godb",
"greyscale",
"IERC",
"keccak",
"keypair",
"Knip",
"libsodium",
"mswjs",
"Numberish",
"outdir",
"pageable",
Expand All @@ -46,7 +53,18 @@
"XDAI",
"xmark"
],
"dictionaries": ["typescript", "node", "software-terms", "html"],
"import": ["@cspell/dict-typescript/cspell-ext.json", "@cspell/dict-node/cspell-ext.json", "@cspell/dict-software-terms"],
"ignoreRegExpList": ["[0-9a-fA-F]{6}"]
"dictionaries": [
"typescript",
"node",
"software-terms",
"html"
],
"import": [
"@cspell/dict-typescript/cspell-ext.json",
"@cspell/dict-node/cspell-ext.json",
"@cspell/dict-software-terms"
],
"ignoreRegExpList": [
"[0-9a-fA-F]{6}"
]
}
90 changes: 19 additions & 71 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,24 @@
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": ["./tsconfig.json"],
"project": "./tsconfig.json"
},
"plugins": ["@typescript-eslint", "sonarjs"],
"plugins": ["@typescript-eslint", "sonarjs", "filename-rules"],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:sonarjs/recommended"],
"ignorePatterns": ["**/*.js"],
"ignorePatterns": ["**/*.js", ".github/knip.ts"],
"rules": {
"prefer-arrow-callback": [
"warn",
{
"allowNamedFunctions": true,
},
],
"func-style": [
"warn",
"declaration",
{
"allowArrowFunctions": false,
},
],
"filename-rules/match": [2, "/^(e2e\\.ts$|.*/e2e\\.ts$|[a-z0-9]+(?:[-._a-z0-9]+)*\\.ts|\\.[a-z0-9]+)$/"],
"prefer-arrow-callback": ["warn", { "allowNamedFunctions": true }],
"func-style": ["warn", "declaration", { "allowArrowFunctions": false }],
"@typescript-eslint/no-floating-promises": "error",
"@typescript-eslint/no-non-null-assertion": "error",
"constructor-super": "error",
"no-invalid-this": "off",
"@typescript-eslint/no-invalid-this": ["error"],
"@typescript-eslint/no-invalid-this": ["error", { "capIsConstructor": false }],
"no-restricted-syntax": ["error", "ForInStatement"],
"use-isnan": "error",
"no-unneeded-ternary": "error",
"no-nested-ternary": "error",
"@typescript-eslint/no-unused-vars": [
"error",
{
Expand All @@ -49,60 +41,16 @@
"sonarjs/no-identical-expressions": "error",
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "interface",
"format": ["PascalCase"],
"custom": {
"regex": "^I[A-Z]",
"match": false,
},
},
{
"selector": "memberLike",
"modifiers": ["private"],
"format": ["camelCase"],
"leadingUnderscore": "require",
},
{
"selector": "typeLike",
"format": ["PascalCase"],
},
{
"selector": "typeParameter",
"format": ["PascalCase"],
"prefix": ["T"],
},
{
"selector": "variable",
"format": ["camelCase", "UPPER_CASE"],
"leadingUnderscore": "allow",
"trailingUnderscore": "allow",
},
{
"selector": "variable",
"format": ["camelCase"],
"leadingUnderscore": "allow",
"trailingUnderscore": "allow",
},
{
"selector": "variable",
"modifiers": ["destructured"],
"format": null,
},
{
"selector": "variable",
"types": ["boolean"],
"format": ["PascalCase"],
"prefix": ["is", "should", "has", "can", "did", "will", "does"],
},
{
"selector": "variableLike",
"format": ["camelCase"],
},
{
"selector": ["function", "variable"],
"format": ["camelCase"],
},
{ "selector": "interface", "format": ["StrictPascalCase"], "custom": { "regex": "^I[A-Z]", "match": false } },
{ "selector": "memberLike", "modifiers": ["private"], "format": ["strictCamelCase"], "leadingUnderscore": "require" },
{ "selector": "typeLike", "format": ["StrictPascalCase"] },
{ "selector": "typeParameter", "format": ["StrictPascalCase"], "prefix": ["T"] },
{ "selector": "variable", "format": ["strictCamelCase", "UPPER_CASE"], "leadingUnderscore": "allow", "trailingUnderscore": "allow" },
{ "selector": "variable", "format": ["strictCamelCase"], "leadingUnderscore": "allow", "trailingUnderscore": "allow" },
{ "selector": "variable", "modifiers": ["destructured"], "format": null },
{ "selector": "variable", "types": ["boolean"], "format": ["StrictPascalCase"], "prefix": ["is", "should", "has", "can", "did", "will", "does"] },
{ "selector": "variableLike", "format": ["strictCamelCase"] },
{ "selector": ["function", "variable"], "format": ["strictCamelCase"] },
],
},
}
14 changes: 14 additions & 0 deletions .github/knip.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { KnipConfig } from "knip";

const config: KnipConfig = {
entry: ["build/esbuild-build.ts", "static/scripts/rewards/init.ts"],
project: ["src/**/*.ts", "static/scripts/**/*.ts"],
ignore: ["src/types/config.ts", "**/__mocks__/**", "**/__fixtures__/**", "lib/**/*"],
ignoreExportsUsedInFile: true,
// eslint can also be safely ignored as per the docs: https://knip.dev/guides/handling-issues#eslint--jest
ignoreDependencies: ["eslint-config-prettier", "eslint-plugin-prettier"],
eslint: true,
ignoreBinaries: ["forge"],
};

export default config;
25 changes: 9 additions & 16 deletions .github/workflows/cypress-testing.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
name: test

name: Run Cypress testing suite
on:
push:
branches:
- main
- development
pull_request:
branches:
- main
- development

env:
FOUNDRY_PROFILE: ci
workflow_dispatch:
workflow_run:
workflows: ["Build"]
types:
- completed

jobs:
tests:
name: Cypress tests
cypress-run:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v4
Expand Down Expand Up @@ -68,7 +60,8 @@ jobs:
PAYMENT_TOKEN_ADDRESS: "0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d"
RPC_PROVIDER_URL: "http://localhost:8545"
UBIQUIBOT_PRIVATE_KEY: "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"

CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v4
if: failure()
with:
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/knip-reporter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Knip-reporter

on:
workflow_run:
workflows: ["Knip"]
types:
- completed

jobs:
knip-reporter:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion != 'success' }}
steps:
- uses: actions/download-artifact@v4
with:
name: knip-results
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Read pr number
id: pr-number
uses: juliangruber/read-file-action@v1
with:
path: ./pr-number.txt
trim: true

- name: Report knip results to pull request
uses: gitcoindev/knip-reporter@main
with:
verbose: true
comment_id: ${{ github.workflow }}-reporter
command_script_name: knip-ci
annotations: true
ignore_results: false
json_input: true
json_input_file_name: knip-results.json
pull_request_number: ${{ steps.pr-number.outputs.content }}
token: ${{ secrets.GITHUB_TOKEN }}
38 changes: 38 additions & 0 deletions .github/workflows/knip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Knip

on:
pull_request:

jobs:
run-knip:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

# needed to use yarn v4
- name: Enable corepack
run: corepack enable

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20.10.0

- name: Install toolchain
run: yarn install

- name: Store PR number
run: echo ${{ github.event.number }} > pr-number.txt

- name: Run Knip
run: yarn knip || yarn knip --reporter json > knip-results.json

- name: Upload knip result
if: failure()
uses: actions/upload-artifact@v4
with:
name: knip-results
path: |
knip-results.json
pr-number.txt
26 changes: 26 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: release-please

on:
workflow_dispatch:
push:
branches:
- main

permissions:
contents: write
pull-requests: write

jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v3
with:
release-type: node
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20.10.0"
registry-url: https://registry.npmjs.org/
- run: |
yarn install --immutable --immutable-cache --check-cache
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ commit.txt
# yarn2
.pnp.cjs
.pnp.loader.mjs
.env
static/dist

cypress/screenshots
cypress/videos
.wrangler
.wrangler
coverage
junit.xml
4 changes: 0 additions & 4 deletions build/index.ts

This file was deleted.

12 changes: 12 additions & 0 deletions cypress/e2e/main.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
describe("Homepage tests", () => {
it("Console is cleared of errors and warnings", () => {
cy.visit("/", {
onBeforeLoad(win) {
cy.stub(win.console, "error").as("consoleError");
},
});
cy.get("@consoleError").should("not.be.called");
cy.get("body").should("exist");
cy.get("h1").should("exist");
});
});
2 changes: 1 addition & 1 deletion functions/post-order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Tokens, chainIdToRewardTokenMap, giftCardTreasuryAddress, permit2Addres
import { getFastestRpcUrl, getGiftCardOrderId } from "../shared/helpers";
import { getGiftCardValue, isClaimableForAmount } from "../shared/pricing";
import { ExchangeRate, GiftCard, OrderRequestParams } from "../shared/types";
import { permit2Abi } from "../static/scripts/rewards/abis/permit2Abi";
import { permit2Abi } from "../static/scripts/rewards/abis/permit2-abi";
import { getTransactionFromOrderId } from "./get-order";
import { allowedChainIds, commonHeaders, getAccessToken, getBaseUrl } from "./helpers";
import { AccessToken, Context, ReloadlyFailureResponse, ReloadlyOrderResponse } from "./types";
Expand Down
Loading

0 comments on commit acae5b2

Please sign in to comment.