Skip to content

Commit e5ea2c8

Browse files
committed
fix(tsconfig): node_modules exclude 노이즈 완화
TypeScript 기본 exclude 디렉터리와 동일한 node_modules/bower_components/jspm_packages no-op exclude는 기본 audit finding에서 제외합니다. 비기본 exclude no-op finding과 empty include warning은 기존 계약대로 유지하고 regression test로 고정했습니다. Closes #105
1 parent 3245c61 commit e5ea2c8

2 files changed

Lines changed: 53 additions & 8 deletions

File tree

crates/maximus-checks/src/tsconfig.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,6 +1178,10 @@ fn collect_include_exclude_pattern_findings(
11781178
let removed_count = matches.len();
11791179

11801180
if removed_count == 0 {
1181+
if is_default_excluded_directory_pattern(pattern) {
1182+
continue;
1183+
}
1184+
11811185
findings.push(make_finding(FindingInput {
11821186
id: format!(
11831187
"tsconfig-patterns:{}:exclude:{pattern}",
@@ -1246,6 +1250,19 @@ fn is_next_generated_types_pattern(pattern: &str) -> bool {
12461250
pattern == ".next/types/**/*.ts" || pattern == "./.next/types/**/*.ts"
12471251
}
12481252

1253+
fn is_default_excluded_directory_pattern(pattern: &str) -> bool {
1254+
let normalized = pattern.trim().replace('\\', "/");
1255+
let normalized = normalized
1256+
.strip_prefix("./")
1257+
.unwrap_or(&normalized)
1258+
.trim_end_matches('/');
1259+
1260+
matches!(
1261+
normalized,
1262+
"node_modules" | "bower_components" | "jspm_packages"
1263+
)
1264+
}
1265+
12491266
fn collect_output_path_overlap_findings(
12501267
findings: &mut Vec<Finding>,
12511268
project_root: &Path,

crates/maximus-checks/tests/tsconfig_checks.rs

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -883,6 +883,19 @@ fn tsconfig_pattern_severity_contract_keeps_noop_excludes_non_blocking() {
883883
.join("noop-node-modules-exclude/src/index.ts"),
884884
"export const ok = true;\n",
885885
);
886+
write(
887+
fixture.path().join("noop-generated-exclude/tsconfig.json"),
888+
r#"
889+
{
890+
"include": ["src/**/*.ts"],
891+
"exclude": ["generated/**/*.ts"]
892+
}
893+
"#,
894+
);
895+
write(
896+
fixture.path().join("noop-generated-exclude/src/index.ts"),
897+
"export const ok = true;\n",
898+
);
886899

887900
let project = discover_project(fixture.path()).expect("project should discover");
888901
let outcome = run_tsconfig_check(&project).expect("check should run");
@@ -913,33 +926,48 @@ fn tsconfig_pattern_severity_contract_keeps_noop_excludes_non_blocking() {
913926
.join("noop-node-modules-exclude/tsconfig.json")
914927
.to_string_lossy()
915928
);
929+
assert!(
930+
outcome
931+
.findings
932+
.iter()
933+
.all(|finding| finding.id != noop_exclude_id),
934+
"default node_modules exclude should not report no-op audit noise"
935+
);
936+
937+
let non_default_noop_exclude_id = format!(
938+
"tsconfig-patterns:{}:exclude:generated/**/*.ts",
939+
fixture
940+
.path()
941+
.join("noop-generated-exclude/tsconfig.json")
942+
.to_string_lossy()
943+
);
916944
assert_has_finding(
917945
&outcome.findings,
918-
&noop_exclude_id,
946+
&non_default_noop_exclude_id,
919947
Severity::Info,
920948
"Exclude pattern does not filter any included files",
921949
&format!(
922-
"exclude pattern \"node_modules\" removed 0 files from 1 included file(s) under base dir {}.",
950+
"exclude pattern \"generated/**/*.ts\" removed 0 files from 1 included file(s) under base dir {}.",
923951
fixture
924952
.path()
925-
.join("noop-node-modules-exclude")
953+
.join("noop-generated-exclude")
926954
.to_string_lossy()
927955
),
928956
"Remove or tighten exclude entries that do not change the effective TypeScript input set.",
929957
Some(
930958
fixture
931959
.path()
932-
.join("noop-node-modules-exclude/tsconfig.json"),
960+
.join("noop-generated-exclude/tsconfig.json"),
933961
),
934962
);
935963

936-
let noop_exclude_finding = outcome
964+
let non_default_noop_exclude_finding = outcome
937965
.findings
938966
.iter()
939-
.find(|finding| finding.id == noop_exclude_id)
940-
.expect("no-op node_modules exclude finding should exist");
967+
.find(|finding| finding.id == non_default_noop_exclude_id)
968+
.expect("non-default no-op exclude finding should exist");
941969
let summary = summarize_findings(
942-
std::slice::from_ref(noop_exclude_finding),
970+
std::slice::from_ref(non_default_noop_exclude_finding),
943971
&outcome.fixes,
944972
&StructureReport {
945973
is_monorepo: false,

0 commit comments

Comments
 (0)