Format with Prettier on save doesn't work in WebStorm 2022.2.2 - webstorm

I installed everything like in official tutorial https://www.jetbrains.com/help/webstorm/prettier.html#ws_prettier_reformat_code and it doesn't work on save, although the checkbox is set.
What can I do to make it work?
Prettier version: 2.7.1
WebStorm version: 2022.2.2

Must be WEB-57086, Prettier plugin doesn't work if you have a directory name in a glob pattern.
Try changing the Run for files: back to default value, {**/*,*}.{js,ts,jsx,tsx,scc,scss,sass}

Also make sure you have correct file extensions included, for instance if you are working with Vue add vue to the list:
{**/*,*}.{js,ts,jsx,tsx,vue}

Related

disable prettier plugin for specific directory

In my typescript & svelte project, I use prettier to format codes.
Also, I use prettier-plugin-organize-imports to automatically organize imports.
However, this plugin does not support svelte yet (it kind of works, but it's buggy), so I want to disable the plugin for *.svelte files while enabling it for *.ts files.
According to the official doc of prettier, it seems impossible to do this by adding options to config file (prettier.config.js).
Is there a good way?
You can create a .prettierignore to exclude files from formatting.
# Ignore artifacts:
build
coverage
# Ignore all HTML files:
*.html
Check the docs.

WebStorm with Babel not working with import statements

I'm using WebStorm 2017.1.3, although also tried with latest EAP, and i can't get import from statement to work. I just keep getting the following error:
import Utils from './utils'
^^^^^^
SyntaxError: Unexpected token import
In my packages.json i have babel-cli, babel-preset-env and babel-preset-es2015 defined. I have followed various blog posts and videos but still get same error.
ES6 is enabled in settings and i tried adding Babel file watch as per documentation but nothing seems to work. This feels like it should be a lot easier and just work, so i must be missing a important part of the jigsaw.
Does anyone have a working step by step, from fresh project, how to guide in configuring webstorm to work with import ?
Some places say use file watch, others say just to change project configuration interpreter to use babel-node. Other say must use Gulp... very confusing.
Thank you.
fLo
To make things clear: this is not about configuring WebStorm, error comes from Node.js interpreter that runs your code. Node.js still doesn't support ES6 modules natively (actually, no JavaScript runtime currently supports them - ECMAScript does not define a "Loader" specification which determines how Modules are inserted into the runtime. The Loader spec is being defined by WHATWG, but is not yet finalized). So, to get ES6 imports/exports accepted, you need using transpilers. Current industry standard is Babel
The most simple way to make it work is the following:
install babel in your project using npm install --save-dev babel-cli babel-preset-env
create a .babelrc file in project root dir:
{ "presets": ["env"] }
in your Node.js Run configuration, pass -r babel-register to Node:
With this configuration, your code will be transpiled on-the-fly by Babel, no file watchers, etc. are needed

Install third-party Markdown extension in Pelican

I'm using Pelican for a static blog, and attempting to install the figure-ref extension. Since I'm using Markdown, the plugin relies on the figureAltCaption third-party Markdown extension. However I have no idea how to install it.
Pelican has an MD_EXTENSIONS configuration option, but I've tried a few obvious options with no luck. It seems like this is a dead-simple gimme but it's not clear how to proceed. Would love some suggestions.
Unfortunately, the author of figureAltCaption appears to have not provided an install script. My suggestion would be to create one and contribute it as a pull request. This tutorial about creating Extensions for Python-Markdown covers creating an install script as well.
However, as a shortcut, you should be able to just copy the figureAltCaption.py file to the appropriate directory. Usually you want the site-packages directory. As this answer shows, just do the following from Python:
>>> import site; site.getsitepackages()
Then copy the figureAltCaption.py file to the first directory returned.
Now that the extension is on your PYTHONPATH, it should be importable. From the Python prompt, try:
import figureAltCaption
If you get no errors, then it worked and you just need to tell Pelican about it.
MD_EXTENSIONS = ['figureAltCaption']

Use ember-i18n with ember-cli production environment

I run into an issue where ember-i18n can be used with an ember-cli server running in development environment. But when I set --environment production I get the following error:
Error: The default Ember.I18n.compile function requires the full Handlebars. Either include the full Handlebars or override Ember.I18n.compile.
The error occurres because ember-cli includes Handlebars-production on production environment. Is there a solution for this problem?
I think I need to precompile the translations.
One way to fix this is to configure ember-cli to include the full handlebars version on production:
app.import({
development: 'vendor/handlebars/handlebars.js',
production: 'vendor/handlebars/handlebars.js'
});
A drawback is that the (much) bigger library is included in the build, only for my translations. I keep looking for a way to precompile my translations.
There is no way to get around importing the full handlebars when using ember-i18n. You do not need to specify the same string import for development and production though. Just add this to your Brocfile:
app.import('vendor/handlebars/handlebars.js');
I had exactly the same issue and this is the solution that Stefan Penner advised. https://github.com/stefanpenner/ember-cli/pull/675#issuecomment-47431195. Worked fine for me. One thing to note though, for some reason I had the import statement as the first import. When it was the last one it didn't seem to work. I didn't try anywhere in between though, or try to debug that issue.

Django - javascript path

sometime simplest things are so complex!
I have some javascript which works fine. I decided to put it in a seperate javascript file that I want to link to my template.
I have put it in folder scripts/a_ajax.js off the root of the application.
Whatever folder structure I've tried has not worked.
I've also read something about that I must put a reference in urlpatterns but I'm not sure what I had to do.
Can anyone help tell me what I have to do to embed this code as a file?
thx
If your Django version is 1.3+: https://docs.djangoproject.com/en/dev/howto/static-files/
If your Django version 1.2.* or lower: https://docs.djangoproject.com/en/1.2/howto/static-files/