Commit Graph
7 Commits
Author SHA1 Message Date
Tim van der Lippe 6021e3e22e Automatically fix imports with missing file extensions
Missing file extensions are a runtime error in the browser, even though
TypeScript accepts imports without a file extension.

R=jacktfranklin@chromium.org

Bug: 1011811
Change-Id: I5c5abac2c45be7c8151340cc3981c74c89e96fb7
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2116444
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
2020-03-24 12:19:42 +00:00
Tim van der Lippe 44d389ace1 Relax import style rules for inner-module imports
Since imports within a module can be of any style, relax the rules
to also allow `import * as` for all files, not only ARIAutils.js

R=sigurds@chromium.org,jacktfranklin@chromium.org

Change-Id: I9cd8973176c200c72a6009496e07404b959435a6
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2116442
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
2020-03-24 11:28:42 +00:00
Tim van der Lippe 4a8441c385 Port license header check to ESLint
This improves the PRESUBMIT performance as we can rely on the AST
parsing of ESLint, meaning we don't have to parse AST twice.

It also allows us to use the nice `--fix` solution to insert the proper
license header in the files.

This shaves an expected 5 seconds of the presubmit time
(non-scientifically computed based on 2 uploads).

Change-Id: I5c53e9b232585f9ec46f86b36557c50bf80f7add
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2097992
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
2020-03-12 16:08:22 +00:00
Tim van der Lippe ba26b2b503 Run ESLint on the scripts directory
We weren't running ESLint on this directory and, as it turns out, there
are quite a few linter errors in this folder.

R=jacktfranklin@chromium.org

Change-Id: Ic6cb9f6ad4858f69114e0c433a954041215b49e2
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2096705
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
2020-03-11 14:47:51 +00:00
Jack Franklin 6a14c8da7c Allow third_party DEPs to be exempt from import rules
We want to use the same rules for importing from third_party but
ultimately if the dep isn't quite structured in a way that lets us do
that we need to be able to make it exempt, which is what this CL does,
starting with `lit-html`.

We don't import `lit-html` on master yet but we do in the Breadcrumbs CL
[1] and we're unable to import everything from the root `lit-html.js`
file as it doesn't expose everything we need.

[1]:
https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2067066

Change-Id: I0678d5ee75e8dcb376cc40df6f9b37f32fbb557d
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2097983
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
2020-03-11 14:14:06 +00:00
Jack Franklin eaa866a0a1 Allow TypeScript to import ls directly
(Initially made this change on the breadcrumbs CL but pulled it out).

In the components TypeScript world we want it to be really easy and
obvious which function to use for localized strings. We agreed that `ls`
is the best option.

Right now not all of `Common` is TypeScriptified and that means that
from a TypeScript file you can't do `import * as Common ...`. So to get
around this we create a new module, `Common/ls.ts` which literally
re-exports `ls` from `Common/UIString`.

We then update the ES modules importing rules to special case that:

1. IF you are in a TypeScript file
2. AND the import ends in `common/ls.js`
3. then it's OK - else you have to stick to the usual rules.

I'm sure this will change over time as we migrate more to TypeScript and
build more components but this is a good starting point for enabling
easier localization from TypeScript components.

Additionally we can swap the export in `common/ls.ts` out for a newer
one if we decide to change how it works without changing all the
callsites.

Change-Id: I226525b2e606cf70a50ef37a4d17aa37b18a34ab
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2097978
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Tim van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Paul Lewis <aerotwist@chromium.org>
2020-03-11 11:52:36 +00:00
Tim van der Lippe d6c33c4cd6 Add custom ESLint rule to check ES import statements
This makes sure that the guidance of
https://docs.google.com/presentation/d/1KaTDaKEcLmgv3Wum79gPP9mv9x2fm3kuEgx_b8wLVug/edit?usp=sharing
will be caught during build time. This prevent issues where duplication
of code in combination with Rollup can cause runtime issues.

Bug: 1060003
Change-Id: Ic8c8dfcc4e9890592791adc23044033b1aa3ca1b
Fixed: 1060123
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2096700
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
2020-03-10 17:33:13 +00:00