feat: implement native hooks runtime
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
import type { VerificationPolicy } from "pi-native-hooks/policy";
|
||||
const manifests = new Set(["package.json", "package-lock.json", "tsconfig.json"]);
|
||||
const behavior = (path: string) => /^(extensions|scripts|services|skills|config)\//.test(path) || manifests.has(path);
|
||||
const types = (path: string) => /\.tsx?$/.test(path) || manifests.has(path);
|
||||
export default { kind: "verification", id: "harness-tools-verification", project: { matches: (project) => project.packageName === "harness-tools" }, requirements: [
|
||||
{ id: "tests", command: "npm test", cwd: "project-root", affects: behavior },
|
||||
{ id: "typecheck", command: "npm run typecheck", cwd: "project-root", affects: types },
|
||||
] } satisfies VerificationPolicy;
|
||||
@@ -0,0 +1,8 @@
|
||||
import type { VerificationPolicy } from "pi-native-hooks/policy";
|
||||
const manifests = new Set(["package.json", "package-lock.json", "tsconfig.json"]);
|
||||
const behavior = (path: string) => /^(extensions|src|tests|examples|skills)\//.test(path) || manifests.has(path);
|
||||
const types = (path: string) => /\.tsx?$/.test(path) || manifests.has(path);
|
||||
export default { kind: "verification", id: "pi-native-hooks-verification", project: { matches: (project) => project.packageName === "pi-native-hooks" }, requirements: [
|
||||
{ id: "tests", command: "npm test", cwd: "project-root", affects: behavior },
|
||||
{ id: "typecheck", command: "npm run typecheck", cwd: "project-root", affects: types },
|
||||
] } satisfies VerificationPolicy;
|
||||
@@ -0,0 +1,7 @@
|
||||
import type { DiagnosticPolicy } from "pi-native-hooks/policy";
|
||||
const ruleIds = new Set(["typescript-no-dynamic-import-ts", "typescript-no-dynamic-import-tsx"]);
|
||||
export default {
|
||||
kind: "diagnostic", id: "typescript-no-dynamic-import", analyzerKeys: ["ast-grep:personal"],
|
||||
appliesTo: (_project, paths) => paths.some((path) => /\.tsx?$/.test(path)),
|
||||
evaluate: (analysis) => (analysis.get("ast-grep:personal")?.findings ?? []).filter((finding) => ruleIds.has(finding.ruleId)).map((finding) => ({ policyId: "typescript-no-dynamic-import", ruleId: finding.ruleId, path: finding.path, line: finding.range.start.line, column: finding.range.start.column, message: finding.message, guidance: "Prefer a static import unless lazy loading, code splitting, an optional dependency, or runtime module selection is intentional.", exception: `Use ast-grep-ignore: ${finding.ruleId} -- <short rationale> for an intentional dynamic import.`, matchedTextHash: finding.matchedTextHash })),
|
||||
} satisfies DiagnosticPolicy;
|
||||
@@ -0,0 +1,7 @@
|
||||
import type { DiagnosticPolicy } from "pi-native-hooks/policy";
|
||||
const ruleIds = new Set(["typescript-no-non-null-assertion-ts", "typescript-no-non-null-assertion-tsx"]);
|
||||
export default {
|
||||
kind: "diagnostic", id: "typescript-no-non-null-assertion", analyzerKeys: ["ast-grep:personal"],
|
||||
appliesTo: (_project, paths) => paths.some((path) => /\.tsx?$/.test(path)),
|
||||
evaluate: (analysis) => (analysis.get("ast-grep:personal")?.findings ?? []).filter((finding) => ruleIds.has(finding.ruleId)).map((finding) => ({ policyId: "typescript-no-non-null-assertion", ruleId: finding.ruleId, path: finding.path, line: finding.range.start.line, column: finding.range.start.column, message: finding.message, guidance: "Prefer a guard, refinement, assertion function, or corrected type.", exception: `Use ast-grep-ignore: ${finding.ruleId} -- <short rationale> when the invariant is intentional.`, matchedTextHash: finding.matchedTextHash })),
|
||||
} satisfies DiagnosticPolicy;
|
||||
Reference in New Issue
Block a user