IntelliJ - GradedJestRisk/tools GitHub Wiki

Also covers: Webstorm

Table of Contents

Language-specific configuration

In addition to Code Style

JavaScript

List:

  • activate Node.js code assistance
  • node_modules - Mark as Excluded
  • exclude library for code search/debug

Java

List:

  • import project
  • synchronize maven
  • mark directories with test/source
  • create test configuration Junit, running all tests
  • enable auto-build

Settings

List:

  • select sub-words:
    • use camelHumps
    • honor camelHumps
Show parameters

Shortcut

Must-know

  • Find:
    • file, by name: Shift Shift (you can provide initials, eg foo bar for FoozzzzBariton)
    • string: Ctrl Shift F
  • Go to : Ctrl Shift
    • brace: M
    • panel: Alt + Number (1 - 9)
    • last edit: Backspace (Loop)
  • Action: Ctrl Shift A
  • Rename file: Shift F6
  • Replace in all files: Ctrl Shift R
  • Select:
    • enclosing: Ctrl W
    • next: Alt J (unselect: Shift)
Move selection: Ctrl Shift
  • up: Up
  • down: Down
Navigate: Alt Shift
    • forward: Right
    • backward: Left
Find:
  • this: Ctrl F
  • next: F3
  • previous: Shift F3
Paste history: Ctrl Shift V

Refactor:

  • this: Ctrl Alt Shift T
  • extract: Ctrl Alt
    • constant: C
    • method: M
    • variable: V
    • parameter: P
Test:
  • go to test (matching with code): T
  • rerun last test: Ctrl F5
  • run all test from file: ?

Plugin

List:

Window

List:

  • close: Shift Esc
  • maximize: Ctrl Shift 4
Settings:
  • keep tools pinned on left: Show tools windows bar (Appearance / Windows options / Show tools windows bar)

Debug

whole application (attach)

npm

Guide

Steps:

  • add breakpoint
  • open package.json, scroll on start task
  • click Debug in the gutter: it will run the script and link it to the debugger
  • perform an action that would enter breakpoint
  • check breakpoint is reached in call stack
Alternatively:
  • start anywhere with node --inspect-brk bin/www
  • attach debugger (how ?)

libraries

List (eg., for knex, acquireConnection method in client.js):

  • disable search exclusion on library: node_module / knex - Mark Directory as / Cancel exclusion
  • add breakpoints : search acquireConnection and add breakpoint
  • enable stepping-in libraries: Setting / Build, Execution / Debugger / Stepping / Uncheck "Do not step into library scripts"
You may consider option "Do not step into scripts" and add "internals*" to avoid Node.js code, but it's not working that well for me

environment variables

auto-completion

Use bundled plugin

load in run/debug configuration

Use [EnvFile](https://github.com/Ashald/EnvFile) plugin. In Run.debug configuration, check "Environment variables section" Check "Enable EnvFile". Check "Enable experimental integrations" (mandatory for SpringBoot). Add line, select `.env`file.

Static code checking (lint)

Lint rules fall into 2 categories:

  • formatting, eg indent (make code easier to read) - does not affect the AST
  • code-quality rules, eg no-unused-var (avoid bug introduction) - affect the AST
When come against a rule violation, they can work in 2 mode :
  • alert: warn, keep code as-is.
  • fix
IntelliJ offer support in both categories:
  • read configuration file to implement rule, eg. it keys in the appropriate indent when hitting tab
  • read configuration file detect rule violation "after-the-fact", eg. by underlining it or through Code inspection (Problem Window)
  • fix rule violation, eg. in Reformat (formatting only)

Code Style

Setting:

  • can be imported from Eslint rules (eg, indent)
  • can be imported from .editorconfig
  • can be set manually in Code Style specific section
  • can be set manually in Code Style, section "Other file type"
Fix
  • with Reformat (Ctrl Alt R)
  • with "Fix ESLint problems" contextual menu (launch eslint -fix)
  • with Prettier

editorconfig

EditorConfig properties:

  • indent_style
  • indent_size
  • tab_width
  • end_of_line
  • charset
  • trim_trailing_whitespace
  • insert_final_newline
Scope:
  • general (all files)
  • specific, on file extension
Below a sample for 2 file types
root = true

[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.js]
spaces_around_brackets = both

[*.hbs]
insert_final_newline = false

ESLint

Use ESLint to reformat

⚠️ **GitHub.com Fallback** ⚠️