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