eslint-plugin-esm
Version:
ESLint plugin for linting ESM (import/export syntax)
14 lines (10 loc) • 439 B
text/typescript
import { create, createRule, getRuleName } from "../common.ts";
const depth = 3;
export const noRelativeParentImports = createRule({
name: getRuleName(import.meta.url),
message: "Disallow importing module from a relative parent path too deeply.",
create: (context) => create(context, checkDepth),
});
function checkDepth(_filename: string, source: string) {
return new RegExp(`^(\\.\\./){${depth.toString()},}`).test(source);
}