Skip to content

Commit d399357

Browse files
samchonclaude
andcommitted
Share TypeScript and lint configuration through config package
Following the structure of samchon/shopping and nestia-start#634: - Add the config workspace package exposing a shared tsconfig.json (esnext / nodenext / noUncheckedIndexedAccess) and lint.config.ts (@ttsc/lint rules); packages extend and spread them - Remove prettier entirely: formatting is now done by "ttsc format" and linting by "ttsc --noEmit" through the shared configuration - Pin moduleFormat = "cjs" on the prisma-client generator; with the shared tsconfig switching to module nodenext, Prisma 7.4 started emitting an ESM client which broke the CommonJS runtime - Fix violations surfaced by the stricter compiler options and lint rules (node: protocol imports, unknown-typed catch callbacks, eqeqeq, guard-for-in, no-return-assign, await-thenable, unchecked index accesses) - Anchor catalog versions on the base packages (nestia, ttsc) and reference them from their namespace families Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K1Q5EM6GT2Q89UPrNRKX1z
1 parent aeabd28 commit d399357

52 files changed

Lines changed: 352 additions & 370 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.prettierignore

Lines changed: 0 additions & 8 deletions
This file was deleted.

.vscode/settings.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
{
22
"editor.tabSize": 2,
3-
"editor.formatOnSave": true,
4-
"[javascript][typescript][json]": {
5-
"editor.defaultFormatter": "esbenp.prettier-vscode"
6-
},
73
"[prisma]": {
84
"editor.defaultFormatter": "Prisma.prisma",
95
},

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ List of the run commands defined in the [packages/backend/package.json](packages
220220
- `build:test`: Type check [Test Automation Program](#33-test-automation-program)
221221
- `build:main`: Build main program
222222
- **`dev`**: **Incremental type checker of the [Test Automation Program](#33-test-automation-program)**
223+
- `lint`: Type check and lint with [`@ttsc/lint`](https://ttsc.dev)
224+
- `format`: Format every TypeScript file with [`ttsc format`](https://ttsc.dev)
223225
- Deploy
224226
- `schema`: Create DB, users and schemas on local database
225227
- `start`: Start the backend server
@@ -234,6 +236,7 @@ To publish the SDK library, run `npm publish` in the [packages/api](packages/api
234236

235237
### 4.2. Directories
236238
- [.vscode/launch.json](.vscode/launch.json): Configuration for debugging
239+
- [config/](config): Shared TypeScript ([config/tsconfig.json](config/tsconfig.json)) and [`@ttsc/lint`](https://ttsc.dev) ([config/lint.config.ts](config/lint.config.ts)) configuration reused by every package
237240
- [packages/api/](packages/api): Client [SDK](#32-software-development-kit) library for the client developers
238241
- [**packages/api/src/functional/**](packages/api/src/functional/): API functions generated by the [`nestia`](https://github.com/samchon/nestia)
239242
- [**packages/api/src/structures/**](packages/api/src/structures/): DTO structures

config/lint.config.ts

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
import type { ITtscLintConfig } from "@ttsc/lint";
2+
3+
const config = {
4+
format: {
5+
// Keep @ttsc/lint formatting aligned with the repository import groups.
6+
severity: "off",
7+
semi: true,
8+
singleQuote: false,
9+
arrowParens: "always",
10+
bracketSpacing: true,
11+
quoteProps: "as-needed",
12+
trailingComma: "all",
13+
printWidth: 80,
14+
tabWidth: 2,
15+
useTabs: false,
16+
endOfLine: "lf",
17+
sortImports: {
18+
order: [
19+
"^@ORGANIZATION/PROJECT-api(.*)$",
20+
"^@/(.*)$",
21+
"<THIRD_PARTY_MODULES>",
22+
"^[./]",
23+
],
24+
},
25+
jsDoc: true,
26+
},
27+
rules: {
28+
// ESLint core: runtime correctness and low-noise modern JavaScript.
29+
"default-param-last": "error",
30+
eqeqeq: "error",
31+
"for-direction": "error",
32+
"getter-return": "error",
33+
"grouped-accessor-pairs": "error",
34+
"guard-for-in": "error",
35+
"no-array-constructor": "error",
36+
"no-async-promise-executor": "error",
37+
"no-caller": "error",
38+
"no-case-declarations": "error",
39+
"no-class-assign": "error",
40+
"no-compare-neg-zero": "error",
41+
"no-cond-assign": "error",
42+
"no-constructor-return": "error",
43+
"no-debugger": "error",
44+
"no-delete-var": "error",
45+
"no-dupe-args": "error",
46+
"no-dupe-class-members": "error",
47+
"no-dupe-else-if": "error",
48+
"no-dupe-keys": "error",
49+
"no-duplicate-case": "error",
50+
"no-duplicate-imports": "error",
51+
"no-empty-character-class": "error",
52+
"no-empty-pattern": "error",
53+
"no-empty-static-block": "error",
54+
"no-eval": "error",
55+
"no-ex-assign": "error",
56+
"no-extend-native": "error",
57+
"no-extra-bind": "error",
58+
"no-extra-boolean-cast": "error",
59+
"no-fallthrough": "error",
60+
"no-func-assign": "error",
61+
"no-import-assign": "error",
62+
"no-inner-declarations": "error",
63+
"no-invalid-this": "error",
64+
"no-irregular-whitespace": "error",
65+
"no-iterator": "error",
66+
"no-loss-of-precision": "error",
67+
"no-multi-assign": "error",
68+
"no-multi-str": "error",
69+
"no-new-func": "error",
70+
"no-new-symbol": "error",
71+
"no-new-wrappers": "error",
72+
"no-obj-calls": "error",
73+
"no-object-constructor": "error",
74+
"no-octal": "error",
75+
"no-octal-escape": "error",
76+
"no-promise-executor-return": "error",
77+
"no-proto": "error",
78+
"no-prototype-builtins": "error",
79+
"no-redeclare": "error",
80+
"no-regex-spaces": "error",
81+
"no-return-assign": "error",
82+
"no-script-url": "error",
83+
"no-self-assign": "error",
84+
"no-self-compare": "error",
85+
"no-sequences": "error",
86+
"no-setter-return": "error",
87+
"no-shadow-restricted-names": "error",
88+
"no-sparse-arrays": "error",
89+
"no-template-curly-in-string": "error",
90+
"no-this-before-super": "error",
91+
"no-unreachable": "error",
92+
"no-unsafe-finally": "error",
93+
"no-unsafe-negation": "error",
94+
"no-unused-labels": "error",
95+
"no-useless-assignment": "error",
96+
"no-useless-call": "error",
97+
"no-useless-catch": "error",
98+
"no-useless-computed-key": "error",
99+
"no-useless-escape": "error",
100+
"no-useless-rename": "error",
101+
"no-var": "error",
102+
"no-with": "error",
103+
"prefer-const": "error",
104+
radix: "error",
105+
"use-isnan": "error",
106+
"valid-typeof": "error",
107+
108+
// RegExp: invalid, empty, or misleading regular-expression structure.
109+
"regexp/no-dupe-characters-character-class": "error",
110+
"regexp/no-empty-alternative": "error",
111+
"regexp/no-empty-capturing-group": "error",
112+
"regexp/no-empty-group": "error",
113+
"regexp/no-empty-lookarounds-assertion": "error",
114+
"regexp/no-useless-character-class": "error",
115+
"regexp/no-useless-escape": "error",
116+
"regexp/no-useless-flag": "error",
117+
"regexp/no-useless-quantifier": "error",
118+
"regexp/no-useless-two-nums-quantifier": "error",
119+
"regexp/no-zero-quantifier": "error",
120+
"regexp/sort-flags": "error",
121+
122+
// Promise: chain shapes that can swallow or misroute async errors.
123+
"promise/no-multiple-resolved": "error",
124+
"promise/no-new-statics": "error",
125+
"promise/no-return-in-finally": "error",
126+
"promise/no-return-wrap": "error",
127+
"promise/param-names": "error",
128+
"promise/prefer-catch": "error",
129+
"promise/spec-only": "error",
130+
131+
// Security: concrete sink patterns with a low false-positive rate here.
132+
"security/detect-bidi-characters": "error",
133+
"security/detect-buffer-noassert": "error",
134+
"security/detect-eval-with-expression": "error",
135+
"security/detect-new-buffer": "error",
136+
"security/detect-pseudoRandomBytes": "error",
137+
"security/detect-unsafe-regex": "error",
138+
139+
// TypeScript: type-aware correctness rules.
140+
"typescript/adjacent-overload-signatures": "error",
141+
"typescript/await-thenable": "error",
142+
"typescript/ban-ts-comment": "error",
143+
"typescript/ban-tslint-comment": "error",
144+
"typescript/no-array-delete": "error",
145+
"typescript/no-confusing-non-null-assertion": "error",
146+
"typescript/no-duplicate-enum-values": "error",
147+
"typescript/no-extra-non-null-assertion": "error",
148+
"typescript/no-floating-promises": "error",
149+
"typescript/no-for-in-array": "error",
150+
"typescript/no-invalid-void-type": "error",
151+
"typescript/no-misused-new": "error",
152+
"typescript/no-misused-promises": "error",
153+
"typescript/no-misused-spread": "error",
154+
"typescript/no-mixed-enums": "error",
155+
"typescript/no-non-null-asserted-nullish-coalescing": "error",
156+
"typescript/no-non-null-asserted-optional-chain": "error",
157+
"typescript/no-redundant-type-constituents": "error",
158+
"typescript/no-unnecessary-type-constraint": "error",
159+
"typescript/no-unsafe-declaration-merging": "error",
160+
"typescript/no-unsafe-function-type": "error",
161+
"typescript/no-unsafe-unary-minus": "error",
162+
"typescript/no-wrapper-object-types": "error",
163+
"typescript/only-throw-error": "error",
164+
"typescript/prefer-as-const": "error",
165+
"typescript/prefer-promise-reject-errors": "error",
166+
"typescript/require-array-sort-compare": "error",
167+
"typescript/switch-exhaustiveness-check": "error",
168+
"typescript/triple-slash-reference": "error",
169+
"typescript/use-unknown-in-catch-callback-variable": "error",
170+
171+
// Unicorn: correctness-oriented runtime/API traps, not broad style policy.
172+
"unicorn/error-message": "error",
173+
"unicorn/new-for-builtins": "error",
174+
"unicorn/no-accessor-recursion": "error",
175+
"unicorn/no-await-in-promise-methods": "error",
176+
"unicorn/no-empty-file": "error",
177+
"unicorn/no-invalid-fetch-options": "error",
178+
"unicorn/no-invalid-remove-event-listener": "error",
179+
"unicorn/no-new-buffer": "error",
180+
"unicorn/no-thenable": "error",
181+
"unicorn/no-useless-promise-resolve-reject": "error",
182+
"unicorn/prefer-node-protocol": "error",
183+
},
184+
} satisfies ITtscLintConfig;
185+
186+
export default config;

config/package.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"private": true,
3+
"name": "@ORGANIZATION/PROJECT-config",
4+
"version": "0.1.0",
5+
"description": "Shared TypeScript and @ttsc/lint configuration for the workspace",
6+
"exports": {
7+
"./lint": {
8+
"types": "./lint.config.ts",
9+
"default": "./lint.config.ts"
10+
},
11+
"./tsconfig": "./tsconfig.json",
12+
"./package.json": "./package.json"
13+
},
14+
"files": [
15+
"lint.config.ts",
16+
"tsconfig.json"
17+
],
18+
"devDependencies": {
19+
"@ttsc/lint": "catalog:typescript",
20+
"typescript": "catalog:typescript"
21+
}
22+
}

config/tsconfig.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"compilerOptions": {
3+
"target": "esnext",
4+
"lib": ["DOM", "ESNext"],
5+
"module": "nodenext",
6+
"moduleResolution": "nodenext",
7+
"types": ["*"],
8+
"resolveJsonModule": true,
9+
"sourceMap": true,
10+
"newLine": "lf",
11+
"esModuleInterop": true,
12+
"forceConsistentCasingInFileNames": true,
13+
"strict": true,
14+
"noImplicitReturns": true,
15+
"noUncheckedIndexedAccess": true,
16+
"skipLibCheck": true,
17+
}
18+
}

package.json

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
"version": "0.1.0",
55
"description": "Backend for PROJECT",
66
"scripts": {
7-
"build": "pnpm -r build",
7+
"build": "pnpm -r --if-present build",
88
"dev": "pnpm -C packages/backend dev",
9-
"format": "prettier --write \"**/*.ts\"",
10-
"format:check": "prettier --check \"**/*.ts\"",
9+
"format": "pnpm -r --if-present format",
10+
"lint": "pnpm -r --if-present lint",
1111
"start": "pnpm -C packages/backend start",
1212
"test": "pnpm -C packages/backend test"
1313
},
@@ -27,13 +27,5 @@
2727
"prisma",
2828
"@prisma/engines"
2929
]
30-
},
31-
"devDependencies": {
32-
"@trivago/prettier-plugin-sort-imports": "catalog:typescript",
33-
"@types/node": "^24.0.0",
34-
"prettier": "catalog:typescript",
35-
"prettier-plugin-prisma": "^5.0.0",
36-
"ttsc": "catalog:typescript",
37-
"typescript": "catalog:typescript"
3830
}
3931
}

packages/api/lint.config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import type { ITtscLintConfig } from "@ttsc/lint";
2+
3+
import shared from "../../config/lint.config";
4+
5+
const config = {
6+
...shared,
7+
ignores: ["src/functional/**/*.ts"],
8+
} satisfies ITtscLintConfig;
9+
10+
export default config;

packages/api/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
"scripts": {
1010
"build": "pnpm build:sdk && pnpm build:ttsc && pnpm build:rollup",
1111
"build:sdk": "cd ../backend && pnpm build:sdk",
12-
"build:ttsc": "rimraf lib && ttsc -p tsconfig.json",
12+
"build:ttsc": "ttsc -p tsconfig.json",
1313
"build:rollup": "rollup -c",
14+
"format": "ttsc format -p tsconfig.json",
15+
"lint": "ttsc -p tsconfig.json --noEmit",
1416
"prepack": "pnpm build"
1517
},
1618
"repository": {
@@ -37,7 +39,7 @@
3739
"devDependencies": {
3840
"@ORGANIZATION/PROJECT-api": "workspace:^",
3941
"@rollup/plugin-terser": "^0.4.4",
40-
"rimraf": "catalog:utils",
42+
"@ttsc/lint": "catalog:typescript",
4143
"rollup": "^4.18.0",
4244
"ttsc": "catalog:typescript",
4345
"typescript": "catalog:typescript"

packages/api/rollup.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ const compileProject = () => {
2222
declaration: false,
2323
declarationMap: false,
2424
module: "ESNext",
25+
moduleResolution: "bundler",
26+
plugins: [
27+
{
28+
transform: "@ttsc/lint",
29+
configFile: normalize(path.join(PROJECT_DIR, "lint.config.ts")),
30+
},
31+
],
2532
target: "ESNext",
2633
},
2734
},

0 commit comments

Comments
 (0)