Commit f7ee2534 authored by Mark Banner's avatar Mark Banner
Browse files

Bug 1734823 - Enable ESLint rule no-unused-vars globally for xpcshell test*.js...

Bug 1734823 - Enable ESLint rule no-unused-vars globally for xpcshell test*.js files. r=necko-reviewers,Gijs,valentin

This enables it as a warning for all files, and as an error for some files.

Differential Revision: https://phabricator.services.mozilla.com/D127944
parent e0845722
Loading
Loading
Loading
Loading
+71 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ function removeOverrides(config) {
  return config;
}

const xpcshellTestPaths = ["**/test*/unit*/", "**/test*/xpcshell/"];
const xpcshellTestPaths = ["**/test*/unit*/**/", "**/test*/xpcshell/**/"];

const browserTestPaths = ["**/test*/**/browser*/"];

@@ -124,6 +124,76 @@ module.exports = {
        ],
      },
    },
    {
      // This section enables warning of no-unused-vars globally for all test*.js
      // files in xpcshell test paths.
      // These are turned into errors with selected exclusions in the next
      // section.
      // Bug 1612907: This section should go away once the exclusions are removed
      // from the following section.
      files: xpcshellTestPaths.map(path => `${path}test*.js`),
      rules: {
        // No declaring variables that are never used
        "no-unused-vars": [
          "warn",
          {
            args: "none",
            vars: "all",
          },
        ],
      },
    },
    {
      // This section makes global issues with no-unused-vars be reported as
      // errors - except for the excluded lists which are being fixed in the
      // dependencies of bug 1612907.
      files: xpcshellTestPaths.map(path => `${path}test*.js`),
      excludedFiles: [
        // These are suitable as good first bugs, take one or two related lines
        // per bug.
        "caps/tests/unit/test_origin.js",
        "caps/tests/unit/test_site_origin.js",
        "chrome/test/unit/test_no_remote_registration.js",
        "extensions/permissions/**",
        "image/test/unit/**",
        "intl/uconv/tests/unit/test_bug317216.js",
        "intl/uconv/tests/unit/test_bug340714.js",
        "modules/libjar/test/unit/test_empty_jar_telemetry.js",
        "modules/libjar/zipwriter/test/unit/test_alignment.js",
        "modules/libjar/zipwriter/test/unit/test_bug419769_2.js",
        "modules/libjar/zipwriter/test/unit/test_storedata.js",
        "modules/libjar/zipwriter/test/unit/test_zippermissions.js",
        "modules/libpref/test/unit/test_changeType.js",
        "modules/libpref/test/unit/test_dirtyPrefs.js",
        "toolkit/crashreporter/test/unit/test_crash_AsyncShutdown.js",
        "toolkit/mozapps/update/tests/unit_aus_update/testConstants.js",
        "xpcom/tests/unit/test_hidden_files.js",
        "xpcom/tests/unit/test_localfile.js",

        // These are more complicated bugs which may require some in-depth
        // investigation or different solutions. They are also likely to be
        // a reasonable size.
        "browser/components/**",
        "browser/modules/**",
        "dom/**",
        "netwerk/**",
        "security/manager/ssl/tests/unit/**",
        "services/**",
        "testing/xpcshell/**",
        "toolkit/components/**",
        "toolkit/modules/**",
      ],
      rules: {
        // No declaring variables that are never used
        "no-unused-vars": [
          "error",
          {
            args: "none",
            vars: "all",
          },
        ],
      },
    },
    {
      ...browserTestConfig,
      files: browserTestPaths.map(path => `${path}**`),

chrome/test/.eslintrc.js

deleted100644 → 0
+0 −5
Original line number Diff line number Diff line
"use strict";

module.exports = {
  extends: ["plugin:mozilla/xpcshell-test"],
};
+2 −2
Original line number Diff line number Diff line
@@ -66,11 +66,9 @@ const SEGMENT_AND_HALF = [1, 2, 3, 4, 5, 6];
const QUARTER_SEGMENT = [1];
const HALF_SEGMENT = [1, 2];
const SECOND_HALF_SEGMENT = [3, 4];
const THREE_QUARTER_SEGMENT = [1, 2, 3];
const EXTRA_HALF_SEGMENT = [5, 6];
const MIDDLE_HALF_SEGMENT = [2, 3];
const LAST_QUARTER_SEGMENT = [4];
const FOURTH_HALF_SEGMENT = [7, 8];
const HALF_THIRD_SEGMENT = [9, 10];
const LATTER_HALF_THIRD_SEGMENT = [11, 12];

@@ -388,6 +386,8 @@ function note(m) {
 * PUBLIC API!  If you use any of these I will knowingly break your code by
 * changing the names of variables and properties.
 */
// These are used in head.js.
/* exported BinaryInputStream, BinaryOutputStream */
var BinaryInputStream = function BIS(stream) {
  return stream;
};
+2 −3
Original line number Diff line number Diff line
@@ -105,11 +105,10 @@ function newPrefixHandler(channel) {
}

var srv;
var serverBasePath;
var testsDirectory;

function run_test() {
  testsDirectory = do_get_profile();
  // Ensure the profile exists.
  do_get_profile();

  srv = createServer();
  srv.start(-1);
+0 −1
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@ function veryLongRequestLine(request, response) {
  response.setStatusLine(request.httpVersion, 200, "TEST PASSED");
}

var path = "/very-long-request-line?";
var reallyLong = "0123456789ABCDEF0123456789ABCDEF"; // 32
reallyLong = reallyLong + reallyLong + reallyLong + reallyLong; // 128
reallyLong = reallyLong + reallyLong + reallyLong + reallyLong; // 512
Loading