Giter Site home page Giter Site logo

Comments (6)

nzakas avatar nzakas commented on June 14, 2024

Thanks for the suggestion. I'm having trouble understanding the problem you're trying to solve and also how what you're proposing would help. Please describe the problem in more detail.

from eslint.

loynoir avatar loynoir commented on June 14, 2024

Given config

    linterOptions: {
      reportUnusedDisableDirectives: 'error'
    }

Below code will report error, when code does not violate xxx1 to xxx5.

/* eslint-disable xxx1 */
/* eslint-disable xxx2 */
/* eslint-disable xxx3 */
/* eslint-disable xxx4 */
/* eslint-disable xxx5 */

code

But this makes code ugly.

I prefer

    rules: {
      'xxx1': 'off',
      'xxx2': 'off',
      'xxx3': 'off',
      'xxx4': 'off',
      'xxx5': 'off',
    },
    linterOptions: {
      reportUnusedDisableDirectives: 'error'
    }

But the problem is, when code don't violate rule xxx1 to xxx5, I expect eslint to report disable rules are unused.

So, I propose a new value disable.

Before proposal, available values are 'error' | 'off' | 'warn'.

After proposal, available values are 'error' | 'off' | 'warn' | 'disable'.

Value 'xxx1': 'disable'

  • is treated as same as /* eslint-disable xxx1 */, but let code looks less ugly.

  • is better than 'xxx1': 'off', because it is reported when code does not violate rule xxx1.

    rules: {
      'xxx1': 'disable',
      'xxx2': 'disable',
      'xxx3': 'disable',
      'xxx4': 'disable',
      'xxx5': 'disable',
    },
    linterOptions: {
      reportUnusedDisableDirectives: 'error'
    }

from eslint.

nzakas avatar nzakas commented on June 14, 2024

But the problem is, when code don't violate rule xxx1 to xxx5, I expect eslint to report disable rules are unused.

Just to make sure I understand: you're saying that you want a way to say that a rule (xxx1) that is set to "off" can be removed because it would not cause any errors?

from eslint.

loynoir avatar loynoir commented on June 14, 2024

Just to make sure I understand: you're saying that you want a way to say that a rule (xxx1) that is set to "off" can be removed because it would not cause any errors?

Yes.

But also consider the fact of the plugin ecosystem

    "no-unused-vars": "off",
    "@typescript-eslint/no-unused-vars": "error"

I propose a rule (xxx1) that is set to "disable" can be removed because it would not cause any errors.

from eslint.

nzakas avatar nzakas commented on June 14, 2024

Okay, thanks for confirming.

I'm not sure what you're proposing makes sense. If the rule is set to "disable", we would actually still need to execute the rule to determine if it produced any errors, which incurs a performance cost. So it's not actually disabled at all. The only difference is that when the rule does not report errors, that itself would be reported as an unused rule.

The confusion between "disable" and "off" would also be a key concern. I understand you're proposing "disable" so that it would still be reported by "reportUnusedDisableDirectives", but I think overall this is confusing.

So, I don't think the proposal as stated is something we want to implement.

This seems targeted at an edge case, and it's pretty easy to tell if a rule would result in an error by temporarily turning it on.

At this point, we're not going to pursue implementing such a change.

from eslint.

eslint-github-bot avatar eslint-github-bot commented on June 14, 2024

It looks like there wasn't enough information for us to know how to help you, so we're closing the issue.

Thanks for your understanding.

from eslint.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.