WebStorm & PHPStorm
Search for global node_modules
folder (GLOBAL_NODE_MODULES)
node_modules
folder (GLOBAL_NODE_MODULES)Use the
npm config get prefix
command to find the path to themhy
executable file.The global
node_modules
folder should be around there somewhere. It varies between different systems, maybe it is right next to it, maybe inside alib
directory next to it or the upper levels.Inside the global
node_modules
folder, you'll findmhy/node_modules
. The path to that directory is what we will need.
Generating config files
node_modules
resolution
node_modules
resolutionSince you're using modules coming from mhy
, you need to tell the IDE to include a node_modules
folder outside your project's directory.
Find
GLOBAL_NODE_MODULES/mhy/node_modules
Add the path at
File > Settings > Directories
and mark it asExcluded
andResource root
.
Alias resolution
Alias resolution is done by Webpack. You only need to have a webpack.config.js
file in your root.
ONLY in case you haven't run
mhy config
yet to set-up your empty project, runmhy config webpack -i
to initialize a config file.Make sure at
File > Settings > Webpack
that the feature is turned on.
Prettier (for automatic formatting on save; recommended)
While it's possible to add watchers without the Prettier plugin
, the plugin simply helps you with pre-filling the necessary fields with the necessary values for your watcher.
Install
Prettier plugin
fromFile > Settings > Plugins
Restart IDE
Go to
File > Settings > Tools > File Watchers
Create watcher by clicking the
+
sign.Select
prettier
Set
Scope
toCurrent file
which is more optimal.Set
Program
toGLOBAL_NODE_MODULES/mhy/node_modules/.bin/prettier
(add.cmd
on Windows).Save with
OK
.(Optional) You might want to add change the
Level
of the watcher toGlobal
to be able to re-use it across projects.
Unfortunately you'll need to create watcher for each
File Type
you want the IDE to watch. By default it was creating it only for JavaScript. Most probably you want to addjsx, ts, tsx
watcher also. Do this with copying the watcher and change theFile Type
.
TypeScript
Step 0: If it's necessary, please do
npm i
first for your project, only createtsconfig.json
file after that. This is important to avoid duplicated@types
to be loaded.
ONLY in case you don't have
tsconfig.json
file yet:mhy config typescript -i
Go to
File > Settings > Language & Frameworks > TypeScript
For
TypeScript
setGLOBAL_NODE_MODULES/mhy/node_modules/typescript
Note that in
mhy
TypeScript is only being used to perform type-checks and to generate.d.ts
files. You don't need to enable compilation, that is being done by SWC.
ESLint
ONLY in case you don't have
.eslintrc
file yet:mhy config eslint -i
Go to
File > Settings > Language & Frameworks > JavaScript > Code Quality Tools > ESLint
Enable
For
ESLint package
setGLOBAL_NODE_MODULES/mhy/node_modules/eslint
Go to
Help > Find Action
and typeregistry
Click the first result (
Registry...
)Scroll down to
eslint.additional.file.extensions
and setjs,jsx,ts,tsx
as value.
Tips
Disable automatic
package.json
dependency inspection.Disable statement termination inspection.
CTRL+Enter
at the end of any line. (ONLY in case you choose to continue using ASI which is the default setting.)Set 4 spaces for indent. (ONLY in case you choose to continue using the default setting.)
Make sure you use LF for line endings. Set it globally or project level, and also you can convert every file if needed by selecting the
root folder
thenFile > Line separators
.You might want most settings/watchers to be global (where possible), so you can re-use them for all your projects.
Last updated