@@ -4,6 +4,7 @@ import postcss from "postcss"
44import selectorParser from "postcss-selector-parser"
55// eslint-disable-next-line @mysticatea/node/no-extraneous-import
66import { ScopeManager } from "eslint-scope"
7+ import { Rule } from "eslint"
78
89export { AST }
910
@@ -13,11 +14,12 @@ export type Rule = {
1314 docs : {
1415 description : string
1516 category : string
16- ruleId : string
17- ruleName : string
17+ ruleId ? : string
18+ ruleName ? : string
1819 default ?: string
1920 replacedBy ?: string [ ]
2021 url : string
22+ suggestion ?: true
2123 }
2224 deprecated ?: boolean
2325 fixable ?: "code" | "whitespace" | null
@@ -64,7 +66,7 @@ interface ParserServices {
6466 * Get the token store of the template body.
6567 * @returns The token store of template body.
6668 */
67- // getTemplateBodyTokenStore(): TokenStore
69+ getTemplateBodyTokenStore ?: ( ) => TokenStore
6870
6971 /**
7072 * Get the root document fragment.
@@ -80,13 +82,45 @@ export interface RuleContext {
8082 getFilename : ( ) => string
8183 parserServices : ParserServices
8284}
83- export type ReportDescriptor = {
84- loc ?: SourceLocation | { line : number ; column : number }
85- node ?: AST . HasLocation
86- messageId ?: string
87- message ?: string
88- data ?: { [ key : string ] : any }
85+
86+ export type ReportSuggestion = ( { messageId : string } | { desc : string } ) & {
87+ fix ?( fixer : Rule . RuleFixer ) : null | Rule . Fix | IterableIterator < Rule . Fix >
88+ }
89+ export type ReportDescriptorNodeLocation = { node : AST . HasLocation }
90+ export type ReportDescriptorSourceLocation = {
91+ loc : SourceLocation | { line : number ; column : number }
8992}
93+
94+ export type ReportDescriptorLocation =
95+ | ReportDescriptorNodeLocation
96+ | ReportDescriptorSourceLocation
97+
98+ export type ReportDescriptor = ReportDescriptorLocation &
99+ Rule . ReportDescriptorOptions &
100+ Rule . ReportDescriptorMessage & {
101+ suggest ?: ReportSuggestion [ ]
102+ }
103+
104+ type FilterPredicate = ( tokenOrComment : AST . Token ) => boolean
105+
106+ type CursorWithSkipOptions =
107+ | number
108+ | FilterPredicate
109+ | {
110+ includeComments ?: boolean
111+ filter ?: FilterPredicate
112+ skip ?: number
113+ }
114+
115+ // type CursorWithCountOptions =
116+ // | number
117+ // | FilterPredicate
118+ // | {
119+ // includeComments?: boolean
120+ // filter?: FilterPredicate
121+ // count?: number
122+ // }
123+
90124export interface SourceCode {
91125 text : string
92126 ast : AST . ESLintProgram
@@ -105,6 +139,26 @@ export interface SourceCode {
105139 getLocFromIndex ( index : number ) : LineAndColumnData
106140
107141 getIndexFromLoc ( location : LineAndColumnData ) : number
142+
143+ getFirstToken (
144+ node : AST . Node ,
145+ options ?: CursorWithSkipOptions ,
146+ ) : AST . Token | null
147+ }
148+ export interface TokenStore {
149+ getFirstToken (
150+ node : AST . Node ,
151+ options ?: CursorWithSkipOptions ,
152+ ) : AST . Token | null
153+ getLastToken (
154+ node : AST . Node ,
155+ options ?: CursorWithSkipOptions ,
156+ ) : AST . Token | null
157+ getTokens (
158+ node : AST . Node ,
159+ beforeCount ?: number ,
160+ afterCount ?: number ,
161+ ) : AST . Token [ ]
108162}
109163type HasPostCSSSource = {
110164 source : postcss . NodeSource
0 commit comments