fictivekin / eslint-config-fk

MIT License
0 stars 0 forks source link

Warn on the use of console #4

Closed ashur closed 2 years ago

ashur commented 2 years ago

Summary

Adding no-console as a warning could help catch any debugging uses of console calls before being committed or pushed.

Usage

In cases where a console call is desired in non-debugging contexts, the rule can be disabled:

// eslint-disable-next-line no-console
console.log("This message should be logged to an end-user's browser");

Tasks

Notes

ESLint on console use:

In JavaScript that is designed to be executed in the browser, it’s considered a best practice to avoid using methods on console. Such messages are considered to be for debugging purposes and therefore not suitable to ship to the client.

Links

jakefentress commented 2 years ago

@ashur I like the no-console for commits, but this might keep things from compiling locally so you couldn't use a console.log for debugging, either. But, that may be more a function of how we're currently using eslint in the bootstrap as opposed to maybe how it should be used.

ashur commented 2 years ago

@jacobfentress Great point! I dropped the rule to warn instead of error to prevent breaking existing uses of eslint-config-fk.