Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add ESLint Unicorn Plugin for Enhanced Code Quality Standards
Summary
This PR integrates the
eslint-plugin-unicorninto the TypeScript SDK's linting configuration and applies its recommended rules across the entire codebase. The changes enforce modern JavaScript/TypeScript best practices, improve code consistency, and enhance long-termmaintainability.
Motivation and Context
Why This Change is Needed
As an SDK that serves as a reference implementation for the Model Context Protocol, code quality and consistency are paramount. The codebase should exemplify best practices that the broader community can follow when building their own MCP implementations.
Key motivations:
Consistency in a Growing Codebase: As more contributors join the project, having automated enforcement of coding standards reduces cognitive load during code reviews and ensures uniform patterns regardless of who writes the code.
Modern JavaScript/TypeScript Idioms: The unicorn plugin enforces contemporary patterns that are cleaner, more readable, and often more performant.
Filename Conventions: Enforcing
camelCasefilenames eliminates inconsistencies (e.g.,auth-extensions.tsvsauthExtensions.ts) and aligns with common TypeScript/JavaScript conventions in the ecosystem.Reduced Bike-Shedding: Automated linting removes subjective style discussions from PRs, letting reviewers focus on logic and architecture rather than formatting preferences.
Onboarding Experience: New contributors can rely on the linter to guide them toward idiomatic code, reducing the learning curve and back-and-forth in reviews.
Auto-fix Support: The majority of unicorn rules support automatic fixing via
eslint --fix, making it easy for contributors to comply with standards without manual effort.Specific Rules Enabled
The unicorn plugin is added with its recommended configuration, plus some additional rules explicitly enabled and a few pragmatic exceptions:
unicorn/filename-casecamelCaseunicorn/better-regexunicorn/consistent-destructuringunicorn/no-useless-undefinedundefinedin function arguments for clarityunicorn/prevent-abbreviationsparams,args,configare industry-standardunicorn/no-nullnullis semantically meaningful in JSON-RPC and the MCP protocolunicorn/prefer-add-event-listeneronrequestand similar and gives false-positive recommendationsFor the full list of 100+ rules included in the recommended configuration, see the eslint-plugin-unicorn rules documentation.
How Has This Been Tested?
pnpm test)pnpm lint)pnpm build)Breaking Changes
This is a non-breaking change for SDK consumers.
index.tsfiles updated accordingly)For contributors:
pnpm lint --fixTypes of changes
Checklist
Additional Context
Files Renamed (kebab-case → camelCase)
auth-extensions.tsauthExtensions.tsauth-utils.tsauthUtils.tsin-memory.tsinMemory.tszod-compat.tszodCompat.tszod-json-schema-compat.tszodJsonSchemaCompat.tsajv-provider.tsajvProvider.tscfworker-provider.tscfWorkerProvider.tsmcp-server.tsmcpServer.tstask-listing.test.tstaskListing.test.tsFuture Benefits
Once merged, the linter will automatically enforce these standards on all future contributions, ensuring the codebase maintains a consistent, modern style as it evolves.