kentcdodds / eslint-config-kentcdodds

ESLint configuration for projects that I do... Feel free to use this!
http://eslint.org/docs/user-guide/configuring#extending-configuration-files
MIT License
340 stars 65 forks source link

Import @typescript-eslint rules in ts files #100

Closed silviuaavram closed 3 years ago

silviuaavram commented 3 years ago

Hi! I am recently trying to move Downshift to Typescript. For this migration I also want to use the typescript rules defined here. However I can't figure out how to do so.

My .eslintrc.js looks like this, although I will probably revert and keep it in package.json.

module.exports = {
  settings: {
    'import/resolver': {
      node: {
        extensions: ['.js', '.jsx', '.ts', '.tsx'],
      },
    },
  },
  extends: require.resolve('./node_modules/kcd-scripts/eslint.js'),
  rules: {
    'react/jsx-indent': 'off',
    'react/prop-types': 'off',
    'max-lines-per-function': 'off',
    'jsx-a11y/label-has-for': 'off',
    'jsx-a11y/label-has-associated-control': 'off',
    'jsx-a11y/autocomplete-valid': 'off',
    'testing-library/prefer-user-event': 'off',
    'testing-library/no-node-access': 'off',
    'testing-library/no-container': 'off',
    'testing-library/render-result-naming-convention': 'off',
  },
  "overrides": [
    {
      files: ['cypress/**/*.js'],
      rules: {
        'testing-library/prefer-screen-queries': 'off',
        'testing-library/await-async-query': 'off'
      }
    }
  ]
}

Everything looks fine apart from the fact that the @typescript-eslint rules, defined here as overrides, are missing from my resulted config file. I don't know how to make sure they are added as well. I also tried to remove the overrides part above (thought it overrides the rest), but no.

When I use npx eslint --print-config ./.eslintrc.js I get all the rules defined in this repo, which is great, but nothing for @typescript, which is in the overrides part.

What do you think? How can I have those rules applied as well? Worth mentioning, I am importing from kcd-scripts but I am posting this question here since it's eslint config related. Thanks!

https://github.com/downshift-js/downshift/pull/1268 is the PR where I experience this problem. It's the PR I'm kicking off the TS migration for Downshift.

kentcdodds commented 3 years ago

Sorry for the trouble @silviuaavram. I can't think of anything off the top of my head and unfortunately I don't have bandwidth to look into this any further 😬

silviuaavram commented 3 years ago

@MichaelDeBoey can you think of anything? To my mind, if the typescript rules don't work for me in Downshift, how can they work anywhere else?

MichaelDeBoey commented 3 years ago

@silviuaavram I'm sorry, but I currently also don't have the bandwidth to look into the @downshift-js codebase

silviuaavram commented 3 years ago

It seems I kinda forgot to install @typescript-eslint/parser @typescript-eslint/eslint-plugin. I think we could add this information to the Readme, in the Due to this bug... section. I will create a PR if you agree.

kentcdodds commented 3 years ago

Docs updates are always welcome 😁