0.0.7 • Published 4 years ago
eslint-plugin-prefer-logger v0.0.7
eslint-plugin-prefer-logger
Usage
Example .eslintrc.js
// eslintrc
module.exports = {
"parserOptions": {
"sourceType": "module",
},
"rules": {
"prefer-logger/prefer-logger": ["error", {
"logger": "src/utils/logger.js",
}]
}
}
prefer-logger/prefer-logger
Restrict console.log and Suggest logger
:wrench: The --fix option on the command line can automatically fix some of the problems reported by this rule.
📖 Rule Details
When use method of console
object, then it will be replaced to logger.
Examples of :-1: incorrect code for this rule:
console.log("test")
console.info("test")
console.warn("test")
console.error("test")
Examples of :+1: correct code for this rule:
import logger from "../util/logger.js"
logger.log("test")
logger.info("test")
logger.warn("test")
logger.error("test")
Options
{
"rules": {
"prefer-logger/prefer-logger": ["error",
{
"loggerName": "logger",
"logger": "util/logger.js",
"base": "src"
}
]
}
}
TODO
- variable declaration with
require
function instead of import statement
LICENSE
MIT