eslint-formatting-reporter
Report differences between the formatted and unformatted code for ESLint. Useful to create ESLint plugins that format plain code.
A thin wrapper around prettier-linter-helpers, extracted from eslint-plugin-prettier.
Usage
import { messages, reportDifferences } from 'eslint-formatting-reporter'
import type { Rule } from 'eslint'
export default <Rule.RuleModule>{
meta: {
type: 'layout',
fixable: 'whitespace',
messages
},
create(context) {
return {
Program() {
const source = context.source.text
const formatted = myFormat(source)
reportDifferences(context, source, formatted)
}
}
}
}
License
MIT License © 2023-PRESENT Anthony Fu