typescript-eslint / typescript-eslint

:sparkles: Monorepo for all the tooling which enables ESLint to support TypeScript
https://typescript-eslint.io
Other
15.24k stars 2.73k forks source link

Docs: How to disable a rule? #9815

Closed skhaz closed 2 months ago

skhaz commented 2 months ago

Before You File a Documentation Request Please Confirm You Have Done The Following...

Suggested Changes

I went through the documentation and couldn't find how to customize the rules. I tried several alternatives but couldn't get it to work.

So here's my question: is this possible to do?

Thank you.

const { configs: eslintConfigs } = require('@eslint/js')
const { configs: tsConfigs } = require('@typescript-eslint/eslint-plugin')

module.exports = {
  ...eslintConfigs.recommended,
  ...tsConfigs.strict,
  ...tsConfigs.stylistic,
  rules: {
    '@typescript-eslint/consistent-type-definitions': 'off',
  },
}

Affected URL(s)

https://typescript-eslint.io/getting-started

bradzacher commented 2 months ago

Given the snippet you attached - looks like you need to checkout our docs again.

Like this FAQ https://typescript-eslint.io/troubleshooting/faqs/general#how-do-i-turn-on-a-typescript-eslint-rule

Also checkout eslint's docs on comfig files https://eslint.org/docs/latest/use/configure/configuration-files


Finally. We do not use issues for Q&A. https://typescript-eslint.io/contributing/issues#questions-and-support-requests

skhaz commented 2 months ago

Your docs are incomplete for CJS, look this

module.exports = {
  // ... the rest of your config ...
  rules: {
    // turns a rule on with no configuration (i.e. uses the default configuration)
    '@typescript-eslint/array-type': 'error',
    // turns on a rule with configuration
    '@typescript-eslint/no-explicit-any': ['warn', { ignoreRestArgs: true }],
  },
};

It does not sounds like will work with tseslint.

skhaz commented 2 months ago

I have just migrated to biome.

bradzacher commented 2 months ago

Your docs are incomplete for CJS

You didn't read the tab headings did you? The second tab isn't a "cjs" example - it's a legacy config example - the old config form.

If you wanted a flat config example in CJS then you of course just use module.exports = instead of export default.

If you had read the getting started guide and setup your config then the form of the config would have been clearer.

skhaz commented 2 months ago

Do not me get wrong, but your documentation is not that great.

I already migrated to biome and I recommend everyone else to do the same... Much better in many aspects.

Thank you again for your support.

skhaz commented 2 months ago

Also, I must say... ESM vs CJS is madness.

JoshuaKGoldberg commented 2 months ago

I have just migrated to biome.

Good, let them deal with you. 😜

JoshuaKGoldberg commented 2 months ago

Snark aside, here's how we see this interaction as having started:

  1. You didn't use our getting started docs or set up configs the way those docs explicitly suggest to
  2. You filed an issue asking how to do something that is explicitly documented on ESLint core (https://eslint.org/docs/latest/use/configure/configuration-files#configuring-rules) and linked to in the first line of our quickstart (https://typescript-eslint.io/getting-started/#quickstart)
  3. We pointed you to the right docs to answer your original question
  4. You posted another comment here about an unrelated topic, CJS/ESM, that is also answered in the core ESLint docs
  5. You then started telling readers to go use a different software project with similar goals
  6. You then say our docs aren't great
  7. You then gripe about CJS and ESM altogether

...what do you think our reaction to all that is going to be? Why would we want to work on docs with someone who acts as if they either haven't read them or haven't been willing to follow them?

As per the contributing guidelines that Brad sent yesterday, GitHub issues aren't an appropriate place for questions or support requests. We'd be happy to help in the appropriate channels (e.g. our Discord) if you find yourself using ESLint again and want help. But, just as a general piece of advice, have a little empathy for open source maintainers.

JoshuaKGoldberg commented 2 months ago

All that being said, we do have a lot of empathy for where you're coming from. Your situation is totally understandable and moving to Biome makes a lot of sense. There are a lot of parts of ESLint that are inherently more complicated than Biome's approach:

...it's a lot to take in! If you don't have the bandwidth to take in all those things, it's totally reasonable that writing an ESLint config would bring you pain. We get it.

So if anybody has time to work on constructive suggestions for how ESLint core and/or typescript-eslint can improve docs, please do post them on the projects' respective Discords or GitHub issue trackers (after reading the contributing guides, of course). And maybe even send some PRs. We're doing the best we can, but given how many topics there are in the ecosystem + all the other things we're working on, it's hard to get this right.