Skip to content

Commit 20119aa

Browse files
Merge pull request #19 from hipstersmoothie/loader
copy generateDocgenCodeBlock from loader to remove dependency on archived code
2 parents 2cbe64c + d51f445 commit 20119aa

17 files changed

Lines changed: 893 additions & 5 deletions

.eslintrc

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,28 @@
44
"xo",
55
"prettier",
66
"plugin:@typescript-eslint/recommended",
7-
"prettier/@typescript-eslint"
7+
"prettier/@typescript-eslint",
8+
"plugin:jest/recommended",
9+
"plugin:jest/style"
10+
],
11+
"plugins": [
12+
"prettier",
13+
"eslint-plugin-jsdoc",
14+
"@typescript-eslint",
15+
"jest"
816
],
9-
"plugins": ["prettier", "eslint-plugin-jsdoc", "@typescript-eslint"],
1017
"parser": "@typescript-eslint/parser",
1118
"parserOptions": {
1219
"project": "./tsconfig.json",
1320
"sourceType": "module"
1421
},
22+
"ignorePatterns": [
23+
"jest.config.js",
24+
"**/__fixtures__"
25+
],
26+
"env": {
27+
"jest/globals": true
28+
},
1529
"rules": {
1630
"@typescript-eslint/explicit-function-return-type": 0,
1731
"@typescript-eslint/camelcase": 0,

.github/workflows/push.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
yarn
2828
yarn build
2929
yarn lint
30+
yarn test
3031
3132
release:
3233
runs-on: ubuntu-latest

jest.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
testEnvironment: "node",
3+
transform: {
4+
"^.+\\.tsx?$": "ts-jest",
5+
},
6+
testRegex: "(/__tests__/.*|(.|/)).(test|spec).(jsx?|tsx?)$",
7+
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
8+
};

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
"author": "Andrew Lisowski <lisowski54@gmail.com>",
88
"main": "dist/index.js",
99
"scripts": {
10-
"build": "tsc -p tsconfig.json",
10+
"build": "tsc -p tsconfig.build.json",
1111
"start": "yarn build --watch",
1212
"lint": "eslint src --ext .ts,.js",
13+
"test": "jest",
1314
"release": "auto shipit"
1415
},
1516
"keywords": [
@@ -27,13 +28,14 @@
2728
"endent": "^2.0.1",
2829
"micromatch": "^4.0.2",
2930
"react-docgen-typescript": "^1.20.1",
30-
"react-docgen-typescript-loader": "^3.7.2",
3131
"tslib": "^2.0.0"
3232
},
3333
"devDependencies": {
3434
"@types/debug": "^4.1.5",
35+
"@types/jest": "^26.0.16",
3536
"@types/micromatch": "^4.0.1",
3637
"@types/node": "^14.0.12",
38+
"@types/react": "^17.0.0",
3739
"@types/webpack": "^4.41.17",
3840
"@typescript-eslint/eslint-plugin": "2.31.0",
3941
"@typescript-eslint/parser": "2.31.0",
@@ -44,10 +46,14 @@
4446
"eslint-config-prettier": "6.11.0",
4547
"eslint-config-xo": "0.29.1",
4648
"eslint-plugin-import": "2.20.2",
49+
"eslint-plugin-jest": "^24.1.3",
4750
"eslint-plugin-jsdoc": "25.2.0",
4851
"eslint-plugin-jsx-a11y": "6.2.3",
4952
"eslint-plugin-prettier": "3.1.3",
53+
"jest": "^26.6.3",
5054
"prettier": "^2.0.5",
55+
"react": "^17.0.1",
56+
"ts-jest": "^26.4.4",
5157
"typescript": "3.8.3"
5258
},
5359
"peerDependencies": {
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import * as React from "react";
2+
3+
interface DefaultPropValueComponentProps {
4+
/**
5+
* Button color.
6+
*
7+
* @default blue
8+
**/
9+
color: "blue" | "green";
10+
11+
/**
12+
* Button counter.
13+
*/
14+
counter: number;
15+
16+
/**
17+
* Button disabled.
18+
*/
19+
disabled: boolean;
20+
}
21+
22+
/**
23+
* Component with a prop with a default value.
24+
*/
25+
export const DefaultPropValueComponent: React.FC<DefaultPropValueComponentProps> = (
26+
props
27+
) => (
28+
<button disabled={props.disabled} style={{ backgroundColor: props.color }}>
29+
{props.counter}
30+
{props.children}
31+
</button>
32+
);
33+
34+
DefaultPropValueComponent.defaultProps = {
35+
counter: 123,
36+
disabled: false,
37+
};
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import * as React from "react";
2+
3+
interface HyphenatedPropNameProps {
4+
/** Button color. */
5+
"button-color": "blue" | "green";
6+
}
7+
8+
/**
9+
* A component with a hyphenated prop name.
10+
*/
11+
export const HyphenatedPropNameComponent: React.FC<HyphenatedPropNameProps> = (
12+
props
13+
) => (
14+
<button style={{ backgroundColor: props["button-color"] }}>
15+
{props.children}
16+
</button>
17+
);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import * as React from "react";
2+
3+
interface MultiPropsComponentProps {
4+
/** Button color. */
5+
color: "blue" | "green";
6+
7+
/** Button size. */
8+
size: "small" | "large";
9+
}
10+
11+
/**
12+
* This is a component with multiple props.
13+
*/
14+
export const MultiPropsComponent: React.FC<MultiPropsComponentProps> = (
15+
props
16+
) => <button style={{ backgroundColor: props.color }}>{props.children}</button>;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import * as React from "react";
2+
3+
interface MultilineDescriptionProps {
4+
/** Button color. */
5+
color: "blue" | "green";
6+
}
7+
8+
/**
9+
* A component with a multiline description.
10+
*
11+
* Second line.
12+
*/
13+
export const MultilineDescriptionComponent: React.FC<MultilineDescriptionProps> = (
14+
props
15+
) => <button style={{ backgroundColor: props.color }}>{props.children}</button>;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import * as React from "react";
2+
3+
interface MultilinePropDescriptionComponentProps {
4+
/**
5+
* This is a multiline prop description.
6+
*
7+
* Second line.
8+
*/
9+
color: "blue" | "green";
10+
}
11+
12+
/**
13+
* A component with multiline prop description.
14+
*/
15+
export const MultilinePropDescriptionComponent: React.FC<MultilinePropDescriptionComponentProps> = (
16+
props
17+
) => <button style={{ backgroundColor: props.color }}>{props.children}</button>;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import * as React from "react";
2+
3+
interface SimpleComponentProps {
4+
/** Button color. */
5+
color: "blue" | "green";
6+
}
7+
8+
/**
9+
* A simple component.
10+
*/
11+
export const SimpleComponent: React.FC<SimpleComponentProps> = (props) => (
12+
<button style={{ backgroundColor: props.color }}>{props.children}</button>
13+
);

0 commit comments

Comments
 (0)