Azure / Azure/azure-sdk-for-js
[@azure-rest/ai-inference] client instanciation is not following JS standards
- Dominant language
- TypeScript
- Stars
- 2.3k
- Forks
- 1.4k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 150
Description
- **Package Name**: @azure-rest/ai-inference
- **Package Version**: 1.0.0-beta.5
- **Operating system**: MacOS
- [x] **nodejs**
- **version**: v22.13.1
- [ ] **browser**
- **name/version**:
- [ ] **typescript**
- **version**: 5.8.2
- Is the bug related to **documentation** in
- [x] README.md
- [x] source code documentation
- [x] SDK API docs on https://learn.microsoft.com
**Describe the bug**
It's not specific to this SDK, but while using something like `const client = ModelClient(...)` works, as a JS dev the syntax looks confusing: it's a generally accepted standard in JS/TS that **only classes should use an uppercase**, so we can distinguish constructors from regular functions.
Many linters also throw in an error on this syntax, so it can be an issue in enterprise contexts:

The real issue might only be the documentation and sample code though, as in code the function is properly named `createClient()`: https://github.com/Azure/azure-sdk-for-js/blob/93f4001a1b3a2e1b9294d0bf14aa7beac95ddb3b/sdk/ai/ai-inference-rest/src/modelClient.ts#L24
**Expected behavior**
I would expect the documentation and sample code to follow commonly accepted JS/TS conventions, hence using a regular `createClient()` factory function and not a `ModelClient()` method that could be confused as a class constructor.
It might also be interesting to export the `createClient()` for as default export (to keep compatibility) but also as a proper named export. Having to mix both default exports and named export is generally considered an anti-pattern (again, often triggering linter errors/warnings).
Contributor guide
Assessment
This issue has not been assessed yet.