Bug 1558485 - Turn on ESLint for all of dom/ disabling most of the failing rules. r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D34761

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mark Banner 2019-06-13 20:21:46 +00:00
parent c51c2a8807
commit 201255ab84
23 changed files with 216 additions and 71 deletions

View file

@ -12,52 +12,13 @@
obj*/**
# dom/ exclusions which should be removed (aka ESLint enabled)
dom/animation/**
dom/base/*.*
dom/base/test/*.*
dom/base/test/unit/test_serializers_entities*.js
dom/base/test/unit_ipc/**
dom/base/test/jsmodules/**
dom/canvas/**
dom/encoding/**
dom/events/**
dom/fetch/**
dom/file/**
dom/html/**
dom/jsurl/**
dom/media/test/**
!dom/media/test/marionette/yttest/*.js
dom/media/tests/**
dom/media/webaudio/**
dom/media/webspeech/**
dom/messagechannel/**
dom/midi/**
dom/network/**
dom/payments/**
dom/performance/**
dom/permission/**
dom/promise/**
dom/quota/**
dom/security/test/cors/**
dom/security/test/csp/**
dom/security/test/general/**
dom/security/test/mixedcontentblocker/**
dom/security/test/sri/**
dom/serviceworkers/**
dom/smil/**
dom/tests/mochitest/**
dom/u2f/**
dom/vr/**
dom/webauthn/**
dom/webgpu/**
dom/websocket/**
dom/workers/**
dom/worklet/**
dom/xbl/**
dom/xhr/**
dom/xml/**
dom/xslt/**
dom/xul/**
# build/ third-party code
build/pgo/js-input/**
@ -207,6 +168,26 @@ dom/media/webvtt/**
dom/svg/test/test_nonAnimStrings.xhtml
dom/svg/test/test_SVG_namespace_ids.html
# Strange encodings
dom/encoding/test/test_utf16_files.html
dom/encoding/test/file_utf16_be_bom.js
dom/encoding/test/file_utf16_le_bom.js
# Not parsable
dom/tests/mochitest/general/test_focusrings.xul
dom/html/test/test_bug677658.html
# Intentional broken files
dom/base/test/file_js_cache_syntax_error.js
dom/media/tests/mochitest/identity/idp-bad.js
dom/serviceworkers/test/file_js_cache_syntax_error.js
dom/serviceworkers/test/parse_error_worker.js
dom/tests/mochitest/bugs/test_bug531176.html
dom/webauthn/tests/cbor.js
dom/workers/test/importScripts_worker_imported3.js
dom/workers/test/invalid.js
dom/workers/test/threadErrors_worker1.js
# Third-party
editor/libeditor/tests/browserscope/**

View file

@ -330,5 +330,138 @@ module.exports = {
"space-unary-ops": "off",
"spaced-comment": "off",
}
}, {
"files": [
"dom/animation/**",
"dom/base/test/*.*",
"dom/base/test/unit/test_serializers_entities*.js",
"dom/base/test/unit_ipc/**",
"dom/base/test/jsmodules/**",
"dom/base/*.*",
"dom/canvas/**",
"dom/encoding/**",
"dom/events/**",
"dom/fetch/**",
"dom/file/**",
"dom/html/**",
"dom/jsurl/**",
"dom/media/tests/**",
"dom/media/webaudio/**",
"dom/media/webspeech/**",
"dom/messagechannel/**",
"dom/midi/**",
"dom/network/**",
"dom/payments/**",
"dom/performance/**",
"dom/permission/**",
"dom/quota/**",
"dom/security/test/cors/**",
"dom/security/test/csp/**",
"dom/security/test/general/**",
"dom/security/test/mixedcontentblocker/**",
"dom/security/test/sri/**",
"dom/serviceworkers/**",
"dom/smil/**",
"dom/tests/mochitest/**",
"dom/u2f/**",
"dom/vr/**",
"dom/webauthn/**",
"dom/webgpu/**",
"dom/websocket/**",
"dom/workers/**",
"dom/worklet/**",
"dom/xbl/**",
"dom/xml/**",
"dom/xslt/**",
"dom/xul/**",
],
"rules": {
"consistent-return": "off",
"dot-notation": "off",
"object-shorthand": "off",
"mozilla/avoid-removeChild": "off",
"mozilla/consistent-if-bracing": "off",
"mozilla/no-arbitrary-setTimeout": "off",
"mozilla/no-compare-against-boolean-literals": "off",
"mozilla/no-define-cc-etc": "off",
"mozilla/no-useless-parameters": "off",
"mozilla/no-useless-run-test": "off",
"mozilla/reject-importGlobalProperties": "off",
"mozilla/use-cc-etc": "off",
"mozilla/use-chromeutils-generateqi": "off",
"mozilla/use-chromeutils-import": "off",
"mozilla/use-includes-instead-of-indexOf": "off",
"mozilla/use-ownerGlobal": "off",
"mozilla/use-services": "off",
"no-array-constructor": "off",
"no-caller": "off",
"no-cond-assign": "off",
"no-control-regex": "off",
"no-debugger": "off",
"no-else-return": "off",
"no-empty": "off",
"no-eval": "off",
"no-extra-boolean-cast": "off",
"no-func-assign": "off",
"no-global-assign": "off",
"no-implied-eval": "off",
"no-lone-blocks": "off",
"no-lonely-if": "off",
"no-nested-ternary": "off",
"no-new-object": "off",
"no-new-wrappers": "off",
"no-octal": "off",
"no-redeclare": "off",
"no-return-await": "off",
"no-restricted-globals": "off",
"no-self-assign": "off",
"no-self-compare": "off",
"no-sequences": "off",
"no-shadow": "off",
"no-shadow-restricted-names": "off",
"no-sparse-arrays": "off",
"no-throw-literal": "off",
"no-unneeded-ternary": "off",
"no-unreachable": "off",
"no-unsanitized/method": "off",
"no-unsanitized/property": "off",
"no-undef": "off",
"no-unused-vars": "off",
"no-useless-call": "off",
"no-useless-concat": "off",
"no-useless-return": "off",
"no-with": "off",
// Not enabling the rules below for now pending prettier roll-out.
"arrow-spacing": "off",
"block-spacing": "off",
"brace-style": "off",
"comma-dangle": "off",
"comma-spacing": "off",
"comma-style": "off",
"computed-property-spacing": "off",
"eol-last": "off",
"func-call-spacing": "off",
"generator-star-spacing": "off",
"linebreak-style": "off",
"key-spacing": "off",
"keyword-spacing": "off",
"no-extra-semi": "off",
"no-tabs": "off",
"no-mixed-spaces-and-tabs": "off",
"no-multi-spaces": "off",
"no-trailing-spaces": "off",
"no-unexpected-multiline": "off",
"no-whitespace-before-property": "off",
"padded-blocks": "off",
"quotes": "off",
"rest-spread-spacing": "off",
"semi": "off",
"space-before-blocks": "off",
"space-before-function-paren": "off",
"space-infix-ops": "off",
"space-unary-ops": "off",
"spaced-comment": "off",
}
}]
};

View file

@ -16,7 +16,7 @@ function IsD2DEnabled() {
try {
enabled = Cc["@mozilla.org/gfx/info;1"].getService(SpecialPowers.Ci.nsIGfxInfo).D2DEnabled;
} catch(e) {}
return enabled;
}
@ -34,7 +34,7 @@ function IsLinux() {
function IsAzureSkia() {
var enabled = false;
try {
var backend = Cc["@mozilla.org/gfx/info;1"].getService(SpecialPowers.Ci.nsIGfxInfo).getInfo().AzureCanvasBackend;
enabled = (backend == "skia");
@ -45,7 +45,7 @@ function IsAzureSkia() {
function IsAzureCairo() {
var enabled = false;
try {
var backend = Cc["@mozilla.org/gfx/info;1"].getService(SpecialPowers.Ci.nsIGfxInfo).getInfo().AzureCanvasBackend;
enabled = (backend == "cairo");
@ -3639,7 +3639,7 @@ var ctx = canvas.getContext('2d');
var _thrown = undefined; try {
ctx.drawImage(undefined, 0, 0);
} catch (e) { _thrown = e };
} catch (e) { _thrown = e };
ok(_thrown && _thrown.name == "TypeError", "should throw TypeError");
var _thrown = undefined; try {
@ -5891,6 +5891,7 @@ isPixel(ctx, 40,20, 0,255,0,255, 2);
<canvas id="c220" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
// eslint-disable-next-line complexity
function test_2d_gradient_linear_nonfinite() {
var canvas = document.getElementById('c220');
@ -6704,6 +6705,7 @@ var _thrown = undefined; try {
<canvas id="c244" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
// eslint-disable-next-line complexity
function test_2d_gradient_radial_nonfinite() {
var canvas = document.getElementById('c244');
@ -7666,6 +7668,7 @@ ok(imgdata2.data[2] === 255, "imgdata2.data[\""+(2)+"\"] === 255");
<canvas id="c265" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
// eslint-disable-next-line complexity
function test_2d_imageData_get_nonfinite() {
var canvas = document.getElementById('c265');
@ -8564,6 +8567,7 @@ isPixel(ctx, 75,25, 0,255,0,255, 2);
<script>
// eslint-disable-next-line complexity
function test_2d_imageData_put_created() {
var canvas = document.getElementById('c291');
@ -8853,6 +8857,7 @@ isPixel(ctx, 50,25, 0,255,0,255, 2);
<canvas id="c299" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
// eslint-disable-next-line complexity
function test_2d_imageData_put_nonfinite() {
var canvas = document.getElementById('c299');
@ -9236,7 +9241,7 @@ var ctx = canvas.getContext('2d');
var imgdata = { width: 1, height: 1, data: [255, 0, 0, 255] };
var _thrown = undefined; try {
ctx.putImageData(imgdata, 0, 0);
} catch (e) { _thrown = e };
} catch (e) { _thrown = e };
ok(_thrown && _thrown.name == "TypeError", "should throw TypeError");
var _thrown = undefined; try {
@ -10456,6 +10461,7 @@ isPixel(ctx, 86,25, 0,255,0,255, 0);
<canvas id="c331" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
// eslint-disable-next-line complexity
function test_2d_missingargs() {
var canvas = document.getElementById('c331');
@ -19482,7 +19488,7 @@ ok(ctx.createLinearGradient(0, 0, 0, 0).addColorStop(0, 'white') === undefined,
<img id="i3" src="image_green-redirect">
</p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
@ -19502,7 +19508,7 @@ function test_bug397524() {
$("canvas1").toDataURL("image/png");
// Should not be able to get the data out of a cross-site load
var gotData = false;
var gotData = false;
try {
$("canvas2").toDataURL("image/png");
gotData = true;
@ -19514,7 +19520,7 @@ function test_bug397524() {
is(gotData, false, "Shouldn't be able to read images cross-site!");
// Should not be able to get the data out of a redirected cross-site load
var gotData = false;
var gotData = false;
try {
$("canvas3").toDataURL("image/png");
gotData = true;
@ -21160,7 +21166,7 @@ by multiplying by 255/a and rounding down. So if
we will get a change in value when we go through a putImageData/getImageData cycle. Therefore, to make sure we don't have to worry about our color
channels, our alpha channel should never be < 250, unless it's 0. And when it's 0, all our color channels will come back as 0 too. */
/* Our tests. Each test has two arrays: the array of values to set and the
array of values that should read back as a result. */
var tests = [
@ -21236,7 +21242,7 @@ function doTests(type) {
var canvas681;
var ctx681;
function test_2d_imagedata_coercion() {
canvas681 = document.getElementById('c681');
@ -22337,7 +22343,8 @@ function asyncTestsDone() {
setTimeout(asyncTestsDone, 500);
}
}
// eslint-disable-next-line complexity
function runTests() {
/**
* xor and lighter aren't well handled by cairo; they mostly work, but we don't want
@ -22353,7 +22360,7 @@ function runTests() {
//test_2d_composite_canvas_lighter();
//test_2d_composite_clip_xor();
//test_2d_composite_clip_lighter();
/**
* Temporarily disabled tests; unbounded operators changed behaviour, need to reevaluate tests
*/
@ -22365,7 +22372,7 @@ function runTests() {
//test_2d_composite_image_destination_in();
//test_2d_composite_image_source_in();
//test_2d_composite_image_source_out();
/**
* These tests only pass on Mac OS X >= 10.5; see bug 450114
*/
@ -22373,7 +22380,7 @@ function runTests() {
//test_2d_gradient_radial_touch1();
//test_2d_gradient_radial_touch2();
//test_2d_gradient_radial_touch3();
/**
* These 19 tests receive special makefile treatment
*/
@ -22396,7 +22403,7 @@ function runTests() {
//test_2d_path_arc_shape_3();
//test_2d_path_rect_selfintersect();
//test_2d_strokeRect_zero_5();
/**
* Other tests not being run
*/
@ -22408,10 +22415,10 @@ function runTests() {
//test_2d_composite_uncovered_pattern_destination_in();
//test_2d_composite_uncovered_pattern_source_in();
//test_2d_composite_uncovered_pattern_source_out();
//test_2d_path_rect_zero_6(); // This test is bogus according to the spec; see bug 407107
// These tests are bogus according to the spec: shadows should not be
// These tests are bogus according to the spec: shadows should not be
// drawn if shadowBlur, shadowOffsetX, and shadowOffsetY are all zero, whic
// they are in these tests
//test_2d_shadow_composite_3();
@ -25772,7 +25779,7 @@ function runTests() {
} catch (e) {
ok(false, "unexpected exception thrown in: test_2d_drawImage_animated_gif");
}
setTimeout(asyncTestsDone, 500);
}

View file

@ -13,7 +13,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=563329
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=563329">Mozilla Bug 563329</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
@ -25,7 +25,7 @@ var target = null;
var testGen = getTests();
var currentTest = null;
function getTests() {
function* getTests() {
let tests = [
{ "func": function() { setTimeout(doCheckContextMenu, 100)}, "message": "Context menu should has fired"},
{ "func": function() { setTimeout(doCheckDuration, 100)}, "message": "Context menu should has fired with delay"},

View file

@ -17,11 +17,13 @@
<input id="reset" type="reset">
</p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/* eslint-disable max-nested-callbacks */
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(runTests);

View file

@ -17,6 +17,7 @@ const kKeyList = [
const kStrictKeyPressEvents =
SpecialPowers.getBoolPref("dom.keyboardevent.keypress.dispatch_non_printable_keys_only_system_group_in_content");
/* eslint-disable mozilla/no-arbitrary-setTimeout */
function frameScript() {
let doc = content.document;
addMessageListener("Test:RequestFullscreen", () => {
@ -52,6 +53,7 @@ function frameScript() {
}
waitUntilActive();
}
/* eslint-enable mozilla/no-arbitrary-setTimeout */
var gMessageManager;

View file

@ -6,6 +6,7 @@
// error.
SimpleTest.ignoreAllUncaughtExceptions(true);
/* eslint-disable mozilla/no-arbitrary-setTimeout */
function frameScript() {
addMessageListener("Test:RequestFullscreen", () => {
content.document.body.requestFullscreen();
@ -27,6 +28,7 @@ function frameScript() {
}
waitUntilActive();
}
/* eslint-enable mozilla/no-arbitrary-setTimeout */
var gMessageManager;
@ -95,6 +97,7 @@ add_task(async function() {
// Wait a small time to confirm that the first ESC key
// does not exit fullscreen.
// eslint-disable-next-line mozilla/no-arbitrary-setTimeout
await new Promise(resolve => setTimeout(resolve, 1000));
gMessageManager.sendAsyncMessage("Test:QueryFullscreenState");
state = await promiseOneMessage("Test:FullscreenState");

View file

@ -61,6 +61,7 @@ async function runTest() {
// Ensure the browser exits fullscreen state in reasonable time.
await Promise.race([
BrowserTestUtils.waitForCondition(() => getSizeMode() == "normal"),
// eslint-disable-next-line mozilla/no-arbitrary-setTimeout
new Promise(resolve => setTimeout(resolve, 2000))
]);

View file

@ -14,6 +14,7 @@
<script class="testbody" type="application/javascript">
SimpleTest.waitForExplicitFinish();
// eslint-disable-next-line complexity
SimpleTest.waitForFocus(() => {
let content = document.getElementById("content");
/**

View file

@ -315,6 +315,7 @@ var pedanticChecks = report => {
[...report.keys()].forEach(key => is(report[key], undefined,
`Report is not dictionary like, it lacks a property for key ${key}`));
// eslint-disable-next-line complexity
report.forEach((statObj, mapKey) => {
let tested = {};
// Record what fields get tested.

View file

@ -102,6 +102,7 @@ function discreteSum(sourceBuffer, destBuffer) {
// Speaker channel interpretation mixing:
// https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html#UpMix
// eslint-disable-next-line complexity
function speakersSum(sourceBuffer, destBuffer)
{
var numberOfSourceChannels = sourceBuffer.numberOfChannels;

View file

@ -16,7 +16,7 @@
await navigator.requestMIDIAccess({ "sysex": false })
ok(true, "MIDI Access Request successful");
SimpleTest.finish();
} catch {
} catch (ex) {
ok(false, "MIDI Access Request Failed!");
SimpleTest.finish();
}

View file

@ -16,7 +16,7 @@
await navigator.requestMIDIAccess({ "sysex": false });
ok(false, "MIDI Access Request Deny failed");
SimpleTest.finish();
} catch {
} catch (ex) {
ok(true, "MIDI Access Request Deny successful!");
SimpleTest.finish();
}

View file

@ -74,6 +74,7 @@ function checkSimplestRequest(payRequest) {
}
}
// eslint-disable-next-line complexity
function checkComplexRequest(payRequest) {
if (payRequest.topLevelPrincipal.origin != "https://example.com") {
emitTestFail("Top level principal's origin should be 'https://example.com', but got '"

View file

@ -3,7 +3,7 @@
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<title>Test for Cross Site XMLHttpRequest</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body onload="initTest()">
@ -11,7 +11,7 @@
<iframe id=loader></iframe>
</p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="application/javascript">
@ -36,10 +36,11 @@ function initTestCallback() {
});
gen = runTest();
gen.next()
}
// eslint-disable-next-line complexity
function* runTest() {
var loader = document.getElementById('loader');
var loaderWindow = loader.contentWindow;

View file

@ -62,7 +62,6 @@ var tests = {
},
'none-src-by-frame-src': {
id: "none-src-by-frame-src",
file: "file_child-src_iframe.html",
file: IFRAME_SRC,
result : "blocked",
policy : "default-src 'none'; script-src 'unsafe-inline'; child-src http://mochi.test:8888; frame-src 'none'"

View file

@ -11,9 +11,11 @@ const USER_CONTEXT_ID = 3
let mockAlertsService = {
showAlert: function(alert, alertListener) {
ok(true, "Showing alert");
// eslint-disable-next-line mozilla/no-arbitrary-setTimeout
setTimeout(function () {
alertListener.observe(null, "alertshow", alert.cookie);
}, 100);
// eslint-disable-next-line mozilla/no-arbitrary-setTimeout
setTimeout(function () {
alertListener.observe(null, "alertclickcallback", alert.cookie);
}, 100);

View file

@ -1,5 +1,6 @@
var seenIndex = false;
// eslint-disable-next-line complexity
onfetch = function(ev) {
if (ev.request.url.includes("ignore")) {
return;

View file

@ -27,7 +27,7 @@
{ scope: "./sw_clients/focus_stealing_client.html" })
.then((swr) => {
registration = swr;
returun waitForState(swr.installing, 'activated', swr);
return waitForState(swr.installing, 'activated', swr);
});
}
@ -97,4 +97,3 @@
</pre>
</body>
</html>

View file

@ -142,7 +142,7 @@ async function test_noUint8Array_continue(r, that) {
try {
await r.blob();
that.ok(false, "We cannot have a blob here!");
} catch {
} catch (ex) {
that.ok(true, "We cannot have a blob here!");
}
}

View file

@ -8,6 +8,8 @@
<script type="text/javascript">
/* eslint-disable max-nested-callbacks */
/*
This is strictly implementation specific test for dom storage code from bug 600307.
It exercises code for asynchronous data flushing with regard to cache life time and its preload.

View file

@ -197,7 +197,7 @@ function expectException(func, msg) {
ok(failed, msg + " succeeded, but should have failed.");
}
function runTest() {
function* runTest() {
// We can't enable universal XPConnect privleges in this function, because
// test 5 needs to be running at normal privleges in order to test the
// same-origin policy.
@ -531,7 +531,7 @@ function runTest() {
locationEndsWith(popup, "good1.html");
// Even though we replaceState with title "state 1", the title should remain
// "test 1" because we ignore the title argument in push/replaceState.
// "test 1" because we ignore the title argument in push/replaceState.
// See bug 544535.
is(getSHTitle(shistory), "test 1", "SHEntry title 'state 1'");

View file

@ -24,7 +24,15 @@ dom/media/webspeech/recognition/energy_endpointer.cc
dom/media/webspeech/recognition/energy_endpointer.h
dom/media/webspeech/recognition/energy_endpointer_params.cc
dom/media/webspeech/recognition/energy_endpointer_params.h
dom/tests/ajax/jquery/
dom/tests/ajax/mochikit/
dom/tests/mochitest/ajax/
dom/tests/mochitest/dom-level1-core/
dom/tests/mochitest/dom-level2-core/
dom/tests/mochitest/dom-level2-html/
dom/u2f/tests/pkijs/
dom/webauthn/cbor-cpp/
dom/webauthn/tests/pkijs/
editor/libeditor/tests/browserscope/lib/richtext/
editor/libeditor/tests/browserscope/lib/richtext2/
extensions/spellcheck/hunspell/src/