Closed zyy7259 closed 4 years ago
@zyy7259 Thanks for a PR, I also updated it in this PR: https://github.com/prettier/prettier-vscode/pull/850
@svipas Great work~
I will subscribe PR #850, if it get merged I’ll close this one.
Right now I can’t format Typescript with prettier-eslint in VSCode.
Maybe we can first merge this much simpler PR and publish a patch version, which I think will make Typescript auto formatting with prettier-eslint work in VSCode.
It's literally just yarn.lock
that's failing, I'm dying here losing in-editor formatting
@zyy7259 Could you maybe include the package-lock.json
so the build passes? I think this would greatly increase the chances of seing this PR merged 😉
The original build failed with the following message
npm ERR! cipm can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with `npm install` before continuing.
npm ERR!
npm ERR!
npm ERR! Invalid: lock file's prettier-eslint@8.8.2 does not satisfy prettier-eslint@^9.0.0
npm ERR!
npm ERR! A complete log of this run can be found in:
npm ERR! /home/travis/.npm/_logs/2019-06-26T09_17_12_801Z-debug.log
The command "npm ci" failed and exited with 1 during .
So I run npm install
to update the package-lock.json
. But npm install
leads to many modifications in the package-lock.json
file. I'm not sure if this is ok.
@CiGit What do you of think this one? Prettier-vscode is currently completely impossible to use with TypeScript, which is very frustrating. This would fix the issue (and probably others at the same time).
@WaldoJeffers I use prettier-vscode with typescript and react native right now. What issue are you having?
@WaldoJeffers I use prettier-vscode with typescript and react native right now. What issue are you having?
@shamilovtim I added some details in the first comment.
My versions: global eslint v5.16.0 using yarn instead of pure npm npm 6.9.0 yarn 0.21.3
no local versions of eslint or tslint installed inside my project.
in my package.json I use: "typescript": "^3.4.5" and standard VSC-prettier from the VSC marketplace. this all works together fine with no errors and typescript/my IDE do enough linting that this works fine. would love the newer version though
with "prettier.eslintIntegration": false
, prettier
do format typescript correctly.
with "prettier.eslintIntegration": true
, prettier
stop to work.
@WaldoJeffers I use prettier-vscode with typescript and react native right now. What issue are you having?
@shamilovtim It's detailed in this issue. Simply put, as soon as you use the casting TS syntax foo as number
, Prettier breaks for all files in your project. You can find out more about why it creates this issue here.
I used this syntax in my imports and it does not break prettier for me. I have eslint installed globally and not locally
I used this syntax in my imports and it does not break prettier for me. I have eslint installed globally and not locally
This might be the reason you're not seing any error? Which version are you using?
See above where I listed my versions. Give it a shot and see if you have any luck. All works fine, I would just love a more modern version of prettier for the enhancements to syntax.
I used this syntax in my imports and it does not break prettier for me. I have eslint installed globally and not locally
@shamilovtim What's you current configuration of "prettier.eslintIntegration"
@CiGit any chance getting this one merged down soon? I finally fixed my eslint-prettier integration in my precommit hooks but until this is merged I can't run it from vscode.
@zyy7259 my settings are true for both eslint and tslint, but i don't have tslint installed. still works fine though. 🤷🏻♂️
@zyy7259 which rules do you have enabled? I'm also hitting the issue referenced here: https://github.com/prettier/prettier-vscode/issues/842 . It's a combination of using @typescript-eslint/indent rule and using the const myvar as MyType;
syntax. This rule is in the @typescript-eslint recommended but its possible that you may not be using it.
This will be good, but even better would be if the extension picked up the local version. We've been using v9 for weeks and this extension has lagged behind. 😒
local version or configurable location is great too but there's no outstanding PR for that.
This PR fixes my formatting issues with TypeScript + prettier-eslint
Imo the extension should always prefer the local version over the bundled version. It's not quite clear why it does use the local prettier
installation (as mentioned in the docs) but does not use the local prettier-eslint
installation.
I decided to create a new extension from this repo fork which includes latest Prettier, etc. You can find the repo here: https://github.com/svipas/vscode-prettier-plus and the extension in the VS Code marketplace here: https://marketplace.visualstudio.com/items?itemName=svipas.prettier-plus
What was changed you can find in the CHANGELOG.
I truly respect everyones work that's why I'm forking this repo and keeping all the credits. No hard feelings at all!
This has been merged through another commit. Release coming soon.
I also would like to see local module resolution, but that is work for later.
@ntotten when will it be released?
Prettier with
eslintIntegration
enabled could not format typescript right now.The output of
Prettier
shows:Error while loading rule '@typescript-eslint/restrict-plus-operands'xxx.ts:: You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project" property for @typescript-eslint/parser.
Update prettier-eslint to 9.0.0 would solve this issue