Skip to content

fix: misleading dual nativescript.config warning when reading plugin configs - #6122

Open
NathanWalker wants to merge 1 commit into
mainfrom
fix/config-warning
Open

fix: misleading dual nativescript.config warning when reading plugin configs#6122
NathanWalker wants to merge 1 commit into
mainfrom
fix/config-warning

Conversation

@NathanWalker

@NathanWalker NathanWalker commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

During iOS prepare, plugin-declared SPM packages are collected by reading each plugin's nativescript.config.ts via projectConfigService.readConfig.

A plugin that publishes compiled artifacts next to its config source triggered the project-level:

You have both a nativescript.config.js and nativescript.config.ts file

warning, with no indication it referred to a directory inside node_modules rather than the user's project.

Plugin config reads now suppress the warning, and the warning message names the directory it refers to for genuine dual-config projects.

Summary by CodeRabbit

  • Bug Fixes

    • Reduced unnecessary configuration warnings when inspecting compiled plugin artifacts.
    • Configuration warnings now identify the relevant directory for easier troubleshooting.
  • Improvements

    • Added an option to suppress configuration warnings when reading or detecting project configurations.

…configs

During iOS prepare, plugin-declared SPM packages are collected by reading
each plugin's nativescript.config.ts via projectConfigService.readConfig.
A plugin that publishes compiled artifacts next to its config source
triggered the project-level "You have both a nativescript.config.js and nativescript.config.ts file" warning, with no indication it referred to a directory inside node_modules rather than the user's project.

Plugin config reads now suppress the warning, and the warning message
names the directory it refers to for genuine dual-config projects.
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The project configuration APIs now accept optional warning suppression. The service skips dual-config warnings when requested and includes the configuration directory in the warning message. iOS plugin configuration loading enables suppression.

Changes

Configuration warning suppression

Layer / File(s) Summary
Warning suppression API and detection
lib/definitions/project.d.ts, lib/services/project-config-service.ts
readConfig and detectProjectConfigs accept suppressWarnings. Dual TypeScript/JavaScript config warnings are skipped when enabled.
Plugin configuration integration
lib/services/ios-project-service.ts
Plugin configuration reads pass { suppressWarnings: true } during native dependency handling.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant IOSProjectService
  participant ProjectConfigService
  IOSProjectService->>ProjectConfigService: readConfig(pluginDirectory, suppressWarnings=true)
  ProjectConfigService->>ProjectConfigService: detectProjectConfigs(suppressWarnings=true)
  ProjectConfigService-->>IOSProjectService: plugin configuration without dual-config warning
Loading

Suggested reviewers: edusperoni, farfromrefug

Poem

A rabbit reads configs in a row,
Suppresses warnings meant to show.
TypeScript and JavaScript paths align,
Plugin logs stay quiet and fine.
Hop, hop—the settings flow!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the fix for misleading dual NativeScript configuration warnings when reading plugin configurations.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@lib/services/project-config-service.ts`:
- Around line 160-164: Update the warning in the configuration-detection branch
of the project config service to report the actual detected JSConfigPath and
TSConfigPath values, rather than hardcoded default names and only TSConfigPath’s
directory. Preserve the warning’s statement that TypeScript configuration is
selected, and ensure any directory-based wording is used only when both paths
share the same parent directory.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 995860e9-e84d-4f6b-853c-a5496df365c3

📥 Commits

Reviewing files that changed from the base of the PR and between 9322fdc and 5e7750f.

📒 Files selected for processing (3)
  • lib/definitions/project.d.ts
  • lib/services/ios-project-service.ts
  • lib/services/project-config-service.ts

Comment on lines +160 to +164
if (hasTSConfig && hasJSConfig && !options?.suppressWarnings) {
this.$logger.warn(
`You have both a ${CONFIG_FILE_NAME_JS} and ${CONFIG_FILE_NAME_TS} file. Defaulting to ${CONFIG_FILE_NAME_TS}.`,
`You have both a ${CONFIG_FILE_NAME_JS} and ${CONFIG_FILE_NAME_TS} file in ${path.dirname(
TSConfigPath,
)}. Defaulting to ${CONFIG_FILE_NAME_TS}.`,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Report the detected configuration paths.

possibleConfigPaths can combine a custom --config or NATIVESCRIPT_CONFIG_NAME path with the default paths. Therefore, TSConfigPath and JSConfigPath are not guaranteed to have the same parent directory. This message can claim that both files are in path.dirname(TSConfigPath) when the JavaScript file is elsewhere. It also names the default files when custom names were detected.

Build the warning from JSConfigPath and TSConfigPath, or use the directory form only when both parent directories match.

Proposed fix
 			this.$logger.warn(
-				`You have both a ${CONFIG_FILE_NAME_JS} and ${CONFIG_FILE_NAME_TS} file in ${path.dirname(
-					TSConfigPath,
-				)}. Defaulting to ${CONFIG_FILE_NAME_TS}.`,
+				`You have both ${JSConfigPath} and ${TSConfigPath}. Defaulting to ${TSConfigPath}.`,
 			);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (hasTSConfig && hasJSConfig && !options?.suppressWarnings) {
this.$logger.warn(
`You have both a ${CONFIG_FILE_NAME_JS} and ${CONFIG_FILE_NAME_TS} file. Defaulting to ${CONFIG_FILE_NAME_TS}.`,
`You have both a ${CONFIG_FILE_NAME_JS} and ${CONFIG_FILE_NAME_TS} file in ${path.dirname(
TSConfigPath,
)}. Defaulting to ${CONFIG_FILE_NAME_TS}.`,
if (hasTSConfig && hasJSConfig && !options?.suppressWarnings) {
this.$logger.warn(
`You have both ${JSConfigPath} and ${TSConfigPath}. Defaulting to ${TSConfigPath}.`,
🤖 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 `@lib/services/project-config-service.ts` around lines 160 - 164, Update the
warning in the configuration-detection branch of the project config service to
report the actual detected JSConfigPath and TSConfigPath values, rather than
hardcoded default names and only TSConfigPath’s directory. Preserve the
warning’s statement that TypeScript configuration is selected, and ensure any
directory-based wording is used only when both paths share the same parent
directory.

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