Package Exports
- eslint-plugin-only-warn
- eslint-plugin-only-warn/src/only-warn.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (eslint-plugin-only-warn) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
eslint-plugin-only-warn
Downgrade ESLint errors to warnings.
Installation
npm install --save-dev eslint-plugin-only-warnUsage
Using flat config files:
// eslint.config.js
import "eslint-plugin-only-warn";
export default [
...Or, when the package.json that doesn't have "type": "module":
require("eslint-plugin-only-warn");ESLint 8.x and earlier
Add only-warn to the plugins section of your .eslintrc configuration file:
{
"plugins": ["only-warn"]
}--max-warnings=0
Add --max-warnings=0 to the eslint command in package.json
"lint": "eslint --max-warnings=0 ...",Adding the option allows git hooks or CI pipelines to detect failed linting rules.
Because the cli now has a nonzero exitcode when it encountered linting warnings.
Git integration
Use Husky and lint-staged to prevent committing code that contain eslint warnings.
Why only warnings?
- Don't waste time thinking or discussing about when a rule should be an error or a warning, focus on enabling of disabling a rule
- Warnings look different in editors, this allows you to quickly see that some tweaking is required, but your code still runs (ESLint rules generally don't block the code from executing and fatal errors are still reported as error)
- Prevents noise, disallowing warnings to be committed in a codebase prevents clutter in the output of ESLint (use special eslint comments for the instances when you need an exception to the rules)