Comments (6)
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.
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 rulexxx1
.
rules: {
'xxx1': 'disable',
'xxx2': 'disable',
'xxx3': 'disable',
'xxx4': 'disable',
'xxx5': 'disable',
},
linterOptions: {
reportUnusedDisableDirectives: 'error'
}
from eslint.
But the problem is, when code don't violate rule
xxx1
toxxx5
, 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.
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.
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.
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)
- Rule Change: provide an option to turn off counting of optional chaining for complexity HOT 1
- ESLint 9.2.0 reports "is defined but never used" when used with eslint-plugin-react package. HOT 2
- Rule Change: Should `no-magic-numbers` be moved out of core HOT 2
- Bug: object-shorthand auto-fix removes comments HOT 3
- Bug: Flat config ignores option dont work HOT 1
- Change Request: New eslint cli option HOT 1
- ESLint hangs indefinitely, no errors HOT 4
- Docs: no-restricted-imports HOT 5
- Change Request: `release-please` should create release only for certain tags HOT 5
- Change Request: Add feature flag capabilities to ESLint HOT 9
- Bug: can't run a single ESLint rule in CLI after migrating to flat config HOT 7
- Rule Change: Suggestion fixer for `prefer-destructuring` HOT 3
- Docs: Give example for adding meta.name and meta.version to plugin config HOT 6
- Bug: Imports fail in flat config file when ESLint installed elsewhere HOT 3
- Bug: cannot select node within init script
- Issue: pattern is being ignored
- Docs: func-style docs are confusing HOT 1
- Docs: Unexpected file matching behavior when using `ignores` without `files` HOT 12
- Bug: No files matching the pattern "linebreak-style: [2, windows]" were found. HOT 3
- Change Request: Add autofix for func-style HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eslint.