@naturalcycles/dev-lib 13.2.3 → 13.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cfg/eslint-jest-rules.js +9 -0
- package/cfg/eslint.config.js +9 -3
- package/cfg/jest.config.js +4 -0
- package/dist/testing/expect.util.js +1 -0
- package/package.json +1 -1
- package/readme.md +5 -11
package/cfg/eslint.config.js
CHANGED
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Shared eslint config.
|
|
5
5
|
*/
|
|
6
|
+
|
|
7
|
+
// detect if jest is installed
|
|
8
|
+
const hasJest = require('fs').existsSync('./node_modules/jest')
|
|
9
|
+
// console.log({hasJest})
|
|
10
|
+
|
|
6
11
|
module.exports = {
|
|
7
12
|
env: {
|
|
8
13
|
es2020: true,
|
|
@@ -33,8 +38,9 @@ module.exports = {
|
|
|
33
38
|
// https://github.com/import-js/eslint-plugin-import/blob/main/config/typescript.js
|
|
34
39
|
// 'plugin:import/typescript',
|
|
35
40
|
'./eslint-rules.js',
|
|
41
|
+
hasJest && './eslint-jest-rules.js',
|
|
36
42
|
'prettier', // must be last! it only turns off eslint rules that conflict with prettier
|
|
37
|
-
],
|
|
43
|
+
].filter(Boolean),
|
|
38
44
|
parser: '@typescript-eslint/parser',
|
|
39
45
|
parserOptions: {
|
|
40
46
|
project: ['tsconfig.json'],
|
|
@@ -48,9 +54,9 @@ module.exports = {
|
|
|
48
54
|
'@typescript-eslint',
|
|
49
55
|
// https://github.com/sweepline/eslint-plugin-unused-imports
|
|
50
56
|
'unused-imports',
|
|
51
|
-
|
|
57
|
+
hasJest && 'jest',
|
|
52
58
|
'unicorn',
|
|
53
|
-
],
|
|
59
|
+
].filter(Boolean),
|
|
54
60
|
},
|
|
55
61
|
{
|
|
56
62
|
files: ['*.vue'],
|
package/cfg/jest.config.js
CHANGED
|
@@ -79,6 +79,10 @@ module.exports = {
|
|
|
79
79
|
// incremental: true,
|
|
80
80
|
isolatedModules: true, // faster when run without cache (e.g in CI), 50s vs 83s for NCBackend3 right now
|
|
81
81
|
babelConfig: false, // https://kulshekhar.github.io/ts-jest/user/config/babelConfig
|
|
82
|
+
tsconfig: {
|
|
83
|
+
sourceMap: true,
|
|
84
|
+
allowJs: true,
|
|
85
|
+
},
|
|
82
86
|
},
|
|
83
87
|
},
|
|
84
88
|
testEnvironment: 'node',
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -102,8 +102,7 @@ adds `--silent` (and `JEST_SILENT` env var) if all tests are run.
|
|
|
102
102
|
`jest-junit` reporter. Includes fix for "CircleCI out of memory issue"
|
|
103
103
|
- `test-integration`: runs `*.integration.test.ts` with `jest.integration-test.config.js` config.
|
|
104
104
|
- `test-manual`: runs `*.manual.test.ts` with `jest.manual-test.config.js`.
|
|
105
|
-
- `test-leaks`: runs Jest with `--logHeapUsage --detectOpenHandles --detectLeaks
|
|
106
|
-
module to be installed in target project).
|
|
105
|
+
- `test-leaks`: runs Jest with `--logHeapUsage --detectOpenHandles --detectLeaks`.
|
|
107
106
|
|
|
108
107
|
For unit tests (`yarn test`) these `setupFilesAfterEnv` will be used (if found) in that order:
|
|
109
108
|
|
|
@@ -196,14 +195,9 @@ These files are meant to be extended in target project, so act as _recommended d
|
|
|
196
195
|
- `eslint.config.json`
|
|
197
196
|
- `jest.config.js`
|
|
198
197
|
|
|
199
|
-
##
|
|
198
|
+
## eslint
|
|
200
199
|
|
|
201
|
-
|
|
200
|
+
Presence of `jest` is detected by checking if `node_modules/jest` exists.
|
|
202
201
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
module.exports = {
|
|
206
|
-
extends: ['plugin:jest/recommended'],
|
|
207
|
-
plugins: ['jest'],
|
|
208
|
-
}
|
|
209
|
-
```
|
|
202
|
+
If exists - `eslint-plugin-jest` recommended config (plus opinionated `dev-lib`'s rules) are
|
|
203
|
+
enabled. Otherwise disabled ( to not cause "jest not found" errors)
|