Skip to content

Tips for Developers

Daniel Kmak edited this page Nov 20, 2019 · 12 revisions

1. ESLint config for Visual Studio Code

If you want to fix ESlint errors in Visual Studio Code change User/Workspace settings, by editing settings.json file. Add:

"eslint.validate": [
    {  
        "language":"javascript",
        "autoFix":true
    },
    {  
        "language":"javascriptreact",
        "autoFix":true
    },
    {  
        "language":"typescript",
        "autoFix":true
    },
    {  
        "language":"typescriptreact",
        "autoFix":true
    }
]

Setup auto-fix linting problems shortcut

  1. Go to keyboard bindings settings in VS Code.
  2. Search for "ESLint: Fix all auto-fixable problems"
  3. Click on found row, Keybinding column and set a desired keyboard shortcut (for example CTRL+SHIFT+I)
  4. Press enter

Running on Windows Subsystem for Linux 2

Debian

Configure .env URLs

You need to get WSL instance IP address. Run this command:

bash.exe -c "ip addr | grep -Ee 'inet.*eth0'"

Grab first IP address and then, for example, before running:

TAG=canary ./origin-docker-run.sh

Change BACKEND_URL in .env file to be using that IP address you just got. For example if command output was:

inet 171.11.151.33/20 brd xxx.xx.xxx.xxx scope global eth0

Then BACKEND_URL should be:

171.11.151.33:3030

2. Debug UI tests in VS Code

Use breakpoints and take advantage of VS Code debugging experience.

  1. Open Debug pane
  2. Open launch.json by clicking settings icon in Debug pane (next to selected configuration)
  3. Add following configuration:
{
    "type": "node",
    "name": "Debug Jest Tests",
    "request": "launch",
    "program": "${workspaceFolder}/node_modules/jest/bin/jest",
    "args": [
        "--runInBand"
    ],
    "cwd": "${workspaceFolder}/packages/origin-ui",
    "console": "integratedTerminal",
    "internalConsoleOptions": "neverOpen",
    "disableOptimisticBPs": true
}
  1. Place breakpoints in UI code, for example, in tests
  2. Select newly added configuration in Debug pane and press start

3. Move VSCode Terminal to the right

https://stackoverflow.com/a/53352975/2166409

Clone this wiki locally