Jetbrains - GradedJestRisk/tools-training GitHub Wiki

Jetbrains

Covers: IntelliJ, Webstorm

CLI

intellij-idea-ultimate . disableNonBundledPlugins nosplash &>/dev/null
intellij-idea-ultimate . disableNonBundledPlugins nosplash </dev/null &>/dev/null &

Manual

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

Spring

To disable inspection of Hibernate column/table mapping Go to Editor/Inspections/JPA and uncheck rule "Unresolved database references in annotations"

Settings

Editor

Selection

Select sub-words:

  • use camelHumps
  • honor camelHumps

Hints

Show parameter name

Tools

Keep tools pinned on left: Show tools windows bar (Appearance / Windows options / Show tools windows bar)

Project

Always Select Opened File

Structure

Always Select Opened statement

Keyboard shortcuts

Resize

Presentation mode: tpm (Toogle Presentation Mode)

  • go fullscren (hide OS bar)
  • hide all tools windows
  • increase zoom level

Zoom:

  • in: Ctrl Alt Shift = (no Numpad)
  • out: Ctrl Alt Shift - (no Numpad)

Change font size: Ctrl + Wheel Changing font size only modifies current window (editor, terminal) font size.

Navigate IDE

Go to panel: Alt + Number (1 - 9)

Find:

  • all (file, actions), by name: Shift Shift (you can provide initials, eg fb for FooBar.js)
  • file, by name: Ctrl Shift N (you can provide initials, eg fb for FooBar.js)
  • actions, by name: Ctrl Shift A
  • string, in all files: Ctrl Shift F

Navigate source

Go to : Ctrl Shift

  • brace: M
  • panel: Alt + Number (1 - 9)
  • last edit: Backspace (Loop)

Previous location in source : Alt Shift

  • forward: Right
  • backward: Left

Fold

Doc

Fold/collapse

  • recursively : Ctrl Alt +
  • all : Ctrl Maj +

Modify source

  • 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

Find

Find:

  • this: Ctrl F
  • next: F3
  • previous: Shift F3

Paste history: Ctrl Shift V

Refactor

Refactor : Ctrl Alt Shift T

Extract: Ctrl Alt

  • constant: C
  • method: M
  • variable: V
  • parameter: P

Window

List:

  • close: Shift Esc
  • maximize: Ctrl Shift 4

Test

Test:

  • go to test (matching with code): T
  • rerun last test: Ctrl F5
  • run all test from file: ?

Plugin

List:

Debug

whole application (attach)

npm

[https://www.jetbrains.com/help/idea/running-and-debugging-node-js.html#ws_node_debug_from_run_tw 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 plugin. In Run.debug configuration, check "Environment variables section" Check "Enable EnvFile". Check "Enable experimental integrations" (mandatory for SpringBoot). Add line, select .envfile.

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 [https://editorconfig.org/ .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 [https://prettier.io/docs/en/webstorm.html 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** ⚠️