Creating and extending custom rules in eslint.
See original GitHub issueIn my code i wrote on VS Code(Containing eslint) most of the cases where a line containing a string. like the below one.
var temp = "Stackoverflow";
var other=temp+" javascript";
I need an auto-fix option in es-lint such that it adds a (a static) comment at the end of line for the lines containing string on VS Code. like this
var temp = "Stackoverflow";//Custom comment
var other=temp+" javascript";//Custom comment
Is there any way of achieving this on eslint using node or VSCode?
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
How to write a custom ESLint rule - Scott Logic Blog
I found it very helpful to use https://astexplorer.net/ while writing my linting rules. Navigate to the website, hover over the Transform option ...
Read more >Working with Rules - ESLint - Pluggable JavaScript Linter
The thing that makes ESLint different from other linters is the ability to define custom rules at runtime. This is perfect for rules...
Read more >How to Create Custom ESLint Rules in 5 Minutes
Before you decide to create your own rule, first search the rules list and any other ESLint plugins that may be available. Someone...
Read more >Creating Custom Eslint Rules - Better Programming
This article will explain how to create your own custom ESLint rules and create a script with the ESLint module that will be...
Read more >Creating a custom ESlint plugin - Medium
An ESLint rule is custom rule which is enabled for your codebase for better code quality or write something is a specific manner...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Technically, yes, you can create a custom rule with a fixer. The rule would check that every string literal appears on a line that ends in a comment, and add the comment if necessary.
https://eslint.org/docs/developer-guide/working-with-rules#applying-fixes
If you can share more information on the purpose of the custom comment, we may be able to provide better guidance.
As mentioned, technically it’s possible, but that would be improper use of the tool. ESLint isn’t meant for things like that. You might want to look into jscodeshift and similar tools.