@@ -37,6 +37,7 @@ const store: Store = { dragging: null };
3737export class ReactSortable < T extends ItemInterface > extends Component <
3838 ReactSortableProps < T >
3939> {
40+ /* eslint-disable-next-line */
4041 static defaultProps : Partial < ReactSortableProps < any > > = {
4142 clone : ( item ) => item ,
4243 } ;
@@ -56,7 +57,7 @@ export class ReactSortable<T extends ItemInterface> extends Component<
5657
5758 props . setList ( newList , this . sortable , store ) ;
5859 invariant (
59- //@ts -ignore
60+ //@ts -expect-error: Doesn't exist. Will deprecate soon.
6061 ! props . plugins ,
6162 `
6263Plugins prop is no longer supported.
@@ -65,13 +66,13 @@ Please read the updated README.md at https://github.com/SortableJS/react-sortabl
6566 `
6667 ) ;
6768 }
68- componentDidMount ( ) {
69+ componentDidMount ( ) : void {
6970 if ( this . ref . current === null ) return ;
7071 const newOptions = this . makeOptions ( ) ;
7172 Sortable . create ( this . ref . current , newOptions ) ;
7273 }
7374
74- render ( ) {
75+ render ( ) : JSX . Element {
7576 const { tag, style, className, id } = this . props ;
7677 const classicProps = { style, className, id } ;
7778
@@ -94,17 +95,20 @@ Please read the updated README.md at https://github.com/SortableJS/react-sortabl
9495 dataIdAttr,
9596 selectedClass = "sortable-selected" ,
9697 chosenClass = "sortable-chosen" ,
98+ /* eslint-disable */
9799 dragClass = "sortable-drag" ,
98100 fallbackClass = "sortable-falback" ,
99101 ghostClass = "sortable-ghost" ,
100102 swapClass = "sortable-swap-highlight" ,
103+ /* eslint-enable */
101104 filter = "sortable-filter" ,
102105 list,
103106 } = this . props ;
104107
105108 // if no children, don't do anything.
106109 if ( ! children || children == null ) return null ;
107110 const dataid = dataIdAttr || "data-id" ;
111+ /* eslint-disable-next-line */
108112 return Children . map ( children as ReactElement < any > [ ] , ( child , index ) => {
109113 const item = list [ index ] ;
110114 const { className : prevClassName } = child . props ;
@@ -137,7 +141,7 @@ Please read the updated README.md at https://github.com/SortableJS/react-sortabl
137141 if ( el === null ) return null ;
138142 const key = Object . keys ( el ) . find ( ( k ) => k . includes ( "Sortable" ) ) ;
139143 if ( ! key ) return null ;
140- //@ts -ignore - I know what I'm doing .
144+ //@ts -expect-error: fix me .
141145 return el [ key ] as Sortable ;
142146 }
143147
@@ -186,36 +190,39 @@ Please read the updated README.md at https://github.com/SortableJS/react-sortabl
186190 }
187191
188192 /** Prepares a method that will be used in the sortable options to call an `on[Handler]` prop & an `on[Handler]` ReactSortable method. */
189- prepareOnHandlerPropAndDOM ( evtName : HandledMethodNames ) {
190- return ( evt : SortableEvent ) => {
193+ prepareOnHandlerPropAndDOM (
194+ evtName : HandledMethodNames
195+ ) : ( evt : SortableEvent ) => void {
196+ return ( evt ) => {
191197 // call the component prop
192198 this . callOnHandlerProp ( evt , evtName ) ;
193199 // calls state change
194- //@ts -ignore - until @types multidrag item is in
200+ //@ts -expect-error: until @types multidrag item is in
195201 this [ evtName ] ( evt ) ;
196202 } ;
197203 }
198204
199205 /** Prepares a method that will be used in the sortable options to call an `on[Handler]` prop */
200206 prepareOnHandlerProp (
201207 evtName : Exclude < AllMethodsExceptMove , HandledMethodNames >
202- ) {
203- return ( evt : SortableEvent ) => {
208+ ) : ( evt : SortableEvent ) => void {
209+ return ( evt ) => {
204210 // call the component prop
205211 this . callOnHandlerProp ( evt , evtName ) ;
206212 } ;
207213 }
208214
209215 /** Calls the `props.on[Handler]` function */
210- callOnHandlerProp ( evt : SortableEvent , evtName : AllMethodsExceptMove ) {
216+ callOnHandlerProp ( evt : SortableEvent , evtName : AllMethodsExceptMove ) : void {
211217 const propEvent = this . props [ evtName ] ;
212218 if ( propEvent ) propEvent ( evt , this . sortable , store ) ;
213219 }
214220
215221 // SORTABLE DOM HANDLING
216222
217- onAdd ( evt : MultiDragEvent ) {
223+ onAdd ( evt : MultiDragEvent ) : void {
218224 const { list, setList, clone } = this . props ;
225+ /* eslint-disable-next-line */
219226 const otherList = [ ...store . dragging ! . props . list ] ;
220227 const customs = createCustoms ( evt , otherList ) ;
221228 removeNodes ( customs ) ;
@@ -226,7 +233,7 @@ Please read the updated README.md at https://github.com/SortableJS/react-sortabl
226233 setList ( newList , this . sortable , store ) ;
227234 }
228235
229- onRemove ( evt : MultiDragEvent ) {
236+ onRemove ( evt : MultiDragEvent ) : void {
230237 const { list, setList } = this . props ;
231238 const mode = getMode ( evt ) ;
232239 const customs = createCustoms ( evt , list ) ;
@@ -248,7 +255,7 @@ Please read the updated README.md at https://github.com/SortableJS/react-sortabl
248255 } ) ) ;
249256 break ;
250257 case "normal" :
251- customClones = customs . map ( ( item , index ) => ( {
258+ customClones = customs . map ( ( item ) => ( {
252259 ...item ,
253260 element : evt . clone ,
254261 } ) ) ;
@@ -266,6 +273,7 @@ Please read the updated README.md at https://github.com/SortableJS/react-sortabl
266273 // replace selected items with cloned items
267274 customs . forEach ( ( curr ) => {
268275 const index = curr . oldIndex ;
276+ /* eslint-disable-next-line */
269277 const newItem = this . props . clone ! ( curr . item , evt ) ;
270278 newList . splice ( index , 1 , newItem ) ;
271279 } ) ;
@@ -276,7 +284,7 @@ Please read the updated README.md at https://github.com/SortableJS/react-sortabl
276284 setList ( newList , this . sortable , store ) ;
277285 }
278286
279- onUpdate ( evt : MultiDragEvent ) {
287+ onUpdate ( evt : MultiDragEvent ) : void {
280288 const { list, setList } = this . props ;
281289 const customs = createCustoms ( evt , list ) ;
282290 removeNodes ( customs ) ;
@@ -285,15 +293,15 @@ Please read the updated README.md at https://github.com/SortableJS/react-sortabl
285293 return setList ( newList , this . sortable , store ) ;
286294 }
287295
288- onStart ( evt : SortableEvent ) {
296+ onStart ( ) : void {
289297 store . dragging = this ;
290298 }
291299
292- onEnd ( evt : SortableEvent ) {
300+ onEnd ( ) : void {
293301 store . dragging = null ;
294302 }
295303
296- onChoose ( evt : SortableEvent ) {
304+ onChoose ( evt : SortableEvent ) : void {
297305 const { list, setList } = this . props ;
298306 const newList = list . map ( ( item , index ) => {
299307 if ( index === evt . oldIndex ) {
@@ -307,7 +315,7 @@ Please read the updated README.md at https://github.com/SortableJS/react-sortabl
307315 setList ( newList , this . sortable , store ) ;
308316 }
309317
310- onUnchoose ( evt : SortableEvent ) {
318+ onUnchoose ( evt : SortableEvent ) : void {
311319 const { list, setList } = this . props ;
312320 const newList = list . map ( ( item , index ) => {
313321 if ( index === evt . oldIndex ) {
@@ -321,12 +329,12 @@ Please read the updated README.md at https://github.com/SortableJS/react-sortabl
321329 setList ( newList , this . sortable , store ) ;
322330 }
323331
324- onSpill ( evt : SortableEvent ) {
332+ onSpill ( evt : SortableEvent ) : void {
325333 const { removeOnSpill, revertOnSpill } = this . props ;
326334 if ( removeOnSpill && ! revertOnSpill ) removeNode ( evt . item ) ;
327335 }
328336
329- onSelect ( evt : MultiDragEvent ) {
337+ onSelect ( evt : MultiDragEvent ) : void {
330338 const { list, setList } = this . props ;
331339 const newList = list . map ( ( item ) => ( { ...item , selected : false } ) ) ;
332340 evt . newIndicies . forEach ( ( curr ) => {
@@ -343,7 +351,7 @@ Please read the updated README.md at https://github.com/SortableJS/react-sortabl
343351 setList ( newList , this . sortable , store ) ;
344352 }
345353
346- onDeselect ( evt : MultiDragEvent ) {
354+ onDeselect ( evt : MultiDragEvent ) : void {
347355 const { list, setList } = this . props ;
348356 const newList = list . map ( ( item ) => ( { ...item , selected : false } ) ) ;
349357 evt . newIndicies . forEach ( ( curr ) => {
0 commit comments