Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 1358947 - Make eslint "max-nested-callbacks" rule an error. r=sta…
Browse files Browse the repository at this point in the history
…ndard8

eslint's default max-nested-callbacks threshold is 10, but now we make it an error. We could further lower the max-nested-callbacks threshold globally to 8, like browser/.eslintrc.js, but that would require adding suppression comments in (two) more .js test files. 10 seems good enough for now since it's the eslint default.

We need to specify max-nested-callbacks in accessible/.eslintrc because it doesn't inherit the mozilla/recommended rules.

Also bump the eslint-plugin-mozilla version because we modified the mozilla/recommended rules.

MozReview-Commit-ID: JA41vsi4U7j
  • Loading branch information
cpeterso committed Apr 22, 2017
1 parent f292a18 commit 45db012
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions accessible/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,9 @@ module.exports = {
"dump": true,
"Services": true,
"XPCOMUtils": true
},
"rules": {
// Maximum depth callbacks can be nested.
"max-nested-callbacks": ["error", 10],
}
};
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 max-nested-callbacks: ["warn", 17] */

/**
* This file tests setAndFetchFaviconForPage when it is called with invalid
* arguments, and when no favicon is stored for the given arguments.
Expand Down
2 changes: 2 additions & 0 deletions toolkit/mozapps/extensions/test/browser/browser_bug562797.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/

/* eslint max-nested-callbacks: ["warn", 12] */

/**
* Tests that history navigation works for the add-ons manager.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ module.exports = {
// rule is a better rule to check this.
"max-depth": "off",

// Maximum depth callbacks can be nested.
"max-nested-callbacks": ["error", 10],

// Always require parenthesis for new calls
// "new-parens": "error",

Expand Down Expand Up @@ -135,7 +138,7 @@ module.exports = {
// Disallow empty destructuring
"no-empty-pattern": "error",

// No assiging to exception variable
// No assigning to exception variable
"no-ex-assign": "error",

// No using !! where casting to boolean is already happening
Expand Down
2 changes: 1 addition & 1 deletion tools/lint/eslint/eslint-plugin-mozilla/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-mozilla",
"version": "0.2.42",
"version": "0.2.43",
"description": "A collection of rules that help enforce JavaScript coding standard in the Mozilla project.",
"keywords": [
"eslint",
Expand Down

0 comments on commit 45db012

Please sign in to comment.