Skip to content

Commit

Permalink
tsconfigにリント系のオプションを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
oki07 committed Oct 28, 2024
1 parent 6b7257f commit 7150805
Show file tree
Hide file tree
Showing 17 changed files with 85 additions and 41 deletions.
12 changes: 8 additions & 4 deletions src/components/button/sp-button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,14 @@ export class SpButton extends UbButton {

constructor() {
super();
this.shadowRoot.adoptedStyleSheets = [
...this.shadowRoot.adoptedStyleSheets,
styles,
];

if (this.shadowRoot) {
this.shadowRoot.adoptedStyleSheets = [
...this.shadowRoot!.adoptedStyleSheets,
styles,
];
}

this.#iconElement.classList.add("base__icon");
this.#iconElement.size = "small";
}
Expand Down
11 changes: 7 additions & 4 deletions src/components/checkbox/sp-checkbox-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ styles.replaceSync(`${foundationStyle} ${checkmarkStyle} ${checkboxListStyle}`);
export class SpCheckboxList extends UbCheckboxText {
constructor() {
super();
this.shadowRoot.adoptedStyleSheets = [
...this.shadowRoot.adoptedStyleSheets,
styles,
];

if (this.shadowRoot) {
this.shadowRoot.adoptedStyleSheets = [
...this.shadowRoot.adoptedStyleSheets,
styles,
];
}
}
}

Expand Down
11 changes: 7 additions & 4 deletions src/components/checkbox/sp-checkbox-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ styles.replaceSync(`${foundationStyle} ${checkmarkStyle} ${checkboxTextStyle}`);
export class SpCheckboxText extends UbCheckboxText {
constructor() {
super();
this.shadowRoot.adoptedStyleSheets = [
...this.shadowRoot.adoptedStyleSheets,
styles,
];

if (this.shadowRoot) {
this.shadowRoot.adoptedStyleSheets = [
...this.shadowRoot.adoptedStyleSheets,
styles,
];
}
}
}

Expand Down
11 changes: 7 additions & 4 deletions src/components/checkbox/sp-checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ styles.replaceSync(`${foundationStyle} ${checkmarkStyle} ${checkboxStyle}`);
export class SpCheckbox extends UbCheckbox {
constructor() {
super();
this.shadowRoot.adoptedStyleSheets = [
...this.shadowRoot.adoptedStyleSheets,
styles,
];

if (this.shadowRoot) {
this.shadowRoot.adoptedStyleSheets = [
...this.shadowRoot.adoptedStyleSheets,
styles,
];
}
}
}

Expand Down
11 changes: 7 additions & 4 deletions src/components/icon/sp-icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ export class SpIcon extends UbIcon {

constructor() {
super();
this.shadowRoot.adoptedStyleSheets = [
...this.shadowRoot.adoptedStyleSheets,
styles,
];

if (this.shadowRoot) {
this.shadowRoot.adoptedStyleSheets = [
...this.shadowRoot.adoptedStyleSheets,
styles,
];
}
}

set type(value: string) {
Expand Down
11 changes: 7 additions & 4 deletions src/components/radio/sp-radio-button-text-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ styles.replaceSync(`${foundationStyle} ${radioButtonTextGroupStyle}`);
export class SpRadioButtonTextGroup extends UbRadioButtonTextGroup {
constructor() {
super();
this.shadowRoot.adoptedStyleSheets = [
...this.shadowRoot.adoptedStyleSheets,
styles,
];

if (this.shadowRoot) {
this.shadowRoot.adoptedStyleSheets = [
...this.shadowRoot.adoptedStyleSheets,
styles,
];
}
}
}

Expand Down
11 changes: 7 additions & 4 deletions src/components/segmentedControl/sp-segmented-control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ styles.replaceSync(`${foundationStyle} ${segmentedControlStyle}`);
export class SpSegmentedControl extends UbRadioButtonTextGroup {
constructor() {
super();
this.shadowRoot.adoptedStyleSheets = [
...this.shadowRoot.adoptedStyleSheets,
styles,
];

if (this.shadowRoot) {
this.shadowRoot.adoptedStyleSheets = [
...this.shadowRoot.adoptedStyleSheets,
styles,
];
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion stories/button/sp-button.story.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const AttributeHTML: Story = {
};

export const OverflowWrap: Story = {
render: (args) => html`
render: () => html`
<p style="overflow-wrap: break-word;">
texttexttexttexttexttexttextttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttextexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttext
</p>
Expand Down
4 changes: 2 additions & 2 deletions stories/checkbox/sp-checkbox-list.story.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const Form: Story = {
};

export const OverflowWrap: Story = {
render: (args) => html`
render: () => html`
<sp-checkbox-list
text="texttexttexttexttexttexttextttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttextexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttext"
></sp-checkbox-list>
Expand All @@ -123,7 +123,7 @@ export const OverflowWrap: Story = {
};

export const ALL: Story = {
render: (args) => html`
render: () => html`
<table>
<thead>
<tr>
Expand Down
4 changes: 2 additions & 2 deletions stories/checkbox/sp-checkbox-text.story.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const Form: Story = {
};

export const OverflowWrap: Story = {
render: (args) => html`
render: () => html`
<sp-checkbox-text
text="texttexttexttexttexttexttextttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttextexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttexttext"
></sp-checkbox-text>
Expand All @@ -123,7 +123,7 @@ export const OverflowWrap: Story = {
};

export const ALL: Story = {
render: (args) => html`
render: () => html`
<table>
<thead>
<tr>
Expand Down
2 changes: 1 addition & 1 deletion stories/checkbox/sp-checkbox.story.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export const Form: Story = {
};

export const ALL: Story = {
render: (args) => html`
render: () => html`
<table>
<thead>
<tr>
Expand Down
2 changes: 1 addition & 1 deletion stories/radio/sp-radio-button-text-group.story.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export const OverflowWrap: Story = {
};

export const ALL: Story = {
render: (args) => html`
render: () => html`
<table>
<thead>
<tr>
Expand Down
2 changes: 1 addition & 1 deletion stories/segmentedControl/sp-segmented-control.story.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ type Story = StoryObj;
export const Basic: Story = {};

export const ALL: Story = {
render: (args) => html`
render: () => html`
<table>
<thead>
<tr>
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export function isElementMatchingSpeedaIcon(
iconName: keyof typeof speedaIconPaths,
) {
const path = svg.querySelector("path");
return `<path d="${path.getAttribute("d")}"/>` === speedaIconPaths[iconName];
return `<path d="${path?.getAttribute("d")}"/>` === speedaIconPaths[iconName];
}
16 changes: 15 additions & 1 deletion tools/figma-icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ import { promisify } from "util";
import * as fs from "fs";
import * as path from "path";

if (!process.env.FIGMA_TOKEN) {
throw new Error("FIGMA_TOKENが設定されていません");
}

if (!process.env.FIGMA_DESIGN_FILE_KEY) {
throw new Error("FIGMA_DESIGN_FILE_KEYが設定されていません");
}

const TOKEN = process.env.FIGMA_TOKEN;
const FIGMA_FILE_KEY = process.env.FIGMA_DESIGN_FILE_KEY;

Expand Down Expand Up @@ -45,6 +53,9 @@ async function fetchFigma(
async function fetchImageAndExtractPath(url: string): Promise<string> {
const response: any = await fetch(url).then((response) => response.text());
const match = /<svg.*?>([\s\S]*?)<\/svg>/.exec(response);
if (!match) {
throw new Error("SVGが見つかりません");
}
return match[1].replace(/\sfill=".*"/, "").replace(/\n|\r/g, "");
}

Expand Down Expand Up @@ -81,7 +92,10 @@ const main = async () => {
await Promise.all(
Object.entries(images).map(async ([key, value]) => {
const path = await fetchImageAndExtractPath(String(value)); // TODO:型がよくわからん
icons.find((icon) => icon.id === key).path = path;
const icon = icons.find((icon) => icon.id === key);
if (icon) {
icon.path = path;
}
}),
);

Expand Down
8 changes: 6 additions & 2 deletions tsconfig-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
"experimentalDecorators": true,
"useDefineForClassFields": false,
"outDir": "dist",
"skipLibCheck": true
"skipLibCheck": true,
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"exclude": ["example", "stories", "dist", "tools"]
"exclude": ["example", "stories", "tests", "dist", "tools"]
}
6 changes: 5 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
"experimentalDecorators": true,
"useDefineForClassFields": false,
"outDir": "dist",
"skipLibCheck": true
"skipLibCheck": true,
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"exclude": ["example", "dist"]
}

0 comments on commit 7150805

Please sign in to comment.