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

formatting differently than VSCode format on save #121

Open
sgehrman opened this issue Feb 3, 2021 · 5 comments
Open

formatting differently than VSCode format on save #121

sgehrman opened this issue Feb 3, 2021 · 5 comments

Comments

@sgehrman
Copy link

sgehrman commented Feb 3, 2021

On some files, I lint, format and save in VSCode, but then on push, husky runs pretty-quick and formats some files differently that make it fail the eslint check on push that comes after it when it checks the prettier rules.

@f0urfingeredfish
Copy link

I ran into a similar issue. I think the problem is with the VS Code Prettier extension resolving your prettier config file. Prettier uses cosmic config which allows you to define your prettier config in lots of ways. However prettier-vscode is only looking for .prettierrc or .editorconfig config files. So if you aren't using one of those prettier-vscode falls back to their settings. I fixed this by configuring prettier with a .prettierrc file.

@f0urfingeredfish
Copy link

Well it looks like it should support more config formats https://github.com/prettier/prettier-vscode/blob/3c80018d69fa129fed638f624404e728870e4a90/src/PrettierEditService.ts#L32 but I had issues when it was defined as a prettier.config.js file

@flybayer
Copy link

This might be the same thing as #95

@JounQin
Copy link
Member

JounQin commented Jan 16, 2024

Not sure to understand what's the issue.

A minimal but runnable online reproduction is required.

@69pmb
Copy link

69pmb commented Oct 9, 2024

Hi !
I have a similar issue.
I am using pretty-quick and VsCode on a Vue.js project.
I've enabled the "format on save" option.
However, when I save, it formats the file differently than when formatting with npx pretty-quick.
I think maybe it's because VsCode can't find the Prettier configuration file
Here is my package.json file:

{
  "name": "xxx",
  "version": "0.3.20-0",
  "private": true,
  "scripts": {
    "serve": "vite",
    "build": "vite build",
    "preview": "vite preview",
    "prepare": "husky",
    "lint": "prettier --check .",
    "fix": "prettier --write ."
  },
  "dependencies": {
    "@oruga-ui/oruga-next": "~0.7.0",
    "keycloak-js": "~25.0.4",
    "vue": "~3.5.8",
    "vue-router": "~4.4.5",
  },
  "devDependencies": {
    "@tsconfig/node18": "^18.2.4",
    "@types/node": "^18.18.5",
    "@vitejs/plugin-vue": "^4.6.2",
    "@vue/tsconfig": "~0.5.1",
    "autoprefixer": "^10.4.20",
    "husky": "^9.1.6",
    "postcss": "^8.4.47",
    "postcss-grid-kiss": "^3.1.0",
    "postcss-loader": "^8.1.1",
    "postcss-nested": "^6.2.0",
    "postcss-nesting": "^13.0.0",
    "postcss-simple-vars": "^7.0.1",
    "prettier": "^3.3.3",
    "pretty-quick": "^4.0.0",
    "tslint-config-prettier": "^1.18.0",
    "typescript": "~5.2.0",
    "vite": "^4.5.5",
    "vite-plugin-webpackchunkname": "^0.2.4",
    "vue-tsc": "^2.1.6",
    "webpack": "^5.95.0"
  }
}

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

No branches or pull requests

5 participants