-
Notifications
You must be signed in to change notification settings - Fork 511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(lit): add linting and fix #12221
Conversation
https://mozilla-hub.atlassian.net/browse/MP-1738 migrate existing lit components to plain javascript with typescript in jsdoc to avoid the headache of dealing with typescript and babel
Bundle StatsHey there, this message comes from a github action that helps you and reviewers to understand how these changes affect the size of this project's bundle. As this PR is updated, I'll keep you updated on how the bundle size is impacted. Total
View detailed bundle breakdownAdded
Removed
Bigger No assets were bigger Smaller No assets were smaller Unchanged
|
This pull request has merge conflicts that must be resolved before it can be merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't test, but LGTM.
/** @type {HTMLElement} */ | ||
(e.target).dataset.glean = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL: This declares the type of (e.target)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, though it's very weird syntax isn't it? I've changed it to a instanceof HTMLElement
check for better readability and safety
/** | ||
* @typedef {Object} ContributorData | ||
* @property {string} name | ||
* @property {string} github | ||
* @property {string} [org] | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My preference would be to define these in a .d.ts
file next to the JavaScript, as it's a bit easier / less verbose + error-prone than the JSDoc. Wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, good idea: it's a pattern we'll be using a lot anyway with rari emitting typescript types (perhaps it could be configured to also emit jsdoc types? but it'll be easier for migration if we keep all the types in typescript, at least for now)
Summary
https://mozilla-hub.atlassian.net/browse/MP-1738
Problem
There's various things we shouldn't do it Lit, and best practices with web components more widely, which we're not checking for.
Solution
Add eslint rules for lit and web components, and typescript support for lit html templates. Also fix existing components and migrate to ts in jsdoc to avoid ts/babel weirdness.
How did you test this change?
yarn dev
locally