Skip to content

Commit

Permalink
Extend base checker to use fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandomg committed Jan 9, 2020
1 parent 88a88f8 commit 6018f79
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/rules/base-checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@ class BaseChecker {
this.meta = meta
}

error(ctx, message) {
this.reporter.error(ctx, this.ruleId, message)
error(ctx, message, fix) {
this.addReport('error', ctx, message, fix)
}

errorAt(line, column, message) {
this.reporter.errorAt(line, column, this.ruleId, message)
errorAt(line, column, message, fix) {
this.error({ loc: { start: { line, column } } }, message, fix)
}

warn(ctx, message) {
this.reporter.warn(ctx, this.ruleId, message)
warn(ctx, message, fix) {
this.addReport('warn', ctx, message, fix)
}

addReport(type, ctx, message, fix) {
this.reporter[type](ctx, this.ruleId, message, this.meta.fixable ? fix : null)
}
}

Expand Down

0 comments on commit 6018f79

Please sign in to comment.