Skip to content

Commit a75ec1d

Browse files
committed
[cleanup] Remove rules/lit_html_data_as_type ESLint rule.
Bug: 375114000 Change-Id: I73e1f7b44733cbd98ad4565dc8e68a88596a3e0e Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5953150 Reviewed-by: Danil Somsikov <[email protected]> Auto-Submit: Benedikt Meurer <[email protected]>
1 parent 9920e4b commit a75ec1d

File tree

6 files changed

+1
-185
lines changed

6 files changed

+1
-185
lines changed

extensions/cxx_debugging/src/ExtensionOptions.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
/* eslint-disable rulesdir/check_component_naming */
66
/* eslint-disable rulesdir/inject_checkbox_styles */
7-
/* eslint-disable rulesdir/lit_html_data_as_type */
87
/* eslint-disable rulesdir/lit_html_host_this */
98

109
import {html, render} from 'lit-html';

front_end/.eslintrc.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ module.exports = {
3737
'rulesdir/enforce_custom_event_names': 'error',
3838
'rulesdir/set_data_type_reference': 'error',
3939
'rulesdir/no_bound_component_methods': 'error',
40-
'rulesdir/lit_html_data_as_type': 'error',
4140
'rulesdir/lit_no_style_interpolation': 'error',
4241
'rulesdir/ban_self_closing_custom_element_tagnames': 'error',
4342
'rulesdir/ban_style_tags_in_lit_html': 'error',

front_end/ui/components/docs/building-ui-documentation/ComponentPerformance.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,7 @@ set y(y: number) {
8080
}
8181
```
8282

83-
We did this for two reasons:
84-
85-
1. We can provide _some_ type-safety via `.data=${{x: 1, y: 2} as FooData}`.
86-
2. We avoided having to immediately implement batched rendering.
83+
We did this to avoid having to immediately implement batched rendering.
8784

8885
However, this decision came with a performance penalty. Lit will only trigger a re-render of a component if one of its properties changes. But when we pass in a new object on each render, we are effectively triggering a re-render every time. Normally this impact isn't noticable, and most components don't re-render with the frequency required to cause performance issues. When a component that takes an object via `set data()` is frequently re-rendered, that causes a non-negligible amount of garbage collection to tidy up the one-use objects we create.
8986

front_end/ui/components/docs/building-ui-documentation/CreatingComponents.md

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -198,21 +198,6 @@ LitHtml.render(html`
198198
`, this.#shadow, {host: this});
199199
```
200200

201-
To enforce some type safety, we also use TypeScript's `as` keyword to force the compiler to type-check the `data` object against the interface:
202-
203-
```ts
204-
// Within some component
205-
LitHtml.render(html`
206-
<devtools-elements-breadcrumbs .data=${{
207-
selectedNode: node,
208-
crumbs: [...],
209-
} as ElementsBreadcrumbsData}>
210-
</devtools-elements-breadcrumbs>
211-
`, this.#shadow, {host: this});
212-
```
213-
214-
This type-checking requirement is enforced by an ESLint rule.
215-
216201
## Performance concerns with data passing
217202

218203
The approach of `set data(data)` was chosen because:

scripts/eslint_rules/lib/lit_html_data_as_type.js

Lines changed: 0 additions & 83 deletions
This file was deleted.

scripts/eslint_rules/tests/lit_html_data_as_type_test.js

Lines changed: 0 additions & 81 deletions
This file was deleted.

0 commit comments

Comments
 (0)