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
--- 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"
],