Skip to content

Configuration for client and server code

Alberto Santini edited this page Aug 26, 2015 · 1 revision

If you wonder how to lint different part of code, this is a suggestion.

- myproject
--- .eslintrc
--- src
------ client
--------- .eslintrc 
------ server
--------- .eslintrc
  • myproject/.eslintrc contains the common rules. For instance,
rules:
    brace-style: [2, "1tbs"]
    comma-style: [2, "last"]
    default-case: 2
    func-style: [2, "declaration"]
...   
  • src/client/.eslintrc contains client side rules. For instance,
env:
    browser: true

globals:
    angular: false

plugins:
  - angular
  • src/server/.eslintrc contains server side rules. For instance
env:
    node: true

Usually I lint a javascript file when I save it. ESLint is installed also globally. As stated in config help page of ESLint, a globally-installed instance of ESLint can only use globally-installed ESLint plugins. A locally-installed ESLint can make sure of both locally- and globally- installed ESLint plugins. That's I need to install also globally the plugin.

Clone this wiki locally