laurenashpole / react-inner-image-zoom

A React component for zooming images.
https://laurenashpole.github.io/react-inner-image-zoom
MIT License
325 stars 36 forks source link

Empty functions produce ESLint error #101

Closed MaxdAyala closed 2 years ago

MaxdAyala commented 2 years ago

IIZ V3

A minor lint error that may occur in the future if the ESLint version is upgraded.

I came across this when trying to compile with some Typescript code, so you won't get this with current build process.

The solution is to add a comment to show that the function is supposed to be empty.

https://eslint.org/docs/rules/no-empty-function

File: InnerImageZoom.js This is with the comments added to remove the lint error.

  const initialDrag = (pageX, pageY) => {
    let initialPageX = (pageX - (window.pageXOffset + imgProps.current.bounds.left)) * -imgProps.current.ratios.x;
    let initialPageY = (pageY - (window.pageYOffset + imgProps.current.bounds.top)) * -imgProps.current.ratios.y;

    initialPageX = initialPageX + (isFullscreen ? (window.innerWidth - imgProps.current.bounds.width) / 2 : 0);
    initialPageY = initialPageY + (isFullscreen ? (window.innerHeight - imgProps.current.bounds.height) / 2 : 0);
    imgProps.current.bounds = getBounds(img.current, isFullscreen);
    imgProps.current.offsets = getOffsets(0, 0, 0, 0);

    handleDragMove({
      changedTouches: [
        {
          pageX: initialPageX,
          pageY: initialPageY
        }
      ],
      preventDefault: () => {
        // do nothing
      },
      stopPropagation: () => {
        // do nothing
      }
    });
  };
laurenashpole commented 2 years ago

This isn't an issue with the component's current build process, upgrading ESLint doesn't cause any errors, and ESLint ignores node_modules so this seems like a question of personal preference.