Skip to content

Prettier formats lockfiles #4937

@benmccann

Description

@benmccann

Describe the bug

From @delhanty in #4805 (comment):

So the Prettier issues were that package.json and pnpm-lock.yaml get formatted.

For package.json, I'd expect pnpm format to be a null op. That is the generated boilerplate code should all be passed by prettier --check when pnpm lint is run. (I add pnpm format:check to my package.json just to be able to run a prettier --check without ESLint.)

For pnpm-lock.yaml, the issue is that both Prettier and ESLint use .gitignore for their --ignore-path:

"lint": "prettier --ignore-path .gitignore --check --plugin-search-dir=. . && eslint --ignore-path .gitignore .",
"format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. ."

One of the first things I do is fix that by copying .gitignore to .prettierignore and .eslintignore so that I can edit my package.json to

"lint": "prettier --ignore-path .prettierignore --check --plugin-search-dir=. . && eslint --ignore-path .eslintignore .",
"format": "prettier --ignore-path .prettierignore --write --plugin-search-dir=. .",

.prettierignore and .eslintignore end up being close to the same, but have blocks like

# Ignore lockfiles for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock

which isn't dependent on the choice of PNPM, NPM or YARN.

Reproduction

I chose "SvelteKit demo app" and then

  1. Typescript
  2. ESLint: Yes
  3. Prettier: Yes
  4. Playwright: Yes

If it makes a difference, I develop with pnpm. (With pnpm v7, pnpm init svelte appears broken though.)

cd my-app
pnpm install
pnpm build
pnpm check

pnpm build is necessary to create .svelte-kit/tsconfig.json, which is extended by tsconfig.json.

Logs

No response

System Info

latest

Severity

annoyance

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions