eslint: add github/array-foreach rule

This commit is contained in:
undefined committed 2023-10-20 20:59:48 +08:00
1 parent 9901ffa62d
commit 335a272db4
21 files changed
+59 -51

No files matched your search

+3 -5
View File
@@ -36,9 +36,7 @@ export function folderSize(folderPath: string) {
size += stats.size;
const files = fs.readdirSync(p);
if (Array.isArray(files)) {
files.forEach((file) => {
_next(path.join(p, file));
});
for (const file of files) _next(path.join(p, file));
}
}
}
@@ -247,9 +245,9 @@ export function CallableInstance(property = '__call__') {
else func = this.constructor.prototype[property];
const apply = function __call__(...args) { return func.apply(apply, ...args); };
Object.setPrototypeOf(apply, this.constructor.prototype);
Object.getOwnPropertyNames(func).forEach((p) => {
for (const p of Object.getOwnPropertyNames(func)) {
Object.defineProperty(apply, p, Object.getOwnPropertyDescriptor(func, p));
});
}
return apply;
}