Commit Graph
154 Commits
Author SHA1 Message Date
Jack Franklin d7508305f9 Enable ESLint rule for LitHtml.LitTemplate
Bug: 1320753
Change-Id: If7e442d3250508c9be9199f1706e73847782197d
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3629865
Auto-Submit: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Andres Olivares <andoli@chromium.org>
Commit-Queue: Andres Olivares <andoli@chromium.org>
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
2022-05-09 15:06:40 +00:00
Ergün Erdoğmuş 5f638bacef Add eslint rule for binding scheduleRender render argument
Bug: NO_BUG
Change-Id: I64d643a65d0cf4bc3546ed4f75adde7a53c83c4e
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3624641
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
Commit-Queue: Ergün Erdoğmuş <ergunsh@chromium.org>
2022-05-05 11:06:21 +00:00
Jack Franklin a00b89c22a Lint against TemplateResult|typeof nothing
We have a common pattern in our codebase where a function might return a
lit template, or the result of `Lit.nothing` (which is equivalent to
`{}`). Therefore we have a fair amount of code that looks like:

```
foo(): LitHtml.TemplateResult|{}
// or
foo(): LitHtml.TemplateResult|typeof LitHtml.nothing
```

I'd like us to be consistent over which we prefer, but also this feels
like a little bit of an implementation detail that's leaking out - to a
person using our components system, a Lit template result or `{}` are
really equivalent - and we shouldn't have code that cares.

Therefore I'm proposing we expose (this will be done in a separate CL):

```
type LitTemplate = TemplateResult|typeof nothing
```

And then use this ESLint rule to:

1) update existing code to use the new type
2) ban future code from not using the new type

Both of those steps will also be done in a follow-up CL, this CL
introduces the basic rule.

Bug: 1320753
Change-Id: I2f3d5029a695922c9a71334e34259597eaebfcc0
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3613881
Commit-Queue: Andres Olivares <andoli@chromium.org>
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Andres Olivares <andoli@chromium.org>
Auto-Submit: Jack Franklin <jacktfranklin@chromium.org>
2022-04-29 16:07:23 +00:00
Jack Franklin c70d2688e1 ESLint rule for inlined type imports
This rule is able to merge imports such as:

```
import type {Crumb} from './breadcrumbs.js';
import {BreadcrumbComponent} from './breadcrumbs.js';
```

Into:

```
import {BreadcrumbComponent, type Crumb} from './breadcrumbs.js';
```

It can also inline standalone type imports:

```
import type {X, Y} from './foo.js';
```

Into:

```
import {type X, type Y} from './foo.js';
```

Note: this CL only lands the rule and does not enable it.

Bug: 1319340
Change-Id: I0f7d9e8a6833f836a0e4581d68ee7fd1b27c0edc
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3605262
Reviewed-by: Simon Zünd <szuend@chromium.org>
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
2022-04-26 11:54:37 +00:00
Jack Franklin e60446000d Lint for checkbox stylesheet adoption in Lit components
This CL introduces (but does not enable) an ESLint rule to check that if
a Lit component renders a checkbox, that it also imports and adopts the
common `Input.checkboxStyles` into the component's shadow root.

We can also roll this rule out to the text inputs too, but I wanted to
start with just one and see how it goes. I will follow up this CL with a
CL to enable this rule.

Bug: 1316297
Change-Id: Ibed7109d5948c8be3f4c9d376738290137e444ff
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3586906
Reviewed-by: Johan Bay <jobay@chromium.org>
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Auto-Submit: Jack Franklin <jacktfranklin@chromium.org>
2022-04-19 08:53:26 +00:00
Jack Franklin 46a28a3c5d Allow same-module .css.js imports
These don't need to have the same import rules applied quite so
religiously to them.

Bug: none
Change-Id: Iddded5916ff93a5acf661ecf288ee6d5f79a029a
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3584111
Reviewed-by: Simon Zünd <szuend@chromium.org>
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Auto-Submit: Jack Franklin <jacktfranklin@chromium.org>
2022-04-14 15:35:31 +00:00
Jack Franklin 0a2413e991 Add callee check to check_component_naming lint rule
I had an error in my editor; I was midway through typing and ESLint was
running. It turns out we needed to check for the existence of a `callee`
before reading properties on it.

Bug: none
Change-Id: If1f1b2a2fb621514265c894fec94e454048ae6ee
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3569023
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Auto-Submit: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Alex Rudenko <alexrudenko@chromium.org>
Commit-Queue: Alex Rudenko <alexrudenko@chromium.org>
2022-04-04 15:06:22 +00:00
Jack Franklin 3ea21da3c7 Lint against image URLs containing Images/src
Fixed: 1304152
Change-Id: If4e8928af76ab27ef9ea4584399419a4f94b91a9
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3506656
Reviewed-by: Tim Van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Auto-Submit: Jack Franklin <jacktfranklin@chromium.org>
2022-03-08 15:19:00 +00:00
Jack Franklin a584190fb0 Lint against manually binding event handlers in components
Bug: 1270726
Change-Id: I103e91d43fa55abd06d068065175c815f9a59e5d
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3369363
Reviewed-by: Tim Van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Auto-Submit: Jack Franklin <jacktfranklin@chromium.org>
2022-01-06 14:35:29 +00:00
John Emau 94a007152f [ESLint] Update check_license_header_tests with new year
Tests were hardcoded to expect the year 2021 in the license comment.
Implementation was fixed in 5bb7528e.

Happy New Year!

R=jacktfranklin@chromium.org

Bug: none
Change-Id: Id99e2c67ae2d2f66df0508b5754abbd53a14c3f1
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3364293
Auto-Submit: John Emau <John.Emau@microsoft.com>
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
2022-01-04 09:10:29 +00:00
Jack Franklin 85c29e982d Extract isLitHtmlRenderCall into ESLint utils
Bug: 1276968
Change-Id: I9fd6341f71374922e78eb36380411f721c357bf3
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3352211
Auto-Submit: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Andres Olivares <andoli@chromium.org>
Commit-Queue: Andres Olivares <andoli@chromium.org>
2021-12-22 13:51:45 +00:00
Wolfgang Beyer b2da5bb358 Allow removal of entries from UMA enums
`recordEnumeratedHistogram()` needs both the actual bucket and the total
number of buckets. The total number of buckets was previously determined
by `Object.keys(someMap).length`. This prevented us from ever removing
keys from `someMap` since its length would change.
By explicitly adding a `LastValidEnumPosition` we can now safely remove
keys.

Bug: 1278403
Change-Id: Ib256fc2cf54123f596aa9c5525cce2aabe28bec0
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3329541
Reviewed-by: Simon Zünd <szuend@chromium.org>
Commit-Queue: Wolfgang Beyer <wolfi@chromium.org>
2021-12-21 08:42:54 +00:00
Tim van der Lippe db15a5f621 Enforce usage of private class members in components
This adds a rule that we enable for all components sub-folders
of panels, as well as ui/components. The rule bans the private
TypeScript keyword and requires engineers to use private class
member notation instead.

R=jacktfranklin@chromium.org

Bug: 1222126
Change-Id: I99114e12d2dd2c1bdd14a2986fab839d5c4d6c4f
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3341608
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
Commit-Queue: Tim Van der Lippe <tvanderlippe@chromium.org>
2021-12-15 15:07:09 +00:00
Jack Franklin b633909bdc Use ESLint isLitHtmlDotHtmlCall util in rules
Bug: 1276968
Change-Id: I88bb566d92d6c11d42a39d384b83b75efa8ac6ea
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3317580
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Commit-Queue: Tim Van der Lippe <tvanderlippe@chromium.org>
Auto-Submit: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Tim Van der Lippe <tvanderlippe@chromium.org>
2021-12-06 16:19:20 +00:00
Jack Franklin 54e36ade34 Lint against {describe,it}.only in ESLint tests
Bug: none
Change-Id: Ia9dd8e924f14020d02cce25d301d086c382ebb7e
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3317576
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Commit-Queue: Tim Van der Lippe <tvanderlippe@chromium.org>
Auto-Submit: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Tim Van der Lippe <tvanderlippe@chromium.org>
2021-12-06 15:22:30 +00:00
Jack Franklin c1991d2a40 Extract isLitHtmlTemplateCall to ESLint utils
Will update usages to use this util in a follow-up CL, and see if there
are more duplicated utils that deserve to be extracted.

Bug: 1276968
Change-Id: I2470da9c1f1c6fd0bf1d02a3958eabadec91d3e0
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3317352
Reviewed-by: Tim Van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
2021-12-06 14:37:51 +00:00
Jack Franklin f13bdf17c2 Add ESLint rule for unnecessary quotes around attributes
Bug: none
Change-Id: Ic7336d3f28def1ac6bc03d60d70662bddaab03d0
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3313072
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Tim Van der Lippe <tvanderlippe@chromium.org>
2021-12-03 12:36:10 +00:00
Jack Franklin cdbd19c6bd Enable no only: true rule in ESLint directory
Bug: none
Change-Id: Ib3c2e8ccbe30209f3fec04c739612eb970071021
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3314757
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Commit-Queue: Tim Van der Lippe <tvanderlippe@chromium.org>
Auto-Submit: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Tim Van der Lippe <tvanderlippe@chromium.org>
2021-12-03 12:32:19 +00:00
Jack Franklin 2a84998f49 Lint for only: true in ESLint tests
These are just like `it.only()` and we want to ensure they don't make it
to CQ and cause us to not run all the ESLint tests.

Bug: none
Change-Id: I96c1ba2838c16c9e15ae204a39bef68095e6848a
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3314756
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Commit-Queue: Tim Van der Lippe <tvanderlippe@chromium.org>
Auto-Submit: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Tim Van der Lippe <tvanderlippe@chromium.org>
2021-12-03 11:43:59 +00:00
Jack Franklin 18c71916b6 Make l10n_filename_matches always need directory argument
I realised we could make this rule much simpler:

1. It's always enabled in an `.eslintrc.js` file that is in the
   directory we want to lint.
2. Therefore, let's make the rule always required (rather than have
   some hidden default) and then we can just pass `__dirname` in.

Bug: none
Change-Id: I98cd7337181025ba3d3a1e7d1ecdf75974bc0ead
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3310611
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Commit-Queue: Tim Van der Lippe <tvanderlippe@chromium.org>
Auto-Submit: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Tim Van der Lippe <tvanderlippe@chromium.org>
2021-12-01 15:27:56 +00:00
Jack Franklin f47f3975e0 Enable l10n_filename_matches rule to have its root dir configured
This means if we are to re-use this rule we can configure it to have a
custom root directory to validate and check all the paths against.

Bug: 1187014
Change-Id: I2ab5f921030cb41a024250ac29dd1c1c868f5454
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3302739
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Simon Zünd <szuend@chromium.org>
2021-11-26 13:10:30 +00:00
Tim van der Lippe adf814f1f3 Remove unit test folder exemption
Previously, we exempted our unit tests from importing only entrypoints.
However, we later realized that we always have to import the entrypoint
to avoid build non-determinism problems. Therefore, remove these exemptions,
which incidentally caught some existing violations.

The ColorUtils file is special in inspector_overlay, so we can safely
exempt that one as a one-off. The e2e-test need to import the helpers
as all other e2e-tests do. The hello-world is an example, so let's ignore
that one for now.

R=jacktfranklin@chromium.org

Bug: 1271490
Change-Id: Ib05d799b547e46cde4349b8738a5ecd63d50f3e1
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3291160
Auto-Submit: Tim van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
2021-11-19 14:44:06 +00:00
Tim van der Lippe 379c288384 Allow meta-files to import relative entrypoints
We previously disabled this rule in a lot of places to workaround the
fact that the rule wasn't adhering to importing entrypoints in meta
files. Instead, let's update the rule to make it clear that this pattern
is expected and fine.

R=alexrudenko@chromium.org

Bug: 1271490
Change-Id: Idd139b42d9bb27f1f20e573b31bcd5efff8815af
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3289221
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Alex Rudenko <alexrudenko@chromium.org>
Auto-Submit: Tim van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Alex Rudenko <alexrudenko@chromium.org>
2021-11-18 14:53:06 +00:00
Tim van der Lippe 1b5567f78a Remove resources from perf_ui
To remove the module.json file in perf_ui, we need to migrate the
resources to the new `generate_css` template. However, perf_ui is a bit
special, in that it doesn't properly use the widget structure. As such,
it sometimes injects CSS in places where there is no clear shadowRoot
available. Therefore, it is not possible to migrate to CSSStyleSheet in
combination with adoptedStylesheets.

As a workaround (to unblock the module.json removal), we augment
`generate_css` to add legacy file generation. All remaining resources in
DevTools will migrate to these `.css.legacy.js` files. That's because
these resources either are special (perf_ui) or are used in the
`device_mode_emulation_frame` which can't use `CSSStyleSheet` itself.

The files export an object, rather than a plain string. That's because
we need to be able to distinguish what string is referencing a CSS file
path and which strings contain the actual CSS styles. By using an
object, we can remain using the `typeof` check for string in the legacy
CSS infrastructure and otherwise destructure the object.

After this, we can remove perf_ui from the module.json structure and
properly bundle+minify the CSS resources.

R=jacktfranklin@chromium.org

Bug: 1190991, 1127902
Change-Id: I7523333e8025ae5fe5ed74b99b4e45907ff9ad97
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3275787
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
Auto-Submit: Tim van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
2021-11-12 15:25:03 +00:00
Tim van der Lippe 6ddb01d4f5 Upgrade typescript-eslint
This also includes some fixes in the rule implementations that are
required for the 5.0.0 breaking change as documented in
https://github.com/typescript-eslint/typescript-eslint/releases/tag/v5.0.0
which lists the AST-Spec changes. Specifically, `ClassProperty`
was renamed to `PropertyDefinition`.

DISABLE_THIRD_PARTY_CHECK=Requires AST changes in ESLint rules
R=jacktfranklin@chromium.org

Bug: none
Change-Id: I1d107b071fa265af8e178ee5e229f4a9d2f00d75
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3268295
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
2021-11-08 16:19:39 +00:00
Tim van der Lippe e096798938 Fix eslint tests for Windows
The error messages should use the proper file path format, so manually
replace the Windows folder separators with the UNIX path separators.

R=andoli@chromium.org

Fixed: 1266413
Change-Id: I499e79e857eaf97eb65faf1cb180479f08b1ee69
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3259535
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Andres Olivares <andoli@chromium.org>
Auto-Submit: Tim van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Andres Olivares <andoli@chromium.org>
2021-11-05 15:29:59 +00:00
Andres Olivares c860fe1985 Introduce describe.skipOnPlatforms mocha extension
NOPRESUBMIT=true
Bug: none
Change-Id: If0e96e43aa13a2fa557a075975c2e7f365db930a
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3258130
Commit-Queue: Alex Rudenko <alexrudenko@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Alex Rudenko <alexrudenko@chromium.org>
2021-11-03 20:44:06 +00:00
Alex Rudenko 273b9aa203 ESLint: ban <a> tags in lit-html templates
NOPRESUBMIT=true
Bug: 1264796
Change-Id: I58b7e01d4232e93fc08f12fa2f9173e1c6c07060
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3253322
Commit-Queue: Alex Rudenko <alexrudenko@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
2021-10-29 13:47:02 +00:00
Jack Franklin cbd5ee57f9 Add ESLint rule for enforcing {host: this} in LitHtml.render calls
Bug: 1247969
Change-Id: I567dac5d9bb97f3b2b4de77a06e45d7e4cac6cbd
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3150282
Auto-Submit: Jack Franklin <jacktfranklin@chromium.org>
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
2021-09-09 12:39:57 +00:00
Tim van der Lippe 8eade7fa60 Remove special-casing for utils
Historically, we special-cased importing the legacy utils, as
Rollup would eagerly roll them up in a single bundle. However,
since then we changed the Rollup heuristic to always assume that
a different folder is a different entrypoint, including sub-folders.
As such, we are no longer including entrypoints of sub-folders in
parent folders.

However, utils was special-cased and was importing the direct files.
This normally isn't a problem, except for the fact that the
devtools_entrypoint of `ui/legacy:bundle` would now bundle the sources
of `ui/legacy/utils`, but wasn't rebuilding when it needed to.

Therefore, change the utils to a proper sub-folder and avoid the
special-casing. Since we no longer have a circular dependency
between the utils and `ui/legacy`, we can safely make this change.

The ESLint rule has also been updated to make sure we don't regress
in this area again.

R=victorporof@chromium.org

Fixed: 1148274
Change-Id: I020622c5790041d5f676bee2ef883ff0ece76695
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3148370
Auto-Submit: Tim van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Victor Porof <victorporof@chromium.org>
Reviewed-by: Victor Porof <victorporof@chromium.org>
2021-09-08 14:34:10 +00:00
Jack Franklin 734befd5a7 Fix ESLint component naming check with multiple components
This CL updates the check_component_naming rule to make it deal with a
file that has multiple components defined; something that would
previously cause the rule to fail and hence it was disabled in some
files.

Fixed: 1226741
Change-Id: I3eb282182c10e3faf120d6bcd2d0846667524861
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3141471
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Auto-Submit: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Andres Olivares <andoli@chromium.org>
2021-09-03 13:44:37 +00:00
Jack Franklin cc1f192ca1 Add autofix ability to static_custom_event_names ESLint rule
Bug: chromium:1229172
Change-Id: I80d1fcb1432a79a0682ed92ff6335571a62bba55
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3122649
Auto-Submit: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
2021-09-01 08:34:04 +00:00
Jack Franklin 392f476825 Fix check_component_naming rule when litTagName is not LitHtml.literal
Fixed: 1241067
Change-Id: I4e5dbc68f874c27e5cd810e9ca3a47d1b671dff7
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3121432
Auto-Submit: Jack Franklin <jacktfranklin@chromium.org>
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
2021-08-26 12:27:05 +00:00
Jack Franklin 65832d9e01 ESLint rule for enforcing custom event name pattern
This CL adds a rule (but does not enable it) for enforcing the custom
event names as discussed in this design doc:

https://docs.google.com/document/d/1UREbYIcjP9pZWW1mLase4uGDHmUNa1cQXkc3Mfw8nLI

Bug: chromium:1229172
Change-Id: I843cbe9bf172544e2b5b907991d6792d6033b5b8
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3118371
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
2021-08-25 14:54:25 +00:00
Changhao Han 5b178291bc Disable flaky test in memory e2e tests
Bug: chromium:1239550
Change-Id: I57010905189ac8233f42e1871b173d3d147f16b0
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3093153
Reviewed-by: Mathias Bynens <mathias@chromium.org>
Commit-Queue: Changhao Han <changhaohan@chromium.org>
2021-08-13 17:31:50 +00:00
Kriti Sapra 52ffe818db [CSS]: panels/event-listeners, panels/layer_viewer and panels/media
Bug: 1106746
Change-Id: I2a8e4421e9bc1be3c11ee21965041727de1b811d
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3064215
Commit-Queue: Kriti Sapra <kritisapra@google.com>
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
2021-08-03 13:37:03 +00:00
Kriti Sapra e812e1d2c1 [CSS]: panels/animation
Also added checks to migration script to ensure the bodynodes have
expressions and callees.

Bug: 1106746
Change-Id: I7697c0eb725d2a3befc9b97bfcb4fa385c6a68c5
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3060698
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
Commit-Queue: Kriti Sapra <kritisapra@google.com>
2021-07-29 14:49:07 +00:00
Kriti Sapra ec691c3226 Fixed path bug in migration scripts and migrated panels/help
Bug: 1106746
Change-Id: I7ae55553b6669ed60a511ab35107b0f2642862aa
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3059607
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
Commit-Queue: Kriti Sapra <kritisapra@google.com>
2021-07-29 12:28:16 +00:00
Kriti Sapra 4d5496c671 Updated scripts to resolve paths for css files not in same directory
and fixed duplicate entries in `devtools_grd_files`.

Some files import CSS files not in the same directory as them. The
script was currently unable to handle this case and so migrations led
to `File Not Found` errors for the `.css.js` files. The script now
finds the relative path from the imported file to the current file and
adapts the import statement correctly.

Duplicates were being added to `devtools_grd_files` which led to errors
during the build. The check now verifies the entire file path is
contained in the GRD file to prevent duplication.

Bug: 1106746
Change-Id: I5da808a8885bc18477cfa31801a904e17924caab
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3059012
Commit-Queue: Kriti Sapra <kritisapra@google.com>
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
2021-07-28 15:38:56 +00:00
Kriti Sapra 93f79d6e7b Check if the file already imports css file and prevents duplication
Bug: 1106746
Change-Id: I3d3b905c00dd7c6ce0ceefd4b2617ffe0d7ea4bc
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3056377
Commit-Queue: Kriti Sapra <kritisapra@google.com>
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
2021-07-27 16:37:39 +00:00
Kriti Sapra 92b65490c2 [CSS] panels/settings
Bug: 1106746
Change-Id: Ic00f88723ed727a3056d1482b22d4429459254c0
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3056376
Commit-Queue: Kriti Sapra <kritisapra@google.com>
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
2021-07-27 16:27:20 +00:00
Kriti Sapra cf9d397f58 Add .css.js file to devtools_grd_files from migration scrips
Bug: 1106746
Change-Id: Ifdc5ec5bb0e19e73c41e3bd0ed3f48679a161cda
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3055241
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
Commit-Queue: Kriti Sapra <kritisapra@google.com>
2021-07-27 13:36:09 +00:00
Kriti Sapra 8733f78d00 Added edge case support for migrating legacy calls to
`registerRequiredCSS`.

There are two main edge cases: multiple calls to
`this.registerRequiredCSS` and calls to properties of the object, e.g.
`this._widget.registerRequiredCSS`. I have added cases to the ESLint
rule to migrate these automatically.

In ESLint tests, the output is produced after only a single pass of
the rule. Keeping this in mind, the tests for multiple calls have
been broken down into multiple tests cases.

Bug: 1106746
Change-Id: If5a4827ec7230508c9208c6d23882499495be12a
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3053744
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Kriti Sapra <kritisapra@google.com>
2021-07-27 09:14:09 +00:00
Kriti Sapra 62a28b02c0 Added ESLint rule to migrate legacy calls to createShadowRootWithStyles
Bug: 1106746
Change-Id: Id39b79e3baea93411630f6526348f30081844e82
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3048479
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Kriti Sapra <kritisapra@google.com>
2021-07-26 14:12:19 +00:00
Kriti Sapra 8f45fb532f Created ESLint rule and tests to migrate legacy files
It adds `import componentStyles from './component.css.js'` for any
registerRequiredCSS('front_end/component/component.css') call.

It also checks if there is an existing `wasShown()` method. If this
exists then it adds an extra line to add the
`this.adoptedStyleSheets = [componentStyles]` statement. Otherwise,
the `wasShown()` method is created and added.

Bug: 1106746
Change-Id: I7d0244d129fe0f4a50432fd7b53135760ae304ae
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3043915
Commit-Queue: Kriti Sapra <kritisapra@google.com>
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
2021-07-23 11:03:24 +00:00
Simon Zünd 8c172ce037 [l10n] Add linter rule to forbid calling i18nString without UIStrings
This CL prevents calls to i18nString and i18nLazyString without using
`UIStrings` as the first argument. While the rule is rather strict,
the few places where different usage is warranted, the rule can
be disabled.

The CL also fixes all call sites in violation  by either updating
types, or disabling the rule.

R=tvanderlippe@chromium.org

Bug: 1180760
Change-Id: Ibef05525577fc6b4443c1f7ea69023f1bba828ef
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3041381
Commit-Queue: Simon Zünd <szuend@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
2021-07-21 12:29:41 +00:00
Tim van der Lippe a53672de83 Check license headers for CSS files during PRESUBMIT
This mirrors the license header checks we perform for
Python-like files and apply the same logic for CSS.

To do so, we modify the relevant regexes and patch
function to use the correct version of comment structure
for CSS files (which use `/*` rather than `#` as delimiters).

R=jacktfranklin@chromium.org

Bug: 1106746
Change-Id: I51d51e9b793a1015aeb20a3b3a55e075c2ee748f
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3014756
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
Auto-Submit: Tim van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
2021-07-13 12:28:56 +00:00
Jack Franklin af799b35b5 Ensure all web components have a litTagName defined
I discovered that the ESLint rule that enforced static tag names
wouldn't detect components that were defined as `export class ...`.

This CL fixes that rule and then subsequently fixes all the following
violations that were found now the rule is correct.

Fixed: 1225550
Change-Id: I2753659af9ba9e7280c0a212bfaaa42a1f1e849b
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2999487
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Commit-Queue: Paul Lewis <aerotwist@chromium.org>
Auto-Submit: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Paul Lewis <aerotwist@chromium.org>
2021-07-01 09:14:08 +00:00
Jack Franklin 41aa9f2369 Update + enforce all litTagNames are readonly
Bug: 1225263
Change-Id: I3f22d7521229d9659fd546daeb5d776de2571500
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2997502
Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
2021-07-01 07:24:59 +00:00
Kriti Sapra b2b29f2cc7 [CSS Migration]: Enabled wasShown esLint rule
Bug: 1106746
Change-Id: I373793016ce59308d1cde1b8cb7f15989d298ecc
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2988318
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
Commit-Queue: Kriti Sapra <kritisapra@google.com>
2021-06-29 14:00:57 +00:00