Commit 175b5c3a authored by Demetrios Papadopoulos's avatar Demetrios Papadopoulos Committed by Commit Bot

WebUI: Enforce ESLint eqeqeq rule in c/b/r/history/

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: I9af03dd3a7fbd7d7b906a5b0e73786973657634e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1980213Reviewed-by: default avatarDan Beam <dbeam@chromium.org>
Commit-Queue: Demetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#727324}
parent a4128444
// Copyright 2018 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'}]},
};
...@@ -72,9 +72,9 @@ import './strings.js'; ...@@ -72,9 +72,9 @@ import './strings.js';
// Fallback if Event.path is not available. // Fallback if Event.path is not available.
let el = e.target; let el = e.target;
if (!anchor && el.nodeType == Node.ELEMENT_NODE && if (!anchor && el.nodeType === Node.ELEMENT_NODE &&
el.webkitMatchesSelector('A, A *')) { el.webkitMatchesSelector('A, A *')) {
while (el.tagName != 'A') { while (el.tagName !== 'A') {
el = el.parentElement; el = el.parentElement;
} }
anchor = el; anchor = el;
...@@ -85,8 +85,8 @@ import './strings.js'; ...@@ -85,8 +85,8 @@ import './strings.js';
} }
anchor = /** @type {!HTMLAnchorElement} */ (anchor); anchor = /** @type {!HTMLAnchorElement} */ (anchor);
if ((anchor.protocol == 'file:' || anchor.protocol == 'about:') && if ((anchor.protocol === 'file:' || anchor.protocol === 'about:') &&
(e.button == 0 || e.button == 1)) { (e.button === 0 || e.button === 1)) {
BrowserService.getInstance().navigateToUrl( BrowserService.getInstance().navigateToUrl(
anchor.href, anchor.target, /** @type {!MouseEvent} */ (e)); anchor.href, anchor.target, /** @type {!MouseEvent} */ (e));
e.preventDefault(); e.preventDefault();
...@@ -242,7 +242,7 @@ Polymer({ ...@@ -242,7 +242,7 @@ Polymer({
/** Overridden from IronScrollTargetBehavior */ /** Overridden from IronScrollTargetBehavior */
_scrollHandler: function() { _scrollHandler: function() {
if (this.scrollTarget) { if (this.scrollTarget) {
this.toolbarShadow_ = this.scrollTarget.scrollTop != 0; this.toolbarShadow_ = this.scrollTarget.scrollTop !== 0;
} }
}, },
...@@ -331,7 +331,7 @@ Polymer({ ...@@ -331,7 +331,7 @@ Polymer({
/** @private */ /** @private */
onDeleteCommand_: function() { onDeleteCommand_: function() {
if (this.$.toolbar.count == 0 || this.pendingDelete_) { if (this.$.toolbar.count === 0 || this.pendingDelete_) {
return; return;
} }
this.deleteSelected(); this.deleteSelected();
...@@ -383,7 +383,7 @@ Polymer({ ...@@ -383,7 +383,7 @@ Polymer({
* @private * @private
*/ */
syncedTabsSelected_: function(selectedPage) { syncedTabsSelected_: function(selectedPage) {
return selectedPage == 'syncedTabs'; return selectedPage === 'syncedTabs';
}, },
/** /**
...@@ -395,7 +395,7 @@ Polymer({ ...@@ -395,7 +395,7 @@ Polymer({
* @private * @private
*/ */
shouldShowSpinner_: function(querying, incremental, searchTerm) { shouldShowSpinner_: function(querying, incremental, searchTerm) {
return querying && !incremental && searchTerm != ''; return querying && !incremental && searchTerm !== '';
}, },
/** @private */ /** @private */
......
...@@ -72,7 +72,7 @@ import {ForeignSession, HistoryEntry, HistoryQuery} from './externs.js'; ...@@ -72,7 +72,7 @@ import {ForeignSession, HistoryEntry, HistoryQuery} from './externs.js';
* @param {string} action The name of the action to be logged. * @param {string} action The name of the action to be logged.
*/ */
recordAction(action) { recordAction(action) {
if (action.indexOf('_') == -1) { if (action.indexOf('_') === -1) {
action = `HistoryPage_${action}`; action = `HistoryPage_${action}`;
} }
chrome.send('metricsHandler:recordAction', [action]); chrome.send('metricsHandler:recordAction', [action]);
......
...@@ -126,8 +126,8 @@ Polymer({ ...@@ -126,8 +126,8 @@ Polymer({
onItemClick_: function(e) { onItemClick_: function(e) {
for (let i = 0; i < e.path.length; i++) { for (let i = 0; i < e.path.length; i++) {
const elem = e.path[i]; const elem = e.path[i];
if (elem.id != 'checkbox' && if (elem.id !== 'checkbox' &&
(elem.nodeName == 'A' || elem.nodeName == 'CR-ICON-BUTTON')) { (elem.nodeName === 'A' || elem.nodeName === 'CR-ICON-BUTTON')) {
return; return;
} }
} }
...@@ -211,7 +211,7 @@ Polymer({ ...@@ -211,7 +211,7 @@ Polymer({
return; return;
} }
if (this.$$('#bookmark-star') == this.root.activeElement) { if (this.$$('#bookmark-star') === this.root.activeElement) {
focusWithoutInk(this.$['menu-button']); focusWithoutInk(this.$['menu-button']);
} }
...@@ -249,7 +249,7 @@ Polymer({ ...@@ -249,7 +249,7 @@ Polymer({
browserService.recordAction('SearchResultClick'); browserService.recordAction('SearchResultClick');
} }
if (this.index == undefined) { if (this.index === undefined) {
return; return;
} }
...@@ -336,7 +336,7 @@ Polymer({ ...@@ -336,7 +336,7 @@ Polymer({
* @return {string} The title for a page of search results. * @return {string} The title for a page of search results.
*/ */
export function searchResultsTitle(numberOfResults, searchTerm) { export function searchResultsTitle(numberOfResults, searchTerm) {
const resultId = numberOfResults == 1 ? 'searchResult' : 'searchResults'; const resultId = numberOfResults === 1 ? 'searchResult' : 'searchResults';
return loadTimeData.getStringF( return loadTimeData.getStringF(
'foundSearchResults', numberOfResults, loadTimeData.getString(resultId), 'foundSearchResults', numberOfResults, loadTimeData.getString(resultId),
searchTerm); searchTerm);
......
...@@ -181,7 +181,7 @@ Polymer({ ...@@ -181,7 +181,7 @@ Polymer({
}, },
selectOrUnselectAll: function() { selectOrUnselectAll: function() {
if (this.historyData_.length == this.getSelectedItemCount()) { if (this.historyData_.length === this.getSelectedItemCount()) {
this.unselectAllItems(); this.unselectAllItems();
} else { } else {
this.selectAllItems(); this.selectAllItems();
...@@ -192,7 +192,7 @@ Polymer({ ...@@ -192,7 +192,7 @@ Polymer({
* Select each item in |historyData|. * Select each item in |historyData|.
*/ */
selectAllItems: function() { selectAllItems: function() {
if (this.historyData_.length == this.getSelectedItemCount()) { if (this.historyData_.length === this.getSelectedItemCount()) {
return; return;
} }
...@@ -209,7 +209,7 @@ Polymer({ ...@@ -209,7 +209,7 @@ Polymer({
this.changeSelection_(index, false); this.changeSelection_(index, false);
}); });
assert(this.selectedItems.size == 0); assert(this.selectedItems.size === 0);
}, },
/** @return {number} */ /** @return {number} */
...@@ -228,7 +228,7 @@ Polymer({ ...@@ -228,7 +228,7 @@ Polymer({
const browserService = BrowserService.getInstance(); const browserService = BrowserService.getInstance();
browserService.recordAction('RemoveSelected'); browserService.recordAction('RemoveSelected');
if (this.queryState.searchTerm != '') { if (this.queryState.searchTerm !== '') {
browserService.recordAction('SearchResultRemove'); browserService.recordAction('SearchResultRemove');
} }
this.$.dialog.get().showModal(); this.$.dialog.get().showModal();
...@@ -272,7 +272,7 @@ Polymer({ ...@@ -272,7 +272,7 @@ Polymer({
this.pendingDelete = false; this.pendingDelete = false;
this.removeItemsByIndex_(Array.from(this.selectedItems)); this.removeItemsByIndex_(Array.from(this.selectedItems));
this.fire('unselect-all'); this.fire('unselect-all');
if (this.historyData_.length == 0) { if (this.historyData_.length === 0) {
// Try reloading if nothing is rendered. // Try reloading if nothing is rendered.
this.fire('query-history', false); this.fire('query-history', false);
} }
...@@ -350,7 +350,7 @@ Polymer({ ...@@ -350,7 +350,7 @@ Polymer({
} }
for (let i = 0; i < this.historyData_.length; i++) { for (let i = 0; i < this.historyData_.length; i++) {
if (this.historyData_[i].url == url) { if (this.historyData_[i].url === url) {
this.set(`historyData_.${i}.starred`, false); this.set(`historyData_.${i}.starred`, false);
} }
} }
...@@ -436,7 +436,7 @@ Polymer({ ...@@ -436,7 +436,7 @@ Polymer({
this.removeItemsByIndex_([itemData.index]); this.removeItemsByIndex_([itemData.index]);
const index = itemData.index; const index = itemData.index;
if (index == undefined) { if (index === undefined) {
return; return;
} }
setTimeout(() => { setTimeout(() => {
...@@ -470,14 +470,14 @@ Polymer({ ...@@ -470,14 +470,14 @@ Polymer({
// Handle shift selection. Change the selection state of all items between // Handle shift selection. Change the selection state of all items between
// |path| and |lastSelected| to the selection state of |item|. // |path| and |lastSelected| to the selection state of |item|.
if (e.detail.shiftKey && this.lastSelectedIndex != undefined) { if (e.detail.shiftKey && this.lastSelectedIndex !== undefined) {
for (let i = Math.min(index, this.lastSelectedIndex); for (let i = Math.min(index, this.lastSelectedIndex);
i <= Math.max(index, this.lastSelectedIndex); i++) { i <= Math.max(index, this.lastSelectedIndex); i++) {
indices.push(i); indices.push(i);
} }
} }
if (indices.length == 0) { if (indices.length === 0) {
indices.push(index); indices.push(index);
} }
...@@ -503,7 +503,7 @@ Polymer({ ...@@ -503,7 +503,7 @@ Polymer({
*/ */
needsTimeGap_: function(item, index) { needsTimeGap_: function(item, index) {
const length = this.historyData_.length; const length = this.historyData_.length;
if (index === undefined || index >= length - 1 || length == 0) { if (index === undefined || index >= length - 1 || length === 0) {
return false; return false;
} }
...@@ -511,11 +511,11 @@ Polymer({ ...@@ -511,11 +511,11 @@ Polymer({
const nextItem = this.historyData_[index + 1]; const nextItem = this.historyData_[index + 1];
if (this.searchedTerm) { if (this.searchedTerm) {
return currentItem.dateShort != nextItem.dateShort; return currentItem.dateShort !== nextItem.dateShort;
} }
return currentItem.time - nextItem.time > BROWSING_GAP_TIME && return currentItem.time - nextItem.time > BROWSING_GAP_TIME &&
currentItem.dateRelativeDay == nextItem.dateRelativeDay; currentItem.dateRelativeDay === nextItem.dateRelativeDay;
}, },
/** /**
...@@ -527,11 +527,11 @@ Polymer({ ...@@ -527,11 +527,11 @@ Polymer({
*/ */
isCardStart_: function(item, i) { isCardStart_: function(item, i) {
const length = this.historyData_.length; const length = this.historyData_.length;
if (i === undefined || length == 0 || i > length - 1) { if (i === undefined || length === 0 || i > length - 1) {
return false; return false;
} }
return i == 0 || return i === 0 ||
this.historyData_[i].dateRelativeDay != this.historyData_[i].dateRelativeDay !==
this.historyData_[i - 1].dateRelativeDay; this.historyData_[i - 1].dateRelativeDay;
}, },
...@@ -544,11 +544,11 @@ Polymer({ ...@@ -544,11 +544,11 @@ Polymer({
*/ */
isCardEnd_: function(item, i) { isCardEnd_: function(item, i) {
const length = this.historyData_.length; const length = this.historyData_.length;
if (i === undefined || length == 0 || i > length - 1) { if (i === undefined || length === 0 || i > length - 1) {
return false; return false;
} }
return i == length - 1 || return i === length - 1 ||
this.historyData_[i].dateRelativeDay != this.historyData_[i].dateRelativeDay !==
this.historyData_[i + 1].dateRelativeDay; this.historyData_[i + 1].dateRelativeDay;
}, },
...@@ -586,7 +586,7 @@ Polymer({ ...@@ -586,7 +586,7 @@ Polymer({
* @private * @private
*/ */
initializeResults_: function(info, results) { initializeResults_: function(info, results) {
if (results.length == 0) { if (results.length === 0) {
return; return;
} }
...@@ -596,9 +596,9 @@ Polymer({ ...@@ -596,9 +596,9 @@ Polymer({
// Sets the default values for these fields to prevent undefined types. // Sets the default values for these fields to prevent undefined types.
results[i].selected = false; results[i].selected = false;
results[i].readableTimestamp = results[i].readableTimestamp =
info.term == '' ? results[i].dateTimeOfDay : results[i].dateShort; info.term === '' ? results[i].dateTimeOfDay : results[i].dateShort;
if (results[i].dateRelativeDay != currentDate) { if (results[i].dateRelativeDay !== currentDate) {
currentDate = results[i].dateRelativeDay; currentDate = results[i].dateRelativeDay;
} }
} }
......
...@@ -92,7 +92,7 @@ Polymer({ ...@@ -92,7 +92,7 @@ Polymer({
* @private * @private
*/ */
searchTermChanged_: function() { searchTermChanged_: function() {
if (this.searchField.getValue() != this.searchTerm) { if (this.searchField.getValue() !== this.searchTerm) {
this.searchField.showAndFocus(); this.searchField.showAndFocus();
this.searchField.setValue(this.searchTerm); this.searchField.setValue(this.searchTerm);
} }
......
...@@ -88,8 +88,8 @@ Polymer({ ...@@ -88,8 +88,8 @@ Polymer({
const changes = /** @type {{search: ?string}} */ (e.detail); const changes = /** @type {{search: ?string}} */ (e.detail);
let needsUpdate = false; let needsUpdate = false;
if (changes.search != null && if (changes.search !== null &&
changes.search != this.queryState.searchTerm) { changes.search !== this.queryState.searchTerm) {
this.set('queryState.searchTerm', changes.search); this.set('queryState.searchTerm', changes.search);
needsUpdate = true; needsUpdate = true;
} }
......
...@@ -77,7 +77,7 @@ Polymer({ ...@@ -77,7 +77,7 @@ Polymer({
serializeUrl: function() { serializeUrl: function() {
let path = this.selectedPage; let path = this.selectedPage;
if (path == 'history') { if (path === 'history') {
path = ''; path = '';
} }
......
...@@ -30,7 +30,8 @@ Polymer({ ...@@ -30,7 +30,8 @@ Polymer({
const titleText = this.title; const titleText = this.title;
if (this.searchTerm == '' || this.searchTerm == null) { if (this.searchTerm === '' || this.searchTerm === null ||
this.searchTerm === undefined) {
this.textContent = titleText; this.textContent = titleText;
return; return;
} }
......
...@@ -142,7 +142,7 @@ Polymer({ ...@@ -142,7 +142,7 @@ Polymer({
/** @private */ /** @private */
isWindowSeparatorIndex_: function(index, separatorIndexes) { isWindowSeparatorIndex_: function(index, separatorIndexes) {
return this.separatorIndexes.indexOf(index) != -1; return this.separatorIndexes.indexOf(index) !== -1;
}, },
/** /**
......
...@@ -128,7 +128,7 @@ Polymer({ ...@@ -128,7 +128,7 @@ Polymer({
for (let i = 0; i < session.windows.length; i++) { for (let i = 0; i < session.windows.length; i++) {
const windowId = session.windows[i].sessionId; const windowId = session.windows[i].sessionId;
const newTabs = session.windows[i].tabs; const newTabs = session.windows[i].tabs;
if (newTabs.length == 0) { if (newTabs.length === 0) {
continue; continue;
} }
...@@ -145,13 +145,13 @@ Polymer({ ...@@ -145,13 +145,13 @@ Polymer({
const searchText = this.searchTerm.toLowerCase(); const searchText = this.searchTerm.toLowerCase();
for (let j = 0; j < newTabs.length; j++) { for (let j = 0; j < newTabs.length; j++) {
const tab = newTabs[j]; const tab = newTabs[j];
if (tab.title.toLowerCase().indexOf(searchText) != -1) { if (tab.title.toLowerCase().indexOf(searchText) !== -1) {
tabs.push(tab); tabs.push(tab);
windowAdded = true; windowAdded = true;
} }
} }
} }
if (windowAdded && i != session.windows.length - 1) { if (windowAdded && i !== session.windows.length - 1) {
separatorIndexes.push(tabs.length - 1); separatorIndexes.push(tabs.length - 1);
} }
} }
...@@ -241,7 +241,7 @@ Polymer({ ...@@ -241,7 +241,7 @@ Polymer({
return true; return true;
} }
return signInState && syncedDevicesLength == 0; return signInState && syncedDevicesLength === 0;
}, },
/** /**
...@@ -299,7 +299,7 @@ Polymer({ ...@@ -299,7 +299,7 @@ Polymer({
const devices = []; const devices = [];
sessionList.forEach((session) => { sessionList.forEach((session) => {
const device = this.createInternalDevice_(session); const device = this.createInternalDevice_(session);
if (device.tabs.length != 0) { if (device.tabs.length !== 0) {
devices.push(device); devices.push(device);
} }
}); });
......
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