@@ -510,7 +510,7 @@ export const withState = <WrappedProps extends InjectedProps>(
510510};
511511
512512` ` `
513- <details><summary>show usage </summary><p>
513+ <details style="background: #f6f8fa;border-radius: 3px;" ><summary style="padding: 6px 12px;border-radius: 3px;"><i>Click to expand</i> </summary><p>
514514
515515` ` ` tsx
516516import * as React from ' react' ;
@@ -594,7 +594,7 @@ export const withErrorBoundary = <WrappedProps extends InjectedProps>(
594594};
595595
596596` ` `
597- <details><summary>show usage </summary><p>
597+ <details style="background: #f6f8fa;border-radius: 3px;" ><summary style="padding: 6px 12px;border-radius: 3px;"><i>Click to expand</i> </summary><p>
598598
599599` ` ` tsx
600600import * as React from ' react' ;
@@ -658,7 +658,7 @@ export const SFCCounterConnected = connect(mapStateToProps, {
658658})(SFCCounter );
659659
660660` ` `
661- <details><summary>show usage </summary><p>
661+ <details style="background: #f6f8fa;border-radius: 3px;" ><summary style="padding: 6px 12px;border-radius: 3px;"><i>Click to expand</i> </summary><p>
662662
663663` ` ` tsx
664664import * as React from ' react' ;
@@ -698,7 +698,7 @@ export const SFCCounterConnectedVerbose =
698698 connect (mapStateToProps , mapDispatchToProps )(SFCCounter );
699699
700700` ` `
701- <details><summary>show usage </summary><p>
701+ <details style="background: #f6f8fa;border-radius: 3px;" ><summary style="padding: 6px 12px;border-radius: 3px;"><i>Click to expand</i> </summary><p>
702702
703703` ` ` tsx
704704import * as React from ' react' ;
@@ -738,7 +738,7 @@ export const SFCCounterConnectedExtended = connect(mapStateToProps, {
738738})(SFCCounter );
739739
740740` ` `
741- <details><summary>show usage </summary><p>
741+ <details style="background: #f6f8fa;border-radius: 3px;" ><summary style="padding: 6px 12px;border-radius: 3px;"><i>Click to expand</i> </summary><p>
742742
743743` ` ` tsx
744744import * as React from ' react' ;
@@ -852,7 +852,7 @@ export const add = (amount: number) => action(ADD, amount);
852852// });
853853
854854` ` `
855- <details><summary>show usage </summary><p>
855+ <details style="background: #f6f8fa;border-radius: 3px;" ><summary style="padding: 6px 12px;border-radius: 3px;"><i>Click to expand</i> </summary><p>
856856
857857` ` ` tsx
858858import store from ' ../../store' ;
@@ -1215,14 +1215,16 @@ export const SFCCounterConnectedVerbose =
12151215- Add additional ` react ` specific rules: ` npm i - D tslint - react ` https://github.com/palantir/tslint-react
12161216- Overwritten some defaults for more flexibility
12171217
1218- ` ` ` js
1218+ <details style="background: #f6f8fa;border-radius: 3px;"><summary style="padding: 6px 12px;border-radius: 3px;"><i>Click to expand</i></summary><p>
1219+
1220+ ` ` ` tsx
12191221{
12201222 " extends" : [" tslint:recommended" , " tslint-react" ],
12211223 " rules" : {
12221224 " arrow-parens" : false ,
12231225 " arrow-return-shorthand" : [false ],
12241226 " comment-format" : [true , " check-space" ],
1225- " import-blacklist" : [true , " rxjs " ],
1227+ " import-blacklist" : [true ],
12261228 " interface-over-type-literal" : false ,
12271229 " interface-name" : false ,
12281230 " max-line-length" : [true , 120 ],
@@ -1234,6 +1236,7 @@ export const SFCCounterConnectedVerbose =
12341236 " no-import-side-effect" : [true ],
12351237 " no-inferrable-types" : [true , " ignore-params" , " ignore-properties" ],
12361238 " no-invalid-this" : [true , " check-function-in-method" ],
1239+ " no-namespace" : false ,
12371240 " no-null-keyword" : false ,
12381241 " no-require-imports" : false ,
12391242 " no-submodule-imports" : [true , " @src" , " rxjs" ],
@@ -1247,26 +1250,38 @@ export const SFCCounterConnectedVerbose =
12471250 " prefer-method-signature" : false ,
12481251 " prefer-template" : [true , " allow-single-concat" ],
12491252 " quotemark" : [true , " single" , " jsx-double" ],
1250- " semicolon" : [true , " always" ],
1251- " trailing-comma" : [true , {
1252- " singleline" : " never" ,
1253- " multiline" : {
1254- " objects" : " always" ,
1255- " arrays" : " always" ,
1256- " functions" : " never" ,
1257- " typeLiterals" : " ignore"
1258- },
1259- " esSpecCompliant" : true
1260- }],
1253+ " semicolon" : [true , " always" , " ignore-bound-class-methods" ],
1254+ " trailing-comma" : [
1255+ true ,
1256+ {
1257+ " singleline" : " never" ,
1258+ " multiline" : {
1259+ " objects" : " always" ,
1260+ " arrays" : " always" ,
1261+ " functions" : " ignore" ,
1262+ " typeLiterals" : " ignore"
1263+ },
1264+ " esSpecCompliant" : true
1265+ }
1266+ ],
12611267 " triple-equals" : [true , " allow-null-check" ],
12621268 " type-literal-delimiter" : true ,
1263- " typedef" : [true ," parameter" , " property-declaration" ],
1264- " variable-name" : [true , " ban-keywords" , " check-format" , " allow-pascal-case" , " allow-leading-underscore" ],
1269+ " typedef" : [true , " parameter" , " property-declaration" ],
1270+ " variable-name" : [
1271+ true ,
1272+ " ban-keywords" ,
1273+ " check-format" ,
1274+ " allow-pascal-case" ,
1275+ " allow-leading-underscore"
1276+ ],
12651277 // tslint-react
1278+ " jsx-no-multiline-js" : false ,
12661279 " jsx-no-lambda" : false
12671280 }
12681281}
1282+
12691283` ` `
1284+ </p></details>
12701285
12711286[⇧ back to top](#table-of-contents)
12721287
@@ -1276,11 +1291,13 @@ export const SFCCounterConnectedVerbose =
12761291` npm i - D jest ts - jest @types / jest `
12771292
12781293#### jest.config.json
1279- ` ` ` json
1294+ <details style="background: #f6f8fa;border-radius: 3px;"><summary style="padding: 6px 12px;border-radius: 3px;"><i>Click to expand</i></summary><p>
1295+
1296+ ` ` ` tsx
12801297{
12811298 " verbose" : true ,
12821299 " transform" : {
1283- " .(ts|tsx)" : " ./node_modules/ ts-jest/preprocessor.js "
1300+ " .(ts|tsx)" : " ts-jest"
12841301 },
12851302 " testRegex" : " (/spec/.*|\\ .(test|spec))\\ .(ts|tsx|js)$" ,
12861303 " moduleFileExtensions" : [" ts" , " tsx" , " js" ],
@@ -1290,19 +1307,29 @@ export const SFCCounterConnectedVerbose =
12901307 " globals" : {
12911308 " window" : {},
12921309 " ts-jest" : {
1293- " tsConfigFile " : " ./tsconfig.json"
1310+ " tsConfig " : " ./tsconfig.json"
12941311 }
12951312 },
1296- " setupFiles" : [
1297- " ./jest.stubs.js"
1298- ],
1299- " setupTestFrameworkScriptFile" : " ./jest.tests.js"
1313+ " setupFiles" : [" ./jest.stubs.js" ],
1314+ " testURL" : " http://localhost/"
13001315}
1316+
13011317` ` `
1318+ </p></details>
13021319
13031320#### jest.stubs.js
1304- ` ` ` js
1321+ <details style="background: #f6f8fa;border-radius: 3px;"><summary style="padding: 6px 12px;border-radius: 3px;"><i>Click to expand</i></summary><p>
1322+
1323+ ` ` ` tsx
13051324// Global/Window object Stubs for Jest
1325+ window .matchMedia = window .matchMedia || function () {
1326+ return {
1327+ matches: false ,
1328+ addListener : function () { },
1329+ removeListener : function () { },
1330+ };
1331+ };
1332+
13061333window .requestAnimationFrame = function (callback ) {
13071334 setTimeout (callback );
13081335};
@@ -1313,22 +1340,9 @@ window.localStorage = {
13131340};
13141341
13151342Object .values = () => [];
1316- ` ` `
1317-
1318- [⇧ back to top](#table-of-contents)
1319-
1320- ## Enzyme
1321-
1322- > Installation
1323- ` npm i - D enzyme enzyme - adapter - react - 16 @types / enzyme `
1324-
1325- #### jest.tests.js
1326- ` ` ` js
1327- import { configure } from ' enzyme' ;
1328- import Adapter from ' enzyme-adapter-react-16' ;
13291343
1330- configure ({ adapter: new Adapter () });
13311344` ` `
1345+ </p></details>
13321346
13331347[⇧ back to top](#table-of-contents)
13341348
@@ -1364,34 +1378,33 @@ configure({ adapter: new Adapter() });
13641378- Install [ ` tslib ` ](https://www.npmjs.com/package/tslib) to cut on bundle size, by using external runtime helpers instead of adding them inline: ` npm i tslib `
13651379- Example "paths" setup for baseUrl relative imports with Webpack
13661380
1367- ` ` ` js
1381+ <details style="background: #f6f8fa;border-radius: 3px;"><summary style="padding: 6px 12px;border-radius: 3px;"><i>Click to expand</i></summary><p>
1382+
1383+ ` ` ` tsx
13681384{
13691385 " compilerOptions" : {
1370- " baseUrl" : " ./" , // enables project relative paths config
1371- " paths" : { // define paths mappings
1372- " @src/*" : [" src/*" ] // will enable import aliases -> import { ... } from '@src/components'
1373- // WARNING: Add this to your webpack config -> resolve: { alias: { '@src': PATH_TO_SRC } }
1374- // "redux": ["typings/redux"], // use an alternative type-definitions instead of the included one
1386+ " baseUrl" : " ./" , // relative paths base
1387+ " paths" : {
1388+ // "@src/*": ["src/*"] // will enable import aliases -> import { ... } from '@src/components'
1389+ // WARNING: Require to add this to your webpack config -> resolve: { alias: { '@src': PATH_TO_SRC } }
1390+ // "redux": ["typings/redux"], // override library types with your alternative type-definitions in typings folder
13751391 },
13761392 " outDir" : " dist/" , // target for compiled files
13771393 " allowSyntheticDefaultImports" : true , // no errors with commonjs modules interop
13781394 " esModuleInterop" : true , // enable to do "import React ..." instead of "import * as React ..."
13791395 " allowJs" : true , // include js files
13801396 " checkJs" : true , // typecheck js files
13811397 " declaration" : false , // don't emit declarations
1382- " emitDecoratorMetadata" : true , // only if using decorators
1383- " experimentalDecorators" : true , // only if using decorators
1398+ " emitDecoratorMetadata" : true , // include only if using decorators
1399+ " experimentalDecorators" : true , // include only if using decorators
13841400 " forceConsistentCasingInFileNames" : true ,
13851401 " importHelpers" : true , // importing transpilation helpers from tslib
13861402 " noEmitHelpers" : true , // disable inline transpilation helpers in each file
1387- " jsx" : " react" , // translate JSX
1388- " lib" : [
1389- " dom" ,
1390- " es2016" ,
1391- " es2017.object"
1392- ],
1403+ " jsx" : " react" , // transform JSX
1404+ " lib" : [" dom" , " es2017" ], // you will need to include polyfills for es2017 manually
1405+ " types" : [" jest" ], // which global types to use
13931406 " target" : " es5" , // "es2015" for ES6+ engines
1394- " module" : " commonjs " , // "es2015" for tree-shaking
1407+ " module" : " es2015 " , // "es2015" for tree-shaking
13951408 " moduleResolution" : " node" ,
13961409 " noEmitOnError" : true ,
13971410 " noFallthroughCasesInSwitch" : true ,
@@ -1401,15 +1414,12 @@ configure({ adapter: new Adapter() });
14011414 " removeComments" : true ,
14021415 " sourceMap" : true
14031416 },
1404- " include" : [
1405- " src/**/*"
1406- ],
1407- " exclude" : [
1408- " node_modules" ,
1409- " src/**/*.spec.*"
1410- ]
1417+ " include" : [" src" , " typings" ],
1418+ " exclude" : [" src/**/*.spec.*" ]
14111419}
1420+
14121421` ` `
1422+ </p></details>
14131423
14141424[⇧ back to top](#table-of-contents)
14151425
0 commit comments