Skip to content

Commit dd2933f

Browse files
test(patina): cover namespace exports in no-export-in-script-setup (#3216)
Co-authored-by: Codesmith <codesmith-bot@users.noreply.github.com>
1 parent 809ab08 commit dd2933f

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

crates/vize_patina/src/rules/script/no_export_in_script_setup_tests.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,17 @@ export {}
109109
assert_eq!(result.error_count, 1);
110110
}
111111

112+
#[test]
113+
fn test_invalid_export_namespace_with_macro() {
114+
// A non-ambient namespace emits a runtime object, so it must be flagged.
115+
let source = r#"
116+
defineProps<{ count: number }>()
117+
export namespace Config { export const value = 1 }
118+
"#;
119+
let result = create_linter().lint(source, 0);
120+
assert_eq!(result.error_count, 1);
121+
}
122+
112123
// --- Valid: type-only exports are erased and stay legal in <script setup> ---
113124

114125
#[test]
@@ -177,6 +188,18 @@ export declare const version: string
177188
assert_eq!(result.error_count, 0);
178189
}
179190

191+
#[test]
192+
fn test_valid_export_declare_namespace() {
193+
// An ambient namespace is erased at compile time; only non-ambient
194+
// `export namespace` emits a runtime object.
195+
let source = r#"
196+
defineProps<{ count: number }>()
197+
export declare namespace Config { const value: number }
198+
"#;
199+
let result = create_linter().lint(source, 0);
200+
assert_eq!(result.error_count, 0);
201+
}
202+
180203
// --- Valid: normal <script> (no setup markers) is never flagged ---
181204

182205
#[test]

0 commit comments

Comments
 (0)