Commit 3fbbeec3 authored by Demetrios Papadopoulos's avatar Demetrios Papadopoulos Committed by Commit Bot

WebUI: Enforce ESLint eqeqeq rule in c/b/r/{downloads,welcome}

The rule disallows == in favor of ===, and != in favor of !==, which
matches the Google JS styleguide (which Chromium's JS styleguide
inherits from).

Bug: 720034
Change-Id: I192120525da6458a19e9eeb61e4e63aa598c4589
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1963350
Commit-Queue: Demetrios Papadopoulos <dpapad@chromium.org>
Auto-Submit: Demetrios Papadopoulos <dpapad@chromium.org>
Reviewed-by: default avatarJohn Lee <johntlee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#724486}
parent aeca9a17
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module.exports = {
'env': {
'browser': true,
'es6': true,
},
'rules': {'eqeqeq': ['error', 'always', {'null': 'ignore'}]},
};
......@@ -46,7 +46,7 @@ export class IconLoader {
finishedLoading_(e) {
const resolver = assert(this.iconResolvers_[e.currentTarget.src]);
if (!resolver.isFulfilled) {
resolver.resolve(e.type == 'load');
resolver.resolve(e.type === 'load');
}
}
}
......
......@@ -156,10 +156,10 @@ Polymer({
/** Overrides FocusRowBehavior. */
getCustomEquivalent: function(sampleElement) {
if (sampleElement.getAttribute('focus-type') == 'cancel') {
if (sampleElement.getAttribute('focus-type') === 'cancel') {
return this.$$('[focus-type="retry"]');
}
if (sampleElement.getAttribute('focus-type') == 'retry') {
if (sampleElement.getAttribute('focus-type') === 'retry') {
return this.$$('[focus-type="pauseOrResume"]');
}
return null;
......@@ -203,7 +203,7 @@ Polymer({
* @private
*/
computeCompletelyOnDisk_: function() {
return this.data.state == States.COMPLETE &&
return this.data.state === States.COMPLETE &&
!this.data.fileExternallyRemoved;
},
......@@ -235,7 +235,7 @@ Polymer({
* @private
*/
computeDate_: function() {
assert(typeof this.data.hideDate == 'boolean');
assert(typeof this.data.hideDate === 'boolean');
if (this.data.hideDate) {
return '';
}
......@@ -244,7 +244,7 @@ Polymer({
/** @private @return {boolean} */
computeDescriptionVisible_: function() {
return this.computeDescription_() != '';
return this.computeDescription_() !== '';
},
/**
......@@ -313,8 +313,8 @@ Polymer({
const dangerType = this.data.dangerType;
if ((loadTimeData.getBoolean('requestsApVerdicts') &&
dangerType == DangerType.UNCOMMON_CONTENT) ||
dangerType == DangerType.SENSITIVE_CONTENT_WARNING) {
dangerType === DangerType.UNCOMMON_CONTENT) ||
dangerType === DangerType.SENSITIVE_CONTENT_WARNING) {
return 'cr:error';
}
......@@ -341,8 +341,8 @@ Polymer({
* @private
*/
computeIsActive_: function() {
return this.data.state != States.CANCELLED &&
this.data.state != States.INTERRUPTED &&
return this.data.state !== States.CANCELLED &&
this.data.state !== States.INTERRUPTED &&
!this.data.fileExternallyRemoved;
},
......@@ -351,7 +351,7 @@ Polymer({
* @private
*/
computeIsDangerous_: function() {
return this.data.state == States.DANGEROUS;
return this.data.state === States.DANGEROUS;
},
/**
......@@ -359,7 +359,7 @@ Polymer({
* @private
*/
computeIsInProgress_: function() {
return this.data.state == States.IN_PROGRESS;
return this.data.state === States.IN_PROGRESS;
},
/**
......@@ -368,10 +368,10 @@ Polymer({
*/
computeIsMalware_: function() {
return this.isDangerous_ &&
(this.data.dangerType == DangerType.DANGEROUS_CONTENT ||
this.data.dangerType == DangerType.DANGEROUS_HOST ||
this.data.dangerType == DangerType.DANGEROUS_URL ||
this.data.dangerType == DangerType.POTENTIALLY_UNWANTED);
(this.data.dangerType === DangerType.DANGEROUS_CONTENT ||
this.data.dangerType === DangerType.DANGEROUS_HOST ||
this.data.dangerType === DangerType.DANGEROUS_URL ||
this.data.dangerType === DangerType.POTENTIALLY_UNWANTED);
},
/** @private */
......@@ -427,8 +427,8 @@ Polymer({
* @private
*/
computeShowCancel_: function() {
return this.data.state == States.IN_PROGRESS ||
this.data.state == States.PAUSED;
return this.data.state === States.IN_PROGRESS ||
this.data.state === States.PAUSED;
},
/**
......@@ -465,7 +465,7 @@ Polymer({
* @private
*/
isIndeterminate_: function() {
return this.data.percent == -1;
return this.data.percent === -1;
},
/** @private */
......@@ -501,7 +501,7 @@ Polymer({
IconLoader.getInstance()
.loadIcon(this.$['file-icon'], path)
.then(success => {
if (path == this.data.filePath) {
if (path === this.data.filePath) {
this.useFileIcon_ = success;
}
});
......
......@@ -203,14 +203,14 @@ Polymer({
this.$.toolbar.hasClearableDownloads =
loadTimeData.getBoolean('allowDeletingHistory') &&
this.items_.some(
({state}) => state != States.DANGEROUS &&
state != States.IN_PROGRESS && state != States.PAUSED);
({state}) => state !== States.DANGEROUS &&
state !== States.IN_PROGRESS && state !== States.PAUSED);
if (this.inSearchMode_) {
this.fire('iron-announce', {
text: this.items_.length == 0 ?
text: this.items_.length === 0 ?
this.noDownloadsText_() :
(this.items_.length == 1 ?
(this.items_.length === 1 ?
loadTimeData.getStringF(
'searchResultsSingular', this.$.toolbar.getSearchText()) :
loadTimeData.getStringF(
......@@ -336,7 +336,7 @@ Polymer({
continue;
}
const prev = this.items_[i - 1];
current.hideDate = !!prev && prev.dateString == current.dateString;
current.hideDate = !!prev && prev.dateString === current.dateString;
}
},
......
......@@ -52,10 +52,10 @@ export class SearchService {
*/
search(searchText) {
const searchTerms = SearchService.splitTerms(searchText);
let sameTerms = searchTerms.length == this.searchTerms_.length;
let sameTerms = searchTerms.length === this.searchTerms_.length;
for (let i = 0; sameTerms && i < searchTerms.length; ++i) {
if (searchTerms[i] != this.searchTerms_[i]) {
if (searchTerms[i] !== this.searchTerms_[i]) {
sameTerms = false;
}
}
......
......@@ -53,7 +53,7 @@ Polymer({
/** @return {boolean} Whether "Clear all" should be allowed. */
canClearAll: function() {
return this.getSearchText().length == 0 && this.hasClearableDownloads;
return this.getSearchText().length === 0 && this.hasClearableDownloads;
},
/** @return {string} The full text being searched. */
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module.exports = {
'env': {
'browser': true,
'es6': true,
},
'rules': {'eqeqeq': ['error', 'always', {'null': 'ignore'}]},
};
......@@ -210,9 +210,9 @@ Polymer({
* @private
*/
onAppKeyUp_: function(e) {
if (e.key == 'ArrowRight') {
if (e.key === 'ArrowRight') {
this.changeFocus_(e.currentTarget, 1);
} else if (e.key == 'ArrowLeft') {
} else if (e.key === 'ArrowLeft') {
this.changeFocus_(e.currentTarget, -1);
} else {
e.currentTarget.classList.add(KEYBOARD_FOCUSED);
......
......@@ -72,7 +72,7 @@ function notifyObservers() {
// Modules are only attached to DOM if they're for the current route, so
// as long as the id of an element matches up to the current step, it
// means that element is for the current route.
if (observer.id == `step-${step}`) {
if (observer.id === `step-${step}`) {
currentRouteElement = observer;
}
});
......@@ -152,7 +152,7 @@ export const NavigationBehavior = {
// Modules are only attached to DOM if they're for the current route, so
// as long as the id of an element matches up to the current step, it
// means that element is for the current route.
if (this.id == `step-${step}`) {
if (this.id === `step-${step}`) {
currentRouteElement = this;
this.onRouteEnter();
this.updateFocusForA11y();
......
......@@ -125,7 +125,7 @@ Polymer({
* @private
*/
isSelectedBackground_: function(background) {
return background == this.selectedBackground_;
return background === this.selectedBackground_;
},
/** @private */
......@@ -184,9 +184,9 @@ Polymer({
* @private
*/
onBackgroundKeyUp_: function(e) {
if (e.key == 'ArrowRight' || e.key == 'ArrowDown') {
if (e.key === 'ArrowRight' || e.key === 'ArrowDown') {
this.changeFocus_(e.currentTarget, 1);
} else if (e.key == 'ArrowLeft' || e.key == 'ArrowUp') {
} else if (e.key === 'ArrowLeft' || e.key === 'ArrowUp') {
this.changeFocus_(e.currentTarget, -1);
} else {
this.changeFocus_(e.currentTarget, 0);
......
......@@ -199,14 +199,14 @@ export class ModuleMetricsManager {
recordClickedOption() {
// Only overwrite this.firstPart if it's not overwritten already
if (this.firstPart == this.options_.didNothing) {
if (this.firstPart === this.options_.didNothing) {
this.firstPart = this.options_.choseAnOption;
}
}
recordClickedDisabledButton() {
// Only overwrite this.firstPart if it's not overwritten already
if (this.firstPart == this.options_.didNothing) {
if (this.firstPart === this.options_.didNothing) {
this.firstPart = this.options_.clickedDisabledNextButton;
}
}
......
......@@ -44,6 +44,6 @@ Polymer({
* @private
*/
getActiveClass_: function(index) {
return index == this.model.active ? 'active' : '';
return index === this.model.active ? 'active' : '';
},
});
......@@ -106,7 +106,7 @@ Polymer({
};
// If the route changed, initialize the steps of modules for that route.
if (this.currentRoute_ != route) {
if (this.currentRoute_ !== route) {
this.initializeModules(route).then(setStep);
} else {
setStep();
......@@ -123,7 +123,7 @@ Polymer({
.forEach(element => element.remove());
// If it is on landing route, end here.
if (route == Routes.LANDING) {
if (route === Routes.LANDING) {
return Promise.resolve();
}
......@@ -153,7 +153,7 @@ Polymer({
])
.then(([canSetDefault]) => {
modules = modules.filter(module => {
if (module == 'nux-set-as-default') {
if (module === 'nux-set-as-default') {
return canSetDefault;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment