jaredpalmer / tsdx

Zero-config CLI for TypeScript package development
https://tsdx.io
MIT License
11.24k stars 508 forks source link

How to disable `eslint-config-react-app`? #907

Closed NARUTOne closed 3 years ago

NARUTOne commented 3 years ago

Current Behavior

React Hook "useCompose" is called in function "getWidgetProps" that is neither a React function component nor a custom React Hook function.eslint(react-hooks/rules-of-hooks)

Desired Behavior

Don't tip. This is only function. The current project is a pure library of tools using Typescript

It doesn't work.

module.exports = {
  "extends": [
    // "react-app",
    "prettier/@typescript-eslint",
    "plugin:prettier/recommended"
  ],
  "settings": {
    // "react": {
    //   "version": "999.999.999"
    // }
  }
}

Suggested Solution

Who does this impact? Who is this for?

Describe alternatives you've considered

Additional context

agilgur5 commented 3 years ago

Based on the names of your functions (useCompose and getWidgetProps, it sounds like you're writing a library for React components, is that not correct? If so, I'd certainly recommend following the official hooks lint rules. getWidgetProps doesn't follow hook naming conventions, which is why you're getting the error; I'd recommend naming it appropriately.

If you really want to disable a rule for that particular function, you can use an ESLint inline ignore for that.

If you're not writing for usage in React, which isn't really clear as you didn't provide any repro, then yes you're hitting a known issue with the way the ESLint API's merging works. This would be a duplicate of #514 which is a duplicate of #498. In https://github.com/formium/tsdx/issues/498#issuecomment-583244717 I described how to disable rules using ESLint configuration, which you can similarly use for this (just different rules).

As I mentioned in https://github.com/formium/tsdx/issues/514#issuecomment-591841967, if you use package.json#eslint instead of an eslintrc, that uses a shallow merge and so your config that you've written here should work if put into package.json#eslint instead.

agilgur5 commented 3 years ago

Also, if you set react to 999.999.999 that should disable all React rules per #308 . You've commented out settings.react; you should uncomment that if you're not writing for React.