Skip to content

Commit

Permalink
Chore lint import abs path (#216)
Browse files Browse the repository at this point in the history
Any questions should be directed to @vujita

---

Replace any ":question:" below with information about your pull request.

## Pull Request Details

Provide details about your pull request and what it adds, fixes, or
changes.

:question:

## Breaking Changes

Describe what features are broken by this pull request and why, if any.

:question:

## Issues Fixed

Enter the issue numbers resolved by this pull request below, if any.

1. :question:

## Other Relevant Information

Provide any other important details below.

:question:

---------

Signed-off-by: Vu Nguyen <[email protected]>
  • Loading branch information
vujita authored May 16, 2024
1 parent 51a6466 commit c84cd87
Show file tree
Hide file tree
Showing 32 changed files with 176 additions and 106 deletions.
12 changes: 0 additions & 12 deletions apps/newnew-performancetool/.eslintrc.cjs

This file was deleted.

13 changes: 13 additions & 0 deletions apps/newnew-performancetool/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@
"lint:fix": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0 --fix",
"preview": "vite preview"
},
"eslintConfig": {
"extends": [
"eslint-config-vujita/base",
"eslint-config-vujita/nextjs",
"eslint-config-vujita/react"
],
"rules": {
"@typescript-eslint/no-unnecessary-condition": 0,
"@typescript-eslint/no-unsafe-assignment": 0,
"@typescript-eslint/no-unsafe-call": 0
},
"root": true
},
"dependencies": {
"react": "18.2.0",
"react-dom": "18.2.0",
Expand Down
23 changes: 12 additions & 11 deletions apps/newnew-performancetool/src/components/MemoryStats.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable react/forbid-dom-props */
import { type FC } from "react";

import { MemorySnapshot, useMemoryStates } from "../stores/memory";
import { useMemoryStates, type MemorySnapshot } from "newnew-performancetool/src/stores/memory";

const memoryStat = (memoryState: MemorySnapshot): number => ((memoryState.usedJSHeapSize / memoryState.jsHeapSizeLimit) * 100).toFixed(2);

Expand All @@ -11,40 +11,41 @@ export const MemoryStats: FC = () => {
return (
<div
style={{
position: "fixed",
bottom: 0,
boxSizing: "border-box",
left: 0,
padding: 5,
boxSizing: "border-box",
position: "fixed",
}}
>
{last && (
{last ? (
<div
style={{
margin: "auto",
width: "fit-content",
}}
>{`${memoryStat(last)}%`}</div>
)}
) : null}
<div
style={{
alignItems: "flex-end",
backgroundColor: "lightgrey",
display: "flex",
flexDirection: "row",
backgroundColor: "lightgrey",
opacity: 0.8,
alignItems: "flex-end",
height: 100,
opacity: 0.8,
width: MEM_STAT_WIDTH,
}}
>
{memoryStates.map((memoryState) => (
<div
key={memoryState.timestamp}
style={{
backgroundColor: "lightgreen",
width: MEM_STAT_WIDTH / memoryStates.length,
height: memoryStat(memoryState) + "%",
width: MEM_STAT_WIDTH / memoryStates.length,
}}
></div>
/>
))}
</div>
</div>
Expand Down
5 changes: 2 additions & 3 deletions apps/newnew-performancetool/src/content.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { MemoryStats } from "newnew-performancetool/src/components/MemoryStats";
import { webVitalsStore } from "newnew-performancetool/src/stores/web-vitals";
import { createRoot } from "react-dom/client";

import { MemoryStats } from "./components/MemoryStats";
import { webVitalsStore } from "./stores/web-vitals";

chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
console.log("onMessage", {
message,
Expand Down
2 changes: 1 addition & 1 deletion apps/newnew-performancetool/src/options.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import "./index.css";
import "newnew-performancetool/src/index.css";

import { createRoot } from "react-dom/client";

Expand Down
2 changes: 1 addition & 1 deletion apps/newnew-performancetool/src/popup.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import "./index.css";
import "newnew-performancetool/src/index.css";

import { createRoot } from "react-dom/client";

Expand Down
28 changes: 6 additions & 22 deletions apps/newnew-performancetool/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,12 @@
{
"compilerOptions": {
"allowImportingTsExtensions": true,
"isolatedModules": true,
"jsx": "preserve",

"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
/* Bundler mode */
"moduleResolution": "bundler",
"noEmit": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"baseUrl": ".",
"paths": {
"newnew-performancetool/src/*": ["./src/*"]
"newnew-performancetool/*": ["./*"]
},
"resolveJsonModule": true,
"skipLibCheck": true,
/* Linting */
"strict": true,
"target": "ES2020",
"useDefineForClassFields": true
"strict": true
},
"include": ["src/**/*.ts", "src/**/*.tsx", "tailwind.config.ts", ".eslintrc.mjs", "vite.config.ts"],
"references": [{ "path": "./tsconfig.node.json" }]
"exclude": [],
"extends": "../../tsconfig.json",
"include": ["src/**/*.ts", "src/**/*.tsx", "tailwind.config.ts", ".eslintrc.mjs", "vite.config.ts"]
}
12 changes: 0 additions & 12 deletions apps/newnew-performancetool/tsconfig.node.json

This file was deleted.

7 changes: 7 additions & 0 deletions apps/newnew-performancetool/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import path from "path";
import { crx } from "@crxjs/vite-plugin";
import react from "@vitejs/plugin-react";
import { defineConfig } from "vite";

// eslint-disable-next-line no-relative-import-paths/no-relative-import-paths
import manifest from "./manifest.json";

export default defineConfig(({ command, mode }) => {
Expand All @@ -13,6 +15,11 @@ export default defineConfig(({ command, mode }) => {
watch: isDev ? {} : undefined,
},
plugins: [react(), crx({ manifest })],
resolve: {
alias: {
"newnew-performancetool": path.resolve(__dirname),
},
},
server: {
hmr: {
port: 5173,
Expand Down
9 changes: 7 additions & 2 deletions apps/vubnguyen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
"dev": "pnpm with-env next dev",
"dev:preview": "pnpm with-env next start",
"e2e": "pnpm with-env playwright test",
"lint": "dotenv -v SKIP_ENV_VALIDATION=1 next lint",
"lint:fix": "pnpm lint -- --fix",
"eslint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"eslint:fix": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0 --fix",
"lint": "xrun -s next:lint eslint",
"lint:fix": "xrun -s next:lint:fix eslint:fix",
"next:lint": "dotenv -v SKIP_ENV_VALIDATION=1 next lint",
"next:lint:fix": "dotenv -v SKIP_ENV_VALIDATION=1 next lint --fix",
"start": "pnpm with-env next start",
"type-check": "tsc --noEmit",
"with-env": "dotenv -e ../../.env --"
Expand Down Expand Up @@ -53,6 +57,7 @@
"@types/node": "18.16.19",
"@types/react": "18.2.77",
"@types/react-dom": "18.2.7",
"@xarc/run": "1.1.1",
"autoprefixer": "10.4.14",
"dotenv-cli": "7.2.1",
"eslint": "8.45.0",
Expand Down
6 changes: 3 additions & 3 deletions apps/vubnguyen/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { type Metadata } from "next";
import { Inter } from "@next/font/google";

import "vubnguyen/styles/globals.css";
import "@vujita/vubnguyen/src/styles/globals.css";

import { type ReactNode } from "react";
import { Header } from "vubnguyen/components/Header";
import classnames from "vujita-ui/classnames";

import { TRPCReactProvider } from "./providers";
import { TRPCReactProvider } from "@vujita/vubnguyen/src/app/providers";
import { Header } from "@vujita/vubnguyen/src/components/Header";

const fontSans = Inter({
subsets: ["latin"],
Expand Down
4 changes: 2 additions & 2 deletions apps/vubnguyen/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Suspense } from "react";
import { PostList } from "vubnguyen/components/posts";
import { Skeleton } from "vujita-ui/skeleton";

import Signature from "../components/signature";
import { PostList } from "@vujita/vubnguyen/src/components/posts";
import Signature from "@vujita/vubnguyen/src/components/signature";

export const dynamic = "force-dynamic";

Expand Down
3 changes: 2 additions & 1 deletion apps/vubnguyen/src/app/providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { httpBatchLink, loggerLink } from "@trpc/client";
import { SessionProvider } from "next-auth/react";
import { ThemeProvider } from "next-themes";
import superjson from "superjson";
import { api } from "vubnguyen/utils/api";

import { api } from "@vujita/vubnguyen/src/utils/api";

const getBaseUrl = () => {
if (typeof window !== "undefined") return ""; // browser should use relative url
Expand Down
3 changes: 1 addition & 2 deletions apps/vubnguyen/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { Avatar } from "vujita-ui/avatar";

import { auth } from "@vujita/auth";

import ThemeSwitcher from "./theme-switcher";
import ThemeSwitcher from "@vujita/vubnguyen/src/components/theme-switcher";

export const Header: FC = async () => {
const session = await auth();
Expand Down
2 changes: 1 addition & 1 deletion apps/vubnguyen/src/components/posts.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"use client";

import { useState } from "react";
import { api } from "vubnguyen/utils/api";

import { type RouterOutputs } from "@vujita/api";
import { api } from "@vujita/vubnguyen/src/utils/api";

export function CreatePostForm() {
const context = api.useContext();
Expand Down
2 changes: 1 addition & 1 deletion apps/vubnguyen/tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Config } from "tailwindcss";
import { type Config } from "tailwindcss";
import vujitaUiPreset from "vujita-ui/tailwind.preset";

export default {
Expand Down
2 changes: 1 addition & 1 deletion apps/vubnguyen/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"compilerOptions": {
"baseUrl": ".",
"paths": {
"vubnguyen/*": ["./src/*"]
"@vujita/vubnguyen/*": ["./*"]
},
"plugins": [
{
Expand Down
3 changes: 3 additions & 0 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
"extends": [
"eslint-config-vujita/base"
],
"rules": {
"no-relative-import-paths/no-relative-import-paths": "off"
},
"root": true
},
"dependencies": {
Expand Down
14 changes: 7 additions & 7 deletions packages/auth/env.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ import { createEnv } from "@t3-oss/env-nextjs";
import { z } from "zod";

export const env = createEnv({
client: {},
runtimeEnv: {
DISCORD_CLIENT_ID: process.env.DISCORD_CLIENT_ID,
DISCORD_CLIENT_SECRET: process.env.DISCORD_CLIENT_SECRET,
NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET,
NEXTAUTH_URL: process.env.NEXTAUTH_URL,
},
server: {
DISCORD_CLIENT_ID: z.string().min(1),
DISCORD_CLIENT_SECRET: z.string().min(1),
Expand All @@ -14,12 +21,5 @@ export const env = createEnv({
process.env.VERCEL ? z.string() : z.string().url(),
),
},
client: {},
runtimeEnv: {
NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET,
NEXTAUTH_URL: process.env.NEXTAUTH_URL,
DISCORD_CLIENT_ID: process.env.DISCORD_CLIENT_ID,
DISCORD_CLIENT_SECRET: process.env.DISCORD_CLIENT_SECRET,
},
skipValidation: !!process.env.CI || !!process.env.SKIP_ENV_VALIDATION,
});
3 changes: 3 additions & 0 deletions packages/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
"extends": [
"eslint-config-vujita/base"
],
"rules": {
"no-relative-import-paths/no-relative-import-paths": "off"
},
"root": true
},
"dependencies": {
Expand Down
31 changes: 29 additions & 2 deletions packages/config/eslint/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,39 @@ const config = {
es2022: true,
node: true,
},
extends: ["turbo", "eslint:recommended", "plugin:@typescript-eslint/recommended-type-checked", "plugin:@typescript-eslint/stylistic-type-checked", "prettier"],
settings: {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"],
},
// "import/resolver": {
// typescript: {
// alwaysTryTypes: true, // always try to resolve types under `<root>@types` directory even it doesn't contain any source code, like `@types/unist`
//
// // Choose from one of the "project" configs below or omit to use <root>/tsconfig.json by default
//
// // use <root>/path/to/folder/tsconfig.json
// project: "path/to/folder",
//
// // Multiple tsconfigs (Useful for monorepos)
//
// // use a glob pattern
// project: "packages/*/tsconfig.json",
//
// // use an array
// project: ["packages/module-a/tsconfig.json", "packages/module-b/tsconfig.json"],
//
// // use an array of glob patterns
// project: ["packages/*/tsconfig.json", "other-packages/*/tsconfig.json"],
// },
// },
},
extends: ["turbo", "eslint:recommended", "plugin:@typescript-eslint/recommended-type-checked", "plugin:@typescript-eslint/stylistic-type-checked", "prettier", "plugin:import/typescript"],
ignorePatterns: ["**/.eslintrc.cjs", "**/*.config.js", "**/*.config.cjs", "packages/config/**", ".next", "dist", "pnpm-lock.yaml"],
parser: "@typescript-eslint/parser",
parserOptions: {
project: true,
},
plugins: ["@typescript-eslint", "import", "prettier", "sort-keys-fix", "typescript-sort-keys"],
plugins: ["@typescript-eslint", "import", "prettier", "sort-keys-fix", "typescript-sort-keys", "no-relative-import-paths"],
reportUnusedDisableDirectives: true,
rules: {
"@typescript-eslint/consistent-type-imports": ["warn", { prefer: "type-imports", fixStyle: "separate-type-imports" }],
Expand All @@ -29,6 +55,7 @@ const config = {
"@typescript-eslint/type-annotation-spacing": "error",
"import/consistent-type-specifier-style": ["error", "prefer-inline"],
"import/no-extraneous-dependencies": ["error", { includeInternal: true, includeTypes: true }],
"no-relative-import-paths/no-relative-import-paths": "error",
indent: "off", // Let pretteir handle this
"prettier/prettier": [
"error",
Expand Down
2 changes: 2 additions & 0 deletions packages/config/eslint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
"@typescript-eslint/parser": "6.1.0",
"eslint-config-prettier": "8.8.0",
"eslint-config-turbo": "1.10.9",
"eslint-import-resolver-typescript": "3.6.1",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-jsx-a11y": "6.7.1",
"eslint-plugin-no-relative-import-paths": "1.5.4",
"eslint-plugin-react": "7.33.0",
"eslint-plugin-react-hooks": "4.6.2",
"eslint-plugin-sort-keys-fix": "1.1.2",
Expand Down
Loading

0 comments on commit c84cd87

Please sign in to comment.