Skip to content

Commit

Permalink
fix: add no-console to rules (#1214)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret authored Nov 24, 2023
1 parent 4abfcae commit b563057
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ fn get_all_rules_raw() -> Vec<&'static dyn LintRule> {
&no_class_assign::NoClassAssign,
&no_compare_neg_zero::NoCompareNegZero,
&no_cond_assign::NoCondAssign,
&no_console::NoConsole,
&no_const_assign::NoConstAssign,
&no_constant_condition::NoConstantCondition,
&no_control_regex::NoControlRegex,
Expand Down
5 changes: 5 additions & 0 deletions www/static/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@
"recommended"
]
},
{
"code": "no-console",
"docs": "# no_console\n\nDisallows the use of the `console` global.\n\nOftentimes, developers accidentally commit `console.log`/`console.error`\nstatements, left in particularly after debugging. Moreover, using these in code\nmay leak sensitive information to the output or clutter the console with\nunnecessary information. This rule helps maintain clean and secure code by\ndisallowing the use of `console`.\n\nThis rule is especially useful in libraries where you almost never want to\noutput to the console.\n\n### Invalid\n\n```typescript\nconsole.log(\"Debug message\");\nconsole.error(\"Debug message\");\nconsole.debug(obj);\n\nif (debug) console.log(\"Debugging\");\n\nfunction log() {\n console.log(\"Log\");\n}\n```\n\n### Valid\n\nIt is recommended to explicitly enable the console via a `deno-lint-ignore`\ncomment for any calls where you actually want to use it.\n\n```typescript\nfunction logWarning(message: string) {\n // deno-lint-ignore no-console\n console.warn(message);\n}\n```\n",
"tags": []
},
{
"code": "no-const-assign",
"docs": "Disallows modifying a variable declared as `const`.\n\nModifying a variable declared as `const` will result in a runtime error.\n\n### Invalid:\n\n```typescript\nconst a = 0;\na = 1;\na += 1;\na++;\n++a;\n```\n\n### Valid:\n\n```typescript\nconst a = 0;\nconst b = a + 1;\n\n// `c` is out of scope on each loop iteration, allowing a new assignment\nfor (const c in [1, 2, 3]) {}\n```\n",
Expand Down

0 comments on commit b563057

Please sign in to comment.