Bug 1347712 - Add the tree-wide rules and config to the recommended eslint-plugin-mozilla config, to make it easier for outside projects. r?jaws draft
authorMark Banner <standard8@mozilla.com>
Tue, 21 Mar 2017 15:40:33 +0100
changeset 502762 29ab49a46d6f7d8f20a0f42aba13ecca12400773
parent 502761 04e62456b25a5c9d219e010091b7907e6bbcbd02
child 550253 c55a5265646e094b6c6d31e6ea85872ef5f100d5
push id50389
push usermbanner@mozilla.com
push dateWed, 22 Mar 2017 09:44:16 +0000
reviewersjaws
bugs1347712
milestone55.0a1
Bug 1347712 - Add the tree-wide rules and config to the recommended eslint-plugin-mozilla config, to make it easier for outside projects. r?jaws MozReview-Commit-ID: K7X57ZNppkE
tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js
tools/lint/eslint/eslint-plugin-mozilla/package.json
--- a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js
@@ -1,14 +1,34 @@
 "use strict";
 
 module.exports = {
+  // When adding items to this file please check for effects on sub-directories.
+  "plugins": [
+    "mozilla"
+  ],
+  "env": {
+    "browser": true,
+    "es6": true
+  },
+  "parserOptions": {
+    "ecmaVersion": 8
+  },
   // When adding items to this file please check for effects on all of toolkit
   // and browser
   "rules": {
+    "mozilla/avoid-removeChild": "error",
+    "mozilla/avoid-nsISupportsString-preferences": "error",
+    "mozilla/import-globals": "error",
+    "mozilla/no-import-into-var-and-global": "error",
+    "mozilla/no-useless-parameters": "error",
+    "mozilla/no-useless-removeEventListener": "error",
+    "mozilla/use-default-preference-values": "error",
+    "mozilla/use-ownerGlobal": "error",
+
     // Braces only needed for multi-line arrow function blocks
     // "arrow-body-style": ["error", "as-needed"],
 
     // Require spacing around =>
     "arrow-spacing": "error",
 
     // Always require spacing around a single line block
     "block-spacing": "error",
@@ -189,16 +209,19 @@ module.exports = {
     "no-unexpected-multiline": "error",
 
     // No unreachable statements
     "no-unreachable": "error",
 
     // Disallow control flow statements in finally blocks
     "no-unsafe-finally": "error",
 
+    // No (!foo in bar) or (!object instanceof Class)
+    "no-unsafe-negation": "error",
+
     // No declaring variables that are never used
     "no-unused-vars": ["error", {
       "vars": "local",
       "varsIgnorePattern": "^Cc|Ci|Cu|Cr|EXPORTED_SYMBOLS",
       "args": "none"
     }],
 
     // No using variables before defined
@@ -258,20 +281,16 @@ module.exports = {
 
     // Only check typeof against valid results
     "valid-typeof": "error",
 
     // Don't concatenate string literals together (unless they span multiple
     // lines)
     "no-useless-concat": "error"
   },
-  "env": {
-    "es6": true,
-    "browser": true
-  },
   "globals": {
     "BroadcastChannel": false,
     // Specific to Firefox (Chrome code only).
     "ChromeWindow": false,
     "ChromeWorker": false,
     "ChromeUtils": false,
     "Components": false,
     "dump": true,
--- a/tools/lint/eslint/eslint-plugin-mozilla/package.json
+++ b/tools/lint/eslint/eslint-plugin-mozilla/package.json
@@ -1,11 +1,11 @@
 {
   "name": "eslint-plugin-mozilla",
-  "version": "0.2.31",
+  "version": "0.2.32",
   "description": "A collection of rules that help enforce JavaScript coding standard in the Mozilla project.",
   "keywords": [
     "eslint",
     "eslintplugin",
     "eslint-plugin",
     "mozilla",
     "firefox"
   ],