eslint-plugin-prefer-logger
TypeScript icon, indicating that this package has built-in type declarations

0.0.7 • Public • Published

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

🔧 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 👎 incorrect code for this rule:

console.log("test")
console.info("test")
console.warn("test")
console.error("test")

Examples of 👍 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

Package Sidebar

Install

npm i eslint-plugin-prefer-logger

Weekly Downloads

2

Version

0.0.7

License

MIT

Unpacked Size

13.7 kB

Total Files

11

Last publish

Collaborators

  • wreulicke