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

Commit

Permalink
Bug 1358949 - Lower eslint cyclomatic complexity threshold in some di…
Browse files Browse the repository at this point in the history
…rectories. r=standard8

We can lower the eslint cyclomatic complexity threshold in some directories without adding eslint suppression comments in any .js source files. We need to specify the complexity rule in accessible/.eslintrc because it doesn't inherit the mozilla/recommended rules. eslint's default complexity threshold is 20.

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

MozReview-Commit-ID: 57T4gAjPH7z
  • Loading branch information
cpeterso committed Apr 24, 2017
1 parent 45db012 commit 2877b0d
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 5 deletions.
3 changes: 3 additions & 0 deletions accessible/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ module.exports = {
"XPCOMUtils": true
},
"rules": {
// Warn about cyclomatic complexity in functions.
"complexity": ["error", 42],

// Maximum depth callbacks can be nested.
"max-nested-callbacks": ["error", 10],
}
Expand Down
2 changes: 1 addition & 1 deletion accessible/tests/browser/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ module.exports = { // eslint-disable-line no-undef
"comma-dangle": ["error", "never"],
"comma-spacing": "error",
"comma-style": ["error", "last"],
"complexity": ["error", 35],
"complexity": ["error", 20],
"consistent-this": "off",
"curly": ["error", "multi-line"],
"default-case": "off",
Expand Down
2 changes: 1 addition & 1 deletion browser/components/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ module.exports = {
rules: {
// XXX Bug 1326071 - This should be reduced down - probably to 20 or to
// be removed & synced with the mozilla/recommended value.
"complexity": ["error", {"max": 69}],
"complexity": ["error", 61],
}
};
5 changes: 5 additions & 0 deletions mobile/android/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ rules:
camelcase: 0
comma-dangle: 0
comma-spacing: 0

# XXX Bug 1358949 - This should be reduced down - probably to 20 or to
# be removed & synced with the mozilla/recommended value.
complexity: ["error", 31]

consistent-return: 0
curly: 0
dot-notation: 0
Expand Down
2 changes: 2 additions & 0 deletions mobile/android/chrome/content/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ globals:
Rect: false

rules:
complexity: ["error", 20]

# Disabled stuff
no-console: 0 # TODO: Can we use console?
no-cond-assign: 0
Expand Down
2 changes: 1 addition & 1 deletion toolkit/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ module.exports = {
rules: {
// XXX Bug 1326071 - This should be reduced down - probably to 20 or to
// be removed & synced with the mozilla/recommended value.
"complexity": ["error", {"max": 48}],
"complexity": ["error", 41],
}
};
4 changes: 4 additions & 0 deletions toolkit/components/passwordmgr/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ module.exports = {
// Commas at the end of the line not the start
"comma-style": "error",

// XXX Bug 1358949 - This should be reduced down - probably to 20 or to
// be removed & synced with the mozilla/recommended value.
"complexity": ["error", 43],

// Use [] instead of Array()
"no-array-constructor": "error",

Expand Down
6 changes: 6 additions & 0 deletions toolkit/content/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,10 @@ module.exports = {
"plugins": [
"mozilla"
],

rules: {
// XXX Bug 1358949 - This should be reduced down - probably to 20 or to
// be removed & synced with the mozilla/recommended value.
"complexity": ["error", 48],
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module.exports = {

// Warn about cyclomatic complexity in functions.
// XXX Get this down to 20?
"complexity": ["error", {"max": 35}],
"complexity": ["error", 32],

// Don't require spaces around computed properties
"computed-property-spacing": ["error", "never"],
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.43",
"version": "0.2.44",
"description": "A collection of rules that help enforce JavaScript coding standard in the Mozilla project.",
"keywords": [
"eslint",
Expand Down

0 comments on commit 2877b0d

Please sign in to comment.