declapract-typescript-ehmpathy 0.47.37 → 0.47.38

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.
@@ -2,7 +2,10 @@ import type { FileCheckFunction, FileFixFunction } from 'declapract';
2
2
  import { dedupe } from 'domain-objects';
3
3
  import expect from 'expect';
4
4
 
5
- const expectedIgnores = [
5
+ /**
6
+ * ignores that can be sorted alphabetically (no order dependencies)
7
+ */
8
+ const ignoresSortable = [
6
9
  '*.log',
7
10
  '*.tsbuildinfo',
8
11
  '.artifact', // deployment artifacts from `simple-artifact-builder` are produced here
@@ -17,15 +20,38 @@ const expectedIgnores = [
17
20
  '*.bak.*', // backup files
18
21
  'coverage',
19
22
  'dist',
20
- 'node_modules',
21
23
  ].sort();
22
24
 
25
+ /**
26
+ * ignores that must appear in a specific order (negations must follow their targets)
27
+ *
28
+ * note
29
+ * - node_modules under .test* dirs are test fixtures (cloned repos via genTempDir)
30
+ * - gitignore negation requires the negated pattern to come after the original
31
+ */
32
+ const ignoresOrdered = [
33
+ 'node_modules',
34
+ '!.test*/**/node_modules',
35
+ '!.test*/**/node_modules/**',
36
+ ];
37
+
23
38
  const defineExpectedContents = (contents: string | null): string => {
24
- const ignoresAlreadyDefined = contents ? contents.split('\n') : [];
25
- const finalLines = dedupe([...ignoresAlreadyDefined, ...expectedIgnores])
26
- .sort() // sorted
27
- .filter((line) => !!line); // without empty lines
28
- return [...finalLines.sort(), ''].join('\n');
39
+ // parse ignores from file
40
+ const ignoresFromFile = contents ? contents.split('\n') : [];
41
+
42
+ // separate into sortable vs ordered
43
+ const orderedPatterns = new Set(ignoresOrdered);
44
+ const ignoresFromFileSortable = ignoresFromFile.filter(
45
+ (line) => !!line && !orderedPatterns.has(line),
46
+ );
47
+
48
+ // combine and sort the sortable ignores
49
+ const sortedIgnores = dedupe([...ignoresFromFileSortable, ...ignoresSortable])
50
+ .sort()
51
+ .filter((line) => !!line);
52
+
53
+ // append ordered ignores at the end (order preserved)
54
+ return [...sortedIgnores, ...ignoresOrdered, ''].join('\n');
29
55
  };
30
56
 
31
57
  export const check: FileCheckFunction = (contents) => {
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.47.37",
5
+ "version": "0.47.38",
6
6
  "license": "MIT",
7
7
  "main": "src/index.js",
8
8
  "repository": "ehmpathy/declapract-typescript-ehmpathy",