I have a typescript project formatted with prettier. My issue is when I save code like this:
const thing = await call({ // comment
a: 1
});
Prettier moves the comment to a new line which is not what I want.
const thing = await call({
// comment
a: 1
});
How do I prevent this from happening while retaining all other format settings?
EDIT: I do not want to use another formatter or // prettier-ignore. I need this done from the config file .prettierrc.json
This is a known issue with Prettier. If you're looking for the corresponding bug/feature request, it's here: https://github.com/prettier/prettier/issues/807
I'm pretty sure there is no way to configure this in .prettierrc, as prettier is opinionated. Though this kind of moving of comments to new line only happens when it appears beside opening brackets. If it really annoys you, you could change to a different linter, such as eslint, which to my knowledge does not do the above.
In my experience, you can specify certain areas of your code for prettier to ignore in the .prettierignore which uses the same syntax as a .gitignore. You can also ignore specific comments as this section of their documentation.
Related
Thanks for making papaja. It's really terrific!
I just submitted my first journal article using it and ran into problems. The layout staff don't know what to do with the code chunks and listings that are fine in single-column, full page format, but not in their 2-column format. I'm trying use the class 'jou' option to make 2 columns, but I can't figure out how to control the size of code and listing fonts (possibly by modifying the css, as recommended here), or how to using the latex package 'listings' to set listings to wrap (as recommended here).
I'd be grateful for any advice, and my apologies if I've missed how one might do this in the documentation.
If it's only about getting the listings package to work, you can modify the YAML header that it looks similar to the following:
documentclass : "apa6"
classoption : "jou"
output :
papaja::apa6_pdf:
pandoc_args: --listings
header-includes:
- \lstset{breaklines=true}
However, note that using automatic line breaks will most likely break the code at some points. Therefore, it is worthwhile to consider alternatives: For instance, you could try to use a code style that uses more line breaks. The styler package and add-in might be helpful accomplishing this: https://styler.r-lib.org/
In my Bookdown project, I have both a bookdown::pdf_book and a beamer_presentation specificed in the _output.yml. (Why? Here is an example, and here is the explanation.)
The problem is that pdf_book seems to respect the output_dir specified in _bookdown.yml, but not the beamer_presentation. Thus, when hitting the Build Book button, the presentation won't get into the docs directory, it'll appear in the base directory.
Is there any way to make beamer_presentation respect the output_dir specification?
(Also, it'll mean that something has to be done with the filenames, as by default the the names would be the same.)
EDIT: I realized that using bookdown::beamer_presentation2 instead of beamer_presentation will solve the problem, as it'll respect the output_dir. But I'd call it a partial answer, as my fears in the last sentence realized: this will simply overwrite the pdf_book (as they'll indeed have the same name), so it is still not really working...
Yes, you need to use bookdown::beamer_presentation2, which will respect the output_dir setting in _bookdown.yml.
Regarding to your second problem (two formats having the same output filename), there isn't a nice solution at the moment if you only want to click the Knit button in RStudio---you have to call rmarkdown::render() and specify the output filename in the call, e.g.,
rmarkdown::render('file.Rmd', 'bookdown::pdf_book', output_file = 'book.pdf')
rmarkdown::render('file.Rmd', 'bookdown::beamer_presentation2', output_file = 'beamer.pdf')
Is there a way to disable the printWidth rule warning in prettier?
I want to be able to determine my own line length for readability. In certain cases I want a line break, and in other cases I don't.
I tried this in my .prettierrc file :
{
"singleQuote": true,
"printWidth" : "off"
}
But this does not work.
The short answer is no, you cannot disable it entirely.
There are, however, a few workarounds, but they have caveats.
To quote an answer from this issue on github: https://github.com/prettier/prettier/issues/3468.
printWidth is not a rule but an input into the algorithm they use to generate their output. Meaning, it is required to be there.
One workaround is to set printWidth to a really high number, but although this will prevent lines from breaking, changing this property will affect your entire codebase, causing other lines throughout it to combine into a single line, which is most likely not desired.
Your second option is to disable prettier for a block of code with the // prettier-ignore syntax. The downside to this is that you'll disable all prettier features for this section of the code. Also, I personally don't find it very "clean" to have comments like that all over your code.
You can read about how to use the ignore functionality here: https://prettier.io/docs/en/ignore.html
If you want to disable prettier rules once, just do:
// prettier-ignore
const date = new Date() // prettier disabled on this line
So basically I have a project using Webpack, if I build using Webpack -w, editing the file with another editor will trigger the watch; however if I edit the file using Webstorm, nothing will happen.
I have came across this post, which seems I'm not the only one, however that solution is for Ubuntu, so I was wondering if there is anything similar for Windows?
Thanks
Seems Webpack watch doesn't work if the file is not saved directly. Please try turning 'Safe write' option ( Settings | Appearance & Behavior | System Settings | Use "safe write" (save changes to temporary file first)) off.
In 2020.* the option name is Back up files before saving
Also make sure you use Node's path construction instead of slashes. Example:
entry: {
'MyPackage': path.join(__dirname, 'modules', 'PkgEntry.js'),
...
instead of:
entry: {
'MyPackage': '\\modules\\PkgEntry.js'),
...
Had the same issue today. And accepted answer didn't help me.
Check this page https://confluence.jetbrains.com/display/IDEADEV/Inotify+Watches+Limit and try to increase your Inotify Watches Limit. Helped me.
This is an URL I have to send an invitation to an app of mine:
https://www.facebook.com/dialog/send?app_id=MY_APP_ID&
name=hola&
link=http://www.aWebSite.com&
picture=http://www.aWebSite.com/im01068442.jpg&description=participar!&
redirect_uri=http://elsuperdt.com
I'm trying to have a linebreak included within the description, but I just haven't found a way to do so. How do I do it?
I had the same issue and eventually gave up. Facebook seems to have gone to great lengths to avoid letting us have any linebreaks in the description.
The one thing you can do is add a &caption=first%20line which gets you one linebreak between the caption and the description. (There's a pretty short limit on how long the caption can be though - something like 80 characters.)
Update: this no longer works for send dialogs. It does still work for feed dialogs
Try using <center></center> this will create a new line in Facebook dialog description.
Try including %0D%0A in your description where you want the line break to be. This is the URL-encoded equivalent of a line break.
\n works in message but not in name parameter
I tried center></center> and %0D%0A. Both worked... for a split second. You could see the breaks upon page load, and then, like evil magic, facebook took it away and it was all scrunched up. Too bad. I'm trying to share a daily schedule, which would look much better with line breaks.
You can use blanks that are not posted to facebook in the length of the feed so the line breaks.
Or you just style your post by adding ".........." in the end of each line. This way people would maybe be more attracted to your post as they are eyecatching.