1+ /* eslint-disable react/jsx-no-bind */
2+ /* eslint-disable react/destructuring-assignment */
3+ /* eslint-disable react/sort-comp */
4+
15// For Next.js 13 and react 18. Switch component for support server components later.
26"use client" ;
37
4- import { Component } from "react" ;
8+ import React , { Component , JSX } from "react" ;
59import { getFormatFeatures } from "../helpers/get-format-features.js" ;
610
711export interface IImageOptions extends React . DetailedHTMLProps < React . ImgHTMLAttributes < HTMLImageElement > , HTMLImageElement > {
@@ -14,7 +18,7 @@ export interface IImageOptions extends React.DetailedHTMLProps<React.ImgHTMLAttr
1418
1519export class Image < P extends IImageOptions > extends Component < P > {
1620
17- public static isShowDiagnostic : boolean = false ;
21+ public static isShowDiagnostic = false ;
1822
1923 public static controlPoints : number [ ] = [ 160 , 320 , 640 , 1280 , 1920 ] ;
2024
@@ -27,7 +31,7 @@ export class Image<P extends IImageOptions> extends Component<P> {
2731 * Example:
2832 * Image.isUseSourceUrl = process.env.NODE_ENV !== "production";
2933 */
30- public static isUseSourceUrl : boolean = false ;
34+ public static isUseSourceUrl = false ;
3135
3236 /**
3337 * Image optimizer will change origin to other domain.
@@ -47,25 +51,25 @@ export class Image<P extends IImageOptions> extends Component<P> {
4751
4852 private static isWebP : boolean | null = null ;
4953
50- public resultUrl : string = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" ;
54+ public resultUrl = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" ;
5155
52- public resizeCheckTimeout : number = 0 ;
56+ public resizeCheckTimeout = 0 ;
5357
5458 public thisComponent : HTMLImageElement | null = null ;
5559
56- protected sourceUrl : string = "" ;
60+ protected sourceUrl = "" ;
5761
5862 protected readonly extensionsRegexp : RegExp = / \. \w + $ / u;
5963
6064 protected readonly windowResizeHandler : EventListenerOrEventListenerObject ;
6165
62- protected lastOptimalSize : number = 0 ;
66+ protected lastOptimalSize = 0 ;
6367
6468 /**
6569 * Serves to prevent recursion when resizing images to determine the optimal size.
6670 * This recursion can be caught with poor layout that does not take into account the scaling of images.
6771 */
68- protected checks : number = 0 ;
72+ protected checks = 0 ;
6973
7074 public constructor ( props : P ) {
7175 super ( props ) ;
@@ -112,7 +116,7 @@ export class Image<P extends IImageOptions> extends Component<P> {
112116 ) ;
113117 }
114118
115- protected async checkImage ( isResize : boolean = false ) : Promise < void > {
119+ protected async checkImage ( isResize = false ) : Promise < void > {
116120 if ( this . checks > 1 ) {
117121 return ;
118122 }
@@ -151,7 +155,7 @@ export class Image<P extends IImageOptions> extends Component<P> {
151155 }
152156
153157 protected getContainerSize ( ) : number {
154- let containerSize : number = 0 ;
158+ let containerSize = 0 ;
155159
156160 let element : HTMLElement | null = this . thisComponent ;
157161
@@ -207,6 +211,7 @@ export class Image<P extends IImageOptions> extends Component<P> {
207211 }
208212
209213 protected extractImageFormat ( path : string ) : string {
214+ // eslint-disable-next-line no-useless-assignment
210215 let format = "" ;
211216
212217 const match : RegExpExecArray | null = this . extensionsRegexp . exec ( path ) ;
@@ -267,6 +272,7 @@ export class Image<P extends IImageOptions> extends Component<P> {
267272 }
268273 }
269274
275+ // eslint-disable-next-line class-methods-use-this
270276 protected async initImageFormats ( ) : Promise < void > {
271277 const format = await getFormatFeatures ( ) ;
272278
0 commit comments