Skip to content

Commit 6c4bec7

Browse files
Havretpvasek
authored andcommitted
Apply prettier and lint to example project (#70)
1 parent 0bedde7 commit 6c4bec7

File tree

10 files changed

+486
-110
lines changed

10 files changed

+486
-110
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"components/**/*.{ts,tsx}": [
3+
"npm run prettier:base -- --write",
4+
"git add"
5+
]
6+
}
Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
11
import * as React from 'react';
2-
import {Component} from 'react';
2+
import { Component } from 'react';
33

44
/**
55
* Column properties.
66
*/
77
export interface IColumnProps extends React.HTMLAttributes<any> {
8-
/** prop1 description */
9-
prop1?: string;
10-
/** prop2 description */
11-
prop2: number;
12-
/**
13-
* prop3 description
14-
*/
15-
prop3: () => void;
16-
/** prop4 description */
17-
prop4: 'option1' | 'option2' | 'option3';
8+
/** prop1 description */
9+
prop1?: string;
10+
/** prop2 description */
11+
prop2: number;
12+
/**
13+
* prop3 description
14+
*/
15+
prop3: () => void;
16+
/** prop4 description */
17+
prop4: 'option1' | 'option2' | 'option3';
1818
}
1919

2020
/**
2121
* Form column.
2222
*/
2323
export class Column extends Component<IColumnProps, {}> {
24-
25-
render() {
26-
return <div>Column</div>;
27-
}
24+
render() {
25+
return <div>Column</div>;
26+
}
2827
}
2928

30-
export default Column;
29+
export default Column;

examples/react-styleguidist-example/components/ConstExport.tsx

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,45 @@ import * as React from 'react';
44
* Row properties.
55
*/
66
export interface IRowProps {
7-
/** prop1 description */
8-
prop1?: string;
9-
/** prop2 description */
10-
prop2: number;
11-
/**
12-
* prop3 description
13-
*/
14-
prop3: () => void;
15-
/** prop4 description */
16-
prop4: 'option1' | 'option2' | "option3";
7+
/** prop1 description */
8+
prop1?: string;
9+
/** prop2 description */
10+
prop2: number;
11+
/**
12+
* prop3 description
13+
*/
14+
prop3: () => void;
15+
/** prop4 description */
16+
prop4: 'option1' | 'option2' | 'option3';
1717
}
1818

1919
/**
2020
* test
21-
*
21+
*
2222
*/
2323
export const test = (one: number) => {
24-
return one;
25-
}
24+
return one;
25+
};
2626

2727
export const myObj = {
28-
foo: 'bar',
29-
}
28+
foo: 'bar'
29+
};
3030

3131
/**
3232
* Form row.
3333
*/
3434
export const ConstExportRow = (props: IRowProps) => {
35-
const innerFunc = (props: IRowProps) => {
36-
return <span>Inner Func</span>
37-
};
38-
const innerNonExportedFunc = (props: IRowProps) => {
39-
return <span>Inner Func</span>
40-
};
41-
return <div>Test</div>;
35+
const innerFunc = (props: IRowProps) => {
36+
return <span>Inner Func</span>;
37+
};
38+
const innerNonExportedFunc = (props: IRowProps) => {
39+
return <span>Inner Func</span>;
40+
};
41+
return <div>Test</div>;
4242
};
4343

4444
const nonExportedFunc = (props: IRowProps) => {
45-
return <div>No Export</div>
45+
return <div>No Export</div>;
4646
};
4747

4848
export default ConstExportRow;

examples/react-styleguidist-example/components/Grid.tsx

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,30 @@ import * as React from 'react';
44
* Grid properties.
55
*/
66
export interface IGridProps {
7-
/** prop1 description */
8-
prop1?: string;
9-
/** prop2 description */
10-
prop2: number;
11-
/**
12-
* prop3 description
13-
*/
14-
prop3: () => void;
15-
/** Working grid description */
16-
prop4: 'option1' | 'option2' | 'option3';
7+
/** prop1 description */
8+
prop1?: string;
9+
/** prop2 description */
10+
prop2: number;
11+
/**
12+
* prop3 description
13+
*/
14+
prop3: () => void;
15+
/** Working grid description */
16+
prop4: 'option1' | 'option2' | 'option3';
1717
}
1818

1919
/**
2020
* Form Grid.
2121
*/
2222
export const Grid = (props: IGridProps) => {
23-
const smaller = () => {return;};
24-
return <div>Grid</div>;
23+
const smaller = () => {
24+
return;
25+
};
26+
return <div>Grid</div>;
2527
};
2628

2729
const notExported = (props: IGridProps) => {
28-
return <div>not exported grid</div>
30+
return <div>not exported grid</div>;
2931
};
3032

31-
export default Grid;
33+
export default Grid;

examples/react-styleguidist-example/components/HocComponent.tsx

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,31 @@ import * as React from 'react';
44
* Row properties.
55
*/
66
export interface IRowProps {
7-
/** prop1 description */
8-
prop1?: string;
9-
/** prop2 description */
10-
prop2: number;
11-
/**
12-
* prop3 description
13-
*/
14-
prop3: () => void;
15-
/** prop4 description */
16-
prop4: 'option1' | 'option2' | "option3";
7+
/** prop1 description */
8+
prop1?: string;
9+
/** prop2 description */
10+
prop2: number;
11+
/**
12+
* prop3 description
13+
*/
14+
prop3: () => void;
15+
/** prop4 description */
16+
prop4: 'option1' | 'option2' | 'option3';
1717
}
1818

1919
/**
2020
* Form row.
2121
*/
2222
class Component extends React.Component<IRowProps, {}> {
23-
24-
render() {
23+
render() {
2524
return <div>Test</div>;
26-
}
27-
};
25+
}
26+
}
2827

2928
export function hoc<T>(Component: T): T {
30-
// do whatever you need but return the same type T
31-
return Component as T;
29+
// do whatever you need but return the same type T
30+
return Component as T;
3231
}
3332

3433
/** This example shows HocComponent */
35-
export const HocComponent = hoc(Component);
34+
export const HocComponent = hoc(Component);

examples/react-styleguidist-example/components/PureRow.tsx

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,25 @@ import * as React from 'react';
44
* Row properties.
55
*/
66
export interface IRowProps {
7-
/** prop1 description */
8-
prop1?: string;
9-
/** prop2 description */
10-
prop2: number;
11-
/**
12-
* prop3 description
13-
*/
14-
prop3: () => void;
15-
/** prop4 description */
16-
prop4: 'option1' | 'option2' | "option3";
7+
/** prop1 description */
8+
prop1?: string;
9+
/** prop2 description */
10+
prop2: number;
11+
/**
12+
* prop3 description
13+
*/
14+
prop3: () => void;
15+
/** prop4 description */
16+
prop4: 'option1' | 'option2' | 'option3';
1717
}
1818

1919
/**
2020
* Form row.
2121
*/
2222
export class PureRow extends React.PureComponent<IRowProps, {}> {
23-
24-
render() {
23+
render() {
2524
return <div>Test</div>;
26-
}
27-
};
25+
}
26+
}
2827

29-
export default PureRow;
28+
export default PureRow;

examples/react-styleguidist-example/components/Row.tsx

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,25 @@ import { Component } from 'react';
55
* Row properties.
66
*/
77
export interface IRowProps {
8-
/** prop1 description */
9-
prop1?: string;
10-
/** prop2 description */
11-
prop2: number;
12-
/**
13-
* prop3 description
14-
*/
15-
prop3: () => void;
16-
/** prop4 description */
17-
prop4: 'option1' | 'option2' | 'option3';
8+
/** prop1 description */
9+
prop1?: string;
10+
/** prop2 description */
11+
prop2: number;
12+
/**
13+
* prop3 description
14+
*/
15+
prop3: () => void;
16+
/** prop4 description */
17+
prop4: 'option1' | 'option2' | 'option3';
1818
}
1919

2020
/**
2121
* Form Row.
2222
*/
2323
export class Row extends Component<IRowProps, {}> {
24-
25-
render() {
26-
return <div>Row</div>;
27-
}
24+
render() {
25+
return <div>Row</div>;
26+
}
2827
}
2928

30-
export default Row;
29+
export default Row;

examples/react-styleguidist-example/package.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@
77
"tsc": "tsc",
88
"styleguidist": "styleguidist",
99
"start": "tsc && styleguidist server --config styleguide.config.js",
10-
"webpack": "webpack"
10+
"webpack": "webpack",
11+
"lint": "tslint -c tslint.json 'src/**/*.{ts,tsx}'",
12+
"lint:fix": "npm run lint -- --fix",
13+
"prettier:base": "prettier --parser typescript --single-quote --trailing-comma none",
14+
"prettier:check": "npm run prettier:base -- -l \"components/**/*.{ts,tsx}\"",
15+
"prettier:write": "npm run prettier:base -- --write \"components/**/*.{ts,tsx}\""
1116
},
1217
"author": "pvasek",
1318
"license": "MIT",
@@ -18,9 +23,13 @@
1823
"react-dom": "^16.2.0"
1924
},
2025
"devDependencies": {
26+
"husky": "^0.14.3",
27+
"lint-staged": "^6.0.1",
28+
"prettier": "^1.10.2",
2129
"react-docgen-typescript": "^1.2.2",
2230
"react-styleguidist": "^6.1.0",
2331
"ts-loader": "^3.3.0",
32+
"tslint": "^5.9.1",
2433
"typescript": "^2.3.3",
2534
"webpack": "^3.10.0"
2635
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"defaultSeverity": "error",
3+
"extends": [
4+
"tslint:recommended"
5+
],
6+
"jsRules": {},
7+
"rules": {
8+
"member-access": false,
9+
"trailing-comma": [true, {"multiline": "never", "singleline": "never"}],
10+
"interface-name": false,
11+
"quotemark": [true, "single"],
12+
"arrow-parens": false
13+
},
14+
"rulesDirectory": []
15+
}

0 commit comments

Comments
 (0)