Skip to content

chore: explicitly import node process#2685

Open
iiio2 wants to merge 1 commit intonpmx-dev:mainfrom
iiio2:chore/import-node-process-explicy-way
Open

chore: explicitly import node process#2685
iiio2 wants to merge 1 commit intonpmx-dev:mainfrom
iiio2:chore/import-node-process-explicy-way

Conversation

@iiio2
Copy link
Copy Markdown
Contributor

@iiio2 iiio2 commented May 7, 2026

No description provided.

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment May 7, 2026 5:57pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview May 7, 2026 5:57pm
npmx-lunaria Ignored Ignored May 7, 2026 5:57pm

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 7, 2026

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • Chores

    • Updated build scripts and configuration modules to use explicit Node.js package imports for improved compatibility and code quality standards.
  • Tests

    • Added test coverage for security headers module behaviour across different development and configuration states.

Walkthrough

This pull request standardises explicit Node.js node:process imports across build-time scripts, runtime modules, and test files. Key features include a git-merge guard in lunaria.ts, environment-conditional configuration in security-headers and uno.config, error handling via process.exit() in validation scripts, and new test coverage for security-headers module behaviour with devtools enabled and disabled states.

Changes

Node Process Import Standardisation

Layer / File(s) Summary
Node Process Import Pattern
lunaria/lunaria.ts, modules/build-env.ts, modules/security-headers.ts, scripts/find-invalid-translations.ts, scripts/generate-file-tree-sprite.ts, scripts/next-version.ts, scripts/remove-unused-translations.ts, scripts/unocss-checker.ts, uno.config.ts, test/unit/modules/security-headers.spec.ts
Explicit import process from 'node:process' additions across all modules and scripts for standardised Node.js native module usage.
Build-Time i18n Dashboard Generation
lunaria/lunaria.ts
Adds git-merge detection guard, Lunaria instance setup with force: true, recursive translation key counting, locale-to-file mapping via countryLocaleVariants, app locale filtering, GitHub URL generation, and HTML/JSON output to dist/lunaria/.
Runtime Configuration Environment Conditionals
modules/security-headers.ts, uno.config.ts
process.env.TEST gates devtools CSP behaviour in security-headers; process.env.CI conditionally includes RTL and A11y presets in uno.config.
Script Error Handling
scripts/find-invalid-translations.ts, scripts/remove-unused-translations.ts
Error paths and catch blocks now use process.exit(1) to terminate with error status code.
Generation and Validation Scripts
scripts/generate-file-tree-sprite.ts, scripts/next-version.ts, scripts/unocss-checker.ts
Updated with explicit process imports enabling environment and CLI argument access; core generation logic remains unchanged.
Security Headers Module Testing
test/unit/modules/security-headers.spec.ts
New test suite with mocked useNuxt, helper utilities, and comprehensive test cases verifying CSP and route header behaviour with devtools enabled and disabled.

Suggested reviewers

  • graphieros
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding explicit imports of Node's process module across multiple files.
Description check ✅ Passed No description was provided, but the title is sufficiently clear and the changeset is straightforward, making this acceptable.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
lunaria/lunaria.ts (1)

100-100: 💤 Low value

Redundant optional chain on a non-nullable locale.

locale is an element of appLocales (a filtered Array), so it is never undefined or null at this point. The ?. on locale?.dir is unnecessary.

♻️ Proposed fix
-      dir: locale?.dir ?? 'ltr',
+      dir: locale.dir ?? 'ltr',
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lunaria/lunaria.ts` at line 100, The optional chaining on locale
(locale?.dir) is redundant because locale is sourced from appLocales (a filtered
Array) and cannot be null/undefined here; replace locale?.dir with locale.dir
and keep the fallback 'ltr' intact so the line becomes dir: locale.dir ?? 'ltr',
updating the expression in lunaria.ts where locale is used.
test/unit/modules/security-headers.spec.ts (1)

51-54: ⚡ Quick win

Use vi.stubEnv instead of delete process.env.TEST to ensure proper env restoration.

delete process.env.TEST mutates the global environment without restoring it. If process.env.TEST was set before this suite (e.g., by the test runner or a vitest setup file), the deletion leaks — other test files sharing the same worker process that rely on process.env.TEST (e.g., modules/build-env.ts tests) may behave unexpectedly. vi.stubEnv stubs the value per-test and automatically restores the original after each test.

🛠️ Proposed fix
  beforeEach(() => {
-   delete process.env.TEST
    useNuxt.mockReset()
+   vi.stubEnv('TEST', undefined)
  })

No afterEach cleanup is needed; Vitest restores stubbed env vars automatically after each test.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/unit/modules/security-headers.spec.ts` around lines 51 - 54, The
beforeEach currently mutates the global env by doing delete process.env.TEST;
replace that with a per-test stub using vi.stubEnv({ TEST: undefined }) inside
the same beforeEach so Vitest will restore the original value automatically, and
keep the useNuxt.mockReset() call; remove any manual afterEach cleanup for TEST
because vi.stubEnv handles restoration.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@lunaria/lunaria.ts`:
- Line 100: The optional chaining on locale (locale?.dir) is redundant because
locale is sourced from appLocales (a filtered Array) and cannot be
null/undefined here; replace locale?.dir with locale.dir and keep the fallback
'ltr' intact so the line becomes dir: locale.dir ?? 'ltr', updating the
expression in lunaria.ts where locale is used.

In `@test/unit/modules/security-headers.spec.ts`:
- Around line 51-54: The beforeEach currently mutates the global env by doing
delete process.env.TEST; replace that with a per-test stub using vi.stubEnv({
TEST: undefined }) inside the same beforeEach so Vitest will restore the
original value automatically, and keep the useNuxt.mockReset() call; remove any
manual afterEach cleanup for TEST because vi.stubEnv handles restoration.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: bdca9202-62dc-4c73-a6cb-3261b1838570

📥 Commits

Reviewing files that changed from the base of the PR and between 001d748 and cdce166.

📒 Files selected for processing (10)
  • lunaria/lunaria.ts
  • modules/build-env.ts
  • modules/security-headers.ts
  • scripts/find-invalid-translations.ts
  • scripts/generate-file-tree-sprite.ts
  • scripts/next-version.ts
  • scripts/remove-unused-translations.ts
  • scripts/unocss-checker.ts
  • test/unit/modules/security-headers.spec.ts
  • uno.config.ts

@codecov
Copy link
Copy Markdown

codecov Bot commented May 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

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.

1 participant