Skip to content

Commit 0365a7e

Browse files
authored
chore(code-quality): upgrade linter and implement stricter rules (#215)
* update linter and tsconfig * update tsconfig to include tests * update scripts * hard ignore tests by linter
1 parent 6358a94 commit 0365a7e

File tree

184 files changed

+11384
-8473
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

184 files changed

+11384
-8473
lines changed

.prettierrc

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"bracketSpacing": true,
3+
"printWidth": 80,
4+
"semi": true,
5+
"singleQuote": false,
6+
"tabWidth": 2,
7+
"trailingComma": "all",
8+
"arrowParens": "avoid",
9+
"bracketSameLine": false,
10+
"endOfLine": "lf",
11+
"htmlWhitespaceSensitivity": "css",
12+
"jsxSingleQuote": false,
13+
"singleAttributePerLine": true,
14+
"plugins": ["prettier-plugin-organize-imports"]
15+
}

.prettierrc.json

-4
This file was deleted.

docs/.vitepress/config.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
import {defineConfig} from 'vitepress';
1+
import { defineConfig } from "vitepress";
2+
import nav from "./nav";
23
import sidebar from "./sidebar";
34
import socialLinks from "./socialLinks";
4-
import nav from "./nav";
55

66
// https://vitepress.dev/reference/site-config
77
export default defineConfig({
8-
title: 'Tapsi components',
9-
description: 'A set of components based on Tapsi design system.',
8+
title: "Tapsi components",
9+
description: "A set of components based on Tapsi design system.",
1010
base: "/web-components/",
11-
vite:{},
11+
vite: {},
1212
themeConfig: {
1313
sidebar,
1414
socialLinks,
15-
nav
15+
nav,
1616
},
1717
});

docs/.vitepress/nav.ts

+14-10
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,25 @@ import { DefaultTheme } from "vitepress";
22

33
export default [
44
{
5-
text: 'Getting Started',
6-
link: '/dev/getting-started',
5+
text: "Getting Started",
6+
link: "/dev/getting-started",
77
},
88
{
9-
text: 'Components',
10-
link: '/dev/components/tap-avatar',
9+
text: "Components",
10+
link: "/dev/components/tap-avatar",
1111
},
1212
{
13-
text: 'Design Guidelines',
14-
link: '/design/guidelines',
13+
text: "Design Guidelines",
14+
link: "/design/guidelines",
1515
},
1616
{
17-
text: 'Related Links',
17+
text: "Related Links",
1818
items: [
19-
{text: 'Icon Library', link: 'https://tap30.github.io/icons', target: '_blank'},
19+
{
20+
text: "Icon Library",
21+
link: "https://tap30.github.io/icons",
22+
target: "_blank",
23+
},
2024
],
21-
}
22-
] as DefaultTheme.NavItem[]
25+
},
26+
] as DefaultTheme.NavItem[];

docs/.vitepress/sidebar.ts

+48-42
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,90 @@
1-
import fs from 'fs';
2-
import { DefaultTheme } from "vitepress";
31
import type { Package } from "custom-elements-manifest";
2+
import fs from "fs";
3+
import { DefaultTheme } from "vitepress";
44

5-
const getComponentsDevItems = () => {
6-
const file = fs.readFileSync('dist/custom-elements.json');
5+
const getComponentsDevItems = () => {
6+
const file = fs.readFileSync("dist/custom-elements.json");
77
const manifest = JSON.parse(file.toString()) as Package;
88
return manifest.modules
9-
.filter((module) => !!module.declarations?.length)
10-
.map((module) => {
9+
.filter(module => !!module.declarations?.length)
10+
.map(module => {
1111
if (!module.exports)
1212
throw new Error(`Module has no export: ${module.path}`);
1313

1414
const components = module.exports.filter(
15-
(exp) => exp.kind === 'custom-element-definition',
15+
exp => exp.kind === "custom-element-definition",
1616
);
1717

1818
// For now, we assume we have only one custom element per module
1919
const component = components[0];
2020

21-
return {
22-
link: '/components/' + component.name,
23-
text: component.name,
24-
};
25-
});
26-
}
21+
return {
22+
link: "/components/" + component.name,
23+
text: component.name,
24+
};
25+
});
26+
};
2727

2828
const getSidebarDevContents = (): DefaultTheme.Sidebar => {
2929
return [
30-
{text: 'Getting Started', link: '/getting-started'},
30+
{ text: "Getting Started", link: "/getting-started" },
3131
{
32-
text: 'Design System Guidelines',
33-
base: '/design/',
34-
link: '/guidelines'
32+
text: "Design System Guidelines",
33+
base: "/design/",
34+
link: "/guidelines",
3535
},
3636
{
37-
text: 'Components',
37+
text: "Components",
3838
collapsed: false,
3939
items: getComponentsDevItems(),
4040
},
4141
{
42-
text: 'API References',
42+
text: "API References",
4343
collapsed: false,
4444
items: [
45-
{text: 'CSS Parts', link: '/references/css-parts'},
45+
{ text: "CSS Parts", link: "/references/css-parts" },
4646
{
47-
text: 'Design Tokens', items: [
48-
{text: 'Colors', link: '/references/color-tokens'},
49-
{text: 'Radius', link: '/references/radius-tokens'},
50-
{text: 'Spacing', link: '/references/spacing-tokens'},
51-
{text: 'Stroke', link: '/references/stroke-tokens'},
52-
{text: 'Typography', link: '/references/typography-tokens'},
53-
{text: 'Components', link: '/references/components-tokens'},
54-
]
47+
text: "Design Tokens",
48+
items: [
49+
{ text: "Colors", link: "/references/color-tokens" },
50+
{ text: "Radius", link: "/references/radius-tokens" },
51+
{ text: "Spacing", link: "/references/spacing-tokens" },
52+
{ text: "Stroke", link: "/references/stroke-tokens" },
53+
{ text: "Typography", link: "/references/typography-tokens" },
54+
{ text: "Components", link: "/references/components-tokens" },
55+
],
5556
},
5657
],
5758
},
5859
];
59-
}
60+
};
6061

61-
const getComponentsDesignItems = () => {
62-
const componentGuidelinesBasePath = 'docs/design/components'
63-
const files = fs.readdirSync(componentGuidelinesBasePath)
64-
.filter((file) => file.endsWith('.md'))
65-
.map((file) => file.replace('.md', ''));
66-
return files.map((file) => {
62+
const getComponentsDesignItems = () => {
63+
const componentGuidelinesBasePath = "docs/design/components";
64+
const files = fs
65+
.readdirSync(componentGuidelinesBasePath)
66+
.filter(file => file.endsWith(".md"))
67+
.map(file => file.replace(".md", ""));
68+
return files.map(file => {
6769
return {
68-
link: 'components/' + file,
70+
link: "components/" + file,
6971
text: file,
7072
};
7173
});
7274
};
7375

7476
const getSidebarDesignContents = (): DefaultTheme.Sidebar => {
7577
return [
76-
{text: 'Introduction', link: '/guidelines'},
77-
{text: 'Component Guidelines', base: '/design/', items: getComponentsDesignItems()}
78+
{ text: "Introduction", link: "/guidelines" },
79+
{
80+
text: "Component Guidelines",
81+
base: "/design/",
82+
items: getComponentsDesignItems(),
83+
},
7884
];
79-
}
85+
};
8086

8187
export default {
82-
'/dev/': { base: '/dev/', items: getSidebarDevContents() },
83-
'/design/': { base: '/design/', items: getSidebarDesignContents() },
84-
} as DefaultTheme.Sidebar
88+
"/dev/": { base: "/dev/", items: getSidebarDevContents() },
89+
"/design/": { base: "/design/", items: getSidebarDesignContents() },
90+
} as DefaultTheme.Sidebar;

docs/.vitepress/socialLinks.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { DefaultTheme } from "vitepress";
22

33
export default [
4-
{ icon: 'github', link: 'https://github.com/Tap30/web-components' },
5-
{ icon: 'linkedin', link: 'https://www.linkedin.com/company/tapsi' },
6-
] as DefaultTheme.SocialLink[]
4+
{ icon: "github", link: "https://github.com/Tap30/web-components" },
5+
{ icon: "linkedin", link: "https://www.linkedin.com/company/tapsi" },
6+
] as DefaultTheme.SocialLink[];

docs/components/doc-guideline-card/doc-guideline-card.style.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {css} from "lit";
1+
import { css } from "lit";
22

33
export default css`
44
:host {

docs/components/doc-guideline-card/doc-guideline-card.ts

+26-20
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,54 @@
1-
import {html, LitElement, nothing} from 'lit';
2-
import {property} from 'lit/decorators.js';
1+
import { html, LitElement, nothing } from "lit";
2+
import { property } from "lit/decorators.js";
33

44
export class GuidelineCard extends LitElement {
5-
@property({ attribute: 'image-url' }) imageUrl = '';
5+
@property({ attribute: "image-url" })
6+
public imageUrl? = "";
67

7-
@property() variant?: 'do' | 'dont' | 'caution';
8-
9-
private renderBadge () {
8+
@property()
9+
public variant?: "do" | "dont" | "caution";
1010

11+
private _renderBadge() {
1112
const badgeConfig = {
1213
do: {
13-
title: 'Do',
14-
class: 'do'
14+
title: "Do",
15+
class: "do",
1516
},
1617
dont: {
17-
title: 'Don\'t',
18-
class: 'dont'
18+
title: "Don't",
19+
class: "dont",
1920
},
2021
caution: {
21-
title: 'Caution',
22-
class: 'caution'
22+
title: "Caution",
23+
class: "caution",
2324
},
24-
}
25-
25+
};
2626

2727
if (this.variant && Object.keys(badgeConfig).includes(this.variant)) {
2828
const selectedBadge = badgeConfig[this.variant];
29-
return html`<div class="badge ${selectedBadge.class}">${selectedBadge.title}</div>`
29+
30+
return html`<div class="badge ${selectedBadge.class}">
31+
${selectedBadge.title}
32+
</div>`;
3033
}
31-
return nothing
34+
35+
return nothing;
3236
}
3337

34-
render() {
38+
protected override render() {
3539
return html`
36-
<div part="guideline-card" class="guideline-card ">
40+
<div
41+
part="guideline-card"
42+
class="guideline-card "
43+
>
3744
<div class="image">
3845
<slot name="card-image"></slot>
3946
</div>
40-
${this.renderBadge()}
47+
${this._renderBadge()}
4148
<div class="content">
4249
<slot></slot>
4350
</div>
4451
</div>
4552
`;
4653
}
4754
}
48-
+6-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import { customElement } from 'lit/decorators.js';
2-
import styles from './doc-guideline-card.style';
3-
import {GuidelineCard} from "./doc-guideline-card";
1+
import { customElement } from "lit/decorators.js";
2+
import { GuidelineCard } from "./doc-guideline-card";
3+
import styles from "./doc-guideline-card.style";
44

5-
@customElement('doc-guideline-card')
5+
@customElement("doc-guideline-card")
66
export class DocGuidelineCard extends GuidelineCard {
7-
static readonly styles = [styles];
7+
public static override readonly styles = [styles];
88
}
99

1010
declare global {
1111
interface HTMLElementTagNameMap {
12-
'doc-guideline-card': DocGuidelineCard;
12+
"doc-guideline-card": DocGuidelineCard;
1313
}
1414
}

docs/components/doc-guideline-section/doc-guideline-section.style.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {css} from "lit";
1+
import { css } from "lit";
22

33
export default css`
44
:host {
@@ -33,7 +33,6 @@ export default css`
3333
width: 100%;
3434
}
3535
36-
3736
@media (max-width: 1100px) {
3837
.guideline-section {
3938
flex-direction: column;
@@ -49,4 +48,4 @@ export default css`
4948
margin: auto;
5049
}
5150
}
52-
`
51+
`;

docs/components/doc-guideline-section/doc-guideline-section.ts

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
1-
import {html, LitElement} from 'lit';
2-
import {property} from 'lit/decorators.js';
1+
import { html, LitElement } from "lit";
2+
import { property } from "lit/decorators.js";
33

44
export class GuidelineSection extends LitElement {
5-
@property({ type: Boolean }) reverse = false;
5+
@property({ type: Boolean })
6+
public reverse = false;
67

7-
render() {
8+
protected override render() {
89
return html`
9-
<div part="guideline-section" class="guideline-section ${this.reverse ? 'reverse' : ''}">
10+
<div
11+
part="guideline-section"
12+
class="guideline-section ${this.reverse ? "reverse" : ""}"
13+
>
1014
<div class="content">
1115
<slot></slot>
1216
</div>
13-
<div class="image">
14-
<slot name="image"></slot>
15-
</div>
17+
<div class="image">
18+
<slot name="image"></slot>
19+
</div>
1620
</div>
1721
`;
1822
}
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import { customElement } from 'lit/decorators.js';
2-
import {GuidelineSection} from "./doc-guideline-section.js";
3-
import styles from './doc-guideline-section.style.js';
1+
import { customElement } from "lit/decorators.js";
2+
import { GuidelineSection } from "./doc-guideline-section.js";
3+
import styles from "./doc-guideline-section.style.js";
44

5-
@customElement('doc-guideline-section')
5+
@customElement("doc-guideline-section")
66
export class DocGuidelineSection extends GuidelineSection {
7-
static readonly styles = [styles];
7+
public static override readonly styles = [styles];
88
}
99

1010
declare global {
1111
interface HTMLElementTagNameMap {
12-
'doc-guideline-section': DocGuidelineSection;
12+
"doc-guideline-section": DocGuidelineSection;
1313
}
1414
}

0 commit comments

Comments
 (0)