forked from FOSS/BangleApps
eslint: list generated js files to ignore
parent
3c2f6bd0ab
commit
40c851217f
|
@ -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/"),
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue