Always add braces to single-line if-statements
The Chromium/Google style guides does not enforce curly braces for
single-line if-statements, but does strongly recommend doing so. Adding
braces will improve code readability, by visually separating code
blocks. This will also prevent issues where accidental additions are
pushed to the "else"-clause instead of in the if-block.
This CL also updates the presubmit `eslint` to run the fix with the
correct configuration. It will now fix all issues it can fix.
Change-Id: I4b616f21a99393f168dec743c0bcbdc7f5db04a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1821526
Commit-Queue: Tim Van der Lippe <[email protected]>
Reviewed-by: Yang Guo <[email protected]>
Reviewed-by: Jeff Fisher <[email protected]>
Cr-Original-Commit-Position: refs/heads/master@{#701070}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 7e0bdbe2d7f9fc2386bfaefda3cc29c66ccc18f9
diff --git a/front_end/resources/ResourcesPanel.js b/front_end/resources/ResourcesPanel.js
index 9dd82a4..a07c33b 100644
--- a/front_end/resources/ResourcesPanel.js
+++ b/front_end/resources/ResourcesPanel.js
@@ -77,8 +77,9 @@
}
resetView() {
- if (this.visibleView && Resources.ResourcesPanel._shouldCloseOnReset(this.visibleView))
+ if (this.visibleView && Resources.ResourcesPanel._shouldCloseOnReset(this.visibleView)) {
this.showView(null);
+ }
}
/**
@@ -86,20 +87,24 @@
*/
showView(view) {
this._pendingViewPromise = null;
- if (this.visibleView === view)
+ if (this.visibleView === view) {
return;
+ }
- if (this.visibleView)
+ if (this.visibleView) {
this.visibleView.detach();
+ }
- if (view)
+ if (view) {
view.show(this.storageViews);
+ }
this.visibleView = view;
this._storageViewToolbar.removeToolbarItems();
const toolbarItems = (view instanceof UI.SimpleView && view.syncToolbarItems()) || [];
- for (let i = 0; i < toolbarItems.length; ++i)
+ for (let i = 0; i < toolbarItems.length; ++i) {
this._storageViewToolbar.appendToolbarItem(toolbarItems[i]);
+ }
this._storageViewToolbar.element.classList.toggle('hidden', !toolbarItems.length);
}
@@ -110,8 +115,9 @@
async scheduleShowView(viewPromise) {
this._pendingViewPromise = viewPromise;
const view = await viewPromise;
- if (this._pendingViewPromise !== viewPromise)
+ if (this._pendingViewPromise !== viewPromise) {
return null;
+ }
this.showView(view);
return view;
}
@@ -121,8 +127,9 @@
* @param {string|null} categoryLink
*/
showCategoryView(categoryName, categoryLink) {
- if (!this._categoryView)
+ if (!this._categoryView) {
this._categoryView = new Resources.StorageCategoryView();
+ }
this._categoryView.setText(categoryName);
this._categoryView.setLink(categoryLink);
this.showView(this._categoryView);
@@ -132,13 +139,15 @@
* @param {!Resources.DOMStorage} domStorage
*/
showDOMStorage(domStorage) {
- if (!domStorage)
+ if (!domStorage) {
return;
+ }
- if (!this._domStorageView)
+ if (!this._domStorageView) {
this._domStorageView = new Resources.DOMStorageItemsView(domStorage);
- else
+ } else {
this._domStorageView.setStorage(domStorage);
+ }
this.showView(this._domStorageView);
}
@@ -148,12 +157,14 @@
*/
showCookies(cookieFrameTarget, cookieDomain) {
const model = cookieFrameTarget.model(SDK.CookieModel);
- if (!model)
+ if (!model) {
return;
- if (!this._cookieView)
+ }
+ if (!this._cookieView) {
this._cookieView = new Resources.CookieItemsView(model, cookieDomain);
- else
+ } else {
this._cookieView.setCookiesDomain(model, cookieDomain);
+ }
this.showView(this._cookieView);
}
@@ -163,11 +174,13 @@
*/
clearCookies(target, cookieDomain) {
const model = target.model(SDK.CookieModel);
- if (!model)
+ if (!model) {
return;
+ }
model.clear(cookieDomain, () => {
- if (this._cookieView)
+ if (this._cookieView) {
this._cookieView.refreshItems();
+ }
});
}
};
@@ -182,8 +195,9 @@
* @return {!Promise}
*/
async reveal(resource) {
- if (!(resource instanceof SDK.Resource))
+ if (!(resource instanceof SDK.Resource)) {
return Promise.reject(new Error('Internal error: not a resource'));
+ }
const sidebar = Resources.ResourcesPanel._instance()._sidebar;
await UI.viewManager.showView('resources');
await sidebar.showResource(resource);