Skip to content
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

Update to prettier 3.0.0 or later #30147

Open
MikeMcC399 opened this issue Aug 30, 2024 · 2 comments
Open

Update to prettier 3.0.0 or later #30147

MikeMcC399 opened this issue Aug 30, 2024 · 2 comments
Labels
process: dependencies Related to internal dependencies type: chore Work is required w/ no deliverable to end user

Comments

@MikeMcC399
Copy link
Contributor

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"
@jennifer-shehane jennifer-shehane added process: dependencies Related to internal dependencies type: chore Work is required w/ no deliverable to end user labels Aug 30, 2024
@gweesin
Copy link
Contributor

gweesin commented Aug 31, 2024

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

@MikeMcC399
Copy link
Contributor Author

@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:

export function formatConfig (config: string): string {
try {
const prettier = require('prettier') as typeof import('prettier')
return prettier.format(config, {
semi: false,
singleQuote: true,
endOfLine: 'lf',
parser: 'babel',
})
} catch (e) {
// If they do not have prettier
// We do a basic format using babel, which we
// bundle as part of the binary.
// We don't ship a fully fledged formatter like
// prettier, since it's massively bloats the bundle.
return formatWithBundledBabel(config)
}
}

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'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
process: dependencies Related to internal dependencies type: chore Work is required w/ no deliverable to end user
Projects
None yet
Development

No branches or pull requests

3 participants