Commit 6c2b41c
fix(linter/consistent-function-scoping): allow functions in TS modules/namespaces (#11681)
## What This PR Does
Fixes a false positive in `unicorn/consistent-function-scoping` on
non-exported functions in TypeScript `module` and `namespace` nodes.
TypeScript modules and namespaces are valid ways to encapsulate code.
```ts
export namespace Foo {
// public-facing API
export function doThing() {
let x = privateUtility();
return x + 2;
}
// private function only available to functions within this namespace.
// this used to be reported.
function privateUtility() {
return 1;
}
}
```
---------
Co-authored-by: Cameron Clark <cameron.clark@hey.com>1 parent 2ca1c70 commit 6c2b41c
File tree
2 files changed
+64
-4
lines changed- crates/oxc_linter/src
- rules/unicorn
- snapshots
2 files changed
+64
-4
lines changedLines changed: 57 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
161 | 161 | | |
162 | 162 | | |
163 | 163 | | |
164 | | - | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
165 | 168 | | |
166 | 169 | | |
167 | 170 | | |
| |||
195 | 198 | | |
196 | 199 | | |
197 | 200 | | |
198 | | - | |
199 | | - | |
200 | | - | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
201 | 205 | | |
202 | 206 | | |
203 | 207 | | |
| |||
584 | 588 | | |
585 | 589 | | |
586 | 590 | | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
587 | 636 | | |
588 | 637 | | |
589 | 638 | | |
| |||
824 | 873 | | |
825 | 874 | | |
826 | 875 | | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
827 | 880 | | |
828 | 881 | | |
829 | 882 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
410 | 410 | | |
411 | 411 | | |
412 | 412 | | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
0 commit comments