question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Creating and extending custom rules in eslint.

See original GitHub issue

In 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:closed
  • Created 6 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
pmcelhaneycommented, Jan 16, 2018

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.

2reactions
ilyavolodincommented, Jan 16, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found