Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added storybook base + Sample Component
- Loading branch information
aroman
committed
Jun 23, 2019
1 parent
de0162c
commit 33f5789
Showing
11 changed files
with
269 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
"parser": "@typescript-eslint/parser", | ||
"extends": [ | ||
"airbnb-typescript/base", | ||
"plugin:react/recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:prettier/recommended" | ||
], | ||
"plugins": ["react-hooks"], | ||
"parserOptions": { | ||
"ecmaVersion": 2018, | ||
"sourceType": "module", | ||
"ecmaFeatures": { | ||
"jsx": true | ||
} | ||
}, | ||
"settings": { | ||
"react": { | ||
"version": "detect" | ||
}, | ||
"import/resolver": { | ||
"typescript": { | ||
"directory": "./src" | ||
} | ||
} | ||
}, | ||
"rules": { | ||
"@typescript-eslint/indent": "off", | ||
"@typescript-eslint/interface-name-prefix": "always", | ||
"@typescript-eslint/explicit-function-return-type": [ | ||
"error", | ||
{ | ||
"allowExpressions": true, | ||
"allowTypedFunctionExpressions": true | ||
} | ||
], | ||
"no-console": [ | ||
"warn", | ||
{ | ||
"allow": ["error"] | ||
} | ||
], | ||
"import/no-extraneous-dependencies": "off", | ||
"import/named": "off", | ||
"react/prop-types": "off", | ||
"react-hooks/rules-of-hooks": "error", | ||
"react-hooks/exhaustive-deps": "warn" | ||
}, | ||
"globals": { | ||
"window": false, | ||
"document": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
node_modules | ||
|
||
storybook-static | ||
|
||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { configure } from "@storybook/react"; | ||
|
||
const req = require.context("../src", true, /.stories.tsx$/); | ||
|
||
function loadStories() { | ||
req.keys().forEach(req); | ||
} | ||
|
||
configure(loadStories, module); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module.exports = ({ config }) => { | ||
config.module.rules.push( | ||
{ | ||
test: /\.(ts|tsx)$/, | ||
use: [ | ||
{ | ||
loader: require.resolve("awesome-typescript-loader") | ||
}, | ||
{ loader: require.resolve("react-docgen-typescript-loader") } | ||
] | ||
}, | ||
// lint | ||
{ | ||
test: /(\.ts$|\.tsx?$)/, | ||
exclude: /node_modules/, | ||
use: ["eslint-loader"] | ||
} | ||
); | ||
config.resolve.extensions.push(".ts", ".tsx"); | ||
return config; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module.exports = { | ||
roots: ["<rootDir>/src"], | ||
transform: { | ||
"^.+\\.tsx?$": "ts-jest" | ||
}, | ||
reporters: [ | ||
"default", | ||
[ | ||
"jest-junit", | ||
{ | ||
suiteName: "JUnit", | ||
output: "junit.xml", | ||
includeConsoleOutput: true | ||
} | ||
] | ||
], | ||
testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$", | ||
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"], | ||
globals: { | ||
NODE_ENV: "test" | ||
}, | ||
collectCoverage: true, | ||
collectCoverageFrom: [ | ||
"**/*.{js,jsx,ts,tsx}", | ||
"!**/node_modules/**", | ||
"!**/types/**" | ||
], | ||
coveragePathIgnorePatterns: [".stories.tsx", ".style.ts"], | ||
coverageDirectory: "./test-results", | ||
// Testing setup files. | ||
setupFilesAfterEnv: ["<rootDir>/src/setupTests.ts"] | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import * as React from "react"; | ||
|
||
const SampleComponent: React.FC<any> = () => { | ||
return <button>Submit</button>; | ||
}; | ||
|
||
export default SampleComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import * as React from "react"; | ||
import { storiesOf } from "@storybook/react"; | ||
import Sample from "./SampleComponent.component"; | ||
|
||
storiesOf("Sample", module).add("Sample button", () => { | ||
return <Sample />; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* Setup test environment for testing-library/react | ||
*/ | ||
|
||
import "@testing-library/react/cleanup-after-each"; | ||
import "jest-dom/extend-expect"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"compilerOptions": { | ||
"outDir": "build/lib", | ||
"types": ["react", "jest"], | ||
"module": "commonjs", | ||
"target": "es5", | ||
"lib": ["es5", "es6", "es7", "es2017", "dom"], | ||
"sourceMap": true, | ||
"allowJs": false, | ||
"jsx": "react", | ||
"moduleResolution": "node", | ||
"rootDir": "src", | ||
"baseUrl": "src", | ||
"noImplicitReturns": true, | ||
"noImplicitThis": true, | ||
"noImplicitAny": true, | ||
"strictNullChecks": true, | ||
"suppressImplicitAnyIndexErrors": true, | ||
"noUnusedLocals": true, | ||
"allowSyntheticDefaultImports": true, | ||
"experimentalDecorators": true, | ||
"emitDecoratorMetadata": true | ||
}, | ||
"include": ["src/**/*"], | ||
"exclude": ["node_modules", "build", "scripts"] | ||
} |