Enable the no-nested-ternary
ESLint rule in the web/
directory
#11488
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This rule is already enabled in mozilla-central, and helps avoid some confusing formatting[1], see https://searchfox.org/mozilla-central/rev/a92ed79b0bc746159fc31af1586adbfa9e45e264/tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js#209-210
Since some cases may not be aren't entirely straightforward to convert, and some we probably don't want to change either[2], this patch is limited to the
web/
directory as a proof-of-concept.Please find additional details about the ESLint rule at https://eslint.org/docs/rules/no-nested-ternary
[1] One example with three ternary statements:
pdf.js/src/core/fonts.js
Lines 2623 to 2630 in 93aa613
[2] One example that should be whitelisted:
pdf.js/src/core/jbig2.js
Lines 82 to 92 in 93aa613