eslint-formatting-reporter
TypeScript icon, indicating that this package has built-in type declarations

0.0.0 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i eslint-formatting-reporter

Weekly Downloads

13,435

Version

0.0.0

License

MIT

Unpacked Size

8.85 kB

Total Files

8

Last publish

Collaborators

  • antfu