Commit 5e5e8ed3 authored by dpapad's avatar dpapad Committed by Commit Bot

Enforce ESLint eqeqeq rule in chrome://discards.

Bug: 720034
Change-Id: I3a6b4a4994930b1da62680672efd181506a5a6f8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2148845
Commit-Queue: Sigurður Ásgeirsson <siggi@chromium.org>
Auto-Submit: dpapad <dpapad@chromium.org>
Reviewed-by: default avatarSigurður Ásgeirsson <siggi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#759221}
parent 32b3c249
// Copyright 2020 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'}]},
};
......@@ -19,7 +19,7 @@ import {SortedTableBehavior} from './sorted_table_behavior.js';
* being compared.
* @param {discards.mojom.SiteCharacteristicsDatabaseEntry} b The second value
* being compared.
* @return {number} A negative number if a < b, 0 if a == b, and a positive
* @return {number} A negative number if a < b, 0 if a === b, and a positive
* number if a > b.
*/
function compareRowsByOrigin(a, b) {
......@@ -32,7 +32,7 @@ function compareRowsByOrigin(a, b) {
* being compared.
* @param {discards.mojom.SiteCharacteristicsDatabaseEntry} b The second value
* being compared.
* @return {number} A negative number if a < b, 0 if a == b, and a positive
* @return {number} A negative number if a < b, 0 if a === b, and a positive
* number if a > b.
*/
function compareRowsByIsDirty(a, b) {
......@@ -45,7 +45,7 @@ function compareRowsByIsDirty(a, b) {
* being compared.
* @param {discards.mojom.SiteCharacteristicsDatabaseEntry} b The second value
* being compared.
* @return {number} A negative number if a < b, 0 if a == b, and a positive
* @return {number} A negative number if a < b, 0 if a === b, and a positive
* number if a > b.
*/
function compareRowsByLastLoaded(a, b) {
......@@ -58,7 +58,7 @@ function compareRowsByLastLoaded(a, b) {
* being compared.
* @param {discards.mojom.SiteCharacteristicsDatabaseEntry} b The second value
* being compared.
* @return {number} A negative number if a < b, 0 if a == b, and a positive
* @return {number} A negative number if a < b, 0 if a === b, and a positive
* number if a > b.
*/
function compareRowsByCpuUsage(a, b) {
......@@ -75,7 +75,7 @@ function compareRowsByCpuUsage(a, b) {
* being compared.
* @param {discards.mojom.SiteCharacteristicsDatabaseEntry} b The second value
* being compared.
* @return {number} A negative number if a < b, 0 if a == b, and a positive
* @return {number} A negative number if a < b, 0 if a === b, and a positive
* number if a > b.
*/
function compareRowsByMemoryUsage(a, b) {
......@@ -92,7 +92,7 @@ function compareRowsByMemoryUsage(a, b) {
* being compared.
* @param {discards.mojom.SiteCharacteristicsDatabaseEntry} b The second value
* being compared.
* @return {number} A negative number if a < b, 0 if a == b, and a positive
* @return {number} A negative number if a < b, 0 if a === b, and a positive
* number if a > b.
*/
function compareRowsByLoadDuration(a, b) {
......@@ -110,7 +110,7 @@ function compareRowsByLoadDuration(a, b) {
* @return {function(discards.mojom.SiteCharacteristicsDatabaseEntry,
discards.mojom.SiteCharacteristicsDatabaseEntry): number}
* A comparison function that compares two tab infos, returns
* negative number if a < b, 0 if a == b, and a positive
* negative number if a < b, 0 if a === b, and a positive
* number if a > b.
*/
function getSortFunctionForKey(sortKey) {
......@@ -342,7 +342,7 @@ Polymer({
* @param {boolean} sortReverse True if sorting is reversed.
* @return {function({Object}, {Object}): number}
* A comparison function that compares two tab infos, returns
* negative number if a < b, 0 if a == b, and a positive
* negative number if a < b, 0 if a === b, and a positive
* number if a > b.
* @private
*/
......@@ -443,7 +443,7 @@ Polymer({
* @private
*/
kilobytesToString_(value) {
return value == -1 ? 'N/A' : kilobytesToString(value);
return value === -1 ? 'N/A' : kilobytesToString(value);
},
/**
......@@ -452,6 +452,6 @@ Polymer({
* @private
*/
optionalIntegerToString_(value) {
return value == -1 ? 'N/A' : value.toString();
return value === -1 ? 'N/A' : value.toString();
},
});
......@@ -33,10 +33,10 @@
* 's' is sufficient to make a string plural.
* @param {string} s The string to be made plural if necessary.
* @param {number} n The count of the number of ojects.
* @return {string} The plural version of |s| if n != 1, otherwise |s|.
* @return {string} The plural version of |s| if n !== 1, otherwise |s|.
*/
export function maybeMakePlural(s, n) {
return n == 1 ? s : s + 's';
return n === 1 ? s : s + 's';
}
/**
......
......@@ -44,7 +44,7 @@ Polymer({
* @private
*/
selectedChanged_(newValue, oldValue) {
if (oldValue != undefined) {
if (oldValue !== undefined) {
// The first tab is special-cased to the empty path.
const defaultTab = this.tabs[0].toLowerCase();
const tabName = this.tabs[newValue].toLowerCase();
......
......@@ -19,7 +19,7 @@ import {SortedTableBehavior} from './sorted_table_behavior.js';
* attribute of the table headers for valid sort-keys.
* @param {boolean|number|string} a The first value being compared.
* @param {boolean|number|string} b The second value being compared.
* @return {number} A negative number if a < b, 0 if a == b, and a positive
* @return {number} A negative number if a < b, 0 if a === b, and a positive
* number if a > b.
*/
export function compareTabDiscardsInfos(sortKey, a, b) {
......@@ -27,10 +27,10 @@ export function compareTabDiscardsInfos(sortKey, a, b) {
let val2 = b[sortKey];
// Compares strings.
if (sortKey == 'title' || sortKey == 'tabUrl') {
if (sortKey === 'title' || sortKey === 'tabUrl') {
val1 = val1.toLowerCase();
val2 = val2.toLowerCase();
if (val1 == val2) {
if (val1 === val2) {
return 0;
}
return val1 > val2 ? 1 : -1;
......@@ -38,17 +38,17 @@ export function compareTabDiscardsInfos(sortKey, a, b) {
// Compares boolean fields.
if (['canFreeze', 'isAutoDiscardable'].includes(sortKey)) {
if (val1 == val2) {
if (val1 === val2) {
return 0;
}
return val1 ? 1 : -1;
}
// Compare lifecycle state. This is actually a compound key.
if (sortKey == 'state') {
if (sortKey === 'state') {
// If the keys are discarding state, then break ties using the discard
// reason.
if (val1 == val2 && val1 == mojom.LifecycleUnitState.DISCARDED) {
if (val1 === val2 && val1 === mojom.LifecycleUnitState.DISCARDED) {
val1 = a['discardReason'];
val2 = b['discardReason'];
}
......@@ -113,7 +113,7 @@ Polymer({
* @param {boolean} sortReverse True if sorting is reversed.
* @return {function({Object}, {Object}): number}
* A comparison function that compares two tab infos, returns
* negative number if a < b, 0 if a == b, and a positive
* negative number if a < b, 0 if a === b, and a positive
* number if a > b.
* @private
*/
......@@ -225,7 +225,7 @@ Polymer({
return 'frozen';
case mojom.LifecycleUnitState.DISCARDED:
return 'discarded (' + this.discardReasonToString_(reason) + ')' +
((reason == mojom.LifecycleUnitDiscardReason.URGENT) ? ' at ' +
((reason === mojom.LifecycleUnitDiscardReason.URGENT) ? ' at ' +
// Must convert since Date constructor takes
// milliseconds.
(new Date(stateChangeTime.microseconds / 1000))
......@@ -299,7 +299,7 @@ Polymer({
* @private
*/
getLifeCycleState_(item) {
if (item.loadingState != mojom.LifecycleUnitLoadingState.UNLOADED ||
if (item.loadingState !== mojom.LifecycleUnitLoadingState.UNLOADED ||
item.discardCount > 0) {
return this.lifecycleStateToString_(
item.state, item.discardReason, item.visibility, item.hasFocus,
......@@ -338,7 +338,7 @@ Polymer({
* @private
*/
hasCannotFreezeReasons_(item) {
return item.cannotFreezeReasons.length != 0;
return item.cannotFreezeReasons.length !== 0;
},
/**
* Tests whether an item has reasons why it cannot be discarded.
......@@ -348,7 +348,7 @@ Polymer({
* @private
*/
hasCannotDiscardReasons_(item) {
return item.cannotDiscardReasons.length != 0;
return item.cannotDiscardReasons.length !== 0;
},
/**
......@@ -358,7 +358,7 @@ Polymer({
* @private
*/
canLoad_(item) {
return item.loadingState == mojom.LifecycleUnitLoadingState.UNLOADED;
return item.loadingState === mojom.LifecycleUnitLoadingState.UNLOADED;
},
/**
......@@ -368,8 +368,8 @@ Polymer({
* @private
*/
canFreeze_(item) {
if (item.visibility == discards.mojom.LifecycleUnitVisibility.HIDDEN ||
item.visibility == discards.mojom.LifecycleUnitVisibility.OCCLUDED) {
if (item.visibility === discards.mojom.LifecycleUnitVisibility.HIDDEN ||
item.visibility === discards.mojom.LifecycleUnitVisibility.OCCLUDED) {
// Only tabs that aren't visible can be frozen for now.
switch (item.state) {
case mojom.LifecycleUnitState.DISCARDED:
......@@ -389,8 +389,8 @@ Polymer({
* @private
*/
canDiscard_(item) {
if (item.visibility == discards.mojom.LifecycleUnitVisibility.HIDDEN ||
item.visibility == discards.mojom.LifecycleUnitVisibility.OCCLUDED) {
if (item.visibility === discards.mojom.LifecycleUnitVisibility.HIDDEN ||
item.visibility === discards.mojom.LifecycleUnitVisibility.OCCLUDED) {
// Only tabs that aren't visible can be discarded for now.
switch (item.state) {
case mojom.LifecycleUnitState.DISCARDED:
......
......@@ -269,7 +269,7 @@ function boundingForce(graphHeight) {
const node = nodes[i];
const yOld = node.y;
const yNew = Math.max(bound[0], Math.min(yOld, bound[1]));
if (yOld != yNew) {
if (yOld !== yNew) {
node.y = yNew;
// Zero the velocity of clamped nodes.
node.vy = 0;
......@@ -446,8 +446,8 @@ class Graph {
*/
removeNodeLinks_(node) {
// Filter away any links to or from the deleted node.
this.links_ =
this.links_.filter(link => link.source != node && link.target != node);
this.links_ = this.links_.filter(
link => link.source !== node && link.target !== node);
}
/**
......
......@@ -50,7 +50,7 @@ export const SortedTableBehavior = {
}
const newSortKey = e.currentTarget.dataset.sortKey;
if (newSortKey == this.sortKey) {
if (newSortKey === this.sortKey) {
this.sortReverse = !this.sortReverse;
} else {
this.setSortKey(newSortKey);
......
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