Commit e89c5ba
committed
fix(typescript/prefer-namespace-keyword): skip nested
Prevent fix replacing text within the module name or block in the case of nested modules.
Before this PR:
Input:
```ts
module X.Y.module {
x = "module";
}
```
After fix:
```ts
namespace X.Y.namespace {
x = "namespace";
}
```
Prevent this by exiting early if the `TSModuleDeclaration` is nested (i.e. `Y` or `module` in above example).
Note: I discovered this bug when I replaced early `return` with `unwrap` in #15805. IMO it's better to `unwrap` when you believe the check cannot fail, as the panic may alert us to bugs which may otherwise lie undiscovered.
Side note: The design we have with nested `TSModuleDeclaration`s representing `module X.Y.Z {}` is pretty unintutive. I'd like to change it if we can.TSModuleDeclarations (#15806)1 parent 220d01e commit e89c5ba
File tree
1 file changed
+11
-0
lines changed- crates/oxc_linter/src/rules/typescript
1 file changed
+11
-0
lines changedLines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
64 | 70 | | |
65 | 71 | | |
66 | 72 | | |
| |||
133 | 139 | | |
134 | 140 | | |
135 | 141 | | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
136 | 147 | | |
137 | 148 | | |
138 | 149 | | |
| |||
0 commit comments