may-not-import
Markdown for agentsRule violations. This text is what archangel docs may-not-import prints.
A file in the files of a mayNotImport rule imports a file or package on the rule’s other side, directly or, for a transitive rule, through a chain of imports.
Example
Section titled “Example”// rule({ files: 'entity', mayNotImport: { packages: ['react'] } })import { useState } from 'react';Options narrow the imports the rule checks:
names: ['useEffect']: only imports that bring in one of these names. A default import brings indefault; a namespace import, anexport *, a dynamic import and arequirebring in every name.specifier: only imports written'relative'(./or../),'parent'(../),'alias'(a tsconfig path or a packageimportsfield) or'package'.instance: 'same'or'different': only imports within one instance offiles, or between two;filesmust be a part with a capture.dependency: 'dev'or'undeclared': only imports of packages that the importing file’s nearestpackage.jsonlists only as development dependencies, or does not list.transitively: true: chains of imports count. The diagnostic shows the shortest chain, such asapp/a.tsx → lib/b.ts → server-only, and points at the chain’s first import. A chain stops at packages and at files instopAt, such as{ directive: 'use server' }. A transitive rule checks runtime imports unless it says otherwise, and takes none of the four options above.
What to do
Section titled “What to do”Remove the import, or move the code to files that may import it. For a chain, remove one of its imports.