Skip to content

Install prettier3 + alpha solidity plugin in parallel #640

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: development
Choose a base branch
from

Conversation

antico5
Copy link
Collaborator

@antico5 antico5 commented Feb 24, 2025

<This PR is based on top of the 0.19 update branch>

This PR installs 2 combinations of prettier + plugin versions (prettier2 + solidity v1 plugin and prettier3 + solidity v2 beta puglin) in parallel. This has been done creating two separate implementations of PrettyPrinter, and having each one as an individual package with their own dependencies.

The interface of the PrettyPrinter has been unified to the one of v3 (mainly some functions went from sync to async), so every direct and indirect usage of the printer have been updated as well.

All calls to documentFormat are still being handled by prettier 2 + plugin v1, but 1% of the calls also run prettier3+plugin v2 beta, and logging any exception on sentry.

kanej and others added 5 commits January 30, 2025 18:39
This was previously implicit and depended on a the root build. This
clashes with my attempts to update the typescript version, so I am
scoping the e2e tests to their own build.
This commit at its heart does the following:

1. Updates the version of typescript we are using to 5.5
2. Switches to node16 as our module resolution strategy
3. Updates the underlying node-language-server version we are using

These are all initial steps to allow us to pull in ESM module based dependencies, in particular `slang@19`.

* chore: add eslint config for coc

This brings coc inline with the eslint config pattern found for other
packages in the repo. It showed up as an issue when attempting to update
the typescript version.

* chore: bump version of language server

The language server was 2 years out of date. To maximize ease of
integration with typescript@5 we are updating to the latest version.

* chore: bump version of lodash types

The latest version of lodash types is been taken to better work with
typescript@5.

* chore: bump version of eslint and plugins

Eslint and its plugins are 2 years out of date. They have been brought
up to the same version used in the Hardhat repo.

We initially tried to jump straight to `eslint@10` but backed out with
the config format changes. We will look at this again with the repo
modernization efforts.

* chore: bump verion of @types/node to latest

Node 20 is now the version used in VSCode. The types have been updated
to reflect the new node versions.

* chore: bump version of esbuild

To package the extension we use a bundler, esbuild needs to be updated
to match the new version of typescript.

* chore: update version of typescript

We need better module resolution support as we deal with Slang's ESM
packages, specifically the loading of TS types from commonjs.

* chore: bump node target in tsconfig

To support pulling in more modern ts libraries like Slang@18, we want to
swap to `node16` module resolution. This is not ESM, but the modern
version of commonjs.

It lets us use TS types from Slang from the VSCode extension's commonjs
packages.

* chore: disable lib check on server

This is a hack that we should accept temporarily.

A library that the language server node library uses fails more refined
typechecking in typescript@5. For the moment checking types in dependent
packages is skipped.

* chore: fix linting error on t.type

The update to eslint revealed this equality error.

* chore: update eslint errors

New rules are affecting our naming conventions. Rather than disable the
rule I have scattered disable lines. This is a tradeoff, but we expect a
revamp of the eslint rules based on HH3 in the near future.

* Update bundle script - @solidity-parser got hoisted

---------

Co-authored-by: Armando Andini <[email protected]>
@github-actions github-actions bot added the status:ready This issue is ready to be worked on label Feb 24, 2025
Copy link

codecov bot commented Feb 24, 2025

Codecov Report

Attention: Patch coverage is 47.82609% with 24 lines in your changes missing coverage. Please review.

Project coverage is 53.05%. Comparing base (712e2d1) to head (7446cac).

Files with missing lines Patch % Lines
server/src/utils/prettier3/PrettyPrinter3.ts 20.00% 12 Missing ⚠️
server/src/services/formatting/prettierFormat.ts 41.66% 7 Missing ⚠️
server/src/services/codeactions/onCodeAction.ts 33.33% 2 Missing ⚠️
...er/src/services/formatting/onDocumentFormatting.ts 0.00% 2 Missing ⚠️
...erver/src/services/codeactions/QuickFixResolver.ts 50.00% 1 Missing ⚠️
Additional details and impacted files
@@                  Coverage Diff                   @@
##           upgrade-slang-0.19     #640      +/-   ##
======================================================
- Coverage               53.16%   53.05%   -0.12%     
======================================================
  Files                     226      227       +1     
  Lines                    5199     5223      +24     
  Branches                  801      803       +2     
======================================================
+ Hits                     2764     2771       +7     
- Misses                   2198     2215      +17     
  Partials                  237      237              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@antico5 antico5 force-pushed the upgrade-slang-0.19 branch from 712e2d1 to 63ff95d Compare April 9, 2025 13:39
@kanej kanej force-pushed the upgrade-slang-0.19 branch from af8716f to 4c0da33 Compare April 23, 2025 15:55
@antico5 antico5 force-pushed the upgrade-slang-0.19 branch from 4c0da33 to 5007d98 Compare May 5, 2025 13:35
Base automatically changed from upgrade-slang-0.19 to development May 13, 2025 11:59
@kanej
Copy link
Member

kanej commented Jun 10, 2025

We want to repurpose this PR to support user's who have version 2 of the prettier-plugin-solidity.
We should remove the sampling and add a either a dropdown option to let the user choose in settings between v1 of the prettier-plugin-solidity and v2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:ready This issue is ready to be worked on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants