Skip to content

Commit e82fea5

Browse files
fix(namespaces): only report when there is value emit (#27)
## PR Checklist - [x] Addresses an existing open issue: fixes #22 - [x] That issue was marked as [`status: accepting prs`](https://github.com/JoshuaKGoldberg/eslint-plugin-erasable-syntax-only/issues?q=is%3Aopen+is%3Aissue+label%3A%22status%3A+accepting+prs%22) - [x] Steps in [CONTRIBUTING.md](https://github.com/JoshuaKGoldberg/eslint-plugin-erasable-syntax-only/blob/main/.github/CONTRIBUTING.md) were taken ## Overview Changes the rule to not report when no value emit child is found in a namespace. Adds [`cached-factory`](https://www.npmjs.com/package/cached-factory) as a dependency to cache checks on individual namespace nodes. Parent namespaces need to check their child namespaces. 💖
1 parent a454e11 commit e82fea5

File tree

6 files changed

+392
-29
lines changed

6 files changed

+392
-29
lines changed

cspell.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"automerge",
1515
"joshuakgoldberg",
1616
"markdownlintignore",
17-
"tseslint"
17+
"tseslint",
18+
"TSESTree"
1819
]
1920
}

docs/rules/namespaces.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
Enforces that code doesn't use TypeScript's `namespaces` with values:
66

7+
## Invalid Code
8+
79
```ts
810
module Values {
911
export const value = "a";
@@ -13,3 +15,15 @@ namespace Values {
1315
export const value = "a";
1416
}
1517
```
18+
19+
## Valid Code
20+
21+
```ts
22+
module Values {
23+
export type Value = "a";
24+
}
25+
26+
namespace Values {
27+
export type Value = "a";
28+
}
29+
```

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
"*": "prettier --ignore-unknown --write"
3838
},
3939
"dependencies": {
40-
"@typescript-eslint/utils": "^8.24.0"
40+
"@typescript-eslint/utils": "^8.24.0",
41+
"cached-factory": "^0.1.0"
4142
},
4243
"devDependencies": {
4344
"@eslint-community/eslint-plugin-eslint-comments": "4.4.1",

pnpm-lock.yaml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)