11import { sep } from 'node:path' ;
22import { definePlugin } from '../../../dist/index.js' ;
3+ import type { Rule } from '../../../dist/index.js' ;
34
45// `loc` is required for ESLint
56const SPAN = {
@@ -14,10 +15,10 @@ const SPAN = {
1415const DIR_PATH_LEN = import . meta. dirname . length + 1 ;
1516
1617const relativePath = sep === '/'
17- ? path => path . slice ( DIR_PATH_LEN )
18- : path => path . slice ( DIR_PATH_LEN ) . replace ( / \\ / g, '/' ) ;
18+ ? ( path : string ) => path . slice ( DIR_PATH_LEN )
19+ : ( path : string ) => path . slice ( DIR_PATH_LEN ) . replace ( / \\ / g, '/' ) ;
1920
20- const createRule = {
21+ const createRule : Rule = {
2122 create ( context ) {
2223 context . report ( { message : `create body:\nthis === rule: ${ this === createRule } ` , node : SPAN } ) ;
2324
@@ -37,18 +38,19 @@ const createRule = {
3738// adds to the rule.
3839let createOnceCallCount = 0 ;
3940
40- const createOnceRule = {
41+ const createOnceRule : Rule = {
4142 createOnce ( context ) {
4243 createOnceCallCount ++ ;
4344
4445 // `fileNum` should be different for each file.
4546 // `identNum` should start at 1 for each file.
46- let fileNum = 0 , identNum ;
47+ let fileNum = 0 , identNum : number ;
4748 // Note: Files are processed in unpredictable order, so `files/1.js` may be `fileNum` 1 or 2.
4849 // Therefore, collect all visits and check them in `after` hook of the 2nd file.
49- const visits = [ ] ;
50+ const visits : { fileNum : number ; identNum : number } [ ] = [ ] ;
5051
5152 // `this` should be the rule object
53+ // oxlint-disable-next-line typescript-eslint/no-this-alias
5254 const topLevelThis = this ;
5355
5456 return {
@@ -106,7 +108,7 @@ const createOnceRule = {
106108} ;
107109
108110// Tests that `before` hook returning `false` disables visiting AST for the file.
109- const createOnceBeforeFalseRule = {
111+ const createOnceBeforeFalseRule : Rule = {
110112 createOnce ( context ) {
111113 return {
112114 before ( ) {
@@ -139,7 +141,7 @@ const createOnceBeforeFalseRule = {
139141
140142// These 3 rules test that `createOnce` without `before` and `after` hooks works correctly.
141143
142- const createOnceBeforeOnlyRule = {
144+ const createOnceBeforeOnlyRule : Rule = {
143145 createOnce ( context ) {
144146 return {
145147 before ( ) {
@@ -160,7 +162,7 @@ const createOnceBeforeOnlyRule = {
160162 } ,
161163} ;
162164
163- const createOnceAfterOnlyRule = {
165+ const createOnceAfterOnlyRule : Rule = {
164166 createOnce ( context ) {
165167 return {
166168 Identifier ( node ) {
@@ -181,7 +183,7 @@ const createOnceAfterOnlyRule = {
181183 } ,
182184} ;
183185
184- const createOnceNoHooksRule = {
186+ const createOnceNoHooksRule : Rule = {
185187 createOnce ( context ) {
186188 return {
187189 Identifier ( node ) {
0 commit comments