How to use the prettier-linter-helpers.showInvisibles function in prettier-linter-helpers

To help you get started, we’ve selected a few prettier-linter-helpers examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github prettier / eslint-plugin-prettier / eslint-plugin-prettier.js View on Github external
function reportInsert(context, offset, text) {
  const pos = context.getSourceCode().getLocFromIndex(offset);
  const range = [offset, offset];
  context.report({
    message: 'Insert `{{ code }}`',
    data: { code: showInvisibles(text) },
    loc: { start: pos, end: pos },
    fix(fixer) {
      return fixer.insertTextAfterRange(range, text);
    }
  });
}
github ember-template-lint / ember-template-lint-plugin-prettier / lib / rules / prettier.js View on Github external
differences.forEach(difference => {
              let message = "";
              let { line, column } = getLocFromIndex(
                difference.offset,
                this.source
              );

              switch (difference.operation) {
                case INSERT:
                  message = `Insert \`${showInvisibles(
                    difference.insertText
                  )}\``;
                  break;
                case DELETE:
                  message = `Delete \`${showInvisibles(
                    difference.deleteText
                  )}\``;
                  break;
                case REPLACE:
                  message = `Replace \`${showInvisibles(
                    difference.deleteText
                  )}\` with \`${difference.insertText}\``;
                  break;
              }

              this.log({ message, line, column, source });
            });
          }
github prettier / eslint-plugin-prettier / eslint-plugin-prettier.js View on Github external
function reportDelete(context, offset, text) {
  const start = context.getSourceCode().getLocFromIndex(offset);
  const end = context.getSourceCode().getLocFromIndex(offset + text.length);
  const range = [offset, offset + text.length];
  context.report({
    message: 'Delete `{{ code }}`',
    data: { code: showInvisibles(text) },
    loc: { start, end },
    fix(fixer) {
      return fixer.removeRange(range);
    }
  });
}
github prettier / stylelint-prettier / stylelint-prettier.js View on Github external
  insert: (code) => `Insert "${showInvisibles(code)}"`,
  delete: (code) => `Delete "${showInvisibles(code)}"`,
github prettier / eslint-plugin-prettier / eslint-plugin-prettier.js View on Github external
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);
    }
  });
}
github meteorlxy / eslint-plugin-prettier-vue / lib / rules / prettier / utils / report.js View on Github external
function reportDelete(context, offset, text) {
  const start = context.getSourceCode().getLocFromIndex(offset)
  const end = context.getSourceCode().getLocFromIndex(offset + text.length)
  const range = [offset, offset + text.length]
  context.report({
    message: 'Delete `{{ code }}`',
    data: { code: showInvisibles(text) },
    loc: { start, end },
    fix(fixer) {
      return fixer.removeRange(range)
    },
  })
}
github prettier / stylelint-prettier / stylelint-prettier.js View on Github external
replace: (deleteCode, insertCode) =>
    `Replace "${showInvisibles(deleteCode)}" with "${showInvisibles(
      insertCode
    )}"`,
});
github prettier / eslint-plugin-prettier / eslint-plugin-prettier.js View on Github external
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);
    }
  });
}
github meteorlxy / eslint-plugin-prettier-vue / lib / rules / prettier / utils / report.js View on Github external
function reportInsert(context, offset, text) {
  const pos = context.getSourceCode().getLocFromIndex(offset)
  const range = [offset, offset]
  context.report({
    message: 'Insert `{{ code }}`',
    data: { code: showInvisibles(text) },
    loc: { start: pos, end: pos },
    fix(fixer) {
      return fixer.insertTextAfterRange(range, text)
    },
  })
}

prettier-linter-helpers

Utilities to help expose prettier output in linting tools

MIT
Latest version published 6 years ago

Package Health Score

70 / 100
Full package analysis

Similar packages