Issue 1:
Do you want to request a feature or report a bug?

I want to report a bug

What is the current behavior?

eslint --fix trying to break my hook)

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:

I have a very simple hook:

import { useEffect, useState } from 'react'

export function useSwitchTab(trigger, tabsAmount, initialState = 0) {
const [currentTab, setTab] = useState(initialState - 1)

useEffect(() => {
setTab(currentTab + 1 >= tabsAmount ? 0 : currentTab + 1)
}, [tabsAmount, trigger])

return [currentTab, setTab]
}

If props tabsAmount or trigger will change, I need to increase currentTab value by 1. It works fine and looks ok for me, but in eslint-plugin-react-hook rule react-hooks/exhaustive-deps will warn here:

React Hook useEffect has a missing dependency: 'currentTab'. Either include it or remove the dependency array. You can also do a functional update 'setTab(c => ...)' if you only need 'c

urrentTab' in the 'setTab' call react-hooks/exhaustive-deps

And eslint --fix will break my code like this:

import { useEffect, useState } from 'react'

export function useSwitchTab(trigger, tabsAmount, initialState = 0) {
const [currentTab, setTab] = useState(initialState - 1)

useEffect(() => {
setTab(currentTab + 1 >= tabsAmount ? 0 : currentTab + 1)
}, [currentTab, tabsAmount, trigger])

return [currentTab, setTab]
}

It will add currentTab in deps for useEffect and this will create endless loop.

What is the expected behavior?

Eslint shouldn't fix this warning with --fix option, It may break the code.

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

react: 16.8.5

eslint-plugin-react-hooks: 1.6.0

Issue 2:
Do you want to request a feature or report a bug?

Bug

What is the current behavior?

Consider:

function Example({ fetchData, someArg }) {
let data = 'defaultValue';
useEffect(() => {
data = fetchData(someArg);
}, [someArg]);

return JSON.stringify(data);
}

auto fix will automatically change this to:

function Example({ fetchData, someArg }) {
let data = 'defaultValue';
useEffect(() => {
data = fetchData(someArg);
}, [someArg, fetchData]);

return JSON.stringify(data);
}

Here we have a simple data fetch component that should refetch data when parameters change, but not when the fetch function changes. Whether this is right or not, it is legitimate code, that the lint fix will cause serious problems in the code if it is used like this:

function ExmapleUsage({ fetchData }) {
return <Example fetchData={( arg ) => fetchData('Hello World', arg)} someArg="Goodbye" />
}

What is the expected behavior?

Eslint best practices say that fix rules should not change functionality of code, so that you can safely run fix and expect no functional changes to be made. This rule directly breaks that. I as a repo maintainer see the auto fix as a greater risk than the problems the lint rule prevents. If autofix was turned off, the rule would be entirely a positive.

Unfortunately, ESLint also has rejected the idea of disabling autofix for certain rules. So not following best practices is not ideal.

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

Not a React Bug but a lint rule.