declapract-typescript-ehmpathy 0.42.2 → 0.42.3
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/dist/practices/cicd-common/best-practice/.github/workflows/.install.yml +13 -9
- package/dist/practices/lambda-handlers/best-practice/package.json +1 -1
- package/dist/practices/tests/bad-practices/old-test-utils-and-assets-location/.declapract.readme.md +8 -0
- package/dist/practices/tests/bad-practices/old-test-utils-and-assets-location/<star><star>/<star>.ts.declapract.ts +27 -0
- package/dist/practices/tests/bad-practices/old-test-utils-and-assets-location/<star><star>/__test_assets__/<star><star>/<star>.declapract.ts +17 -0
- package/dist/practices/tests/bad-practices/old-test-utils-and-assets-location/<star><star>/__test_utils__/<star><star>/<star>.declapract.ts +17 -0
- package/license.md +1 -1
- package/package.json +16 -7
|
@@ -16,26 +16,30 @@ jobs:
|
|
|
16
16
|
- name: checkout
|
|
17
17
|
uses: actions/checkout@v3
|
|
18
18
|
|
|
19
|
-
- name: setup pnpm
|
|
20
|
-
uses: pnpm/action-setup@v4
|
|
21
|
-
|
|
22
|
-
- name: set node-version
|
|
23
|
-
uses: actions/setup-node@v3
|
|
24
|
-
with:
|
|
25
|
-
node-version-file: ".nvmrc"
|
|
26
|
-
|
|
27
19
|
- name: node-modules deps hash
|
|
28
20
|
id: deps-hash
|
|
29
21
|
run: |
|
|
30
22
|
PACKAGE_DEPS_HASH=$(md5sum pnpm-lock.yaml | awk '{print $1}');
|
|
31
23
|
echo "PACKAGE_DEPS_HASH=$PACKAGE_DEPS_HASH"
|
|
32
24
|
echo "package-deps-hash=$PACKAGE_DEPS_HASH" >> "$GITHUB_OUTPUT"
|
|
33
|
-
|
|
25
|
+
|
|
26
|
+
- name: node-modules cache check
|
|
34
27
|
uses: actions/cache/restore@v4
|
|
35
28
|
id: cache
|
|
36
29
|
with:
|
|
37
30
|
path: ./node_modules
|
|
38
31
|
key: ${{ runner.os }}-pnpm-${{ steps.deps-hash.outputs.package-deps-hash }}
|
|
32
|
+
lookup-only: true
|
|
33
|
+
|
|
34
|
+
- name: node-modules cache miss setup node
|
|
35
|
+
if: steps.cache.outputs.cache-hit != 'true'
|
|
36
|
+
uses: actions/setup-node@v3
|
|
37
|
+
with:
|
|
38
|
+
node-version-file: ".nvmrc"
|
|
39
|
+
|
|
40
|
+
- name: node-modules cache miss setup pnpm
|
|
41
|
+
if: steps.cache.outputs.cache-hit != 'true'
|
|
42
|
+
uses: pnpm/action-setup@v4
|
|
39
43
|
|
|
40
44
|
- name: node-modules cache miss install
|
|
41
45
|
if: steps.cache.outputs.cache-hit != 'true'
|
package/dist/practices/tests/bad-practices/old-test-utils-and-assets-location/.declapract.readme.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
test utilities and assets should be located in `.test/assets/` instead of `__test_utils__` or `__test_assets__`
|
|
2
|
+
|
|
3
|
+
the `.test/assets/` directory replaces the `__test_utils__` or `__test_assets__` directory in the same relative location.
|
|
4
|
+
|
|
5
|
+
examples:
|
|
6
|
+
- `src/domain/__test_utils__/exampleUser.ts` → `src/domain/.test/assets/exampleUser.ts`
|
|
7
|
+
- `src/logic/__test_assets__/fixtures.json` → `src/logic/.test/assets/fixtures.json`
|
|
8
|
+
- `acceptance/__test_utils__/environment.ts` → `acceptance/.test/assets/environment.ts`
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { FileCheckFunction, FileFixFunction } from 'declapract';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* check if file has imports from __test_utils__ or __test_assets__ directories
|
|
5
|
+
*/
|
|
6
|
+
export const check: FileCheckFunction = (contents) => {
|
|
7
|
+
if (contents?.includes('__test_utils__')) return; // matches bad practice
|
|
8
|
+
if (contents?.includes('__test_assets__')) return; // matches bad practice
|
|
9
|
+
throw new Error('does not match bad practice');
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* replace __test_utils__ and __test_assets__ with .test/assets in import paths
|
|
14
|
+
*/
|
|
15
|
+
export const fix: FileFixFunction = (contents) => {
|
|
16
|
+
if (!contents) return {};
|
|
17
|
+
|
|
18
|
+
// simple string replacement - the relative path stays the same, only the directory name changes
|
|
19
|
+
// e.g., from '../__test_utils__/foo' to '../.test/assets/foo'
|
|
20
|
+
const fixedContents = contents
|
|
21
|
+
.replace(/__test_utils__\//g, '.test/assets/')
|
|
22
|
+
.replace(/__test_assets__\//g, '.test/assets/');
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
contents: fixedContents,
|
|
26
|
+
};
|
|
27
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { FileFixFunction } from 'declapract';
|
|
2
|
+
import { FileCheckType } from 'declapract';
|
|
3
|
+
|
|
4
|
+
export const check = FileCheckType.EXISTS; // if files exist in __test_assets__ directories, it's bad practice
|
|
5
|
+
|
|
6
|
+
export const fix: FileFixFunction = (contents, context) => {
|
|
7
|
+
// move from any/**/__test_assets__/**/* to .test/assets/**/*
|
|
8
|
+
const newPath = context.relativeFilePath.replace(
|
|
9
|
+
/__test_assets__\//g,
|
|
10
|
+
'.test/assets/',
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
contents: contents ?? null,
|
|
15
|
+
relativeFilePath: newPath,
|
|
16
|
+
};
|
|
17
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { FileFixFunction } from 'declapract';
|
|
2
|
+
import { FileCheckType } from 'declapract';
|
|
3
|
+
|
|
4
|
+
export const check = FileCheckType.EXISTS; // if files exist in __test_utils__ directories, it's bad practice
|
|
5
|
+
|
|
6
|
+
export const fix: FileFixFunction = (contents, context) => {
|
|
7
|
+
// move from any/**/__test_utils__/**/* to .test/assets/**/*
|
|
8
|
+
const newPath = context.relativeFilePath.replace(
|
|
9
|
+
/__test_utils__\//g,
|
|
10
|
+
'.test/assets/',
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
contents: contents ?? null,
|
|
15
|
+
relativeFilePath: newPath,
|
|
16
|
+
};
|
|
17
|
+
};
|
package/license.md
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "declapract-typescript-ehmpathy",
|
|
3
3
|
"author": "ehmpathy",
|
|
4
4
|
"description": "declapract best practices declarations for typescript",
|
|
5
|
-
"version": "0.42.
|
|
5
|
+
"version": "0.42.3",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "src/index.js",
|
|
8
8
|
"repository": "ehmpathy/declapract-typescript-ehmpathy",
|
|
@@ -37,11 +37,12 @@
|
|
|
37
37
|
"prepublish": "npm run build",
|
|
38
38
|
"preversion": "npm run prepush",
|
|
39
39
|
"postversion": "git push origin HEAD --tags --no-verify",
|
|
40
|
-
"prepare": "
|
|
41
|
-
"prepare
|
|
40
|
+
"prepare:husky": "npx husky install && chmod ug+x .husky/*",
|
|
41
|
+
"prepare": "[ -d .git ] && npm run prepare:husky || exit 0"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"
|
|
44
|
+
"chalk": "4.1.2",
|
|
45
|
+
"domain-objects": "0.31.0",
|
|
45
46
|
"expect": "29.4.2",
|
|
46
47
|
"flat": "5.0.2",
|
|
47
48
|
"helpful-errors": "1.5.3",
|
|
@@ -51,29 +52,36 @@
|
|
|
51
52
|
"declapract": ">=0.12.1"
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
|
55
|
+
"@babel/core": "7.28.5",
|
|
56
|
+
"@babel/preset-env": "7.28.5",
|
|
54
57
|
"@commitlint/cli": "19.3.0",
|
|
55
58
|
"@commitlint/config-conventional": "13.1.0",
|
|
56
59
|
"@ehmpathy/as-command": "1.0.1",
|
|
57
60
|
"@trivago/prettier-plugin-sort-imports": "4.3.0",
|
|
58
61
|
"@tsconfig/node-lts-strictest": "18.12.1",
|
|
59
62
|
"@types/flat": "5.0.2",
|
|
63
|
+
"@types/node": "22.15.21",
|
|
60
64
|
"@types/jest": "29.4.0",
|
|
61
65
|
"@typescript-eslint/eslint-plugin": "7.8.0",
|
|
62
66
|
"@typescript-eslint/parser": "7.8.0",
|
|
67
|
+
"babel-jest": "30.2.0",
|
|
63
68
|
"core-js": "3.26.1",
|
|
64
69
|
"cz-conventional-changelog": "3.3.0",
|
|
70
|
+
"declastruct": "1.3.0",
|
|
71
|
+
"declastruct-github": "1.0.3",
|
|
65
72
|
"depcheck": "1.4.3",
|
|
66
73
|
"eslint": "8.56.0",
|
|
67
74
|
"eslint-config-airbnb-typescript": "18.0.0",
|
|
68
75
|
"eslint-config-prettier": "8.5.0",
|
|
69
76
|
"eslint-plugin-import": "2.26.0",
|
|
70
77
|
"eslint-plugin-prettier": "4.2.1",
|
|
71
|
-
"eslint-plugin-unused-imports": "4.
|
|
78
|
+
"eslint-plugin-unused-imports": "4.1.4",
|
|
72
79
|
"husky": "8.0.3",
|
|
73
80
|
"jest": "29.3.1",
|
|
74
81
|
"prettier": "2.8.1",
|
|
75
82
|
"test-fns": "1.4.2",
|
|
76
|
-
"ts-jest": "29.
|
|
83
|
+
"ts-jest": "29.4.5",
|
|
84
|
+
"tsx": "4.20.6",
|
|
77
85
|
"type-fns": "0.8.1",
|
|
78
86
|
"typescript": "5.4.5",
|
|
79
87
|
"visualogic": "1.2.3"
|
|
@@ -83,5 +91,6 @@
|
|
|
83
91
|
"path": "./node_modules/cz-conventional-changelog"
|
|
84
92
|
}
|
|
85
93
|
},
|
|
86
|
-
"bugs": "https://github.com/ehmpathy/declapract-typescript-ehmpathy/issues"
|
|
94
|
+
"bugs": "https://github.com/ehmpathy/declapract-typescript-ehmpathy/issues",
|
|
95
|
+
"packageManager": "pnpm@10.24.0"
|
|
87
96
|
}
|