Skip to content

Style Guide

Timothy Wang edited this page May 11, 2018 · 9 revisions

JS/React

We use standard

flycheck javascript-standard has been preinstalled for spacemacs in the dev docker container, just use it.

  • How to check if flycheck javascript-standard is installed in Spacemacs?
SPC e v

to verify installation.

Make sure the output is the same as the following for javascript-standard

Syntax checkers for buffer registry.js in js2-mode:

  javascript-eslint (disabled)
    - may enable:  Automatically disabled!
    - executable:  Found at /usr/bin/eslint
    - config file: missing or incorrect

  javascript-jshint (disabled)
    - may enable:         Automatically disabled!
    - executable:         Not found
    - configuration file: Not found

  javascript-standard
    - may enable: yes
    - executable: Found at /root/projects/VUI_tim/node_modules/.bin/standard

Flycheck Mode is enabled. Use M-m u C-c ! x to enable disabled checkers.

If executable is not found, set the javascript-standard executable to [Repo]/node_modules/.bin/standard. Make sure node_modules/.bin/standard exists, otherwise run

npm install

More information see Flycheck and Standard

Sublime Text 3 config

According to standard's document:

Using Package Control, install SublimeLinter and SublimeLinter-contrib-standard.

For automatic formatting on save, install StandardFormat.

Active jsx support:

Open Preferences -> Package Settings -> SublimeLinter -> Settings.

Copy below codes to the file opened in right half window:

// SublimeLinter Settings - User
{
  "syntax_map": {
        "html (django)": "html",
        "html (rails)": "html",
        "html 5": "html",
        "javascript (babel)": "javascript",
        "magicpython": "python",
        "php": "html",
        "python django": "python",
        "pythonimproved": "python",
        "jsx": "javascript"
    }
}

Save and close it.

Open Preferences -> Package Settings -> Standard For -> Settings - User.

Copy below codes to the file opened:

{
  "extensions": ["js", "jsx"],
  "selectors": {
        "html": "source.js.embedded.html",
        "vue": "source.js.embedded.html",
        "jsx": "source.js.jsx",
    }
}

Save and close it.

Now jsx should be detected and fixed when you save the file.

Solidity

We use Solium

The .soliumrc.json can be found at /root in dev container

{
  "extends": "solium:recommended",
  "plugins": [
    "security"
  ],
  "rules": {
    "quotes": [
      "error",
      "double"
    ],
    "indentation": [
      "error",
      4
    ],
    "max-len": [
      "error",
      99
    ]
  }

Flycheck with solium-checker has been pre-configured for spacemacs.

Clone this wiki locally