noConsole
このコンテンツはまだ日本語訳がありません。
Diagnostic Category: lint/suspicious/noConsole
Since: v1.6.0
Sources:
- Same as:
no-console
Description
Section titled “Description”Disallow the use of console
.
In a browser environment, it’s considered a best practice to log messages using console
.
Such messages are considered to be for debugging purposes and therefore not suitable to ship to the client.
In general, calls using console
should be stripped before being pushed to production.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”console.error('hello world')
code-block.js:1:1 lint/suspicious/noConsole FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ Don’t use console.
> 1 │ console.error(‘hello world’)
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 │
ℹ The use of console is often reserved for debugging.
ℹ Unsafe fix: Remove console.
1 │ console.error(‘hello·world’)
│ ----------------------------
Options
Section titled “Options”Use the options to specify the allowed console
methods.
{ "//": "...", "options": { "allow": ["assert", "error", "info", "warn"] }}
How to configure
Section titled “How to configure”{ "linter": { "rules": { "suspicious": { "noConsole": "error" } } }}