cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.8k stars 3.17k forks source link

Update to `prettier` 3.0.0 or later #30147

Open MikeMcC399 opened 1 month ago

MikeMcC399 commented 1 month ago

What would you like?

  1. Update the npm module prettier to minimum prettier@3.0.0, preferably prettier@3.3.3 (or current latest).
  2. Remove the direct use of the deprecated npm module @types/prettier.

Why is this needed?

The npm module @types/prettier is deprecated and the source information has been deleted from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/prettier. The Blog post for Prettier 3.0: Hello, ECMAScript Modules! includes in an API section the information:

Add type definition files required to use Prettier's JavaScript API from TypeScript. This eliminates the need for users to install @types/prettier.

Other

Item Value
Deprecated npm module @types/prettier
npm registry message This is a stub types definition. prettier provides its own type definitions, so you do not need this installed.
Other message
GitHub repo https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/prettier
Repo status Directory removed with deprecation on Jul 29, 2023 PR #66073
Replacement npm module https://www.npmjs.com/package/prettier
Replacement repo https://github.com/prettier/prettier
Replacement documentation https://prettier.io/
Migration docs https://prettier.io/blog/2023/07/05/3.0.0

Where used:

Directory Version
packages/data-context "@types/prettier": "2.4.3"
"prettier": "2.5.1"
gweesin commented 1 month ago

I noticed we're not actually using Prettier to format our code. Should we remove it?

MikeMcC399 commented 1 month ago

@gweesin

I noticed we're not actually using Prettier to format our code. Should we remove it?

I don't believe that removing prettier is an option, since it is used to migrate legacy user configuration files to current formats if the user has prettier installed:

https://github.com/cypress-io/cypress/blob/195cdb11a2af4b124bb15f8a38d62f058614a59d/packages/data-context/src/sources/migration/codegen.ts#L605-L623

This section of code requires updating to migrate to prettier@3 as it otherwise generates a TypeScript error:

TS2322: Type 'Promise' is not assignable to type 'string'.