Skip to content

Commit 67073a4

Browse files
committed
Updates linting
- Ensures Lit & WC linting is enabled
1 parent f6ff0ec commit 67073a4

File tree

8 files changed

+45
-63
lines changed

8 files changed

+45
-63
lines changed

eslint.config.mjs

Lines changed: 26 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import noSrcImports from './scripts/eslint-rules/no-src-imports.js';
1212
export default ts.config(
1313
js.configs.recommended,
1414
...ts.configs.strictTypeChecked,
15+
litConfigs['flat/recommended'],
16+
wcConfigs['flat/recommended'],
1517
{
1618
ignores: ['*', '*/', '!src/', '!tests/', 'src/@types/', 'src/test/**/*'],
1719
},
@@ -22,11 +24,7 @@ export default ts.config(
2224
plugins: {
2325
'import-x': importX,
2426
'anti-trojan-source': antiTrojanSource,
25-
'@gitlens': {
26-
rules: {
27-
'no-src-imports': noSrcImports,
28-
},
29-
},
27+
'@gitlens': { rules: { 'no-src-imports': noSrcImports } },
3028
},
3129
rules: {
3230
'@gitlens/no-src-imports': 'error',
@@ -328,16 +326,12 @@ export default ts.config(
328326
files: ['src/**/*'],
329327
ignores: ['**/webview/**/*', 'src/test/**/*', 'src/webviews/apps/**/*', 'src/env/browser/**/*'],
330328
languageOptions: {
331-
globals: {
332-
...globals.node,
333-
},
329+
globals: { ...globals.node },
334330
parser: ts.parser,
335331
parserOptions: {
336-
ecmaVersion: 2022,
332+
ecmaVersion: 2023,
337333
sourceType: 'module',
338-
ecmaFeatures: {
339-
impliedStrict: true,
340-
},
334+
ecmaFeatures: { impliedStrict: true },
341335
projectService: true,
342336
},
343337
},
@@ -369,24 +363,18 @@ export default ts.config(
369363
files: ['src/**/*'],
370364
ignores: ['**/webview/**/*', 'src/test/**/*', 'src/webviews/apps/**/*', 'src/env/node/**/*'],
371365
languageOptions: {
372-
globals: {
373-
...globals.worker,
374-
},
366+
globals: { ...globals.worker },
375367
parser: ts.parser,
376368
parserOptions: {
377-
ecmaVersion: 2022,
369+
ecmaVersion: 2023,
378370
sourceType: 'module',
379-
ecmaFeatures: {
380-
impliedStrict: true,
381-
},
371+
ecmaFeatures: { impliedStrict: true },
382372
projectService: true,
383373
},
384374
},
385375
},
386376
{
387377
name: 'webviews',
388-
...litConfigs['flat/recommended'],
389-
...wcConfigs['flat/recommended'],
390378
// Keep in sync with `src/webviews/apps/tsconfig.json`
391379
files: [
392380
'src/webviews/apps/**/*',
@@ -404,16 +392,12 @@ export default ts.config(
404392
],
405393
ignores: ['**/-webview/**/*'],
406394
languageOptions: {
407-
globals: {
408-
...globals.browser,
409-
},
395+
globals: { ...globals.browser },
410396
parser: ts.parser,
411397
parserOptions: {
412-
ecmaVersion: 2022,
398+
ecmaVersion: 2023,
413399
sourceType: 'module',
414-
ecmaFeatures: {
415-
impliedStrict: true,
416-
},
400+
ecmaFeatures: { impliedStrict: true },
417401
projectService: true,
418402
},
419403
},
@@ -457,23 +441,27 @@ export default ts.config(
457441
name: 'webviews-apps-only',
458442
...litConfigs['flat/recommended'],
459443
...wcConfigs['flat/recommended'],
444+
...wcConfigs['flat/best-practice'],
460445
files: ['src/webviews/apps/**/*'],
461446
ignores: ['**/-webview/**/*'],
462447
languageOptions: {
463-
globals: {
464-
...globals.browser,
465-
},
448+
globals: { ...globals.browser },
466449
parser: ts.parser,
467450
parserOptions: {
468-
ecmaVersion: 2022,
451+
ecmaVersion: 2023,
469452
sourceType: 'module',
470-
ecmaFeatures: {
471-
impliedStrict: true,
472-
},
453+
ecmaFeatures: { impliedStrict: true },
473454
projectService: true,
474455
},
475456
},
476457
rules: {
458+
// 'lit/quoted-expressions': 'error',
459+
'lit/lifecycle-super': 'error',
460+
'lit/no-legacy-imports': 'error',
461+
'lit/no-native-attributes': 'error',
462+
'lit/no-template-bind': 'error',
463+
// 'lit/no-template-map': 'warn', // Want to enable this, but it's too noisy right now
464+
'lit/no-this-assign-in-render': 'error',
477465
'@typescript-eslint/explicit-module-boundary-types': 'off',
478466
'@typescript-eslint/no-restricted-imports': [
479467
'error',
@@ -514,16 +502,12 @@ export default ts.config(
514502
name: 'tests:e2e',
515503
files: ['tests/**/*'],
516504
languageOptions: {
517-
globals: {
518-
...globals.node,
519-
},
505+
globals: { ...globals.node },
520506
parser: ts.parser,
521507
parserOptions: {
522-
ecmaVersion: 2022,
508+
ecmaVersion: 2023,
523509
sourceType: 'module',
524-
ecmaFeatures: {
525-
impliedStrict: true,
526-
},
510+
ecmaFeatures: { impliedStrict: true },
527511
projectService: true,
528512
},
529513
},

src/webviews/apps/home/components/ama-banner.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,12 @@ export class GlAmaBanner extends LitElement {
4545
override render() {
4646
if (this.closed || this._state.amaBannerCollapsed === true) return nothing;
4747

48+
const url =
49+
'https://www.gitkraken.com/lp/gitlensama?utm_source=githubdiscussion&utm_medium=hyperlink&utm_campaign=GLAMA&utm_id=GLAMA';
4850
return html`
4951
<gl-card indicator="info">
5052
<h4>Live AMA w/ the creator of GitLens</h4>
51-
<p>
52-
Feb 13 @ 1pm EST &mdash;
53-
<a
54-
href="https://www.gitkraken.com/lp/gitlensama?utm_source=githubdisucssion&utm_medium=hyperlink&utm_campaign=GLAMA&utm_id=GLAMA"
55-
>Register now</a
56-
>
57-
</p>
53+
<p>Feb 13 @ 1pm EST &mdash; <a href="${url}">Register now</a></p>
5854
<gl-button slot="actions" appearance="toolbar" tooltip="Dismiss" @click=${() => this.onClose()}
5955
><code-icon icon="close"></code-icon
6056
></gl-button>

src/webviews/apps/plus/home/components/overview.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,15 @@ export class GlOverview extends SignalWatcher(LitElement) {
7979
@consume({ context: ipcContext })
8080
private readonly _ipc!: HostIpc;
8181

82-
private onChangeRecentThresholdFilter(e: CustomEvent<{ threshold: OverviewRecentThreshold }>) {
82+
private readonly onChangeRecentThresholdFilter = (e: CustomEvent<{ threshold: OverviewRecentThreshold }>) => {
8383
if (!this._inactiveOverviewState.filter.stale || !this._inactiveOverviewState.filter.recent) {
8484
return;
8585
}
8686
this._ipc.sendCommand(SetOverviewFilter, {
8787
stale: this._inactiveOverviewState.filter.stale,
8888
recent: { ...this._inactiveOverviewState.filter.recent, threshold: e.detail.threshold },
8989
});
90-
}
90+
};
9191

9292
private renderComplete(overview: GetInactiveOverviewResponse, isFetching = false) {
9393
if (overview == null) return nothing;
@@ -101,7 +101,7 @@ export class GlOverview extends SignalWatcher(LitElement) {
101101
>
102102
<gl-branch-threshold-filter
103103
slot="heading-actions"
104-
@gl-change=${this.onChangeRecentThresholdFilter.bind(this)}
104+
@gl-change=${this.onChangeRecentThresholdFilter}
105105
.options=${[
106106
{ value: 'OneDay', label: '1 day' },
107107
{ value: 'OneWeek', label: '1 week' },

src/webviews/apps/plus/shared/components/feature-gate-plus-state.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,11 @@ export class GlFeatureGatePlusState extends LitElement {
117117
}
118118

119119
override render(): unknown {
120-
if (this.state == null) {
121-
this.hidden = true;
122-
return undefined;
123-
}
120+
const hidden = this.state == null;
121+
// eslint-disable-next-line lit/no-this-assign-in-render
122+
this.hidden = hidden;
123+
if (hidden) return undefined;
124124

125-
this.hidden = false;
126125
const appearance = (this.appearance ?? 'alert') === 'alert' ? 'alert' : undefined;
127126

128127
switch (this.state) {

src/webviews/apps/shared/components/actions/action-nav.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ export class ActionNav extends LitElement {
2222

2323
override disconnectedCallback(): void {
2424
this._slotSubscriptionsDisposer?.();
25+
26+
super.disconnectedCallback();
2527
}
2628

2729
override render(): unknown {

src/webviews/apps/shared/components/button.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ export class GlButton extends LitElement {
212212
href?: string;
213213

214214
@property({ reflect: true })
215+
// eslint-disable-next-line lit/no-native-attributes
215216
override get role(): 'link' | 'button' {
216217
return this.href ? 'link' : 'button';
217218
}

src/webviews/apps/shared/components/feature-gate.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,18 +121,17 @@ export class GlFeatureGate extends LitElement {
121121
webroot?: string;
122122

123123
override render(): unknown {
124-
if (!this.visible || (this.state != null && isSubscriptionStatePaidOrTrial(this.state))) {
125-
this.hidden = true;
126-
return undefined;
127-
}
124+
const hidden = !this.visible || (this.state != null && isSubscriptionStatePaidOrTrial(this.state));
125+
// eslint-disable-next-line lit/no-this-assign-in-render
126+
this.hidden = hidden;
127+
128+
if (hidden) return undefined;
128129

129130
const appearance =
130131
this.appearance ?? (document.body.getAttribute('data-placement') ?? 'editor') === 'editor'
131132
? 'alert'
132133
: 'welcome';
133134

134-
this.hidden = false;
135-
136135
return html`
137136
<section>
138137
<slot></slot>

src/webviews/apps/shared/components/menu/menu-item.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export class MenuItem extends LitElement {
5858
href?: string;
5959

6060
@property({ reflect: true })
61+
// eslint-disable-next-line lit/no-native-attributes
6162
override role = 'option';
6263

6364
updateInteractiveState(): void {

0 commit comments

Comments
 (0)