feat(repo): add yaml validation pre-commit hook
This commit is contained in:
@@ -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"],
|
||||||
|
};
|
||||||
|
|||||||
20
package.json
20
package.json
@@ -8,6 +8,7 @@
|
|||||||
"dev": "pnpm -r dev",
|
"dev": "pnpm -r dev",
|
||||||
"lint": "pnpm -r lint",
|
"lint": "pnpm -r lint",
|
||||||
"test": "pnpm -r test",
|
"test": "pnpm -r test",
|
||||||
|
"lint:yaml": "node scripts/lint-yaml.js",
|
||||||
"prepare": "husky"
|
"prepare": "husky"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -20,17 +21,18 @@
|
|||||||
"@mintel/next-utils": "^1.7.15",
|
"@mintel/next-utils": "^1.7.15",
|
||||||
"@mintel/tsconfig": "^1.7.3",
|
"@mintel/tsconfig": "^1.7.3",
|
||||||
"@next/eslint-plugin-next": "^16.1.6",
|
"@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/api": "^1.9.0",
|
||||||
"@opentelemetry/context-async-hooks": "^2.1.0",
|
"@opentelemetry/context-async-hooks": "^2.1.0",
|
||||||
"@opentelemetry/core": "^2.1.0",
|
"@opentelemetry/core": "^2.1.0",
|
||||||
"@opentelemetry/sdk-trace-base": "^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"
|
"webpack": "^5.96.1"
|
||||||
},
|
},
|
||||||
"pnpm": {
|
"pnpm": {
|
||||||
@@ -41,7 +43,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@eslint/compat": "^2.0.2",
|
"@directus/sdk": "21.0.0",
|
||||||
"@directus/sdk": "21.0.0"
|
"@eslint/compat": "^2.0.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
14423
pnpm-lock.yaml
generated
14423
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
26
scripts/lint-yaml.js
Executable file
26
scripts/lint-yaml.js
Executable 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);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user