简体   繁体   中英

Eslint warrnings dont allow me to push to repo

I have two problems:

1) i can not push to our team repo since I have warrnings in my code and eslint react when I try to push.

2) That i actally get these warrnings in my local enviorment which noone else in the team does.

The thing is that I am the only one in the team that is getting the erros when trying to push.

What I have done:

installed a older version of eslint (5.16.0) -- nothing changed.

Tried to modify the warrnings in code:

a warrning regarding code that is not used:

const App: React.FC = () => {
  {
    const [view, setView] = useState('SignUp') // error here saying view is declared but not used.

    /*
    const VIEW_STATES: {[key: string]: string}  = {
      SignUp: <SignUp />,
      Success: <SuccessView />,
      Error: <ErrorView />,
    }
*/
    return (
      <>
        <Header />
        <main className="opt-main opt--bg-sm">
          <div className="-container">
            <div className="-row">
              <div className="-offset-sm-2 -col-sm-8 -offset-md-3 -col-md-6">
                <div className="opt--container">
                  <SignUp />
                </div>
              </div>
            </div>
          </div>
        </main>
        <Footer />
      </>
    )
  }
}

When removing the above unused code then I get:

"Nested block is redundant"...

Again this is only happening on my pc. Colleagues do not have that problem and Im stuck right now and can not push my changes.

also tried:

{
  "extends": "react-app",
  "rules": {
    "Handling warnings": {
      "quiet": true,
      "max-warnings": -10
    }
  }
}

What can I do?

view is declared but not used

That seems to be true: you should either use it, or remove it, that's the right way to go. You did mentioned you tried that, and then hit:

"Nested block is redundant"

This is due to an extra outer pair of { } braces. The end of your first line contains a () => { , but then the next line also starts with { , unnecessarily. Remove the extra { and final } , and it should work ok.

您可以使用以下注释在一行上禁用eslint规则:

const mycode = {..} // eslint-disble line

After a few hours on this and after posting a noticed that someone had installed husky in our enviorment.

Since eslint was showing the error i thought it was the problem.

Uninstalled husky and all the problems vent with it.

Would remove the question if could since it is missleading in this case. Hopefully someone might stubble upon this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM