Skip to content

Commit

Permalink
build: update eslint & tsconfig (#469)
Browse files Browse the repository at this point in the history
* build: minimize shared `tsconfig` options

* build: update `eslint` shared conf

* build: add `eslint` to `playwright` & `vitest` confs

* fix: codacy ` @typescript-eslint/no-unsafe-assignment` go away
  • Loading branch information
ashgw authored Jan 20, 2025
1 parent 35773c7 commit e7b0989
Show file tree
Hide file tree
Showing 20 changed files with 79 additions and 60 deletions.
15 changes: 2 additions & 13 deletions apps/blog/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
{
"extends": "@ashgw/tsconfig/base.json",
"compilerOptions": {
"lib": ["ES2022", "dom", "dom.iterable"],
"jsx": "preserve",
"baseUrl": ".",
"module": "esnext",
"target": "ES2022",
"paths": {
"~/*": ["./src/*"]
},
"plugins": [
{
"name": "next"
}
]
},
"include": [".", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}
}
}
2 changes: 1 addition & 1 deletion apps/www/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"lint": "pnpm run lint:ts ",
"lint-all": "pnpm run lint:ts && pnpm run lint:md && pnpm run format && pnpm run lint:knip && pnpm run lint:spelling",
"lint:ts": "tsc --noEmit; eslint .",
"lint:knip": "knip --production --strict --exclude exports,nsExports,types,nsTypes",
"format": "prettier . --write",
"lint:knip": "knip --production --strict --exclude exports,nsExports,types,nsTypes",
"format-check": "prettier --check .",
"lint:md": "markdownlint \"**/*.md\" --config=.markdownlint.json --ignore-path=.markdownlintignore",
"lint:spelling": "cspell \"**\" \".github/**/*\"",
Expand Down
15 changes: 2 additions & 13 deletions apps/www/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
{
"extends": "@ashgw/tsconfig/base.json",
"compilerOptions": {
"lib": ["ES2022", "dom", "dom.iterable"],
"jsx": "preserve",
"baseUrl": ".",
"module": "esnext",
"target": "ES2022",
"paths": {
"~/*": ["./src/*"]
},
"plugins": [
{
"name": "next"
}
]
},
"include": [".", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}
}
}
9 changes: 9 additions & 0 deletions packages/env/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import baseConfig from "@ashgw/eslint-config/base";

/** @type {import('typescript-eslint').Config} */
export default [
{
ignores: ["dist/**"],
},
...baseConfig,
];
4 changes: 3 additions & 1 deletion packages/env/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import path from "path";
import { config } from "dotenv";
import { z } from "zod";

import { createEnv } from "@ashgw/ts-env";

config({ path: require("path").resolve(__dirname, "../../.env") });
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
config({ path: path.resolve(__dirname, "../../.env") });

const isBrowser = typeof window !== "undefined";

Expand Down
6 changes: 6 additions & 0 deletions packages/env/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@
"exports": {
".": "./index.ts"
},
"type": "module",
"private": true,
"version": "0.1.0",
"scripts": {
"lint": "tsc --noEmit; eslint .",
"format": "prettier . --write"
},
"dependencies": {
"@ashgw/ts-env": "^1.3.6",
"zod": "catalog:",
"dotenv": "^16.4.5"
},
"devDependencies": {
"@ashgw/eslint-config": "workspace:*",
"@ashgw/tsconfig": "workspace:*",
"typescript": "catalog:"
}
Expand Down
5 changes: 1 addition & 4 deletions packages/env/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{
"extends": "@ashgw/tsconfig/base.json",
"include": ["."],
"compilerOptions": { "lib": ["DOM", "ES2022"] },
"exclude": ["node_modules"]
"extends": "@ashgw/tsconfig/base.json"
}
9 changes: 1 addition & 8 deletions packages/ui/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
{
"extends": "@ashgw/tsconfig/internal-package.json",
"compilerOptions": {
"lib": ["ES2022", "dom", "dom.iterable"],
"jsx": "preserve",
"rootDir": "."
},
"include": ["src"],
"exclude": ["node_modules"]
"extends": "@ashgw/tsconfig/base.json"
}
9 changes: 9 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions tooling/eslint/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{
"extends": "@ashgw/tsconfig/base.json",
"include": ["."],
"exclude": ["node_modules"]
"extends": "@ashgw/tsconfig/base.json"
}
9 changes: 6 additions & 3 deletions tooling/playwright/base.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { defineConfig, devices } from "@playwright/test";

/* eslint-disable turbo/no-undeclared-env-vars */
const isRunningInCI = !!process.env.CI;

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
Expand All @@ -14,11 +17,11 @@ export const baseConfig = defineConfig({
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
forbidOnly: isRunningInCI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
retries: isRunningInCI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
workers: isRunningInCI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: "html",
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
Expand Down
9 changes: 9 additions & 0 deletions tooling/playwright/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import baseConfig from "@ashgw/eslint-config/base";

/** @type {import('typescript-eslint').Config} */
export default [
{
ignores: ["dist/**"],
},
...baseConfig,
];
8 changes: 7 additions & 1 deletion tooling/playwright/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,17 @@
"exports": {
".": "./index.ts"
},
"type": "module",
"private": true,
"version": "0.1.0",
"scripts": {
"lint": "tsc --noEmit; eslint .",
"format": "prettier . --write"
},
"devDependencies": {
"@playwright/test": "catalog:",
"@ashgw/tsconfig": "workspace:*",
"typescript": "catalog:"
"typescript": "catalog:",
"@ashgw/eslint-config": "workspace:*"
}
}
4 changes: 1 addition & 3 deletions tooling/playwright/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{
"extends": "@ashgw/tsconfig/base.json",
"include": ["."],
"exclude": ["node_modules"]
"extends": "@ashgw/tsconfig/base.json"
}
4 changes: 1 addition & 3 deletions tooling/prettier/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{
"extends": "@ashgw/tsconfig/base.json",
"include": ["."],
"exclude": ["node_modules"]
"extends": "@ashgw/tsconfig/base.json"
}
4 changes: 1 addition & 3 deletions tooling/tailwind/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{
"extends": "@ashgw/tsconfig/base.json",
"include": ["."],
"exclude": ["node_modules"]
"extends": "@ashgw/tsconfig/base.json"
}
4 changes: 3 additions & 1 deletion tooling/typescript/base.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
/** Base Options */
"esModuleInterop": true,
"skipLibCheck": true,
"jsx": "preserve",
"target": "ES2022",
"lib": ["ES2022"],

"lib": ["ES2022", "dom", "dom.iterable"],
"allowJs": true,
"resolveJsonModule": true,
"moduleDetection": "force",
Expand Down
9 changes: 9 additions & 0 deletions tooling/vitest/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import baseConfig from "@ashgw/eslint-config/base";

/** @type {import('typescript-eslint').Config} */
export default [
{
ignores: ["dist/**"],
},
...baseConfig,
];
6 changes: 6 additions & 0 deletions tooling/vitest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@
"exports": {
".": "./index.ts"
},
"type": "module",
"private": true,
"version": "0.1.0",
"scripts": {
"lint": "tsc --noEmit; eslint .",
"format": "prettier . --write"
},
"devDependencies": {
"vitest": "catalog:",
"@vitest/ui": "catalog:",
"@ashgw/tsconfig": "workspace:*",
"@ashgw/eslint-config": "workspace:*",
"typescript": "catalog:"
}
}
4 changes: 1 addition & 3 deletions tooling/vitest/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{
"extends": "@ashgw/tsconfig/base.json",
"include": ["."],
"exclude": ["node_modules"]
"extends": "@ashgw/tsconfig/base.json"
}

0 comments on commit e7b0989

Please sign in to comment.