devex: make it impossible to commit eslint errors

This commit is contained in:
KernelDeimos
2025-09-24 17:41:48 -04:00
parent fe1d78d5bf
commit fa436a7775
4 changed files with 59 additions and 3 deletions
+1
View File
@@ -0,0 +1 @@
node tools/validate-eslint.js
+18 -1
View File
@@ -39,6 +39,7 @@
"globals": "^15.0.0",
"html-entities": "^2.3.3",
"html-webpack-plugin": "^5.6.0",
"husky": "^9.1.7",
"license-check-and-add": "^4.0.5",
"mocha": "^10.6.0",
"nodemon": "^3.1.0",
@@ -12159,6 +12160,22 @@
"ms": "^2.0.0"
}
},
"node_modules/husky": {
"version": "9.1.7",
"resolved": "https://registry.npmjs.org/husky/-/husky-9.1.7.tgz",
"integrity": "sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==",
"dev": true,
"license": "MIT",
"bin": {
"husky": "bin.js"
},
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/typicode"
}
},
"node_modules/ico-endec": {
"version": "0.1.6",
"resolved": "https://registry.npmjs.org/ico-endec/-/ico-endec-0.1.6.tgz",
@@ -20377,7 +20394,7 @@
},
"src/puter-js": {
"name": "@heyputer/puter.js",
"version": "2.0.12",
"version": "2.0.13",
"license": "Apache-2.0",
"dependencies": {
"@heyputer/kv.js": "^0.1.92",
+4 -2
View File
@@ -21,6 +21,7 @@
"globals": "^15.0.0",
"html-entities": "^2.3.3",
"html-webpack-plugin": "^5.6.0",
"husky": "^9.1.7",
"license-check-and-add": "^4.0.5",
"mocha": "^10.6.0",
"nodemon": "^3.1.0",
@@ -33,7 +34,8 @@
"start=gui": "nodemon --exec \"node dev-server.js\" ",
"start": "node ./tools/run-selfhosted.js",
"build": "cd src/gui; node ./build.js",
"check-translations": "node tools/check-translations.js"
"check-translations": "node tools/check-translations.js",
"prepare": "husky"
},
"workspaces": [
"src/*",
@@ -70,4 +72,4 @@
"engines": {
"node": ">=20.0.0"
}
}
}
+36
View File
@@ -0,0 +1,36 @@
// This script does not validate that eslint rules are followed; it only
// ensures that the eslint configuration is valid. When there are errors
// present in the eslint configuration, vscode pretends everything is
// fine and that there are no linter errors in any files.
import { ESLint } from 'eslint';
async function validateConfig() {
let exitWithError = false;
try {
const eslint = new ESLint();
await eslint.lintText('', { filePath: 'src/gui/**/*.js' });
} catch (error) {
console.error('❌ ESLint configuration error (general):', error.message);
exitWithError = true;
}
try {
const eslint = new ESLint();
await eslint.lintText('', { filePath: 'src/backend/**/*.js' });
} catch (error) {
console.error('❌ ESLint configuration error (backend):', error.message);
exitWithError = true;
}
if ( exitWithError ) {
console.log('\x1B[36;1mYou should edit eslint.config.js to resolve this issue.\x1B[0m');
console.log('\x1B[31;1mIf this is an emergency, use `git commit --no-verify`.\x1B[0m');
process.exit(1);
}
console.log('✅ ESLint configuration is valid');
}
validateConfig();