Comments (9)
Thanks, that makes sense.
It's a little too bad though that this is available as a CLI flag only. Unless I'm wrong there would be no way to specify --report-unused-disable-directives
in the configuration file instead.
from eslint-plugin-eslint-comments.
OK it makes sense that combining processors is going to be hard or impossible.
It seems to me the correct solution might be to allow specifying this CLI flag in shareable configs as well.
In the meantime I have raised an issue for Atom users to fix my immediate problem (which basically is: having my IDE notify me as I code that I'm using a unused eslint-disable
comment).
from eslint-plugin-eslint-comments.
I published v3.0.0-beta.0. I used a hack to make the eslint-comments/no-unused-disable
rule aliving on ESLint v5.0.0. The new hack uses only public APIs, but it needs an assumption.
- The rule is loaded from
CLIEngine
class.
I believe that it can cover most usecases.
I'd like to see the response while 3.0.0-beta
then I will publish it as stable after ESLint 5.0.0 stable is released.
from eslint-plugin-eslint-comments.
Thank you for the report.
Yeah, we can't use eslint-comments/no-unused-disable
rule in ESLint 5.0.0. That rule will be replaced by --report-unused-disable-directives CLI option. See eslint/eslint#10140 for details.
I have to deprecate that rule in this plugin.
from eslint-plugin-eslint-comments.
You are right. It's inconvenient.
I have two other ways:
- It's inspired by eslint-plugin-vue's processor. We can know what rules are reported in post-processor, so I can re-implement
eslint-comments/no-unused-disable
rule there, as similar to vue/comment-directive rule. This way is using only public API, but it has a restriction -- ESLint enables only one post-processor for each extension (e.g..js
). This means that this plugin might be going to conflict another plugins. - I might investigate another hack, E.g., it finds
Linter
class in require.cache and patch the public APILinter.prototype.verify
with a logic which is similar to eslint-plugin-vue's processor. I'm not sure if this way can cover wide use cases.
from eslint-plugin-eslint-comments.
Is there a specific reason ESLint allows only one post-processor per file extension? Otherwise maybe this could be improved first, then this can be fixed without resorting to another hack?
I also wanted to mention that having this rule as a CLI flag instead makes it not available in some IDEs. E.g. in Atom, it does not seem to be possible to specify CLI flags to the official ESLint Atom plugin. Although it could be argued that the real fix is to improve that plugin to support CLI flags.
from eslint-plugin-eslint-comments.
Is there a specific reason ESLint allows only one post-processor per file extension? Otherwise maybe this could be improved first, then this can be fixed without resorting to another hack?
Yes, because processors are designed to extract multiple code blocks from a file. For example, .md
can have some code blocks, .html
can have some <script>
tags. So pre-processor is (content: string) => string[]
and post-processor is (messagesOfEachCode: Message[][]) => Message[]
. The types of input and output are different, so it can't compose processor functions. The original purpose of post-processors is to modify the locations of the messages in order to rollback the extraction rather than filtering messages.
I also wanted to mention that having this rule as a CLI flag instead makes it not available in some IDEs. E.g. in Atom, it does not seem to be possible to specify CLI flags to the official ESLint Atom plugin. Although it could be argued that the real fix is to improve that plugin to support CLI flags.
CLIEngine
has corresponding option reportUnusedDisableDirectives: true
. I'm not familiar with Atom, but if Atom has options like eslint.options
in vscode, we can use it.
However, we can't specify the option in shareable configs, it's inconvenient.
from eslint-plugin-eslint-comments.
This is great! Thanks for your work on this.
from eslint-plugin-eslint-comments.
Closing as I have published v3.0.0. Thank you!
from eslint-plugin-eslint-comments.
Related Issues (20)
- [require-description] Add rule to require minimum description length HOT 3
- `disable-enable-pair` option allowWholeFile should be the default HOT 8
- `require-description` shouldn't require a description for `eslint-enable` HOT 2
- Support ESLint 8.x
- Merge this with eslint-plugin-canonical HOT 2
- allow no-restricted-disable to display customize message HOT 2
- Allow requiring collapsed blocks for directive comments HOT 1
- Quickfix of `eslint-comments/no-unused-disable` should not leave empty lines HOT 3
- should not auto fix when configured to warn HOT 1
- rule should not lint itself HOT 1
- [eslint-comments/no-use]: Allow "eslint-disable" only for selected rules (feature request) HOT 5
- Invitation to move to official `eslint-community` org HOT 12
- [eslint-comments/no-use] Is this rule working? HOT 1
- doesn't work on svelte html comments with `eslint-plugin-svelte` HOT 1
- Support `eslint-plugin-vue`'s disable comments HOT 2
- `eslint-comments/require-description` should allow ignoring particular rules HOT 2
- `eslint-comments/no-unused-disable` false positive when disabling line with `eslint-comments/no-unused-disable` HOT 5
- no-restricted-disable rule isn't working with require-description rule HOT 2
- `no-unused-disable` doesn't work with flat config HOT 3
- no-unused-disable is redundant HOT 3
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-plugin-eslint-comments.