To use Prettier in IntelliJ IDEA, PhpStorm, PyCharm, and other JetBrains IDEs, please install this plugin. To run Prettier on save in older IDE versions, you can set up a file watcher following the instructions below. Running Prettier on save using File Watcher. Inside PhpStorm, open the Plugins setting menu. Mac: Preferences → Plugins Win: File → Settings → Plugins Search for wakatime. Click the green Install button. Re-launch PhpStorm. Enter your API key, then click Save. Use PhpStorm like you normally do and your coding activity will be displayed on your WakaTime Dashboard. Provides Twig Template Language support.
PhpStorm integrates with ESLint which brings a wide range of linting rules that can also be extended with plugins. PhpStorm shows warnings and errors reported by ESLint right in the editor, as you type. With ESLint, you can also use JavaScript Standard Style as well as lint your TypeScript code.
Besides JavaScript and TypeScript, ESLint can be applied to files of other types in the entire project or in its specific parts, see Configure linting scope.
Before you start
Download and install Node.js.
Make sure a local Node.js interpreter is configured in your project: open the Settings/Preferences dialog Ctrl+Alt+S and go to Languages and Frameworks | Node.js and NPM. The Node Interpreter field shows the default project Node.js interpreter.
Learn more from Configuring a local Node.js interpreter.
Install ESLint
In the embedded Terminal (Alt+F12), type one of the following commands:
npm install --g eslint
for global installation.npm install --save-dev eslint
to install ESLint as a development dependency.
Optionally, install additional plugins, for example, eslint-plugin-react to lint React applications.
Activate and configure ESLint in PhpStorm
By default, ESLint is disabled. You can choose to configure it automatically or specify all the configuration settings manually.
Configure ESLint automatically
With automatic configuration, PhpStorm uses the ESLint package from the project node_modules folder and the .eslintrc.* configuration file from the folder where the current file is stored. If no .eslintrc.* is found in the current file folder, PhpStorm will look for one in its parent folders up to the project root.
If you have several package.json files with ESLint listed as a dependency, PhpStorm starts a separate process for each package.json and processes everything below it. This lets you apply a specific ESLint version or a specific set of plugins to each path in a monorepo or a project with multiple ESLint configurations.
To configure ESLint automatically in the current project, open the Settings/Preferences dialog Ctrl+Alt+S, go to Languages and Frameworks | JavaScript | Code Quality Tools | ESLint, and select the Automatic ESLint configuration option.
To configure ESLint automatically in all new projects, open the Settings for New Projects dialog (File | Settings for New Projects), go to Languages and Frameworks | JavaScript | Code Quality Tools | ESLint, and select the Automatic ESLint configuration option.
Configure ESLint manually
With manual configuration, you can use a custom ESLint package, configuration file, and working directories, as well as apply various additional rules and options.
In the Settings/Preferences dialog Ctrl+Alt+S, go to Languages and Frameworks | JavaScript | Code Quality Tools | ESLint, and select Manual ESLint configuration.
In the ESLint package field, specify the location of the eslint or standard package.
In the Working directories field, specify the working directories for the ESLint process.
By default the field is empty and PhpStorm detects the working directory automatically. First it looks for a directory closest to the linted file which contains a .eslintignore or .eslintrc.* file, or a package.json file with either a
eslintIgnore
or aeslintConfig
property.If the auto-detected working directory doesn't match your project configuration, you need to specify the working directory (directories) manually. Use semicolons as separators. The acceptable values are:
Absolute paths.
Paths relative to the project base directory (the parent folder of the .idea folder where PhpStorm-specific project metadata is stored). For example:
./
- use project base directory as ESLint process working directory.client;server
- use the <project_base_dir>/client and <project_base_dir>/server as working directories. For files that are neither under the client not under the server folder, the working directory will be auto-detected as described above.packages/*
- each subfolder of the <project_base_dir>/packages folder will be used as the working directory for the corresponding linted files.
Paths relative to the content roots can be used if some linted files are not under project base directory in the folder hierarchy.
Glob patterns that define relative paths to the working directories. For example, with
**/foo -*
each folder with the name starting withfoo-
will be used as the working directory for the corresponding linted files.
Choose the configuration to use.
Automatic search- select this option if ESLint rules are configured in your a package.json or in a .eslintrc.* file. This can be a .eslintrc, .eslintrc.json, or .eslintrc.yaml file, or a file in another supported format, see the ESLint official website for details.
PhpStorm looks for a .eslintrc.* file or for a
eslintConfig
property in a package.json. PhpStorm starts the search from the folder where the file to be checked is stored, then searches in its parent folder, and so on until the project root is reached.Configuration File- select this option to use a custom file and specify the file location in the Path field.
Learn more about configuring ESLint from the ESLint official website.
Optionally:
In the Extra eslint options field, specify additional command-line options to run ESLint with, use spaces as separators.
Learn more about ESLint CLI options from the ESLint official website.
In the Additional rules directory field, specify the location of the files with additional code verification rules. These rules will be applied after the rules from package.json, .eslintrc.*, or a custom configuration file and accordingly will override them.
See the ESLint official website for more information about ESLint configuration files and adding rules.
Configure linting scope
Open the Settings/Preferences dialog Ctrl+Alt+S, go to Languages and Frameworks | JavaScript | Code Quality Tools | ESLint, and select Automatic ESLint configuration or Manual ESLint configuration.
In the Run for files field, specify the pattern that defines the set of files to be linted. You can accept the default pattern or type a custom one.
With the default pattern,
{**/*,*}.{js,ts,jsx,tsx,html,vue}
, ESLint will wake up and process any updated JavaScript, TypeScript, JSX, TSX, HTML, or Vue file. To lint files of other types or files stored in specific folders, use glob patterns to update the default pattern.For example, to automatically reformat CoffeeScript files as well, add
coffee
to the default pattern as follows:To lint files from a specific folder, replace
{**/*,*}
with<path to the folder>*
.Suppose, you have a project with the following structure:
To lint only the files in the coffee folder, update the pattern as follows:
coffee/*.{js,ts,jsx,tsx,html,vue,coffee}As a result, the file linting.coffee will be linted while no_linting.coffee will not.
Fix problems automatically on save
ESLint can fix the detected problems every time your changes are saved either manually, with Ctrl+S, or automatically, when you launch a run/debug configuration, or close PhpStorm, or perform version control actions, see Autosave for details.
Open the Settings/Preferences dialog Ctrl+Alt+S, go to Languages and Frameworks | JavaScript | Code Quality Tools | ESLint, and select the Run eslint --fix on save checkbox.
Lint your code
When installed and enabled, ESLint activates automatically every time you open a JavaScript file.
By default, PhpStorm marks detected problems based on the severity levels from the ESLint configuration. See Configuring ESLint highlighting to learn how to override these settings.
Descriptions of the errors detected in the current file and quick-fixes for them are available from the editor and from the Current File tab of the Problems tool window.
Errors in all previously opened files and quick-fixes for them are shown in the Project Errors tab of the Problems tool window. To open the tool window, click the Inspection widget in the upper-right corner of the editor:
See View problems and apply quick-fixes in the editor and Problems tool window for details.
View problems and apply quick-fixes in the editor
To view the description of a problem, hover over the highlighted code.
To resolve the detected problem, click ESLint: Fix '<rule name>' or press Alt+Shift+Enter.
To resolve all the detected problems in the current file, click More actions (Alt+Enter) and select ESLint: Fix current file from the list.
See View problems and apply quick-fixes in the editor for details.
Alternatively open the Current File tab of the Problems tool window Alt+6, where you can view problem descriptions, apply quick-fixes, navigate to the fragments in the source code where errors occurred, as well as fix them in the Editor Preview pane without leaving the tool window. Learn more from Problems tool window.
You can also configure ESLint to fix all the problems in a file when this file is saved. To configure such behavior, select the Run eslint --fix on save checkbox on the ESLint page of the Settings dialog as described in Activating and configuring ESLint in PhpStorm.
Lint your code in the Problems tool window
To open the Problems tool window, click the Inspections widget in the upper-right corner of the editor.
Alternatively select View | Tool windows | Problems from the main menu or press Alt+6.
The Project Errors tab shows the errors in all files that were opened during the current session, with error messages grouped by files in which they were detected.
Here you can view problem descriptions, apply quick-fixes, navigate to the fragments in the source code where errors occurred, as well as fix them in the Editor Preview pane without leaving the tool window. Learn more from Problems tool window.
Configure highlighting for ESLint
By default, PhpStorm marks the detected errors and warnings based on the severity levels from the ESLint configuration. For example, errors are highlighted with a red squiggly line, while warnings are marked with a yellow background. See Code inspections and Change inspection severity for details.
Change the severity level of a rule in the ESLint configuration
In .eslintrc or under
eslintConfig
in package.json, locate the rule you want to edit and set its ID to1
warn
or to2
error
.Learn more from the ESLint official website.
You can override the severities from the ESLint configuration so that PhpStorm ignores them and shows everything reported by the linter as errors, warnings, or in a custom color.
Ignore the severity levels from the configuration
In the Settings/Preferences dialog Ctrl+Alt+S, select Editor | Inspections. The Inspections page opens.
In the central pane, go to JavaScript | Code quality tools | ESLint.
In the right-hand pane, clear the Use rule severity from the configuration file checkbox and select the severity level to use instead of the default one.
Import code style from ESLint
You can import some of the ESLint code style rules to the PhpStorm JavaScript code style settings. That enables PhpStorm to use more accurate code style options for your project when auto-completing, generating, or refactoring the code or adding import statements. When you use the Reformat action, PhpStorm will then no longer break properly formatted code from the ESLint perspective.
PhpStorm understands ESLint configurations in all official formats: .eslintrc JSON files, package.json files with the eslintConfig
field, as well as JavaScript and YAML configuration files.
When you open your project for the first time, PhpStorm imports the code style from the project ESLint configuration automatically.
If your ESLint configuration is updated (manually or from your version control), open it in the editor and choose Apply ESLint Code Style Rules from the context menu.
Alternatively, just answer Yes to the 'Apply code style from ESLint?' question on top of the file.
The list of applied rules is shown in the Event log tool window:
Use JavaScript Standard Style
You can set JavaScript Standard Style as default JavaScript code style for your application so its main rules are applied when you type the code or reformat it. Since Standard is based on ESLint, you can also use Standard via the PhpStorm ESLint integration.
Install JavaScript Standard
In the embedded Terminal (Alt+F12), type:
npm install standard --save-dev
Learn more from the JavaScript Standard Style official website.
Enable linting with Standard via ESLint
If you open a project where standard
is listed in the project's package.json file, PhpStorm enables linting with Standard automatically.
In the Settings/Preferences dialog Ctrl+Alt+S, go to Languages and Frameworks | JavaScript | Code Quality Tools | ESLint.
On the ESLint page that opens, select Manual ESLint configuration and specify the location of the
standard
package in the ESLint Package field.
Set the JavaScript Standard Style as default
In the Settings/Preferences dialog Ctrl+Alt+S, go to Editor | Code Style | JavaScript.
On the Code Style. JavaScript page that opens, click Set from, and then select JavaScript Standard Style. The style will replace your current scheme.
Moving from WebStorm/Phpstorm to VS Code
Been a user of Phpstorm/webstorm since long and wish to migrate to VS Code ? Skeptical about changing your IDE or the changes that it might bring along ? Fear not, for we will show you how you could setup VS code to be identical to Phpstorm/webstorm.
Why should you migrate to VS Code ?
I love using Webstorm/Phpstorm and it has been the editor of my choice since several years now. But here are a few advantages that I saw that compelled me try out VS Code –
- VS Code provides the same functionality as Webstorm/Phpstorm
- Free of cost (thanks to Microsoft for making it Open Source)
- It is fast. (In fact, faster than Webstorm/Phpstorm and lighter in terms of RAM usage)
Lets see how to get this IDE setup
Setting Up VS Code
Firstly, you should have installed VS Code. If you haven’t, do so by downloading it from its official source
By default, VS Code does not come with out-of-the-box support for many languages like PHP, Java, Ruby, etc or even frameworks like React, Vue, Svelte, Symfony, etc. Thankfully, there are extensions to support almost every language and framework.
You will find a list of useful extensions which are highly recommended to make your new IDE function just like Phpstorm/Webstorm. In general, to keep your IDE fast, the lesser the number of extensions, the better. Consequently, only the bare essential extensions have been listed.
Recommended Extensions
1. IntelliJ Keybindings
This extension ensures your transition to VS Code to be less cumbersome by allowing you to use the same keyboard shortcuts as you did with WebStorm/PhpStorm.
There are a few exceptions but its much better than having to learn new keyboard combinations all over.
2. IntelliSense for CSS class names in HTML
As the name suggests, this adds auto-complete support for css classes in your html files.
3. Gitlens
Gitlens is a cool extension that can be used for all your git based tasks. Allows you to check a file’s history, annotate them, explore repositories, see and compare your stashed items and so on.
4. Javascript Snippets
This extension installs handy javascript snippets to speed up your development. This gives you a functionality similar to that of Live Templates in Webstorm/Phpstorm. You can also add your custom javascript snippets at ~/.config/Code/User/snippets/javascript.json
5. Extensions to Support PHP
- Php Pack – Adds support for Php
- Php Intellisense – Adds autocompletion and refactoring support for Php
- Php-Debug – Adds debug support for php via XDebug
6. Extensions to Support Symfony + Twig
- Symfony – Adds debug/autocomplete support for Symfony
- Twig – Adds support for Twig syntax
7. Linters
Highly recommended if you work with Typescript and/or Javascript.
- TSLint – Adds support for TSLint
- EsLint – Integrates ESLint JavaScript with VS Code
8. Docker
If you’re using docker, then this extension will be your ally. It helps you to build, manage, deploy and debug your containerized applications.
9. Reveal
This extension is the equivalent of the Select Opened File button found in PhpStorm/WebStorm. Its adds a similar button to allow you to quickly highlight an open file in the File Explorer/sidebar.
10. Code Formatting
- Prettier – Formats Code with Prettier
- EditorConfig – Adds EditorConfig Support for VS Code
11. Auto Rename Tag
As the name suggests, this extension will rename matching tags like <html></html>
while you edit them. VS code does this automatically for html files but other file formats aren’t supported. To add support for every other format, use this extension. I find it very helpful while using frameworks like React, Vue, Svelte or any other frameworks that use JSX or even XML files.
12. Syntax Highlighting for Apache, yaml and dotenv
- Apache Conf – Highlights syntax for apache configuration files
- Yaml – Adds Yaml language support
- Dotenv – Adds support for dotenv file syntax
13. Settings Sync
Settings Sync helps you to synchronize your settings between multiple machines. Synchronizing settings has become absolutely essential for people in 2020 who are forced to toggle between work and work from home (thanks Corona!) NOTE: To sync settings, there exists a native way to do it within VS Code. I’d suggest using this recommended way instead of the extension. The extension nonetheless serves as an excellent alternate option.
Phpstorm Prettier Vue
14. Rest Client
If you need to test your API without leaving your IDE, this extension does a great job. Its an alternative to using Postman or Insomnia for the same.
15. Improve Code Readability
- Bracket Pair Colorizer – This extension colorizes matching brackets
- Indent Rainbow – Makes indentation easier to read by adding colours
Bonus: Custom Vscode Icons
This extension adds custom icons for files according to their extension. For example, package.json
files will have an icon with npm written on it, thus making it easier to identify the file.
Bonus Theme: Darcula IntelliJ Theme
Phpstorm Prettier Php
Do you prefer Webstorm’s / Phpstorm’s Darcula theme ? If yes, then this extension is for you!
I’m sure that there are tons of other extensions available at VS code’s marketplace. Feel free to try them out and if they’re worth it, recommend them to the dev community as well.
Update VS Code Settings
Once you’ve installed all the necessary extensions, its time to update the settings of your new IDE. To open the settings, you can use the File Menu (Preferences => Settings) or you could hit Ctrl + ,. This will open up your Settings. You can tinker with the settings as you’d like.
You can also update the settings.json
directly. Hit Ctrl + Shift + P and type settings.json
and then select Preferences: Open Settings (JSON).
You should now have your settings.json file on the screen and could update it as shown below. And you do not need to worry about updating settings of extensions that you haven’t installed. Because, in that case, those settings will simply have no effect. So you could directly copy-paste the following settings –
Phpstorm Prettier Not Working
Useful Keyboard Shortcuts
Phpstorm Prettier Js
Here are a few new keyboard shortcuts that you might wanna learn to make your life easier.
- Open command Palette => Ctrl + Shift + PORF1 key
- Open Settings => Ctrl + ,
- Select all occurrences of Find match => Ctrl + Shift + L
- Add selection/cursor to next match =>Alt + J
- Jump to matching bracket =>Ctrl + Shift +
To help with your transition, here’s a link to my VS Code Settings. You can most certainly use it as a reference. Also, once you finish setting up your new IDE, feel free to go through the official Tips & tricks.
Hope it helps 😉