madskristensen / javascriptprettier Goto Github PK
View Code? Open in Web Editor NEWA Visual Studio extension
License: Other
A Visual Studio extension
License: Other
In vscode running the editor.action.formatDocument
command in a javascript file makes the editor scroll to the last line of the file which is really annoying. It happens for large files that are 6000+ lines. It tends to happen when the content of the line the cursor is on changes due to being formatted.
I've disabled all extensions apart from prettier and it's still happening. I also set up a new codespace and installed prettier and no other extensions and it happens in there.
Since the update yesterday the prettier does nothing in my vsc
I can an error message that there's no css formatted installed.
prettify my code
.prettierignore file seems to be ignored
File is formatted
File should not be formatted
The 'Format on Save' option seems to be ignoring the .prettierignore file (which is in the root folder of my project) - when I save a file, even though it's listed in the .prettierignore file, it still gets prettified.
I've tried npm installing Prettier (V1 and V2), or using the Prettier built into the extension, with no success.
But if I run Prettier from the command line, the .prettierignore file is not ignored.
Is this a bug/missing features, or could I be doing something wrong?
(I'm using VS2019, and Node.js 12.18.4)
At the moment if there's a single change made by prettier in a file then the whole files text is replaced, that means every line is shown as changed in VS, and for large files the syntax highlighting takes a little while to re-parse the file which can be a little jarring.
It'd be better if only the changed lines were updated, if possible.
Now that 1.4.0 has been released with TypeScript support, it'd be really cool to have that support in Visual Studio
Comments on JS code are being oddly formated
Every time a use preetier to format it add spaces to the comment like:
And if I format again, the result will be:
And so on
A normal indentation and format.
I have to write some Chinese Words in alert or in comments.
But after I click Make Prettier button, the Chinese words to be garbled.
I key the code: alert('系統錯誤,請稍後再試!');
Then I click Make Prettier button.
And the code become: alert("�t�ο��~�A�еy���A�աI");
Non-breaking spaces are garbled.
'▕ ▏'
node_modules/.bin/prettier.cmd --write .
) is fineThe extension creates from the valid string '▕ ▏'
the new string '???'
.
should be preserved as it is with the command line
ref #2
Menu for prettier keeps saying "Make Prettier (installing npm modules ...)"
Menu should switch to "Make prettier" and actually format the code.
How would one go about adding support for Vue?
In some other editors (i.e. VS Code), Prettier can be configured to format on save. It would be great to have this functionality in Visual Studio as well.
I am not sure how feasible this is as it is likely largely dependent on the capabilities of a VS extensions. Can anyone provide any insight into the level of difficulty for something like this? I am happy to look into it myself and potentially in attempt a contribution for it if the effort is realistic.
Thanks!
Does not install node module prettier
Context menu item is grayed out with the text "(installing npm modules...)"
I checked the location this plugin attempts to install the prettier node module and the module was not installed there. I restarted VS again to see if it would install, it still did not. I did not see any error messages indicating there was a failure. I manually installed prettier at the expected location. Afterwards the menu item was active. Also, a note here just for awareness but will potentially be a new issue, once the menu item was active it didn't seem to perform any formatting.
Also, I think it would be helpful if the README stated it will install prettier itself, at first I thought it was going to try to use the global version installed by yarn.
I do appreciate the creation of this extension, I was pleasantly surprise to see VS listed as a supported editor.
Formatting function calls with functions as parameters does not indent correctly. The current version of prettier seems to resolve this issue.
request
.get("/api/session", {
headers: { "Content-Type": "application/json" },
handleAs: "json"
})
.then(
function () {
alert("success");
},
function (err) {
alert("failure");
}
);
Notice the success and error functions passed to the then
function are at the same indentation as the .then
line.
This seems to be fixed with the current version 1.7.4 as the playground (https://prettier.io/playground/) formats it correctly.
How to set options (https://github.com/prettier/prettier#api) via Visual Studio extension?
singleQuotes
for exampleNo way to do it
Extension options of config file for that
Where does this extension read a .prettierrc
from?
Does not read config from .prettierrc
Read config from .prettierrc
and format accordingly.
It would be great if they added support for the new Visual Studio 2022
It does not appear in the marketplace
Appear in the marketplace
Right click menu always reads "Make Prettier (installing npm modules...)"
Context menu item reads "Make Prettier (installing npm modules...)"
The make prettier option should be available
I have downloaded a fork of the source and found the issue to be with line 73 of PrettierCommand.cs which reads:
if (pguidCmdGroup == _commandGroup && prgCmds[0].cmdID == _commandId)
However, the value of pguidCmdGroup is {60120aad-4139-4f1c-a5b3-d0c68fff2511}
while the value of _commandGroup is {1adbe5b8-de7d-446c-85d6-c1c121aacff3}
. Because of this, the inside block that sets the appropriate status never runs.
I would update and submit a pull request, but I'm unsure why the mismatch occurs nor what the correct value should be for VS 2017 RTM.
Edit: I have verified that the code that installs the NPM module returns successfully. However, when I check C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Web\External\node_modules
, the module does not exist. I do have the module installed globally, so that may be affecting the install. Regardless, the issue appears to step from the command group ID check noted above.
Able to use .eslintrc.json instead of .prettierrc. Other Prettier formatters e.g. for Visual Studio Code uses this. Often eslint is already used and having 2 files specifying same things is not a good thing.
Ignores rules set by eslint
Look for configuration files by order
.prettierrc > .eslintrc > .eslintrc.json
Running Prettier on a file that includes the Optional chaining operator (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining) causes a syntax error
The file is not prettified and there is an error in the Output:
11/17/2021 11:18:07 AM: [error] stdin: SyntaxError: Expression expected. (146:20)
[error] 144 | (c) =>
[error] 145 | c.value &&
[error] > 146 | (c.value?.toString() === value ||
[error] | ^
[error] 147 | parseFloat(c.value?.toString()) === parseFloat(value))
[error] 148 | ) !== index
[error] 149 | ) {
(Because I'm not sure the text will line up properly here, I want to point out that in the output the caret is pointing to the period after the question mark in "(c.value?.toString()")
Prettier properly parses the code and makes it pretty.
Is it planned to add prettier-option for cshtml-files, which contain <script>
tag?
No way to do it
Formatting code in file
After installing from VS Tools->Extensions, I am getting on the right click menu for JS Files - Disabled menu : "Make Prettier (installing npm modules)"
Same thing happening when I am installing [JavaScript_Prettier_v2.1.47] directly by downloading from Visual Studio marketplace.
Pls advise what to do...
Seeing menu option (Disabled) : "Make Prettier (installing npm modules)".
This menu option should be enabled for formatting the JS files.
Any plans to make this extension also make HTML and CSS prettier, not just JS and TS?
I am unable to install the extension.
Download extension "JavaScript_Prettier_v2.1.47.vsix"
Use VS Code UI or cammand line to try and install
Get error message: "extension/package.json not found inside zip."
Fails to install, complains of missing json file
Install and work without error messages.
Can I apply the Prettier only for certain functions in my JS file?
NA
Currently once applied entire file is formatted.
I wanted to selectively apply Prettier formatting to my functions, so that Pull Request can be created only for the changes I made to function. I wanted to make the changes in stages so that Pull Request review becomes faster.
Not available in JavaScript files
I am not sure whether I am missing something, but I installed the extension, and I don't see anything in the context menu to run it when I am in a .js
file
No way to use the extension
I should see the option to be able to run
Formatting of model properties of type ko.observable are formatted wrong, causing code errors.
Create a class containing a knockout based boolean property
closeButtonVisible = ko.observable < boolean > false;
Causing the following code to be invalid: vm.closeButtonVisible(true);
Cannot invoke an expression whose type lacks a call signature. Type 'Boolean' has no compatible call signatures-
closeButtonVisible = ko.observable<boolean>(false);
Below is the output I see whenever I open my static website project. It appears I can't upgrade the Node.js that VS uses.
11/20/2017 8:20:48 PM: npm install [email protected] (this can take a few minutes)
11/20/2017 8:20:49 PM: npm WARN npm npm does not support Node.js v5.4.1
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8.
npm WARN npm You can find the latest version at https://nodejs.org/
npm ERR! Buffer.alloc is not a function
npm is not happy.
Successfully make my js pretty.
I would like to be able to use this extension with my TypeScript files.
Can this extension first try to see if the current project have prettier installed ? So instead of _installDir we'll look for project dir ?
Prettier versions change the output from time to time and the version that is bundled with the extension might create a different output than the one the user has installed locally in their project
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.