Skip to content

Instantly share code, notes, and snippets.

@ZheyangSong
Last active October 17, 2019 22:13
Show Gist options
  • Save ZheyangSong/49768a9eeac1bceaff3876931c050884 to your computer and use it in GitHub Desktop.
Save ZheyangSong/49768a9eeac1bceaff3876931c050884 to your computer and use it in GitHub Desktop.
Set Up JS Linter

ESLint

Set Up

  • Install ESLint globally

    $ npm install -g [email protected]

    Verify ESLint is available globally

    $ eslint -v

    The terminal should output version info.

  • Ensure .eslintrc.json and .eslintignore exist at the root of the local repo holding your code:

    When the files are missing, get them from the corresponding Github repo.

    Before R3.2, find the files from below branches. Afterwards they should be avaliable and up-to-date on master branch.

  • Enable ESLint in WebStorm

    • Go to Perference > Languages & Frameworks > JavaScript > Code Quality Tools > ESLint
    • Select the Enable checkbox
    • Set ESLint package to /usr/local/lib/node_modules/eslint/
    • Click OK to save

Basic usage

  • To run ESLint on specific file/directory:

    $ eslint <relative/absolute path to the file/directory>
  • To let ESLint automatically fix some safe-to-fix errors:

    $ eslint --fix <relative/absolute path to the file/directory>

    A list of fixable errors can be found here(marked by wrench icon).

  • To disable some ESLint rule for certain code block/statement, find details from here

    /* eslint-disable */
    {
      foo();
      bar();
      baz();
    }
    /* eslint-enable */
    
    alert('foo'); // eslint-disable-line
    
    // eslint-disable-next-line
    alert('foo');

References:

CSSLint

Basic Usage

  • Adjust linting rules: Modify .csslintrc at the root of contrail-web-core repo.
  • Run Linting task against some repo(s) (webCore, webController, webStorage and serverManager):
    1. navigate into the root folder of contrail-web-core repo.

    2. run below command

      $ make css-lint REPO=<comma-seperated-repo-list>

References:

Required Dependencies:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment