Using Stylelint Code Quality Tool
PyCharm provides facilities to run CSS-specific code quality inspections through integration with the Stylelint code verification tool. The tool registers itself as a PyCharm code inspection: it checks CSS code for most common mistakes and discrepancies without running the application. When a tool is activated, it launches automatically on the edited CSS file. Discrepancies are highlighted and reported in pop-up information windows, a pop-up window appears when you hover the mouse pointer over a stripe in the Validation sidebar. You can also press Alt+Enter to examine errors and apply suggested quick fixes. Learn more about inspections and intention actions at Code Inspection and Intention Actions.
On this page:
Before you start
- Integration with PyCharm is supported through the CSS plugin. The plugin is bundled with PyCharm and activated by default. If the plugin is not activated, enable it on the Plugins page of the Settings / Preferences Dialog as described in Enabling and Disabling Plugins.
- Stylelint is run through NodeJS, therefore make sure the NodeJS framework is downloaded and installed on your computer. The framework also contains the Node Package Manager(npm) through which Stylelint is installed.
- Integration with NodeJS and NPM is supported through the NodeJs plugin. The plugin is not bundled with PyCharm, but it can be installed from the JetBrains plugin repository as described in Installing, Updating and Uninstalling Repository Plugins and Enabling and Disabling Plugins.
- Open the Settings / Preferences Dialog by pressing Ctrl+Alt+S or by choosing for Windows and Linux or for macOS, and click Node.js and NPM under Languages & Frameworks.
- On the Node.js and NPM page that opens, the Packages area shows all the Node.js-dependent packages that are currently installed on your computer, both at the global and at the project level. Click .
- In the Available Packages dialog box that opens, select the
stylelintpackage and click Install Package.
Learn more about installing tools through NPM in Installing and Removing External Software Using Node Package Manager.
Activating and configuring Stylelint
- Open the Settings / Preferences Dialog by pressing Ctrl+Alt+S or by choosing for Windows and Linux or for macOS. Expand the Languages & Frameworks node, and then click Stylelint under Stylesheets. The Stylelint page opens.
- Select the Enable check box to activate Stylelint. After that the controls in the dialog box become available.
- In the Node Interpreter field, specify the NodeJS installation home. Type the path to the NodeJS executable file manually, or click the button and select the location in the dialog box, that opens.
- In the Stylelint Package field, specify the location of the
stylelintpackage installed globally or in the current project, see Using Stylelint Code Quality Tool.