File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import js from '@eslint/js' ;
22import { defineConfig } from 'eslint/config' ;
3+ import { dirname } from 'node:path' ;
4+ import { fileURLToPath } from 'node:url' ;
35import prettier from 'eslint-config-prettier' ;
46import jest from 'eslint-plugin-jest' ;
57import react from 'eslint-plugin-react' ;
68import reactHooks from 'eslint-plugin-react-hooks' ;
79import globals from 'globals' ;
810import tseslint from 'typescript-eslint' ;
911
12+ const tsconfigRootDir = dirname ( fileURLToPath ( import . meta. url ) ) ;
13+
1014export default defineConfig ( [
1115 {
1216 plugins : {
@@ -15,7 +19,7 @@ export default defineConfig([
1519 } ,
1620 {
1721 linterOptions : {
18- reportUnusedDisableDirectives : 'off ' ,
22+ reportUnusedDisableDirectives : 'warn ' ,
1923 } ,
2024 } ,
2125 {
@@ -26,10 +30,10 @@ export default defineConfig([
2630 'lib/' ,
2731 'dist/' ,
2832 'docs-dist/' ,
33+ '.docs-dist/' ,
2934 '.dumi/' ,
3035 '.doc/' ,
3136 '.vercel/' ,
32- 'src/index.d.ts' ,
3337 ] ,
3438 } ,
3539 {
@@ -88,7 +92,7 @@ export default defineConfig([
8892 languageOptions : {
8993 parserOptions : {
9094 projectService : true ,
91- tsconfigRootDir : import . meta . dirname ,
95+ tsconfigRootDir,
9296 } ,
9397 } ,
9498 } ,
Original file line number Diff line number Diff line change @@ -65,11 +65,13 @@ const Demo = () => {
6565 const measureRef = React . useRef < HTMLDivElement > ( null ) ;
6666
6767 useLayoutEffect ( ( ) => {
68- setInputWidth ( measureRef . current . offsetWidth ) ;
68+ if ( measureRef . current ) {
69+ setInputWidth ( measureRef . current . offsetWidth ) ;
70+ }
6971 } , [ inputValue ] ) ;
7072
7173 React . useEffect ( ( ) => {
72- inputRef . current . focus ( ) ;
74+ inputRef . current ? .focus ( ) ;
7375 } , [ ] ) ;
7476
7577 return (
Original file line number Diff line number Diff line change 6363 "dumi" : " ^2.4.38" ,
6464 "eslint" : " ^9.39.4" ,
6565 "eslint-config-prettier" : " ^10.1.8" ,
66- "eslint-plugin-import" : " ^2.32.0" ,
6766 "eslint-plugin-jest" : " ^29.15.4" ,
68- "eslint-plugin-jsx-a11y" : " ^6.10.2" ,
6967 "eslint-plugin-react" : " ^7.37.5" ,
7068 "eslint-plugin-react-hooks" : " ^7.1.1" ,
7169 "father" : " ^4.6.24" ,
Original file line number Diff line number Diff line change @@ -124,7 +124,24 @@ class NodeCollection {
124124 }
125125}
126126
127- export function mount ( element : React . ReactElement ) : any {
127+ interface MountWrapper extends ReturnType < typeof render > {
128+ find : ( selector : string ) => NodeCollection ;
129+ findItems : ( ) => NodeCollection ;
130+ findRest : ( ) => NodeCollection ;
131+ findPrefix : ( ) => NodeCollection ;
132+ findSuffix : ( ) => NodeCollection ;
133+ triggerResize : ( clientWidth : number ) => Promise < MountWrapper > ;
134+ triggerItemResize : (
135+ index : number ,
136+ offsetWidth : number ,
137+ ) => Promise < MountWrapper > ;
138+ initSize : ( width : number , itemWidth : number ) => Promise < MountWrapper > ;
139+ setProps : ( props : Record < string , any > ) => MountWrapper ;
140+ update : ( ) => MountWrapper ;
141+ render : ( ) => ChildNode | null ;
142+ }
143+
144+ export function mount ( element : React . ReactElement ) : MountWrapper {
128145 let mergedElement = element ;
129146 const result = render ( mergedElement ) ;
130147
@@ -154,7 +171,7 @@ export function mount(element: React.ReactElement): any {
154171 await flushResize ( ) ;
155172 } ;
156173
157- const wrapper = {
174+ const wrapper : MountWrapper = {
158175 ...result ,
159176 find ( selector : string ) {
160177 if ( selector === 'ResizeObserver' ) {
You can’t perform that action at this time.
0 commit comments