@feature-driven/eslint-plugin
Version:
📓 Lint feature-driven rules in full power
71 lines (63 loc) • 2.21 kB
JavaScript
const defaults = require("json-schema-defaults");
const { docs } = require("../../utils");
// FIXME: simplify regexps!!!
const APFS = "(app|pages|features|shared)";
/** @type {import("json-schema").JSONSchema4[]} */
const schema = [
{
type: "object",
description:
"Restrict allowed-list of project abstractions in src (app/features/pages/shared)",
properties: {
include: {
type: "array",
default: [
// src/{APFS}
`.*src\/${APFS}\/.*`, // eslint-disable-line prettier/prettier, no-useless-escape
// root files/dirs (without src)
"^((?!src).)*$",
// src/{files}
".*src\/[\\w.-]*\\w*$", // eslint-disable-line prettier/prettier, no-useless-escape
],
description: "Allowable paths patterns",
},
exclude: {
type: "array",
default: [
// {APFS}**{APFS} (repeated)
`.*${APFS}\/.*${APFS}\/.*`, // eslint-disable-line prettier/prettier, no-useless-escape
// root/{APFS} (outside of src)
`^((?!src).)*${APFS}.*$`,
],
description: "Prohibited paths patterns",
},
},
additionalProperties: false,
},
];
const MESSAGES = {
INVALID: "INVALID",
};
/** @type {import("eslint").Rule.RuleMetaData} */
const meta = {
type: "suggestion",
docs: {
description:
"Restrict allowed-list of project abstractions in src (app/features/pages/shared)",
recommended: true,
url: docs.getRuleUrl(__dirname),
},
schema,
messages: {
// eslint-disable-next-line max-len, prettier/prettier
[MESSAGES.INVALID]: "This path is prohibited for using in project. Consider about restructuring / renaming.",
},
};
/** @type {import("./types").Options} */
const __default = defaults(schema[0]);
module.exports = {
MESSAGES,
meta,
schema,
__default,
};