Skip to content

build: enable lint rules - #99

Draft
liangmiQwQ wants to merge 9 commits into
Proj-Pigeon:mainfrom
liangmiQwQ:liang/codex/enable-lint
Draft

liangmiQwQ wants to merge 9 commits into
Proj-Pigeon:mainfrom
liangmiQwQ:liang/codex/enable-lint

Conversation

@liangmiQwQ

@liangmiQwQ liangmiQwQ commented Nov 26, 2026 •

Copy link
Copy Markdown

This PR turns on the @liangmi/vp-config lint rules in vp check and fixes what they report. Commits are split into the autofix pass and the hand fixes.

It fixes one real bug. clipboard.writeText returns a promise in Electron 44, but the logging:copy-report handler didn't await it. The renderer heard back before the copy finished, and a failure went unhandled.

Rules that clash with how GuEarth is written are turned off in vite.config.mts, each with a comment. So are rules whose fixes would change behavior. For example:

  • filename-case, no-default-export: components use PascalCase files and default exports.
  • no-unnecessary-condition and its siblings: they remove defensive checks on IPC and JSON data. Their autofix turned textFrame === true into undefined for a missing value.
  • require-await: tool execute, imagery providers and retry handlers must return promises.
  • prefer-structured-clone, prefer-catch: the rewrites behave differently (structuredClone throws on functions, and .then(a, b) only catches the original promise).
  • React Compiler rules (refs, set-state-in-effect, …): fixing them changes render and effect timing, so they need testing in the running app first.

The autofix also changed require('crypto') to node:crypto, so the tests' module stubs and resolve hooks now use node: specifiers too.

🤖 Generated with Claude Code


Proof this PR
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Upgrade electron-vite to v6 and Vite to v8, the base for the Vite+ migration.

- Rename `rollupOptions` to `rolldownOptions`, since Vite 8 bundles with Rolldown.
- Replace the `manualChunks` function with a Rolldown `codeSplitting` group that keeps Cesium in its own chunk.
- Update the pinned Vite version note in AGENTS.md.
Run the unit tests with Vitest instead of `node --test`.

- Import `test` from `vitest` in every test file.
- Replace `t.after` with `t.onTestFinished`, and `t.mock.timers` with `vi.useFakeTimers` and `vi.advanceTimersByTime`.
- Turn off Vite's module runner in `vite.config.mts`, so the tests keep using native Node.js imports and their `module.registerHooks` fixtures.
Type-check with the native TypeScript 7 compiler.

- Remove `baseUrl` and make `paths` relative, since TypeScript 7 dropped `baseUrl`.
- Point the tests that use the compiler API (`transpileModule`, the AST) at `@typescript/typescript6`, because TypeScript 7 has no stable JS API yet.
- Run TypeScript 7's `tsc` by path in `npm run typecheck`. `@typescript/typescript6` also links a TypeScript 6 `tsc` into `node_modules/.bin`, so a bare `tsc` could run the wrong version.
Move the toolchain to Vite+, configured with the `@liangmi/vp-config` preset.

- Alias `vite` to `@voidzero-dev/vite-plus-core`, and import test APIs from `vite-plus/test`.
- Replace `npm run typecheck` with `npm run check` (`vp check`), which type-checks through tsrs-lint. Lint rules and formatting are off (`check: { fmt: false, lint: false }`) and get turned on in follow-up PRs.
- Make the root `tsconfig.json` reference `tsconfig.node.json` and `tsconfig.web.json`, so each file is checked with its own project's settings. Add the two config files to the node project.
- Keep the Node test environment. The preset would pick jsdom, but the tests set up their own DOM.
Turn on the `@liangmi/vp-config` lint rules in `vp check`, and fix what they report.

A few rules are off because they clash with how GuEarth is written, or because their fixes trust types that IPC and JSON payloads don't guarantee at runtime. Each one has a comment in `vite.config.mts`:

- `unicorn/filename-case`, `import/no-default-export`, `import/no-named-as-default`: components use PascalCase files and default exports.
- `unicorn/prefer-global-this`, `eslint/no-underscore-dangle`: the renderer uses `window` and Cesium's private `_` fields on purpose.
- `unicorn/prefer-module`: the main process is bundled as CommonJS.
- `eslint/max-classes-per-file`: stores and errors are classes.
- `react-perf/*`: JSX props aren't memoized anywhere.
- `typescript/no-unnecessary-condition`, `no-unnecessary-boolean-literal-compare`, `no-unnecessary-type-conversion`: the defensive checks they remove guard untyped runtime data. The boolean compare autofix turned `textFrame === true` into `undefined` for a missing value.
- `typescript/prefer-nullish-coalescing`: `||` treats empty strings as missing on purpose.
- `unicorn/no-array-sort`, `unicorn/no-array-reverse`: `toSorted` needs the ES2023 lib.
- `unicorn/consistent-function-scoping`, `unicorn/max-nested-calls`, `promise/prefer-await-to-callbacks`, `typescript/method-signature-style`: style-only churn.
Apply `vp lint --fix`, then repair what it got wrong:

- Keep `thinkingLevels` typed as a `Set<AiThinkingLevel>` after `prefer-set-has`.
- Keep the shape `kind` literal type that `no-unnecessary-type-assertion` dropped.
- Match the `node:` specifiers from `prefer-node-protocol` in the tests' module stubs and resolve hooks.
- Update source-text assertions for the braces from `curly` and the `() => {}` from `no-useless-undefined`.
Give block bodies to arrow callbacks whose return value is ignored, such as `setTimeout` in promise executors and stream listeners, and apply a second autofix pass.

The shutdown flush becomes `.then(() => flushJsonWrites())`. It still waits for the flush, because the chain can't reject after `.catch`.
Turn off the rules that clash with how GuEarth is written, or whose fixes change behavior, each with a comment in `vite.config.mts`. Hoist the late imports in the main process entry, since ES module imports are hoisted anyway.
Fix the reports that point at real problems:

- Await `clipboard.writeText` in the `logging:copy-report` handler. It returns a promise in Electron 44, so the renderer heard back before the copy finished, and a failure went unhandled.
- Mark fire-and-forget promises with `void`, such as `loadURL` and `app.whenReady()`.
- Remove unused imports, variables, a helper, an unused `endpoint` parameter, and a duplicated `if` branch in the model importer.
- Rename echarts' `use` to `registerEcharts`, so it isn't mistaken for a React hook.

Where a rule is wrong for one line, the line has an `oxlint-disable-next-line` comment with the reason, such as control characters that device names must not contain.
@coderabbitai

coderabbitai Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@forkstack-service

Copy link
Copy Markdown

@codacy-production

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 3 critical

Alerts:
⚠ 3 issues (≤ 0 issues of at least minor severity)

Results:
3 new issues

Category Results
Security 3 critical

View in Codacy

🟢 Metrics 156 complexity · 10 duplication

Metric Results
Complexity 156
Duplication 10

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants