1
0
Fork 0

eslint: list generated js files to ignore

master
Rob Pilling 2024-05-05 16:51:53 +01:00
parent 3c2f6bd0ab
commit 40c851217f
1 changed files with 27 additions and 0 deletions

View File

@ -1,4 +1,30 @@
const lintExemptions = require("./lint_exemptions.js");
const fs = require("fs");
const path = require("path");
function findGeneratedJS(root) {
function* listFiles(dir, allow) {
for (const f of fs.readdirSync(dir)) {
const filepath = path.join(dir, f);
const stat = fs.statSync(filepath);
if (stat.isDirectory()) {
yield* listFiles(filepath, allow);
} else if(allow(filepath)) {
yield filepath;
}
}
}
return [...listFiles(root, f => f.endsWith(".ts"))]
.map(f => f.replace(/\.ts$/, ".js"))
.map(f => {
if (f.startsWith(root)) {
return f.substring(root.length);
}
return f;
});
}
module.exports = {
"env": {
@ -222,4 +248,5 @@ module.exports = {
rules: Object.fromEntries(rules.map(rule => [rule, "off"])),
})),
],
ignorePatterns: findGeneratedJS("apps/"),
}