Skip to content

Commit 2b7f397

Browse files
committed
🚨 Fix TS lint errors
1 parent ebc511f commit 2b7f397

3 files changed

Lines changed: 18 additions & 19 deletions

File tree

src/model.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ export default class Model {
1616
return configuration.typescript ? templatesTypescript : templatesJavascript;
1717
}
1818

19+
getWorkspacePath() {
20+
const workspaces = vscode.workspace.workspaceFolders;
21+
22+
if (workspaces) {
23+
return workspaces[0].uri.toString().split(":")[1];
24+
}
25+
26+
return null;
27+
}
28+
1929
createComponent(contextUri: string) {
2030
vscode.window
2131
.showInputBox({
@@ -26,9 +36,7 @@ export default class Model {
2636
.then((name) => {
2737
if (!name) return;
2838

29-
const workspacePath = vscode.workspace.workspaceFolders[0].uri
30-
.toString()
31-
.split(":")[1];
39+
const workspacePath = this.getWorkspacePath();
3240
const folderPath = `${contextUri || workspacePath}/${name}`;
3341

3442
this.createFolder(folderPath);
@@ -51,9 +59,7 @@ export default class Model {
5159
.then((name) => {
5260
if (!name) return;
5361

54-
const workspacePath = vscode.workspace.workspaceFolders[0].uri
55-
.toString()
56-
.split(":")[1];
62+
const workspacePath = this.getWorkspacePath();
5763
const folderPath = `${contextUri || workspacePath}/${name}`;
5864

5965
this.createFolder(folderPath);
@@ -134,7 +140,7 @@ export default class Model {
134140
fs.writeFile(`${path}/${name}`, content, this.handleError);
135141
}
136142

137-
handleError(error) {
143+
handleError(error: any) {
138144
if (error) {
139145
vscode.window.showErrorMessage(error);
140146
}

src/template/component.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
export const index = (name) => `export * from './${name}';\n`;
1+
export const index = (name: string) => `export * from './${name}';\n`;
22

3-
export const indexFela = (name, dependencies: boolean) => `${
3+
export const indexFela = (name: string, dependencies: boolean) => `${
44
dependencies
55
? "import { connectFela } from '../../dependencies'"
66
: "import { connect as connectFela } from 'react-fela'"
@@ -57,8 +57,7 @@ ${name}.propTypes = {
5757
};
5858
`;
5959

60-
export const styles = (dependencies: boolean) =>
61-
"export const container = () => ({});\n";
60+
export const styles = () => "export const container = () => ({});\n";
6261

6362
export const component = (name: string, dependencies: boolean) => `${
6463
dependencies

src/template/componentsTypescript.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,13 @@ export const felaComponent = (
3131
: "import React from 'react';\nimport type { FelaWithStylesProps } from 'react-fela';"
3232
}
3333
${getExtendPropImport(typescriptFelaTheme, typescriptFelaExtendProp)}
34-
${
35-
typescriptFelaExtendProp
36-
? `import * as felaRules from './${name}.rules';`
37-
: ""
38-
}
34+
import * as felaRules from './${name}.rules';
3935
4036
export interface ${name}OwnProps {
4137
${getExtendProp(typescriptFelaTheme, typescriptFelaExtendProp)}
4238
}
4339
44-
interface ${name}Props extends FelaWithStylesProps<${name}OwnProps, ${
45-
typescriptFelaExtendProp ? "typeof felaRules" : "{}"
46-
}>, ${name}OwnProps {}
40+
interface ${name}Props extends FelaWithStylesProps<${name}OwnProps, typeof felaRules> {}
4741
4842
export const ${name} = ({ styles }: ${name}Props) => {
4943
return (

0 commit comments

Comments
 (0)