case.js 892 B

1234567891011121314151617181920
  1. "use strict";
  2. var __importDefault = (this && this.__importDefault) || function (mod) {
  3. return (mod && mod.__esModule) ? mod : { "default": mod };
  4. };
  5. Object.defineProperty(exports, "__esModule", { value: true });
  6. const to_case_1 = __importDefault(require("./to-case"));
  7. exports.default = ensureCase;
  8. function ensureCase(raw = '', target = 'lowercase') {
  9. // We delete any content together with quotes because he can contains proper names (example `refactor: `Eslint` configuration`).
  10. // We need trim string because content with quotes can be at the beginning or end of a line
  11. const input = String(raw)
  12. .replace(/`.*?`|".*?"|'.*?'/g, '')
  13. .trim();
  14. const transformed = (0, to_case_1.default)(input, target);
  15. if (transformed === '' || transformed.match(/^\d/)) {
  16. return true;
  17. }
  18. return transformed === input;
  19. }
  20. //# sourceMappingURL=case.js.map