-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
Once the rules start to pile up, it's easier to keep them in separate files. Currently I have this in index.js
:
const fs = require("node:fs");
const path = require("node:path");
const ruleFiles = fs
.readdirSync(__dirname)
.filter((file) => !file.endsWith("test.js") && !file.endsWith("index.js"));
const rules = Object.fromEntries(
ruleFiles.map((file) => [
path.basename(file, ".js"),
require("./" + file),
])
);
module.exports = rules;
It would be good to add something like it on the condition that:
eslint-local-rules.js
isn't foundeslint-local-rules/index.js
isn't foundeslint-local-rules/*.js
files exist
This follows #22 in that it reduces the amount of boilerplate code that one needs to copy-paste. For people who want custom loading logic, they can keep using the index file.
Metadata
Metadata
Assignees
Labels
No labels