declapract-typescript-ehmpathy 0.43.7 → 0.43.9

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "devDependencies": {
3
- "declastruct": "@declapract{check.minVersion('1.4.0')}",
3
+ "declastruct": "@declapract{check.minVersion('1.4.3')}",
4
4
  "declastruct-aws": "@declapract{check.minVersion('1.0.3')}",
5
5
  "declastruct-unix-network": "@declapract{check.minVersion('1.0.0')}"
6
6
  }
@@ -1,2 +1,3 @@
1
- # exclude package-lock from git diff; https://stackoverflow.com/a/72834452/3068233
1
+ # exclude package locks from git diff; https://stackoverflow.com/a/72834452/3068233
2
+ pnpm-lock.json -diff
2
3
  package-lock.json -diff
@@ -1,6 +1,56 @@
1
- import { FileCheckType } from 'declapract';
1
+ import { FileCheckType, type FileFixFunction } from 'declapract';
2
2
 
3
3
  /**
4
4
  * check that they're contained in the file
5
5
  */
6
6
  export const check: FileCheckType = FileCheckType.CONTAINS;
7
+
8
+ /**
9
+ * the header comment for the package lock exclusions section
10
+ */
11
+ const HEADER =
12
+ '# exclude package locks from git diff; https://stackoverflow.com/a/72834452/3068233';
13
+
14
+ /**
15
+ * the entries that should appear under the header
16
+ */
17
+ const ENTRIES = ['pnpm-lock.json -diff', 'package-lock.json -diff'];
18
+
19
+ /**
20
+ * fix by ensuring all entries are present under the header
21
+ */
22
+ export const fix: FileFixFunction = (contents) => {
23
+ // if no contents, create the file with the header and entries
24
+ if (!contents) {
25
+ return { contents: [HEADER, ...ENTRIES].join('\n') + '\n' };
26
+ }
27
+
28
+ const lines = contents.split('\n');
29
+
30
+ // find the header line index
31
+ const headerIndex = lines.findIndex((line) => line.trim() === HEADER);
32
+
33
+ // if header not found, append the whole section at the end
34
+ if (headerIndex === -1) {
35
+ const newContent =
36
+ contents.trimEnd() + '\n\n' + [HEADER, ...ENTRIES].join('\n') + '\n';
37
+ return { contents: newContent };
38
+ }
39
+
40
+ // find which entries are missing after the header
41
+ const missingEntries = ENTRIES.filter((entry) => !contents.includes(entry));
42
+
43
+ // if no missing entries, nothing to fix
44
+ if (missingEntries.length === 0) {
45
+ return { contents };
46
+ }
47
+
48
+ // insert missing entries right after the header
49
+ const newLines = [
50
+ ...lines.slice(0, headerIndex + 1),
51
+ ...missingEntries,
52
+ ...lines.slice(headerIndex + 1),
53
+ ];
54
+
55
+ return { contents: newLines.join('\n') };
56
+ };
@@ -12,7 +12,8 @@
12
12
  "!**/coverage",
13
13
  "!**/node_modules",
14
14
  "!**/.artifact",
15
- "!**/.generated/**"
15
+ "!**/.generated/**",
16
+ "!**/.test*/**"
16
17
  ]
17
18
  },
18
19
  "formatter": {
@@ -27,7 +28,13 @@
27
28
  "trailingCommas": "all"
28
29
  }
29
30
  },
30
- "assist": { "actions": { "source": { "organizeImports": "on" } } },
31
+ "assist": {
32
+ "actions": {
33
+ "source": {
34
+ "organizeImports": "on"
35
+ }
36
+ }
37
+ },
31
38
  "linter": {
32
39
  "enabled": true,
33
40
  "rules": {
@@ -36,13 +43,19 @@
36
43
  "noExcessiveCognitiveComplexity": "warn"
37
44
  },
38
45
  "correctness": {
39
- "noUnusedImports": { "level": "error", "fix": "safe" },
46
+ "noUnusedImports": {
47
+ "level": "error",
48
+ "fix": "safe"
49
+ },
40
50
  "noUnusedVariables": "warn",
41
51
  "useExhaustiveDependencies": "off"
42
52
  },
43
53
  "style": {
44
54
  "noDefaultExport": "error",
45
- "noNonNullAssertion": { "level": "warn", "fix": "none" },
55
+ "noNonNullAssertion": {
56
+ "level": "warn",
57
+ "fix": "none"
58
+ },
46
59
  "useImportType": "error",
47
60
  "noParameterAssign": "off"
48
61
  },
@@ -6,6 +6,7 @@
6
6
  "homepage": "https://github.com/@declapract{variable.organizationName}/@declapract{variable.projectName}",
7
7
  "bugs": "https://github.com/@declapract{variable.organizationName}/@declapract{variable.projectName}/issues",
8
8
  "scripts": {
9
+ "fix": "npm run fix:format && npm run fix:lint",
9
10
  "prepush": "npm run test && npm run build",
10
11
  "preversion": "npm run prepush",
11
12
  "postversion": "git push origin HEAD --tags --no-verify"
@@ -14,7 +14,9 @@
14
14
  "sourceMap": true,
15
15
  "outDir": "dist",
16
16
  "target": "es2020",
17
- "incremental": true
17
+ "incremental": true,
18
+ "module": "commonjs", // enable usage of esm modules without a strict boundary; todo, cutover to be esm native
19
+ "moduleResolution": "node"
18
20
  },
19
21
  "include": [
20
22
  "**/*.ts"
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.43.7",
5
+ "version": "0.43.9",
6
6
  "license": "MIT",
7
7
  "main": "src/index.js",
8
8
  "repository": "ehmpathy/declapract-typescript-ehmpathy",
@@ -42,7 +42,7 @@
42
42
  },
43
43
  "dependencies": {
44
44
  "chalk": "4.1.2",
45
- "domain-objects": "0.31.0",
45
+ "domain-objects": "0.31.3",
46
46
  "expect": "29.4.2",
47
47
  "flat": "5.0.2",
48
48
  "helpful-errors": "1.5.3",
@@ -61,15 +61,15 @@
61
61
  "@trivago/prettier-plugin-sort-imports": "4.3.0",
62
62
  "@tsconfig/node-lts-strictest": "18.12.1",
63
63
  "@types/flat": "5.0.2",
64
- "@types/node": "22.15.21",
65
64
  "@types/jest": "29.4.0",
65
+ "@types/node": "22.15.21",
66
66
  "@typescript-eslint/eslint-plugin": "7.8.0",
67
67
  "@typescript-eslint/parser": "7.8.0",
68
68
  "babel-jest": "30.2.0",
69
69
  "core-js": "3.26.1",
70
70
  "cz-conventional-changelog": "3.3.0",
71
- "declastruct": "1.3.0",
72
- "declastruct-github": "1.0.3",
71
+ "declastruct": "1.4.3",
72
+ "declastruct-github": "1.0.5",
73
73
  "depcheck": "1.4.3",
74
74
  "eslint": "8.56.0",
75
75
  "eslint-config-airbnb-typescript": "18.0.0",