From 77c0cb50358af42c572f4093f611d5faea728267 Mon Sep 17 00:00:00 2001 From: Rob Pilling Date: Sat, 18 May 2024 10:45:22 +0100 Subject: [PATCH] .eslintrc.js: ignore generate js in modules --- .eslintrc.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 700202fb5..b9675044d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -2,7 +2,7 @@ const lintExemptions = require("./apps/lint_exemptions.js"); const fs = require("fs"); const path = require("path"); -function findGeneratedJS(root) { +function findGeneratedJS(roots) { function* listFiles(dir, allow) { for (const f of fs.readdirSync(dir)) { const filepath = path.join(dir, f); @@ -16,14 +16,10 @@ function findGeneratedJS(root) { } } - 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; - }); + return roots.flatMap(root => + [...listFiles(root, f => f.endsWith(".ts"))] + .map(f => f.replace(/\.ts$/, ".js")) + ); } module.exports = { @@ -248,5 +244,5 @@ module.exports = { rules: Object.fromEntries(rules.map(rule => [rule, "off"])), })), ], - ignorePatterns: findGeneratedJS("apps/"), + ignorePatterns: findGeneratedJS(["apps/", "modules/"]), }