@konvert7/klint 0.6.0 → 0.7.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/core/runner.ts +6 -2
- package/package.json +2 -3
- package/plugins/sonar.ts +6 -8
package/core/runner.ts
CHANGED
|
@@ -15,7 +15,6 @@ import type {
|
|
|
15
15
|
function walk(dir: string): string[] {
|
|
16
16
|
const out: string[] = [];
|
|
17
17
|
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
18
|
-
if (entry.name === "node_modules") continue;
|
|
19
18
|
const full = join(dir, entry.name);
|
|
20
19
|
if (entry.isDirectory()) out.push(...walk(full));
|
|
21
20
|
else if (entry.name.endsWith(".ts")) out.push(full.replaceAll("\\", "/"));
|
|
@@ -39,6 +38,7 @@ function resolveFiles(include: string[], root: string): string[] {
|
|
|
39
38
|
function matchPattern(relPath: string, pattern: string): boolean {
|
|
40
39
|
const norm = relPath.replaceAll("\\", "/");
|
|
41
40
|
const p = pattern.replaceAll("\\", "/");
|
|
41
|
+
if (p === "." || p === "**") return true;
|
|
42
42
|
if (p.endsWith("/**")) return norm.startsWith(`${p.slice(0, -3)}/`);
|
|
43
43
|
if (p.startsWith("**/")) return norm.endsWith(p.slice(2));
|
|
44
44
|
return norm === p || norm.startsWith(`${p}/`);
|
|
@@ -92,7 +92,11 @@ export function runKlint(
|
|
|
92
92
|
...config.rules,
|
|
93
93
|
};
|
|
94
94
|
|
|
95
|
-
const allFiles =
|
|
95
|
+
const allFiles = applyPatterns(
|
|
96
|
+
resolveFiles(config.include, config.root),
|
|
97
|
+
config.include,
|
|
98
|
+
config.root
|
|
99
|
+
);
|
|
96
100
|
const fileContents = new Map(allFiles.map((f) => [f, readFileSync(f, "utf-8")]));
|
|
97
101
|
const violations: Violation[] = [];
|
|
98
102
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@konvert7/klint",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Architecture-as-Code linter for TypeScript. Enforce layer boundaries, import rules, and singleton patterns in YAML.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -39,8 +39,7 @@
|
|
|
39
39
|
"check-write": "biome check --write",
|
|
40
40
|
"knip": "knip-bun",
|
|
41
41
|
"klint": "bun cli.ts",
|
|
42
|
-
"jscpd": "jscpd --noTips
|
|
43
|
-
"jscpd:report": "jscpd --noTips",
|
|
42
|
+
"jscpd": "jscpd --noTips",
|
|
44
43
|
"schema": "bun tools/generate-schema.ts",
|
|
45
44
|
"lint-staged": "lint-staged",
|
|
46
45
|
"prepare": "bun .husky/install.mjs"
|
package/plugins/sonar.ts
CHANGED
|
@@ -17,13 +17,11 @@ export const sonarPlugin: KlintPlugin = {
|
|
|
17
17
|
"sonar/prefer-at": "error",
|
|
18
18
|
},
|
|
19
19
|
implementations: {
|
|
20
|
-
"sonar/prefer-string-replaceall":
|
|
21
|
-
"sonar/prefer-string-raw-regexp":
|
|
22
|
-
"sonar/prefer-string-raw":
|
|
23
|
-
"sonar/prefer-nullish-coalescing-assign":
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"sonar/no-single-char-class": { check: noSingleCharClass.check },
|
|
27
|
-
"sonar/prefer-at": { check: preferAt.check },
|
|
20
|
+
"sonar/prefer-string-replaceall": preferStringReplaceall,
|
|
21
|
+
"sonar/prefer-string-raw-regexp": preferStringRawRegexp,
|
|
22
|
+
"sonar/prefer-string-raw": preferStringRaw,
|
|
23
|
+
"sonar/prefer-nullish-coalescing-assign": preferNullishCoalescingAssign,
|
|
24
|
+
"sonar/no-single-char-class": noSingleCharClass,
|
|
25
|
+
"sonar/prefer-at": preferAt,
|
|
28
26
|
},
|
|
29
27
|
};
|