Commit 47387f28 authored by Kuo Jen Wei's avatar Kuo Jen Wei Committed by Commit Bot

[CCA] Add eqeqeq rule to eslintrc.

Bug: b/117810572
Test: Pass presubmit check. Pass tast run <DUT> 'camera.CCAUI*'
Change-Id: I7ad44a0d3d78ddd2c4f0d052d0bb6402e2406d1c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1886270Reviewed-by: default avatarShik Chen <shik@chromium.org>
Commit-Queue: Kuo Jen Wei <inker@chromium.org>
Auto-Submit: Kuo Jen Wei <inker@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714860}
parent 7d5415e8
......@@ -161,6 +161,7 @@ module.exports = {
// Chromium tree.
'rules': Object.assign({}, googleRules, {
'curly': [2, 'multi-line', 'consistent'],
'eqeqeq': 2,
'no-console': [2, {allow: ['warn', 'error']}],
// We are using 2 spaces before trailing line comments. The option
......
......@@ -141,7 +141,7 @@ cca.device.DeviceInfoUpdater = class {
*/
async enumerateDevices_() {
const devices = (await navigator.mediaDevices.enumerateDevices())
.filter((device) => device.kind == 'videoinput');
.filter((device) => device.kind === 'videoinput');
if (devices.length === 0) {
throw new Error('Device list empty.');
}
......
......@@ -113,7 +113,7 @@ cca.App.prototype.setupToggles_ = function() {
document.querySelectorAll('input').forEach((element) => {
element.addEventListener(
'keypress',
(event) => cca.util.getShortcutIdentifier(event) == 'Enter' &&
(event) => cca.util.getShortcutIdentifier(event) === 'Enter' &&
element.click());
var css = element.getAttribute('data-state');
......@@ -129,7 +129,7 @@ cca.App.prototype.setupToggles_ = function() {
}
if (event.isTrusted) {
element.save();
if (element.type == 'radio' && element.checked) {
if (element.type === 'radio' && element.checked) {
// Handle unchecked grouped sibling radios.
var grouped = `input[type=radio][name=${element.name}]:not(:checked)`;
document.querySelectorAll(grouped).forEach(
......@@ -181,7 +181,7 @@ cca.App.prototype.start = function() {
})
.catch((error) => {
console.error(error);
if (error && error.message == 'no-migrate') {
if (error && error.message === 'no-migrate') {
chrome.app.window.current().close();
return;
}
......
......@@ -88,7 +88,7 @@ cca.mojo.DeviceOperator = class {
// The data of |streamConfigs| looks like:
// streamConfigs: [FORMAT_1, WIDTH_1, HEIGHT_1, TYPE_1,
// FORMAT_2, WIDTH_2, HEIGHT_2, TYPE_2, ...]
if (streamConfigs.length % numElementPerEntry != 0) {
if (streamConfigs.length % numElementPerEntry !== 0) {
throw new Error('Unexpected length of stream configurations');
}
......@@ -129,7 +129,7 @@ cca.mojo.DeviceOperator = class {
// minFrameDurationCOnfigs: [FORMAT_1, WIDTH_1, HEIGHT_1, DURATION_1,
// FORMAT_2, WIDTH_2, HEIGHT_2, DURATION_2,
// ...]
if (minFrameDurationConfigs.length % numElementPerEntry != 0) {
if (minFrameDurationConfigs.length % numElementPerEntry !== 0) {
throw new Error('Unexpected length of frame durations configs');
}
......@@ -181,7 +181,7 @@ cca.mojo.DeviceOperator = class {
// The data of |availableFpsRanges| looks like:
// availableFpsRanges: [RANGE_1_MIN, RANGE_1_MAX,
// RANGE_2_MIN, RANGE_2_MAX, ...]
if (availableFpsRanges.length % numElementPerEntry != 0) {
if (availableFpsRanges.length % numElementPerEntry !== 0) {
throw new Error('Unexpected length of available fps range configs');
}
......@@ -370,7 +370,7 @@ cca.mojo.DeviceOperator = class {
* @return {!Promise<boolean>} True if the DeviceOperator is supported.
*/
static async isSupported() {
return await this.getInstance() != null;
return await this.getInstance() !== null;
}
};
......
......@@ -60,7 +60,7 @@ var Resolution = class {
* @return {boolean} Whether aspect ratio of resolutions are equal.
*/
aspectRatioEquals(resolution) {
return this.width * resolution.height == this.height * resolution.width;
return this.width * resolution.height === this.height * resolution.width;
}
/**
......
......@@ -25,7 +25,7 @@ cca.util.getPhotoOrientation = function(blob) {
let reader = new FileReader();
reader.onload = function(event) {
let view = new DataView(event.target.result);
if (view.getUint16(0, false) != 0xFFD8) {
if (view.getUint16(0, false) !== 0xFFD8) {
resolve(1);
return;
}
......@@ -37,22 +37,22 @@ cca.util.getPhotoOrientation = function(blob) {
}
let marker = view.getUint16(offset, false);
offset += 2;
if (marker == 0xFFE1) {
if (view.getUint32(offset += 2, false) != 0x45786966) {
if (marker === 0xFFE1) {
if (view.getUint32(offset += 2, false) !== 0x45786966) {
break;
}
let little = view.getUint16(offset += 6, false) == 0x4949;
let little = view.getUint16(offset += 6, false) === 0x4949;
offset += view.getUint32(offset + 4, little);
let tags = view.getUint16(offset, little);
offset += 2;
for (let i = 0; i < tags; i++) {
if (view.getUint16(offset + (i * 12), little) == 0x0112) {
if (view.getUint16(offset + (i * 12), little) === 0x0112) {
resolve(view.getUint16(offset + (i * 12) + 8, little));
return;
}
}
} else if ((marker & 0xFF00) != 0xFF00) {
} else if ((marker & 0xFF00) !== 0xFF00) {
break;
} else {
offset += view.getUint16(offset, false);
......@@ -119,7 +119,7 @@ cca.util.orientPhoto = function(blob, onSuccess, onFailure) {
context.translate(-centerX, -centerY);
let outputCanvas = document.createElement('canvas');
if (orientation.rotation == 90 || orientation.rotation == 270) {
if (orientation.rotation === 90 || orientation.rotation === 270) {
outputCanvas.width = original.height;
outputCanvas.height = original.width;
} else {
......@@ -143,7 +143,7 @@ cca.util.orientPhoto = function(blob, onSuccess, onFailure) {
};
cca.util.getPhotoOrientation(blob).then((orientation) => {
if (orientation.rotation == 0 && !orientation.flip) {
if (orientation.rotation === 0 && !orientation.flip) {
onSuccess(blob);
} else {
let original = document.createElement('img');
......@@ -209,7 +209,7 @@ cca.util.animateCancel = function(element) {
cca.util.waitAnimationCompleted = function(element, callback) {
var completed = false;
var onCompleted = (event) => {
if (completed || (event && event.target != element)) {
if (completed || (event && event.target !== element)) {
return;
}
completed = true;
......@@ -372,8 +372,8 @@ cca.util.SmoothScroller.prototype.scrollTo = function(x, y, mode) {
'translate(' + -dx + 'px, ' + -dy + 'px)';
// If nothing to change, then return.
if (this.padder_.style.webkitTransform == transformString ||
(dx == 0 && dy == 0 && !this.padder_.style.webkitTransform)) {
if (this.padder_.style.webkitTransform === transformString ||
(dx === 0 && dy === 0 && !this.padder_.style.webkitTransform)) {
return;
}
......@@ -390,7 +390,7 @@ cca.util.SmoothScroller.prototype.scrollTo = function(x, y, mode) {
// animation is finished.
cca.util.waitAnimationCompleted(this.padder_, () => {
// Check if the animation got invalidated by a later scroll.
if (currentAnimationId == this.animationId_) {
if (currentAnimationId === this.animationId_) {
this.flushScroll_();
}
});
......@@ -453,8 +453,8 @@ cca.util.PointerTracker.prototype.onMouseMove_ = function(event) {
// Ignore mouse events, which are invoked on the same position, but with
// changed client coordinates. This will happen eg. when scrolling. We should
// ignore them, since they are not invoked by an actual mouse move.
if (this.lastMousePosition_ && this.lastMousePosition_[0] == event.screenX &&
this.lastMousePosition_[1] == event.screenY) {
if (this.lastMousePosition_ && this.lastMousePosition_[0] === event.screenX &&
this.lastMousePosition_[1] === event.screenY) {
return;
}
......@@ -649,8 +649,8 @@ cca.util.ScrollTracker.prototype.probe_ = function() {
var scrollTop = this.scroller_.scrollTop;
var scrollChanged =
scrollLeft != this.lastScrollPosition_[0] ||
scrollTop != this.lastScrollPosition_[1] ||
scrollLeft !== this.lastScrollPosition_[0] ||
scrollTop !== this.lastScrollPosition_[1] ||
this.scroller_.animating;
if (scrollChanged) {
......@@ -732,7 +732,7 @@ cca.util.MouseScroller = function(scroller) {
* @private
*/
cca.util.MouseScroller.prototype.onMouseDown_ = function(event) {
if (event.which != 1) {
if (event.which !== 1) {
return;
}
this.startPosition_ = [event.screenX, event.screenY];
......@@ -754,7 +754,7 @@ cca.util.MouseScroller.prototype.onMouseMove_ = function(event) {
// It may happen that we won't receive the mouseup event, when clicking on
// the -webkit-app-region: drag area.
if (event.which != 1) {
if (event.which !== 1) {
this.startPosition_ = null;
this.startScrollPosition_ = null;
return;
......
......@@ -135,7 +135,7 @@ cca.views.Camera = function(
// Monitor the states to stop camera when locked/minimized.
chrome.idle.onStateChanged.addListener((newState) => {
this.locked_ = (newState == 'locked');
this.locked_ = (newState === 'locked');
if (this.locked_) {
this.restart();
}
......@@ -199,7 +199,7 @@ cca.views.Camera.prototype.beginTake_ = function() {
}
await this.modes_.current.startCapture();
} catch (e) {
if (e && e.message == 'cancel') {
if (e && e.message === 'cancel') {
return;
}
console.error(e);
......@@ -272,7 +272,7 @@ cca.views.Camera.prototype.layout = function() {
* @override
*/
cca.views.Camera.prototype.handlingKey = function(key) {
if (key == 'Ctrl-R') {
if (key === 'Ctrl-R') {
cca.toast.show(this.preview_.toString());
return true;
}
......
......@@ -210,7 +210,7 @@ cca.views.camera.Modes = function(
* @param {!cca.views.camera.Mode} mode Mode to be toggled.
*/
cca.views.camera.Modes.prototype.updateModeUI_ = function(mode) {
Object.keys(this.allModes_).forEach((m) => cca.state.set(m, m == mode));
Object.keys(this.allModes_).forEach((m) => cca.state.set(m, m === mode));
const element = document.querySelector(`.mode-item>input[data-mode=${mode}]`);
element.checked = true;
const wrapper = element.parentElement;
......@@ -373,7 +373,7 @@ cca.views.camera.Modes.prototype.updateModeSelectionUI =
*/
cca.views.camera.Modes.prototype.updateMode =
async function(mode, stream, deviceId, captureResolution) {
if (this.current != null) {
if (this.current !== null) {
await this.current.stopCapture();
}
this.updateModeUI_(mode);
......@@ -562,7 +562,7 @@ cca.views.camera.Video.prototype.start_ = async function() {
this.startSound_ = null;
}
if (this.mediaRecorder_ == null) {
if (this.mediaRecorder_ === null) {
try {
if (!MediaRecorder.isTypeSupported(
cca.views.camera.Video.VIDEO_MIMETYPE)) {
......@@ -600,7 +600,7 @@ cca.views.camera.Video.prototype.stop_ = function() {
if (this.startSound_ && this.startSound_.cancel) {
this.startSound_.cancel();
}
if (this.mediaRecorder_ && this.mediaRecorder_.state == 'recording') {
if (this.mediaRecorder_ && this.mediaRecorder_.state === 'recording') {
this.mediaRecorder_.stop();
}
};
......@@ -696,7 +696,7 @@ cca.views.camera.Photo.prototype = {
*/
cca.views.camera.Photo.prototype.start_ = async function() {
cca.sound.play('#sound-shutter');
if (this.imageCapture_ == null) {
if (this.imageCapture_ === null) {
try {
this.imageCapture_ = new ImageCapture(this.stream_.getVideoTracks()[0]);
} catch (e) {
......@@ -903,7 +903,7 @@ cca.views.camera.Portrait.prototype = {
*/
cca.views.camera.Portrait.prototype.start_ = async function() {
cca.sound.play('#sound-shutter');
if (this.crosImageCapture_ == null) {
if (this.crosImageCapture_ === null) {
try {
this.crosImageCapture_ =
new cca.mojo.ImageCapture(this.stream_.getVideoTracks()[0]);
......
......@@ -149,8 +149,8 @@ cca.views.camera.Options.prototype.switchDevice_ = async function() {
const devices = await this.infoUpdater_.getDevicesInfo();
cca.util.animateOnce(document.querySelector('#switch-device'));
var index =
devices.findIndex((entry) => entry.deviceId == this.videoDeviceId_);
if (index == -1) {
devices.findIndex((entry) => entry.deviceId === this.videoDeviceId_);
if (index === -1) {
index = 0;
}
if (devices.length > 0) {
......@@ -203,7 +203,7 @@ cca.views.camera.Options.prototype.updateValues = async function(stream) {
cca.views.camera.Options.prototype.updateMirroring_ = function(facingMode) {
// Update mirroring by detected facing-mode. Enable mirroring by default if
// facing-mode isn't available.
var enabled = facingMode ? facingMode != 'environment' : true;
var enabled = facingMode ? facingMode !== 'environment' : true;
// Override mirroring only if mirroring was toggled manually.
if (this.videoDeviceId_ in this.mirroringToggles_) {
......@@ -261,7 +261,7 @@ cca.views.camera.Options.prototype.videoDeviceIds = async function() {
cros.mojom.CameraFacing.CAMERA_FACING_FRONT;
// Put the selected video device id first.
var sorted = devices.map((device) => device.deviceId).sort((a, b) => {
if (a == b) {
if (a === b) {
return 0;
}
if (this.videoDeviceId_ ? a === this.videoDeviceId_ :
......
......@@ -355,7 +355,7 @@ cca.views.ResolutionSettings.prototype.photoOptTextTempl_ = function(
const /** number */ d = gcd(r.width, r.height);
if (resolutions.some(
(findR) => !findR.equals(r) && r.aspectRatioEquals(findR) &&
toMegapixel(r) == toMegapixel(findR))) {
toMegapixel(r) === toMegapixel(findR))) {
return chrome.i18n.getMessage(
'label_detail_photo_resolution',
[r.width / d, r.height / d, r.width, r.height, toMegapixel(r)]);
......
......@@ -43,8 +43,10 @@ cca.views.View = function(
this.dismissByEsc_ = dismissByEsc;
if (dismissByBkgndClick) {
this.rootElement_.addEventListener('click', (event) =>
event.target == this.rootElement_ && this.leave({bkgnd: true}));
this.rootElement_.addEventListener(
'click',
(event) =>
event.target === this.rootElement_ && this.leave({bkgnd: true}));
}
};
......@@ -71,10 +73,10 @@ cca.views.View.prototype.handlingKey = function(key) {
cca.views.View.prototype.onKeyPressed = function(key) {
if (this.handlingKey(key)) {
return true;
} else if (key == 'Ctrl-V') {
} else if (key === 'Ctrl-V') {
cca.toast.show(chrome.runtime.getManifest().version);
return true;
} else if (this.dismissByEsc_ && key == 'Escape') {
} else if (this.dismissByEsc_ && key === 'Escape') {
this.leave();
return true;
}
......
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