eslint-plugin-prettier.js
function reportReplace(context, offset, deleteText, insertText) {
  const start = context.getSourceCode().getLocFromIndex(offset);
  const end = context
    .getSourceCode()
    .getLocFromIndex(offset + deleteText.length);
  const range = [offset, offset + deleteText.length];
  context.report({
    message: 'Replace `{{ deleteCode }}` with `{{ insertCode }}`',
    data: {
      deleteCode: showInvisibles(deleteText),
      insertCode: showInvisibles(insertText)
    },
    loc: { start, end },
    fix(fixer) {
      return fixer.replaceTextRange(range, insertText);
    }
  });
}
function reportReplace(context, offset, deleteText, insertText) {
  const start = context.getSourceCode().getLocFromIndex(offset);
  const end = context
    .getSourceCode()
    .getLocFromIndex(offset + deleteText.length);
  const range = [offset, offset + deleteText.length];
  context.report({
    message: 'Replace `{{ deleteCode }}` with `{{ insertCode }}`',
    data: {
      deleteCode: showInvisibles(deleteText),
      insertCode: showInvisibles(insertText)
    },
    loc: { start, end },
    fix(fixer) {
      return fixer.replaceTextRange(range, insertText);
    }
  });
}
function reportReplace ( context , offset , deleteText , insertText ) { const start = context . getSourceCode ( ) . getLocFromIndex ( offset ) ; const end = context . getSourceCode ( ) . getLocFromIndex ( offset + deleteText . length ) ; const range = [ offset , offset + deleteText . length ] ; context . report ( { message : 'Replace `{{ deleteCode }}` with `{{ insertCode }}`' , data : { deleteCode : showInvisibles ( deleteText ) , insertCode : showInvisibles ( insertText ) } , loc : { start , end } , fix ( fixer ) { return fixer . replaceTextRange ( range , insertText ) ; } } ) ; }
Reports a "Replace ... with ..." issue where text must be replaced.
@param {RuleContext} context - The ESLint rule context.
@param {number} offset - The source offset where to replace deleted text
with inserted text.
@param {string} deleteText - The text to be deleted.
@param {string} insertText - The text to be inserted.
@returns {void}
Reports a Replace ... with ... issue where text must be replaced .