Skip to content

Conversation

KKonstantinov
Copy link
Contributor

This PR's aim is to introduce Prettier to the Typescript SDK, in order to have consistent formatting.

It is a follow up to #953 and effectively closing it. This PR contains the prettier config changes only so maintainers can run npx prettier --write . on the full repo.

Motivation and Context

Formatting is not automatic and there is no code formatting/styling tool to standardize that. That leads to PR code reviews having to manually identify any styling issues as opposed to that being automatic.

It is integrating prettier with the existing ESlint set up, and adding prettier --check . to the "lint" command in package.json

How Has This Been Tested?

Ran prettier --check . and prettier --write . (to apply the styling) on the full repository.

Breaking Changes

None, it's a devDependency.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

As a further step, if Prettier gets agreed on and merged, a few improvements could be done on this initiative:

  • Add Husky or Lefthook to trigger automatic formatting pre-commit
  • Add Husky / Lefthook to trigger prettier check on push commits.
  • Lint Staged can be added to only lint staged files

@KKonstantinov KKonstantinov requested a review from a team as a code owner September 29, 2025 10:07
@KKonstantinov KKonstantinov changed the title prettier and prettier config setup - without prettier run MCP SDK: Add Prettier to Typescript SDK Sep 29, 2025
@KKonstantinov
Copy link
Contributor Author

KKonstantinov commented Sep 29, 2025

Tests are failing because main branch tests are failing (related to the Icon type updated on the spec) - that is sorted in #947, but until that is sorted, this PR (and any other new PRs) will fail on the test step.

Edit: It got fixed on main, so no longer an issue.

"bracketSpacing": true,
"bracketSameLine": false,
"proseWrap": "always",
"arrowParens": "avoid",
Copy link
Contributor

@fredericbarthelet fredericbarthelet Sep 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you add as well the sort imports plugin while at it ? (you need to add @trivago/prettier-plugin-sort-imports as a dev dependency as well)

Suggested change
"arrowParens": "avoid",
"arrowParens": "avoid",
"plugins": ["@trivago/prettier-plugin-sort-imports"],
"importOrder": ["<THIRD_PARTY_MODULES>", "^../", "^./"],
"importOrderSortSpecifiers": true,
"importOrderSeparation": true,

Copy link
Contributor Author

@KKonstantinov KKonstantinov Sep 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an eslint plugin for that I believe rather than prettier.

I also suggest introducing changes in an iterative matter, more can be done after this PR - there's further linting rules we could benefit from.

@ihrpr ihrpr self-assigned this Sep 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants