|
54 | 54 | ```
|
55 | 55 |
|
56 | 56 | ### tslint.json
|
57 |
| -> - Recommended setup is to extend build-in preset `tslint:latest` (for all rules use `tslint:all`) |
| 57 | +> - Recommended setup is to extend build-in preset `tslint:recommended` (for all rules use `tslint:all`) |
58 | 58 | > - Add tslint react rules: `npm i -D tslint-react` https://github.com/palantir/tslint-react
|
59 | 59 | > - Amended some extended defaults for more flexibility
|
60 | 60 |
|
61 | 61 | ```json
|
62 | 62 | {
|
63 |
| - "extends": ["tslint:latest", "tslint-react"], |
| 63 | + "extends": ["tslint:recommended", "tslint-react"], |
64 | 64 | "rules": {
|
65 | 65 | "arrow-parens": false,
|
66 | 66 | "arrow-return-shorthand": [false],
|
|
75 | 75 | "newline-before-return": false,
|
76 | 76 | "no-any": false,
|
77 | 77 | "no-empty-interface": false,
|
| 78 | + "no-import-side-effect": [true], |
78 | 79 | "no-inferrable-types": [true, "ignore-params", "ignore-properties"],
|
79 | 80 | "no-invalid-this": [true, "check-function-in-method"],
|
80 | 81 | "no-null-keyword": false,
|
81 | 82 | "no-require-imports": false,
|
82 | 83 | "no-switch-case-fall-through": true,
|
| 84 | + "no-submodule-imports": [true, "rxjs", "@src"], |
83 | 85 | "no-trailing-whitespace": true,
|
84 | 86 | "no-this-assignment": [true, {
|
85 | 87 | "allow-destructuring": true
|
|
101 | 103 | }
|
102 | 104 | ```
|
103 | 105 |
|
| 106 | +### jest.config.json |
| 107 | +> - Recommended setup for Jest with TypeScript |
| 108 | +> - Install with `npm i -D jest-cli ts-jest` |
| 109 | +
|
| 110 | +```json |
| 111 | +{ |
| 112 | + "verbose": true, |
| 113 | + "transform": { |
| 114 | + ".(ts|tsx)": "./node_modules/ts-jest/preprocessor.js" |
| 115 | + }, |
| 116 | + "testRegex": "(/spec/.*|\\.(test|spec))\\.(ts|tsx|js)$", |
| 117 | + "moduleFileExtensions": [ |
| 118 | + "ts", |
| 119 | + "tsx", |
| 120 | + "js" |
| 121 | + ], |
| 122 | + "globals": { |
| 123 | + "window": {}, |
| 124 | + "ts-jest": { |
| 125 | + "tsConfigFile": "./tsconfig.json" |
| 126 | + } |
| 127 | + }, |
| 128 | + "setupFiles": [ |
| 129 | + "./jest.stubs.js", |
| 130 | + "./src/rxjs-imports.tsx" |
| 131 | + ] |
| 132 | +} |
| 133 | +``` |
| 134 | + |
104 | 135 | ### Default and Named Module Exports
|
105 | 136 | > Most flexible solution is to use module folder pattern, because you can leverage both named and default import when you see fit.
|
106 | 137 | Using this solution you'll achieve better encapsulation for internal structure/naming refactoring without breaking your consumer code:
|
|
0 commit comments