Skip to content

Commit

Permalink
Bug 1360166 - Make accessible/ ESLint rules inherit from the mozilla/…
Browse files Browse the repository at this point in the history
…recommended configuration. r=surkov

MozReview-Commit-ID: GJs25x7vNgZ
  • Loading branch information
Standard8 committed Apr 27, 2017
1 parent 1e1071f commit 430bdae
Show file tree
Hide file tree
Showing 40 changed files with 113 additions and 120 deletions.
33 changes: 20 additions & 13 deletions accessible/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,30 @@

module.exports = {
"extends": [
"../.eslintrc.js"
"plugin:mozilla/recommended"
],
"globals": {
"Cc": true,
"Ci": true,
"Components": true,
"console": true,
"Cu": true,
"dump": true,
"Services": true,
"XPCOMUtils": true
},
"rules": {
// Warn about cyclomatic complexity in functions.
"complexity": ["error", 42],

// Maximum depth callbacks can be nested.
"max-nested-callbacks": ["error", 10],
// XXX These are rules that are enabled in the recommended configuration, but
// disabled here due to failures when initially implemented. They should be
// removed (and hence enabled) at some stage.
"brace-style": "off",
"consistent-return": "off",
"func-call-spacing": "off",
"quotes": "off",
"object-shorthand": "off",
"space-before-function-paren": "off",
"space-infix-ops": "off",
"key-spacing": "off",
"keyword-spacing": "off",
"no-else-return": "off",
"no-multi-spaces": "off",
"no-trailing-spaces": "off",
"no-unexpected-multiline": "off",
"no-unsafe-finally": "off",
"no-useless-call": "off",
"spaced-comment": "off",
}
};
2 changes: 0 additions & 2 deletions accessible/jsat/AccessFu.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

/* global AccessFu, Components, Utils, PrefCache, Logger, Services,
PointerAdapter, dump, Presentation, Rect */
/* exported AccessFu */

'use strict';
Expand Down
4 changes: 1 addition & 3 deletions accessible/jsat/EventManager.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ this.EventManager.prototype = {
switch (aEvent.type) {
case 'wheel':
{
let attempts = 0;
let delta = aEvent.deltaX || aEvent.deltaY;
this.contentControl.autoMove(
null,
Expand Down Expand Up @@ -271,7 +270,6 @@ this.EventManager.prototype = {
{
// Put vc where the focus is at
let acc = aEvent.accessible;
let doc = aEvent.accessibleDocument;
this._setEditingMode(aEvent);
if ([Roles.CHROME_WINDOW,
Roles.DOCUMENT,
Expand Down Expand Up @@ -486,7 +484,7 @@ this.EventManager.prototype = {
}
return {};
};
let {live, relevant, busy, atomic, memberOf} = getLiveAttributes(aEvent);
let {live, relevant, /* busy, atomic, memberOf */ } = getLiveAttributes(aEvent);
// If container-live is not present or is set to |off| ignore the event.
if (!live || live === 'off') {
return {};
Expand Down
1 change: 0 additions & 1 deletion accessible/jsat/Gestures.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

/* global Components, GestureSettings, XPCOMUtils, Utils, Promise, Logger */
/* exported GestureSettings, GestureTracker */

/******************************************************************************
Expand Down
1 change: 0 additions & 1 deletion accessible/jsat/OutputGenerator.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

/* global Components, XPCOMUtils, Utils, PrefCache, States, Roles, Logger */
/* exported UtteranceGenerator, BrailleGenerator */

'use strict';
Expand Down
2 changes: 0 additions & 2 deletions accessible/jsat/PointerAdapter.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

/* global Components, XPCOMUtils, Utils, Logger, GestureSettings,
GestureTracker */
/* exported PointerRelay, PointerAdapter */

'use strict';
Expand Down
2 changes: 0 additions & 2 deletions accessible/jsat/Presentation.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

/* global Components, XPCOMUtils, Utils, Logger, BraillePresenter, Presentation,
UtteranceGenerator, BrailleGenerator, States, Roles, PivotContext */
/* exported Presentation */

'use strict';
Expand Down
2 changes: 0 additions & 2 deletions accessible/jsat/Traversal.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

/* global PrefCache, Roles, Prefilters, States, Filters, Utils,
TraversalRules, Components, XPCOMUtils */
/* exported TraversalRules, TraversalHelper */

'use strict';
Expand Down
2 changes: 0 additions & 2 deletions accessible/jsat/Utils.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

/* global Components, XPCOMUtils, Services, PluralForm, Logger, Rect, Utils,
States, Relations, Roles, dump, Events, PivotContext, PrefCache */
/* exported Utils, Logger, PivotContext, PrefCache */

'use strict';
Expand Down
2 changes: 2 additions & 0 deletions accessible/jsat/content-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

/* eslint-env mozilla/frame-script */

var Ci = Components.interfaces;
var Cu = Components.utils;

Expand Down
7 changes: 7 additions & 0 deletions accessible/tests/crashtests/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"use strict";

module.exports = {
"extends": [
"plugin:mozilla/mochitest-test"
],
};
16 changes: 8 additions & 8 deletions accessible/tests/crashtests/448064.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
<script>
function dumpAccessibleNode(aNode, level) {
var msg = "";

try {
msg += "name=\"" + aNode.name + "\" ";
} catch (e) {
msg += " noName ";
}

dump(msg + '\n');
}

Expand All @@ -35,7 +35,7 @@ function dumpAccessibleTree(aNode, level) {
level = level || 0;

dumpAccessibleNode(aNode, level);
try {
try {
var child = aNode.firstChild;
while (child) {
dumpAccessibleTree(child, level + 1);
Expand All @@ -46,14 +46,14 @@ function dumpAccessibleTree(aNode, level) {
}
}

function A(o) {
function A(o) {
var acc = SpecialPowers.Cc['@mozilla.org/accessibilityService;1']
.getService(SpecialPowers.Ci.nsIAccessibilityService);
return acc.getAccessibleFor(o);
}

function beginAccessible() {
dumpAccessibleTree(A(document),0);
dumpAccessibleTree(A(document), 0);
}
setTimeout(beginAccessible, 100);

Expand All @@ -62,9 +62,9 @@ setTimeout(doe, 200);
function doe() {
document.getElementById('mw_a').appendChild(document.getElementById('mw_b'));
document.getElementById('mw_c').appendChild(document.getElementById('mw_d'));
document.getElementById('mw_e').appendChild(document.getElementById('mw_f'));
document.getElementById('mw_g').appendChild(document.getElementById('mw_b'));
document.getElementById('mw_e').appendChild(document.getElementById('mw_f'));
document.getElementById('mw_g').appendChild(document.getElementById('mw_b'));
}
</script>
</body>
</html>
</html>
24 changes: 24 additions & 0 deletions accessible/tests/mochitest/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"use strict";

module.exports = {
"extends": [
"plugin:mozilla/mochitest-test"
],
"rules": {
"mozilla/no-cpows-in-tests": "error",
"mozilla/reject-importGlobalProperties": "error",

// XXX These are rules that are enabled in the recommended configuration, but
// disabled here due to failures when initially implemented. They should be
// removed (and hence enabled) at some stage.
"comma-spacing": "off",
"no-cond-assign": "off",
"no-lonely-if": "off",
"no-nested-ternary": "off",
"no-new-object": "off",
"no-redeclare": "off",
"no-shadow": "off",
"no-undef": "off",
"space-unary-ops": "off",
}
};
4 changes: 2 additions & 2 deletions accessible/tests/mochitest/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const XUL_EVENTS = CLICK_EVENTS | COMMAND_EVENT;
*
* // [optional] an array of invoker's checker objects (see eventQueue
* // constructor events.js)
* get eventSeq() {}
* get eventSeq() {}
* };
*
*
Expand Down Expand Up @@ -134,7 +134,7 @@ function actionInvoker(aAccOrElmOrId, aActionIndex, aActionName, aEventSeq)
try {
acc.doAction(aActionIndex);
}
catch (e){
catch (e) {
ok(false, "doAction(" + aActionIndex + ") failed with: " + e.name);
return INVOKER_ACTION_FAILED;
}
Expand Down
2 changes: 1 addition & 1 deletion accessible/tests/mochitest/actions/test_media.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

var audioElm = getAccessible("audio");
var playBtn = audioElm.firstChild;
var scrubber = playBtn.nextSibling.nextSibling.nextSibling;
// var scrubber = playBtn.nextSibling.nextSibling.nextSibling;
var muteBtn = audioElm.lastChild.previousSibling;

var actions = [
Expand Down
19 changes: 1 addition & 18 deletions accessible/tests/mochitest/editabletext/editabletext.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function editableTextTest(aID)
}

this.generateTest(aID, null, [aStartPos, aEndPos, getTextFromClipboard],
copyNPasteInvoke, getValueChecker(aID, aResStr), testID);
copyNPasteTextInvoke, getValueChecker(aID, aResStr), testID);
}

/**
Expand Down Expand Up @@ -222,7 +222,6 @@ function editableTextTest(aID)

function getValue(aID)
{
var value = "";
var elm = getNode(aID);
if (elm instanceof Components.interfaces.nsIDOMNSEditableElement)
return elm.value;
Expand Down Expand Up @@ -258,21 +257,6 @@ function editableTextTest(aID)
return checker;
}

function getValueNClipboardChecker(aID, aValue, aText)
{
var valueChecker = getValueChecker(aID, aValue);
var clipboardChecker = getClipboardChecker(aID, aText);

var checker = {
check: function()
{
valueChecker.check();
clipboardChecker.check();
}
};
return checker;
}

/**
* Process next scheduled test.
*/
Expand Down Expand Up @@ -350,4 +334,3 @@ function editableTextTest(aID)
this.mEventQueue = new eventQueue();
this.mEventQueueReady = false;
}

2 changes: 1 addition & 1 deletion accessible/tests/mochitest/elm/test_canvas.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
context.addHitRegion({control: element});

var input = getAccessible("showA");
var [cnvX, cnvY, cnvWidth, cnvHeight] = getBoundsForDOMElm(canv);
var [cnvX, cnvY, /*cnvWidth*/, /*cnvHeight*/] = getBoundsForDOMElm(canv);
var [accX, accY, accWidth, accHeight] = getBounds(input);

var [x, y, w, h] = CSSToDevicePixels(window, kX, kY, kWidth, kHeight);
Expand Down
26 changes: 12 additions & 14 deletions accessible/tests/mochitest/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ function eventQueue(aEventType)
// (i.e. event types are matched, targets differs).
if (!checker.unexpected && checker.unique &&
eventQueue.compareEventTypes(checker, aEvent)) {
var isExppected = false;
var isExpected = false;
for (var jdx = 0; jdx < eventSeq.length; jdx++) {
isExpected = eventQueue.compareEvents(eventSeq[jdx], aEvent);
if (isExpected)
Expand Down Expand Up @@ -969,7 +969,7 @@ eventQueue.logEvent = function eventQueue_logEvent(aOrigEvent, aMatchedChecker,

var currType = eventQueue.getEventTypeAsString(aMatchedChecker);
var currTargetDescr = eventQueue.getEventTargetDescr(aMatchedChecker);
var consoleMsg = "*****\nScenario " + aScenarioIdx +
var consoleMsg = "*****\nScenario " + aScenarioIdx +
", event " + aEventIdx + " matched: " + currType + "\n" + infoMsg + "\n*****";
gLogger.logToConsole(consoleMsg);

Expand Down Expand Up @@ -1315,8 +1315,8 @@ function synthFocus(aNodeOrID, aCheckerOrEventSeq)
this.DOMNode.focus();
}

this.getID = function synthFocus_getID()
{
this.getID = function synthFocus_getID()
{
return prettyName(aNodeOrID) + " focus";
}
}
Expand All @@ -1336,8 +1336,8 @@ function synthFocusOnFrame(aNodeOrID, aCheckerOrEventSeq)
this.DOMNode.body.focus();
}

this.getID = function synthFocus_getID()
{
this.getID = function synthFocus_getID()
{
return prettyName(aNodeOrID) + " frame document focus";
}
}
Expand Down Expand Up @@ -1991,7 +1991,7 @@ function selChangeSeq(aUnselectedID, aSelectedID)
}

// Return two possible scenarios: depending on widget type when selection is
// moved the the order of items that get selected and unselected may vary.
// moved the the order of items that get selected and unselected may vary.
return [
[
new stateChangeChecker(STATE_SELECTED, false, false, aUnselectedID),
Expand Down Expand Up @@ -2151,7 +2151,7 @@ function removeA11yEventListener(aEventType, aEventHandler)
return false;

listenersArray.splice(index, 1);

if (!listenersArray.length) {
gA11yEventListeners[aEventType] = null;
delete gA11yEventListeners[aEventType];
Expand Down Expand Up @@ -2270,21 +2270,19 @@ var gLogger =
function sequenceItem(aProcessor, aEventType, aTarget, aItemID)
{
// private

this.startProcess = function sequenceItem_startProcess()
{
this.queue.invoke();
}

var item = this;


this.queue = new eventQueue();
this.queue.onFinish = function()
{
aProcessor.onProcessed();
return DO_NOT_FINISH_TEST;
}

var invoker = {
invoke: function invoker_invoke() {
return aProcessor.process();
Expand All @@ -2295,7 +2293,7 @@ function sequenceItem(aProcessor, aEventType, aTarget, aItemID)
},
eventSeq: [ new invokerChecker(aEventType, aTarget) ]
};

this.queue.push(invoker);
}

Expand Down
Loading

0 comments on commit 430bdae

Please sign in to comment.