JSCS
CLion lets you verify your JavaScript code using the JSCS linter.
To install JSCS globally
- Open the built-in CLion Terminal (Alt+F12) and type
npm install jscs -g
at the command prompt.
To enable JSCS and configure its behavior in CLion
- In the Settings/Preferences dialog (Ctrl+Alt+S), choose JavaScript under Languages and Frameworks, and then choose JSCS under Code Quality Tools. On the JSCS page, that opens, select the Enable checkbox. After that the other controls on the page become available.
- In the Node Interpreter field, specify the path to Node.js. If you followed the standard installation procedure, CLion detects the path and fills in the field itself.
- In the JSCS Package field, specify the location of the
jscs
package installed in the current project. - Specify the configuration to use.
By default, CLion first looks for a
jscsConfig
property in thepackage.json
file of the current project. If no such property is found, CLion looks for a.jscsrc
or a.jscs.json
configuration file. CLion starts the search from the folder where the file to be checked is stored, then searches in the parent folder, and so on until reaches the project root. Accordingly, you have to define the configuration to apply either as ajscsConfig
property in thepackage.json
file or in a.jscsrc
or a.jscs.json
configuration file, or in a custom JSON configuration file.You can also apply a predefined set of rules, either independently or in combination with a configuration file. In the latter case, the rules from the configuration file override the predefined rules.
- To have CLion look for a
jscsConfig
property in thepackage.json
file or for a.jscsrc
or a.jscs.json
file, choose the Search for config(s) option. - To use a custom file, choose the Configuration File option and specify the location of the file in the Path field. Choose the path from the drop-down list, or type it manually, or click the button and select the relevant file from the dialog box that opens.
- To have a predefined set or rules applied, choose the desired set from the Code Style Preset drop-down list.
- To have CLion look for a
- If necessary, from the Code Style Preset drop-down list, choose the set of predefined rules associated with the code style you use.