@addon24/eslint-config
Version:
ESLint configuration rules for WorldOfTextcraft projects - Centralized configuration for all project types
32 lines (29 loc) • 814 B
JavaScript
export default {
meta: {
type: "problem",
docs: {
description: "Disallow relative imports with parent directory references",
category: "Best Practices",
recommended: true,
},
fixable: null,
schema: [],
messages: {
noRelativeImport: "Relative imports with parent directory references (../) are not allowed. Use absolute imports with @/ prefix instead.",
},
},
create(context) {
return {
ImportDeclaration(node) {
const source = node.source.value;
// Check if the import path contains parent directory references
if (typeof source === "string" && source.includes("../")) {
context.report({
node: node.source,
messageId: "noRelativeImport",
});
}
},
};
},
};