From 7429a09be6a5cc037261f3913f1ea48ebb61c1c9 Mon Sep 17 00:00:00 2001 From: Tiscs Date: Mon, 1 Apr 2024 15:54:59 +0800 Subject: [PATCH] Update eslint configuration and fix errors Add remix-development-tools integration --- .eslintrc.cjs | 78 +- app/clients/grpc.server.ts | 11 +- app/partials/layout.tsx | 7 +- app/secure.server.ts | 4 +- app/singleton.server.ts | 1 + app/utils/forms.ts | 3 + package.json | 8 +- pnpm-lock.yaml | 1689 +++++++++++++++++++++++++----------- vite.config.ts | 3 +- 9 files changed, 1298 insertions(+), 506 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index d2d4aae..2aec129 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -1,4 +1,80 @@ +/** + * This is intended to be a basic starting point for linting in your app. + * It relies on recommended configs out of the box for simplicity, but you can + * and should modify this configuration to best suit your team's needs. + */ + /** @type {import('eslint').Linter.Config} */ module.exports = { - extends: ["@remix-run/eslint-config", "@remix-run/eslint-config/node", "prettier"], + root: true, + parserOptions: { + ecmaVersion: "latest", + sourceType: "module", + ecmaFeatures: { + jsx: true, + }, + }, + env: { + browser: true, + commonjs: true, + es6: true, + }, + ignorePatterns: ["!**/.server", "!**/.client"], + + // Base config + extends: ["eslint:recommended", "prettier"], + + overrides: [ + // React + { + files: ["**/*.{js,jsx,ts,tsx}"], + plugins: ["react", "jsx-a11y"], + extends: [ + "plugin:react/recommended", + "plugin:react/jsx-runtime", + "plugin:react-hooks/recommended", + "plugin:jsx-a11y/recommended", + ], + settings: { + "react": { + version: "detect", + }, + "formComponents": ["Form"], + "linkComponents": [ + { name: "Link", linkAttribute: "to" }, + { name: "NavLink", linkAttribute: "to" }, + ], + "import/resolver": { + typescript: {}, + }, + }, + }, + + // Typescript + { + files: ["**/*.{ts,tsx}"], + plugins: ["@typescript-eslint", "import"], + parser: "@typescript-eslint/parser", + settings: { + "import/internal-regex": "^~/", + "import/resolver": { + node: { + extensions: [".ts", ".tsx"], + }, + typescript: { + alwaysTryTypes: true, + }, + }, + }, + extends: ["plugin:@typescript-eslint/recommended", "plugin:import/recommended", "plugin:import/typescript"], + }, + + // Node + { + files: [".eslintrc.cjs"], + env: { + node: true, + }, + }, + ], }; diff --git a/app/clients/grpc.server.ts b/app/clients/grpc.server.ts index 8d451ba..9fd7052 100644 --- a/app/clients/grpc.server.ts +++ b/app/clients/grpc.server.ts @@ -9,17 +9,10 @@ import { StateStoreService } from "@proto/state/v1beta/store_connect"; invariant(process.env.GOMMERCE_GRPC_ENDPOINT, "environment variable GOMMERCE_GRPC_ENDPOINT is required."); -declare global { - namespace NodeJS { - interface ProcessEnv { - GOMMERCE_GRPC_ENDPOINT: string; - } - } -} - +export const endpoint = process.env.GOMMERCE_GRPC_ENDPOINT; export const transport = singleton("grpc_transport", () => { return createGrpcTransport({ - baseUrl: process.env.GOMMERCE_GRPC_ENDPOINT, + baseUrl: endpoint, useBinaryFormat: true, httpVersion: "2", interceptors: [], diff --git a/app/partials/layout.tsx b/app/partials/layout.tsx index c674082..c49cb63 100644 --- a/app/partials/layout.tsx +++ b/app/partials/layout.tsx @@ -49,6 +49,7 @@ export default function Frame(props: { context?: unknown }) {