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.

New Rule Request: Enforce strings in front of logged variables (string-with-logs)

See original GitHub issue

Please describe what the rule should do: The rule would force us to provide a string in front of a logged variable.

What category of rule is this? (place an “X” next to just one item)

[ ] Enforces code style [ ] Warns about a potential error [ ] Suggests an alternate way of doing something [x] Other (suggests good practice)

Provide 2-3 code examples that this rule will warn about:

//breaks rule
console.log(aVariable)
//consistent with rule
console.log("a variable", aVariable)

Why should this rule be included in ESLint (instead of a plugin)? This rule is not library specific and it is relevant for all javascript development. Logs are only useful when we know what’s being logged and where it’s coming from. Languages like Elm enforce this behavior out-of-the-box as their console.log equivalent requires a string as the first argument.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
kaicataldocommented, Jul 23, 2018

@cotterjd ESLint allows for custom rules through plugins - you don’t have to maintain a fork for this if you don’t want to!

0reactions
eslint-deprecated[bot]commented, Dec 11, 2018

Unfortunately, it looks like there wasn’t enough interest from the team or community to implement this change. While we wish we’d be able to accommodate everyone’s requests, we do need to prioritize. We’ve found that issues failing to reach accepted status after 21 days tend to never be accepted, and as such, we close those issues. This doesn’t mean the idea isn’t interesting or useful, just that it’s not something the team can commit to.

Thanks for contributing to ESLint and we appreciate your understanding.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Interpreting Log Transformations in a Linear Model
Rules for interpretation. OK, you ran a regression/fit a linear model and some of your variables are log-transformed.
Read more >
Why Logging doesn't use string interpolation - Stack Overflow
In this case an interpolated string does lose important information. The call. Log.Information("Logged in {UserId}", loggedInUserId);. Won't ...
Read more >
Interpreting Regression Coefficients for Log-Transformed ...
This newsletter focuses on how to obtain estimated parameters of interest and how to interpret the coefficients in a regression model involving log-transformed ......
Read more >
String Literal Types in TypeScript - Marius Schulz
TypeScript 1.8 introduced string literal types, which allow for describing a set of possible string values for a given variable.
Read more >
Log Transformation: Purpose and Interpretation - Medium
Log transformation is a data transformation method in which it replaces each variable x with a log(x). The choice of the logarithm base...
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