[tcgc] add language-specific linting rules for special / reserved words
- Dominant language
- TypeScript
- Stars
- 27
- Forks
- 90
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 156
Description
I believe in all of our language emitters, there are special words that can't be used in specific contexts. For example, you can't have a parameter called `if`. Each language is currently padding these names in their generated code so the code can actually compile. I'm proposing that we also have linter warnings for this.
We already have a [test server test](https://github.com/microsoft/typespec/blob/4d47819082c0ec9cea92f0d1cec8940fbd40de4c/packages/http-specs/specs/special-words/main.tsp) for these scenarios. I'm thinking we have a list of words that are reserved for all languages, and also language-specific lists of words that inherit from the shared words list. Then, we could expose these under `best-practices:{language}`. Look at [`propertyNameConflictRule`](https://github.com/Azure/typespec-azure/blob/main/packages/typespec-client-generator-core/src/rules/property-name-conflict.rule.ts) in [`best-practices:csharp`](https://github.com/Azure/typespec-azure/blob/main/packages/typespec-client-generator-core/src/linter.ts#L13)
Contributor guide
Research direction
Start with the existing test server case at packages/http-specs/specs/special-words/main.tsp, then read property-name-conflict.rule.ts and the best-practices:csharp registration in linter.ts. Define shared and language-specific reserved-word lists, expose the resulting warnings under best-practices:{language}, and cover the special-word scenarios.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100