feat(repo): add yaml validation pre-commit hook

This commit is contained in:
2026-02-11 18:31:19 +01:00
parent affd6b3e80
commit 8e99c5abb2
4 changed files with 9848 additions and 4950 deletions

View File

@@ -1 +1,6 @@
export { default } from "@mintel/husky-config/lint-staged";
import sharedConfig from "@mintel/husky-config/lint-staged";
export default {
...sharedConfig,
"*.{yml,yaml}": ["node scripts/lint-yaml.js", "prettier --write"],
};

View File

@@ -8,6 +8,7 @@
"dev": "pnpm -r dev",
"lint": "pnpm -r lint",
"test": "pnpm -r test",
"lint:yaml": "node scripts/lint-yaml.js",
"prepare": "husky"
},
"devDependencies": {
@@ -20,17 +21,18 @@
"@mintel/next-utils": "^1.7.15",
"@mintel/tsconfig": "^1.7.3",
"@next/eslint-plugin-next": "^16.1.6",
"eslint": "10.0.0",
"eslint-plugin-react": "^7.37.5",
"eslint-plugin-react-hooks": "^7.0.1",
"husky": "^9.1.7",
"lint-staged": "^16.2.7",
"prettier": "^3.8.1",
"typescript-eslint": "^8.54.0",
"@opentelemetry/api": "^1.9.0",
"@opentelemetry/context-async-hooks": "^2.1.0",
"@opentelemetry/core": "^2.1.0",
"@opentelemetry/sdk-trace-base": "^2.1.0",
"eslint": "10.0.0",
"eslint-plugin-react": "^7.37.5",
"eslint-plugin-react-hooks": "^7.0.1",
"husky": "^9.1.7",
"js-yaml": "^4.1.1",
"lint-staged": "^16.2.7",
"prettier": "^3.8.1",
"typescript-eslint": "^8.54.0",
"webpack": "^5.96.1"
},
"pnpm": {
@@ -41,7 +43,7 @@
}
},
"dependencies": {
"@eslint/compat": "^2.0.2",
"@directus/sdk": "21.0.0"
"@directus/sdk": "21.0.0",
"@eslint/compat": "^2.0.2"
}
}

14745
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

26
scripts/lint-yaml.js Executable file
View File

@@ -0,0 +1,26 @@
#!/usr/bin/env node
import fs from "node:fs";
import yaml from "js-yaml";
const files = process.argv.slice(2);
let hasError = false;
if (files.length === 0) {
process.exit(0);
}
for (const file of files) {
try {
const content = fs.readFileSync(file, "utf8");
yaml.load(content);
console.log(`${file} is valid`);
} catch (e) {
console.error(`${file} is invalid: ${e.message}`);
hasError = true;
}
}
if (hasError) {
process.exit(1);
}