Now that we switched to ESLint, that we agreed on what our coding standards should be and now that we can auto-format our JS, there are a few more configuration options we can use to be even stricter.

http://eslint.org/docs/rules/

For reference here is the current config:

{
  "env": {
    "browser": true
  },
  "globals": {
    "Drupal": true,
    "drupalSettings": true,
    "domready": true,
    "jQuery": true,
    "_": true,
    "matchMedia": true,
    "Backbone": true,
    "Modernizr": true,
    "CKEDITOR": true
  },
  "rules": {
    "eqeqeq": [2, "smart"],
    "guard-for-in": 2,
    "no-undef": 2,
    //"no-unused-vars": [2, {"vars": "local", "args": "none"}],
    "no-unused-vars": 0,
    "strict": 2,
    "new-cap": 0,
    "quotes": 0,
    "camelcase": 0,
    "no-underscore-dangle": 0,
    "no-new": 0,
    "no-alert": 0,
    "no-use-before-define": 0,
    "consistent-return": 0,
    "no-constant-condition": 0
  }
}

Comments

nod_’s picture

Title: Deceide ESLint config » Decide ESLint config
nod_’s picture

Proposed config in child issue:

{
  "env": {
    "browser": true
  },
  "globals": {
    "Drupal": true,
    "drupalSettings": true,
    "domready": true,
    "jQuery": true,
    "_": true,
    "matchMedia": true,
    "Backbone": true,
    "Modernizr": true,
    "CKEDITOR": true
  },
  "rules": {
    "block-scoped-var": 2,
    "brace-style": [2, "stroustrup", { "allowSingleLine": true }],
    "comma-style": [2, "last"],
    "eqeqeq": [2, "smart"],
    "guard-for-in": 2,
    "no-mixed-spaces-and-tabs": 2,
    "no-trailing-spaces": 2,
    "no-undef": 2,
    "no-undefined": 2,
    "no-unused-vars": [2, {"vars": "local", "args": "none"}],
    "semi": [2, "always"],
    "space-after-keywords": [2, "always", {"checkFunctionKeyword": true}],
    "spaced-line-comment": [2, "always"],
    "strict": 2,
    "new-cap": 0,
    "quotes": 0,
    "camelcase": 0,
    "no-underscore-dangle": 0,
    "no-new": 0,
    "no-alert": 0,
    "no-use-before-define": 0,
    "consistent-return": 0
  }
}
nod_’s picture

All right, I'm happy enough with the config now. It's strict and cover a lot of our coding standards.

Well done everyone on getting all our JS up to snuff :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

andriyun’s picture

How about eslint config for drupal?
What you thinking about this proposition https://www.drupal.org/node/1955232#comment-8936173 ?

nod_’s picture