Bug 1488445 - Remove and replace obsolete ESLint rules. r=mossop
authorMark Banner <standard8@mozilla.com>
Tue, 04 Sep 2018 18:08:43 +0000
changeset 493057 1780997e89ef87b4685cf496438e93c2dd48c64f
parent 493056 8e1a263dd83d5b6a6afacf13205fc0e31135c34d
child 493058 af2c47f0c8d725b2e50a1e43ed3581815a8b66fa
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmossop
bugs1488445
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1488445 - Remove and replace obsolete ESLint rules. r=mossop This removes a number of references to rules that are now deprecated or removed from ESLint. - no-native-reassign is replaced with no-global-assign - no-spaced-func is replaced with func-call-spacing (where enabled) Depends on D4944 Differential Revision: https://phabricator.services.mozilla.com/D4946
accessible/tests/browser/.eslintrc.js
chrome/test/unit/test_resolve_uris.js
devtools/.eslintrc.js
dom/indexedDB/test/helpers.js
dom/presentation/tests/mochitest/PresentationSessionFrameScript.js
mobile/android/.eslintrc.js
mobile/android/tests/browser/robocop/robocop_head.js
testing/web-platform/tests/streams/readable-streams/patched-global.js
testing/web-platform/tests/streams/transform-streams/patched-global.js
toolkit/components/extensions/.eslintrc.js
toolkit/components/extensions/Schemas.jsm
toolkit/components/passwordmgr/test/pwmgr_common.js
tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js
tools/lint/eslint/eslint-plugin-mozilla/package-lock.json
tools/lint/eslint/eslint-plugin-mozilla/package.json
--- a/accessible/tests/browser/.eslintrc.js
+++ b/accessible/tests/browser/.eslintrc.js
@@ -27,89 +27,79 @@ module.exports = {
     "handle-callback-err": ["error", "er"],
     "indent-legacy": ["error", 2, {"SwitchCase": 1}],
     "max-nested-callbacks": ["error", 4],
     "max-params": "off",
     "max-statements": "off",
     "new-cap": ["error", {"capIsNew": false}],
     "new-parens": "error",
     "no-bitwise": "off",
-    "no-catch-shadow": "error",
-    "no-comma-dangle": "off",
     "no-console": "off",
     "no-constant-condition": "off",
     "no-continue": "off",
     "no-div-regex": "off",
     "no-extend-native": "error",
     "no-extra-parens": "off",
-    "no-extra-strict": "off",
     "no-fallthrough": "error",
     "no-floating-decimal": "off",
     "no-inline-comments": "off",
     "no-mixed-requires": "off",
     "no-multi-str": "error",
     "no-multiple-empty-lines": ["error", {"max": 1}],
     "no-new-require": "off",
     "no-param-reassign": "off",
     "no-path-concat": "off",
     "no-plusplus": "off",
     "no-process-env": "off",
     "no-process-exit": "off",
     "no-proto": "error",
-    "no-reserved-keys": "off",
     "no-restricted-modules": "off",
     "no-return-assign": "error",
     "no-script-url": "off",
     "no-shadow": "error",
-    "no-space-before-semi": "off",
     "no-sync": "off",
     "no-ternary": "off",
     "no-throw-literal": "error",
     "no-underscore-dangle": "off",
     "no-undefined": "off",
     "no-unused-vars": ["error", {"vars": "all", "args": "none"}],
     "no-use-before-define": "off",
     "no-var": "off",
     "no-warning-comments": "off",
     "object-shorthand": "off",
     "one-var": ["error", "never"],
     "padded-blocks": ["error", "never"],
     "quote-props": "off",
     "radix": "error",
     "semi-spacing": ["error", {"before": false, "after": true}],
     "sort-vars": "off",
-    "space-in-brackets": "off",
     "space-in-parens": ["error", "never"],
-    "space-unary-word-ops": "off",
     "strict": ["error", "global"],
     "valid-jsdoc": "off",
     "vars-on-top": "off",
     "wrap-iife": "off",
     "wrap-regex": "off",
     "yoda": "error",
     "guard-for-in": "off",
-    "newline-after-var": "off",
     "no-alert": "off",
     "no-eq-null": "off",
     "no-func-assign": "off",
     "no-implied-eval": "off",
     "no-inner-declarations": "off",
     "no-invalid-regexp": "off",
     "no-irregular-whitespace": "off",
     "no-iterator": "off",
     "no-label-var": "off",
     "no-lone-blocks": "off",
     "no-loop-func": "off",
-    "no-negated-in-lhs": "off",
     "no-new": "off",
     "no-new-func": "off",
     "no-new-object": "off",
     "no-obj-calls": "off",
     "no-octal-escape": "off",
     "no-undef-init": "error",
     "object-curly-spacing": "off",
     "no-unused-expressions": "off",
     "no-void": "off",
-    "no-wrap-func": "off",
     "operator-assignment": "off",
     "operator-linebreak": ["error", "after"]
   }
 };
--- a/chrome/test/unit/test_resolve_uris.js
+++ b/chrome/test/unit/test_resolve_uris.js
@@ -77,13 +77,13 @@ function do_run_test() {
       dump(e + "\n");
       do_throw("Should have registered a handler for type '" +
                type + "'\n");
     }
   }
 }
 
 if (typeof run_test === "undefined") {
-  // eslint-disable-next-line no-native-reassign
+  // eslint-disable-next-line no-global-assign
   run_test = function() {
     do_run_test();
   };
 }
--- a/devtools/.eslintrc.js
+++ b/devtools/.eslintrc.js
@@ -248,16 +248,18 @@ module.exports = {
     // Don't require a default case in switch statements. Avoid being forced to
     // add a bogus default when you know all possible cases are handled.
     "default-case": "off",
     // Enforce dots on the next line with property name.
     "dot-location": ["error", "property"],
     // Allow using == instead of ===, in the interest of landing something since
     // the devtools codebase is split on convention here.
     "eqeqeq": "off",
+    // Disallow space between function identifier and application.
+    "func-call-spacing": "error",
     // Don't require function expressions to have a name.
     // This makes the code more verbose and hard to read. Our engine already
     // does a fantastic job assigning a name to the function, which includes
     // the enclosing function name, and worst case you have a line number that
     // you can just look up.
     "func-names": "off",
     // Allow use of function declarations and expressions.
     "func-style": "off",
@@ -283,19 +285,16 @@ module.exports = {
     // operators are followed by a capital letter. Don't warn when capitalized
     // functions are used without the new operator.
     "new-cap": ["error", {"capIsNew": false}],
     // Disallow the omission of parentheses when invoking a constructor with no
     // arguments.
     "new-parens": "error",
     // Allow use of bitwise operators.
     "no-bitwise": "off",
-    // Disallow the catch clause parameter name being the same as a variable in
-    // the outer scope, to avoid confusion.
-    "no-catch-shadow": "error",
     // Allow using the console API.
     "no-console": "off",
     // Allow using constant expressions in conditions like while (true)
     "no-constant-condition": "off",
     // Allow use of the continue statement.
     "no-continue": "off",
     // Allow division operators explicitly at beginning of regular expression.
     "no-div-regex": "off",
@@ -336,33 +335,29 @@ module.exports = {
     // Allow using process.env (not a node environment).
     "no-process-env": "off",
     // Allow using process.exit (not a node environment).
     "no-process-exit": "off",
     // Disallow usage of __proto__ property.
     "no-proto": "error",
     // Disallow multiple spaces in a regular expression literal.
     "no-regex-spaces": "off",
-    // Allow reserved words being used as object literal keys.
-    "no-reserved-keys": "off",
     // Don't restrict usage of specified node modules (not a node environment).
     "no-restricted-modules": "off",
     // Disallow use of assignment in return statement. It is preferable for a
     // single line of code to have only one easily predictable effect.
     "no-return-assign": "error",
     // Allow use of javascript: urls.
     "no-script-url": "off",
     // Warn about declaration of variables already declared in the outer scope.
     // This isn't an error because it sometimes is useful to use the same name
     // in a small helper function rather than having to come up with another
     // random name.
     // Still, making this a warning can help people avoid being confused.
     "no-shadow": "error",
-    // Disallow space between function identifier and application.
-    "no-spaced-func": "error",
     // Allow use of synchronous methods (not a node environment).
     "no-sync": "off",
     // Allow the use of ternary operators.
     "no-ternary": "off",
     // Disallow throwing literals (eg. throw "error" instead of
     // throw new Error("error")).
     "no-throw-literal": "error",
     // Allow dangling underscores in identifiers (for privates).
@@ -393,20 +388,16 @@ module.exports = {
     "quote-props": "off",
     // Require use of the second argument for parseInt().
     "radix": "error",
     // Enforce spacing after semicolons.
     "semi-spacing": ["error", {"before": false, "after": true}],
     // Don't require to sort variables within the same declaration block.
     // Anyway, one-var is disabled.
     "sort-vars": "off",
-    // Disable the rule that checks if spaces inside {} and [] are there or not.
-    // Our code is split on conventions, and it'd be nice to have "error" rules
-    // instead, one for [] and one for {}. So, disabling until we write them.
-    "space-in-brackets": "off",
     // Disallow spaces inside parentheses.
     "space-in-parens": ["error", "never"],
     // Require spaces before/after unary operators (words on by default,
     // nonwords off by default).
     "space-unary-ops": ["error", { "words": true, "nonwords": false }],
     // Require "use strict" to be defined globally in the script.
     "strict": ["error", "global"],
     // Warn about invalid JSDoc comments.
@@ -428,18 +419,16 @@ module.exports = {
     // disabled for now until we introduce them, one at a time.
 
     // enforce consistent spacing before and after the arrow in arrow functions
     "arrow-spacing": "off",
     // enforce consistent spacing inside computed property brackets
     "computed-property-spacing": "off",
     // Require for-in loops to have an if statement.
     "guard-for-in": "off",
-    // allow/disallow an empty newline after var statement
-    "newline-after-var": "off",
     // disallow the use of alert, confirm, and prompt
     "no-alert": "off",
     // disallow comparisons to null without a type-checking operator
     "no-eq-null": "off",
     // disallow overwriting functions written as function declarations
     "no-func-assign": "off",
     // disallow function or variable declarations in nested blocks
     "no-inner-declarations": "off",
@@ -450,18 +439,16 @@ module.exports = {
     // disallow usage of __iterator__ property
     "no-iterator": "off",
     // disallow labels that share a name with a variable
     "no-label-var": "off",
     // disallow unnecessary nested blocks
     "no-lone-blocks": "off",
     // disallow creation of functions within loops
     "no-loop-func": "off",
-    // disallow negation of the left operand of an in expression
-    "no-negated-in-lhs": "off",
     // disallow use of new operator when not part of the assignment or
     // comparison
     "no-new": "off",
     // disallow use of new operator for Function object
     "no-new-func": "off",
     // disallow use of the Object constructor
     "no-new-object": "off",
     // disallows creating new instances of String,Number, and Boolean
@@ -475,17 +462,15 @@ module.exports = {
     // disallow use of undefined when initializing variables
     "no-undef-init": "off",
     // disallow usage of expressions in statement position
     "no-unused-expressions": "off",
     // disallow unnecessary concatenation of literals or template literals
     "no-useless-concat": "off",
     // disallow use of void operator
     "no-void": "off",
-    // disallow wrapping of non-IIFE statements in parens
-    "no-wrap-func": "off",
     // require assignment operator shorthand where possible or prohibit it
     // entirely
     "operator-assignment": "off",
     // enforce operators to be placed before or after line breaks
     "operator-linebreak": "off",
   }
 };
--- a/dom/indexedDB/test/helpers.js
+++ b/dom/indexedDB/test/helpers.js
@@ -12,17 +12,17 @@ var testGenerator = testSteps();
 // SpecialPowers.Components). Expose Components if necessary here to make things
 // work everywhere.
 //
 // Even if the real |Components| doesn't exist, we might shim in a simple JS
 // placebo for compat. An easy way to differentiate this from the real thing
 // is whether the property is read-only or not.
 var c = Object.getOwnPropertyDescriptor(this, "Components");
 if ((!c || !c.value || c.writable) && typeof SpecialPowers === "object") {
-  // eslint-disable-next-line no-native-reassign
+  // eslint-disable-next-line no-global-assign
   Components = SpecialPowers.wrap(SpecialPowers.Components);
 }
 
 function executeSoon(aFun)
 {
   SpecialPowers.Services.tm.dispatchToMainThread({
     run() {
       aFun();
--- a/dom/presentation/tests/mochitest/PresentationSessionFrameScript.js
+++ b/dom/presentation/tests/mochitest/PresentationSessionFrameScript.js
@@ -31,25 +31,25 @@ function loadPrivilegedScriptTest() {
       var type = e.data.type;
       if (!handlers.hasOwnProperty(type)) {
         return;
       }
       var args = [e];
       handlers[type].forEach(handler => handler.apply(null, args));
     };
     var handlers = {};
-    /* eslint-disable-next-line no-native-reassign */
+    /* eslint-disable-next-line no-global-assign */
     addMessageListener = function(message, handler) {
       if (handlers.hasOwnProperty(message)) {
         handlers[message].push(handler);
       } else {
         handlers[message] = [handler];
       }
     };
-    /* eslint-disable-next-line no-native-reassign */
+    /* eslint-disable-next-line no-global-assign */
     removeMessageListener = function(message, handler) {
       if (!handler || !handlers.hasOwnProperty(message)) {
         return;
       }
       var index = handlers[message].indexOf(handler);
       if (index != -1) {
         handlers[message].splice(index, 1);
       }
--- a/mobile/android/.eslintrc.js
+++ b/mobile/android/.eslintrc.js
@@ -5,17 +5,16 @@ module.exports = {
     // XXX Bug 1358949 - This should be reduced down - probably to 20 or to
     // be removed & synced with the mozilla/recommended value.
     "complexity": ["error", 31],
 
     // Rules enabled in mozilla/recommended, and disabled for now, we should
     // re-enable these over time.
     "consistent-return": "off",
     "no-empty": "off",
-    "no-native-reassign": "off",
     "no-nested-ternary": "off",
     "no-new-object": "off",
     "no-octal": "off",
     "no-redeclare": "off",
     "no-useless-call": "off",
     "no-useless-concat": "off",
     "object-shorthand": "off",
   },
--- a/mobile/android/tests/browser/robocop/robocop_head.js
+++ b/mobile/android/tests/browser/robocop/robocop_head.js
@@ -10,16 +10,17 @@
 // work everywhere.
 //
 // Even if the real |Components| doesn't exist, we might shim in a simple JS
 // placebo for compat. An easy way to differentiate this from the real thing
 // is whether the property is read-only or not.
 {
   let c = Object.getOwnPropertyDescriptor(this, "Components");
   if ((!c || !c.value || c.writable) && typeof SpecialPowers === "object")
+    // eslint-disable-next-line no-global-assign
     Components = SpecialPowers.wrap(SpecialPowers.Components);
 }
 
 /*
  * This file contains common code that is loaded before each test file(s).
  * See http://developer.mozilla.org/en/docs/Writing_xpcshell-based_unit_tests
  * for more information.
  */
--- a/testing/web-platform/tests/streams/readable-streams/patched-global.js
+++ b/testing/web-platform/tests/streams/readable-streams/patched-global.js
@@ -42,26 +42,23 @@ test(t => {
   assert_true(isReadableStream(branch2), 'branch2 should be a ReadableStream');
 }, 'ReadableStream tee() should not touch Object.prototype properties');
 
 test(t => {
   const rs = new ReadableStream();
 
   const oldReadableStream = self.ReadableStream;
 
-  /* eslint-disable no-native-reassign */
   self.ReadableStream = function() {
     throw new Error('ReadableStream called on global object');
   };
 
   t.add_cleanup(() => {
     self.ReadableStream = oldReadableStream;
   });
 
   const [branch1, branch2] = rs.tee();
 
   assert_true(isReadableStream(branch1), 'branch1 should be a ReadableStream');
   assert_true(isReadableStream(branch2), 'branch2 should be a ReadableStream');
-
-  /* eslint-enable no-native-reassign */
 }, 'ReadableStream tee() should not call the global ReadableStream');
 
 done();
--- a/testing/web-platform/tests/streams/transform-streams/patched-global.js
+++ b/testing/web-platform/tests/streams/transform-streams/patched-global.js
@@ -16,18 +16,16 @@ Object.defineProperty(Object.prototype, 
   set() { throw new Error('size setter called'); }
 });
 
 test(() => {
   assert_not_equals(new TransformStream(), null, 'constructor should work');
 }, 'TransformStream constructor should not call setters for highWaterMark or size');
 
 test(t => {
-  /* eslint-disable no-native-reassign */
-
   const oldReadableStream = ReadableStream;
   const oldWritableStream = WritableStream;
   const getReader = ReadableStream.prototype.getReader;
   const getWriter = WritableStream.prototype.getWriter;
 
   // Replace ReadableStream and WritableStream with broken versions.
   ReadableStream = function () {
     throw new Error('Called the global ReadableStream constructor');
@@ -42,12 +40,11 @@ test(t => {
 
   const ts = new TransformStream();
 
   // Just to be sure, ensure the readable and writable pass brand checks.
   assert_not_equals(getReader.call(ts.readable), undefined,
                     'getReader should work when called on ts.readable');
   assert_not_equals(getWriter.call(ts.writable), undefined,
                     'getWriter should work when called on ts.writable');
-  /* eslint-enable no-native-reassign */
 }, 'TransformStream should use the original value of ReadableStream and WritableStream');
 
 done();
--- a/toolkit/components/extensions/.eslintrc.js
+++ b/toolkit/components/extensions/.eslintrc.js
@@ -154,20 +154,16 @@ module.exports = {
     // Don't require a capital letter for constructors, only check if all new
     // operators are followed by a capital letter. Don't warn when capitalized
     // functions are used without the new operator.
     "new-cap": ["off", {"capIsNew": false}],
 
     // Allow use of bitwise operators.
     "no-bitwise": "off",
 
-    // Disallow the catch clause parameter name being the same as a variable in
-    // the outer scope, to avoid confusion.
-    "no-catch-shadow": "off",
-
     // Disallow using the console API.
     "no-console": "error",
 
     // Allow using constant expressions in conditions like while (true)
     "no-constant-condition": "off",
 
     // Allow use of the continue statement.
     "no-continue": "off",
@@ -212,19 +208,16 @@ module.exports = {
     "no-process-env": "off",
 
     // Allow using process.exit (not a node environment).
     "no-process-exit": "off",
 
     // Disallow usage of __proto__ property.
     "no-proto": "error",
 
-    // Allow reserved words being used as object literal keys.
-    "no-reserved-keys": "off",
-
     // Don't restrict usage of specified node modules (not a node environment).
     "no-restricted-modules": "off",
 
     // Disallow use of assignment in return statement. It is preferable for a
     // single line of code to have only one easily predictable effect.
     "no-return-assign": "error",
 
     // Don't warn about declaration of variables already declared in the outer scope.
--- a/toolkit/components/extensions/Schemas.jsm
+++ b/toolkit/components/extensions/Schemas.jsm
@@ -2391,17 +2391,17 @@ FunctionEntry = class FunctionEntry exte
     };
   }
 };
 
 // Represents an "event" defined in a schema namespace.
 //
 // TODO Bug 1369722: we should be able to remove the eslint-disable-line that follows
 // once Bug 1369722 has been fixed.
-Event = class Event extends CallEntry { // eslint-disable-line no-native-reassign
+Event = class Event extends CallEntry { // eslint-disable-line no-global-assign
   static parseSchema(root, event, path) {
     let extraParameters = Array.from(event.extraParameters || [], param => ({
       type: root.parseSchema(param, path, ["name", "optional", "default"]),
       name: param.name,
       optional: param.optional || false,
       default: param.default == undefined ? null : param.default,
     }));
 
--- a/toolkit/components/passwordmgr/test/pwmgr_common.js
+++ b/toolkit/components/passwordmgr/test/pwmgr_common.js
@@ -346,17 +346,17 @@ function runChecksAfterCommonInit(aFunct
   return pwmgrCommonScript;
 }
 
 // Code to run when loaded as a chrome script in tests via loadChromeScript
 if (this.addMessageListener) {
   var SpecialPowers = { Cc, Ci, Cr, Cu };
   var ok, is;
   // Ignore ok/is in commonInit since they aren't defined in a chrome script.
-  ok = is = () => {}; // eslint-disable-line no-native-reassign
+  ok = is = () => {};
 
   ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
   ChromeUtils.import("resource://gre/modules/LoginHelper.jsm");
   ChromeUtils.import("resource://gre/modules/LoginManagerParent.jsm");
   ChromeUtils.import("resource://gre/modules/Services.jsm");
 
   function onStorageChanged(subject, topic, data) {
     sendAsyncMessage("storageChanged", {
--- a/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js
+++ b/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js
@@ -246,19 +246,18 @@ module.exports = {
 
     // Disallow unnecessary calls to .bind()
     "no-extra-bind": "error",
 
     // XXX Bug 1487642 - decide if we want to enable this or not.
     // Disallow fallthrough of case statements
     "no-fallthrough": "off",
 
-    // XXX Bug 1487642 - decide if we want to enable this or not.
     // Disallow assignments to native objects or read-only global variables
-    "no-global-assign": "off",
+    "no-global-assign": "error",
 
     // Disallow eval and setInteral/setTimeout with strings
     "no-implied-eval": "error",
 
     // This has been superseded since we're using ES6.
     // Disallow variable or function declarations in nested blocks
     "no-inner-declarations": "off",
 
@@ -277,19 +276,16 @@ module.exports = {
     // No unnecessary spacing
     "no-multi-spaces": ["error", { exceptions: {
       "ArrayExpression": true,
       "AssignmentExpression": true,
       "ObjectExpression": true,
       "VariableDeclarator": true
     } }],
 
-    // No reassigning native JS objects
-    "no-native-reassign": "error",
-
     // Nested ternary statements are confusing
     "no-nested-ternary": "error",
 
     // Use {} instead of new Object()
     "no-new-object": "error",
 
     // Dissallow use of new wrappers
     "no-new-wrappers": "error",
--- a/tools/lint/eslint/eslint-plugin-mozilla/package-lock.json
+++ b/tools/lint/eslint/eslint-plugin-mozilla/package-lock.json
@@ -1,11 +1,11 @@
 {
   "name": "eslint-plugin-mozilla",
-  "version": "0.15.4",
+  "version": "0.16.0",
   "lockfileVersion": 1,
   "requires": true,
   "dependencies": {
     "acorn": {
       "version": "5.7.1",
       "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.1.tgz",
       "integrity": "sha512-d+nbxBUGKg7Arpsvbnlq61mc12ek3EY8EQldM3GPAhWJ1UVxC6TDGbIvUMNU6obBX3i1+ptCIzV4vq0gFPEGVQ==",
       "dev": 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.15.4",
+  "version": "0.16.0",
   "description": "A collection of rules that help enforce JavaScript coding standard in the Mozilla project.",
   "keywords": [
     "eslint",
     "eslintplugin",
     "eslint-plugin",
     "mozilla",
     "firefox"
   ],