JSPM

eslint-formatting-reporter

0.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 79802
  • Score
    100M100P100Q171263F
  • License MIT

Report differences between the formatted and unformatted code for ESLint.

Package Exports

  • eslint-formatting-reporter

Readme

eslint-formatting-reporter

npm version npm downloads bundle JSDocs License

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'

// New ESLint Rule
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)
      }
    }
  }
}

Sponsors

License

MIT License © 2023-PRESENT Anthony Fu