chore: hoist dev dependencies to root and modernize tooling#237
Open
chore: hoist dev dependencies to root and modernize tooling#237
Conversation
- vfm/package.json: consolidate multiple "//" keys into a single object. Duplicate keys are lost when npm pkg or npm install rewrites the file. - Migrate .prettierrc to prettier.config.js for consistency with the upcoming ESLint flat config migration and better type completions. - Add "type": "module" to root package.json, required for Node to recognize prettier.config.js as ESM. - Add format script to vfm; root delegates via --workspaces and passes common --ignore-path options. - Includes minor formatting changes from Prettier 3.
- ESLint 10 enforces flat config; replace .eslintrc.js with eslint.config.js using @eslint/js and typescript-eslint. - Use eslint-config-flat-gitignore to derive ignores from .gitignore, matching the approach used for prettier --ignore-path. - Add lint scripts to vfm and root. - Fix lint errors: remove unused Root import and unused node parameter in section.ts, remove stale eslint-disable directive in utils.ts.
- Replace vfm's tsconfig.json with a minimal config extending the new
root tsconfig.json. The root config tracks tsc --init defaults with
minimal changes, to ease future migration to TypeScript 7 (tsgo).
- Fix type errors introduced by noUncheckedIndexedAccess: add non-null
assertions for regex capture groups and array accesses guarded by
length checks, and add a runtime guard for the ancestors array in
section.ts.
- Convert inline type imports (import { type X } from 'pkg') to
top-level type imports (import type { X } from 'pkg') for packages
without a runtime entry point (unist, hast, mdast, vfile).
With verbatimModuleSyntax, the inline form leaves an empty
import {} in the output, which vite cannot resolve at runtime.
- Disable exactOptionalPropertyTypes in vfm's tsconfig.json as
existing code is not compatible; to be addressed separately.
- Update root build script to use --workspaces --if-present.
- Move prettier ignore-path to each package's format script, instead of passing from root via -- passthrough. - Remove the prepare script from vfm. Auto-building on install is uncommon and increasingly discouraged due to supply chain security concerns. - Hoist shx to root. - Update root scripts to use --workspaces --if-present for build, test, format, and lint. Remove dev from root as watch mode should be run per-package.
- Add | undefined to optional properties in StringifyMarkdownOptions, VFMSettings, Metadata, FootnoteOptions, and ResolvedOption to satisfy exactOptionalPropertyTypes. - Remove exactOptionalPropertyTypes override from vfm's tsconfig.json. - Fix test imports: add .js extensions for ESM module resolution, use import type where required by verbatimModuleSyntax.
Run tsc --project tests/tsconfig.json as part of the test script to ensure tests are type-checked alongside vitest execution.
There was a problem hiding this comment.
Pull request overview
This PR hoists dev dependencies from individual packages to the root of the monorepo and modernizes the development tooling configuration. The changes include:
- Moving dev dependencies to root
package.json - Creating centralized TypeScript, Prettier, and ESLint configurations
- Removing old configuration files (
.prettierrc,.eslintrc.js) - Updating all imports to use explicit
.jsfile extensions for ES modules - Adding
typekeyword to type imports throughout the codebase - Removing the
preparescript frompackages/vfm/package.json - Converting package.json comments to a structured format
Changes:
- New root-level configuration files created (tsconfig.json, prettier.config.js, eslint.config.js)
- Root package.json updated with hoisted devDependencies and new scripts
- All TypeScript source files updated with
.jsextensions andtypekeyword for type imports - Updated test files with ESM-style imports
- Simplified tsconfig.json in packages/vfm by extending root config
- New test tsconfig.json created for type-checking tests
Reviewed changes
Copilot reviewed 38 out of 40 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tsconfig.json | New root TypeScript configuration with strict compiler options |
| prettier.config.js | New root Prettier configuration file (replaces .prettierrc) |
| eslint.config.js | New root ESLint flat config (replaces .eslintrc.js) |
| package.json | Root package updated with hoisted devDependencies and workspace scripts |
| packages/vfm/package.json | Updated to remove hoisted devDependencies and prepare script |
| packages/vfm/tsconfig.json | Simplified to extend root config |
| packages/vfm/tests/tsconfig.json | New configuration for test type-checking |
| packages/vfm/src/**/*.ts | Updated with .js extensions and type imports |
| packages/vfm/tests/**/*.ts | Updated with .js extensions in imports |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
With verbatimModuleSyntax (default in TS 6), `import { type X } from`
leaves an empty `import {} from` in the output. For @types/* packages
without a runtime entry point, this causes vitest to fail (fixed in
8c7fbfc). The modules changed here all have runtime entry points so
the inline form does not error, but we use top-level `import type` for
consistency.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
モノレポにパッケージを追加する( #236 〜)にあたってルートパッケージに開発ツールを集約する必要があり、これだけで作業量が多いと判断したのでPRを分けます。インストールし直すついでにツールのバージョンも上げ、もろもろ通るように少しずつ編集しています。
ほとんどはコミットメッセージに書いてありますが、2つほど自分で言ったことを覆した点があるので個別に説明します。
prepareスクリプトを削除しました。インストール時にビルドするのは全パッケージがやりだすと困るあまり行儀良くない仕草だと考えを改めたこと、また最近はShai-Huludなどセキュリティ問題が広がりignore-scriptsが推奨されることが増えていることを踏まえています。"//"をコメント扱いにするのは引き続き問題なさそうなのですが、複数の"//"を用いるとnpm installなどで書き戻しが起こった際に最後のものだけに直されてしまうことに気付きました。そこで1つの"//"に対して、コメント箇所をキーに、コメント実体は配列にする方式をとることにしました。