From 06ee0d9cf673ffae2df2b2a33d0880a784eb65ee Mon Sep 17 00:00:00 2001 From: Jack Franklin Date: Tue, 11 May 2021 09:05:54 +0000 Subject: [PATCH] [Lit2] Lint against manual tag names This CL adds an ESLint rule that bans the use of: ``` LitHtml.html`` ``` Because from now on we want to enforce: ``` LitHtml.html`<${Foo.litTagName}>` ``` I have disabled the rule in all locations where we do not yet do this, and will be working to fix these problems over a series of CLs. Bug: 1153077 Change-Id: I8d18243d0243ea1403d5d57dbeb32c8a9682d2dd Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2876969 Reviewed-by: Paul Lewis Commit-Queue: Jack Franklin --- front_end/.eslintrc.js | 1 + .../application/BackForwardCacheView.ts | 3 ++ .../components/FrameDetailsView.ts | 20 ++++++++ .../application/components/StackTrace.ts | 1 + .../application/components/TrustTokensView.ts | 3 ++ .../components/ElementsBreadcrumbs.ts | 1 + .../panels/elements/components/LayoutPane.ts | 2 + .../components/StylePropertyEditor.ts | 1 + .../panels/issues/CSPViolationsListView.ts | 1 + .../components/RequestTrustTokensView.ts | 6 +++ .../data_grid/DataGridController.ts | 1 + front_end/ui/components/docs/report/basic.ts | 2 + .../ui/components/icon_button/IconButton.ts | 1 + .../LinearMemoryInspector.ts | 1 + .../LinearMemoryNavigator.ts | 1 + .../LinearMemoryValueInterpreter.ts | 3 ++ .../ValueInterpreterDisplay.ts | 4 +- .../components/markdown_view/MarkdownImage.ts | 1 + .../components/markdown_view/MarkdownView.ts | 2 + .../ui/components/survey_link/SurveyLink.ts | 1 + .../components/inline_editor/CSSAngle.ts | 2 + ...an_literal_devtools_component_tag_names.js | 49 +++++++++++++++++++ ...teral_devtools_component_tag_names_test.js | 40 +++++++++++++++ 23 files changed, 146 insertions(+), 1 deletion(-) create mode 100644 scripts/eslint_rules/lib/ban_literal_devtools_component_tag_names.js create mode 100644 scripts/eslint_rules/tests/ban_literal_devtools_component_tag_names_test.js diff --git a/front_end/.eslintrc.js b/front_end/.eslintrc.js index 219b4501ea..7ac5b2d0fa 100644 --- a/front_end/.eslintrc.js +++ b/front_end/.eslintrc.js @@ -28,6 +28,7 @@ module.exports = { 'rulesdir/set_data_type_reference': 2, 'rulesdir/lit_html_data_as_type': 2, 'rulesdir/lit_no_style_interpolation': 2, + 'rulesdir/ban_literal_devtools_component_tag_names': 2, '@typescript-eslint/naming-convention': [ 'error', { 'selector': ['property', 'parameterProperty'], diff --git a/front_end/panels/application/BackForwardCacheView.ts b/front_end/panels/application/BackForwardCacheView.ts index f512b11c60..29c7de83a9 100644 --- a/front_end/panels/application/BackForwardCacheView.ts +++ b/front_end/panels/application/BackForwardCacheView.ts @@ -69,6 +69,7 @@ export class BackForwardCacheView extends UI.ThrottledWidget.ThrottledWidget { async doUpdate(): Promise { const data = {reportTitle: i18nString(UIStrings.backForwardCacheTitle)}; + // eslint-disable-next-line rulesdir/ban_literal_devtools_component_tag_names const html = LitHtml.html` ${this.renderMainFrameInformation(this.getMainFrame())} @@ -88,11 +89,13 @@ export class BackForwardCacheView extends UI.ThrottledWidget.ThrottledWidget { private renderMainFrameInformation(mainFrame: SDK.ResourceTreeModel.ResourceTreeFrame|null): LitHtml.TemplateResult { if (!mainFrame) { + // eslint-disable-next-line rulesdir/ban_literal_devtools_component_tag_names return LitHtml.html`${i18nString(UIStrings.mainFrame)} ${i18nString(UIStrings.unavailable)} `; } + // eslint-disable-next-line rulesdir/ban_literal_devtools_component_tag_names return LitHtml.html` ${i18nString(UIStrings.lastMainFrameNavigation)} ${i18nString(UIStrings.url)} diff --git a/front_end/panels/application/components/FrameDetailsView.ts b/front_end/panels/application/components/FrameDetailsView.ts index 4b6282cdea..a3f044482a 100644 --- a/front_end/panels/application/components/FrameDetailsView.ts +++ b/front_end/panels/application/components/FrameDetailsView.ts @@ -289,6 +289,7 @@ export class FrameDetailsReportView extends HTMLElement { // Disabled until https://crbug.com/1079231 is fixed. // clang-format off +// eslint-disable-next-line rulesdir/ban_literal_devtools_component_tag_names LitHtml.render(LitHtml.html`