This rule reports a file whose CSS must come after another file’s CSS, while that file’s CSS must also come after this file, directly or through other files, and both files set the same property. A file must come after another file when it imports and uses a value, such as a component or a base style, that the other file declares. See CSS ordering.
When the order forms a cycle, Stillwind keeps one of the orders, and the build continues. The utilities that a caller passes to a component, or that a style adds to its base, can then lose to the utilities of the other file.
The rule does not report a cycle between files that set different properties,
such as mutually recursive Tree and TreeItem components that set different
properties. The order between such files does not change any value.
Reported
import { style } from "stillwind/react";
import { Button } from "./button";
export function Card(props: CardProps) {
return (
<div {...style("rounded p-4", style.forward(props))}>
<Button {...style("w-full")} />
</div>
);
}import { style } from "stillwind/react";
import { Card } from "./card";
export function Button(props: ButtonProps) {
return <Card {...style("p-2", style.forward(props))} />;
}card.tsx imports Button, and button.tsx imports Card. Both files set
padding.
How to fix
- Move the shared parts to a file that neither file imports from, so that the imports go in one direction.
- Or remove the property from the styles of one file.
- Or remove the import in one direction, for example by passing the component as a prop or a slot.
Rule settings
| Preset | Severity |
|---|---|
recommended | warn |
strict | deny |
stylistic | off |
Configure lint to change the severity or options.
The CLI and the editor report this rule only when they analyze the whole project.