|
1 |
| -import type { Node, Container } from "postcss"; |
2 |
| -import type { BaseNode } from "./base"; |
| 1 | +import type { Node, ChildProps, Container } from "postcss"; |
| 2 | +import type { Locations } from "./common"; |
| 3 | + |
| 4 | +type ESLintCompatiblePostCSSContainer< |
| 5 | + PostCSSNode extends Node, |
| 6 | + Child extends Node |
| 7 | +> = { |
| 8 | + each( |
| 9 | + callback: ( |
| 10 | + node: ESLintCompatiblePostCSSNode<Child>, |
| 11 | + index: number |
| 12 | + ) => false | void |
| 13 | + ): false | undefined; |
| 14 | + every( |
| 15 | + condition: ( |
| 16 | + node: ESLintCompatiblePostCSSNode<Child>, |
| 17 | + index: number, |
| 18 | + nodes: ESLintCompatiblePostCSSNode<Child>[] |
| 19 | + ) => boolean |
| 20 | + ): boolean; |
| 21 | + get first(): ESLintCompatiblePostCSSNode<Child> | undefined; |
| 22 | + index(child: ESLintCompatiblePostCSSNode<Child> | number): number; |
| 23 | + insertAfter( |
| 24 | + oldNode: ESLintCompatiblePostCSSNode<Child> | number, |
| 25 | + newNode: |
| 26 | + | ESLintCompatiblePostCSSNode<Child> |
| 27 | + | ChildProps |
| 28 | + | string |
| 29 | + | ESLintCompatiblePostCSSNode<Child>[] |
| 30 | + | ChildProps[] |
| 31 | + | string[] |
| 32 | + ): ESLintCompatiblePostCSSNode<PostCSSNode>; |
| 33 | + insertBefore( |
| 34 | + oldNode: ESLintCompatiblePostCSSNode<Child> | number, |
| 35 | + newNode: |
| 36 | + | ESLintCompatiblePostCSSNode<Child> |
| 37 | + | ChildProps |
| 38 | + | string |
| 39 | + | ESLintCompatiblePostCSSNode<Child>[] |
| 40 | + | ChildProps[] |
| 41 | + | string[] |
| 42 | + ): ESLintCompatiblePostCSSNode<PostCSSNode>; |
| 43 | + get last(): ESLintCompatiblePostCSSNode<Child> | undefined; |
| 44 | + nodes: ESLintCompatiblePostCSSNode<Child>[]; |
| 45 | + push( |
| 46 | + child: ESLintCompatiblePostCSSNode<Child> |
| 47 | + ): ESLintCompatiblePostCSSNode<PostCSSNode>; |
| 48 | + removeChild( |
| 49 | + child: ESLintCompatiblePostCSSNode<Child> | number |
| 50 | + ): ESLintCompatiblePostCSSNode<PostCSSNode>; |
| 51 | + some( |
| 52 | + condition: ( |
| 53 | + node: ESLintCompatiblePostCSSNode<Child>, |
| 54 | + index: number, |
| 55 | + nodes: ESLintCompatiblePostCSSNode<Child>[] |
| 56 | + ) => boolean |
| 57 | + ): boolean; |
| 58 | + walk( |
| 59 | + callback: ( |
| 60 | + node: ESLintCompatiblePostCSSNode<Child>, |
| 61 | + index: number |
| 62 | + ) => false | void |
| 63 | + ): false | undefined; |
| 64 | +}; |
3 | 65 |
|
4 | 66 | export type ESLintCompatiblePostCSSNode<PostCSSNode extends Node = Node> =
|
5 |
| - BaseNode & |
6 |
| - Omit<PostCSSNode, "walk"> & |
7 |
| - (PostCSSNode extends Container<infer Child> |
8 |
| - ? { |
9 |
| - walk( |
10 |
| - callback: ( |
11 |
| - node: ESLintCompatiblePostCSSNode<Child>, |
12 |
| - index: number |
13 |
| - ) => false | void |
14 |
| - ): false | undefined; |
15 |
| - } |
| 67 | + Locations & |
| 68 | + Omit< |
| 69 | + PostCSSNode, |
| 70 | + | "each" |
| 71 | + | "every" |
| 72 | + | "first" |
| 73 | + | "index" |
| 74 | + | "insertAfter" |
| 75 | + | "insertBefore" |
| 76 | + | "last" |
| 77 | + | "nodes" |
| 78 | + | "push" |
| 79 | + | "removeChild" |
| 80 | + | "some" |
| 81 | + | "type" |
| 82 | + | "walk" |
| 83 | + > & { |
| 84 | + type: `SvelteStyle-${PostCSSNode["type"]}`; |
| 85 | + } & (PostCSSNode extends Container<infer Child> |
| 86 | + ? ESLintCompatiblePostCSSContainer<PostCSSNode, Child> |
16 | 87 | : unknown);
|
0 commit comments