Sha256: c16a86da05993cf45b1be6e9c7ae32edcac7723a5d6fd7df5b29facc87d846db

Contents?: true

Size: 1.15 KB

Versions: 58

Compression:

Stored size: 1.15 KB

Contents

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = cleanJSXElementLiteralChild;
var _index = require("../../builders/generated/index.js");
var _index2 = require("../../index.js");
function cleanJSXElementLiteralChild(child, args) {
  const lines = child.value.split(/\r\n|\n|\r/);
  let lastNonEmptyLine = 0;
  for (let i = 0; i < lines.length; i++) {
    if (lines[i].match(/[^ \t]/)) {
      lastNonEmptyLine = i;
    }
  }
  let str = "";
  for (let i = 0; i < lines.length; i++) {
    const line = lines[i];
    const isFirstLine = i === 0;
    const isLastLine = i === lines.length - 1;
    const isLastNonEmptyLine = i === lastNonEmptyLine;
    let trimmedLine = line.replace(/\t/g, " ");
    if (!isFirstLine) {
      trimmedLine = trimmedLine.replace(/^[ ]+/, "");
    }
    if (!isLastLine) {
      trimmedLine = trimmedLine.replace(/[ ]+$/, "");
    }
    if (trimmedLine) {
      if (!isLastNonEmptyLine) {
        trimmedLine += " ";
      }
      str += trimmedLine;
    }
  }
  if (str) args.push((0, _index2.inherits)((0, _index.stringLiteral)(str), child));
}

//# sourceMappingURL=cleanJSXElementLiteralChild.js.map

Version data entries

58 entries across 16 versions & 3 rubygems

Version Path
trusty-cms-6.3.1 node_modules/@babel/types/lib/utils/react/cleanJSXElementLiteralChild.js
trusty-cms-6.3.1 node_modules/@babel/traverse/node_modules/@babel/types/lib/utils/react/cleanJSXElementLiteralChild.js
trusty-cms-6.3.1 node_modules/@babel/helper-function-name/node_modules/@babel/types/lib/utils/react/cleanJSXElementLiteralChild.js
immosquare-cleaner-0.1.51 node_modules/@babel/helper-split-export-declaration/node_modules/@babel/types/lib/utils/react/cleanJSXElementLiteralChild.js
immosquare-cleaner-0.1.51 node_modules/@babel/helper-simple-access/node_modules/@babel/types/lib/utils/react/cleanJSXElementLiteralChild.js
immosquare-cleaner-0.1.51 node_modules/@babel/helper-optimise-call-expression/node_modules/@babel/types/lib/utils/react/cleanJSXElementLiteralChild.js
immosquare-cleaner-0.1.51 node_modules/@babel/helper-member-expression-to-functions/node_modules/@babel/types/lib/utils/react/cleanJSXElementLiteralChild.js
immosquare-cleaner-0.1.51 node_modules/jscodeshift/node_modules/@babel/core/node_modules/@babel/types/lib/utils/react/cleanJSXElementLiteralChild.js
immosquare-cleaner-0.1.51 node_modules/@babel/helper-function-name/node_modules/@babel/types/lib/utils/react/cleanJSXElementLiteralChild.js
immosquare-cleaner-0.1.51 node_modules/@babel/helper-hoist-variables/node_modules/@babel/types/lib/utils/react/cleanJSXElementLiteralChild.js
immosquare-cleaner-0.1.51 node_modules/@babel/helper-module-imports/node_modules/@babel/types/lib/utils/react/cleanJSXElementLiteralChild.js
immosquare-cleaner-0.1.51 node_modules/@babel/helper-environment-visitor/node_modules/@babel/types/lib/utils/react/cleanJSXElementLiteralChild.js
immosquare-cleaner-0.1.51 node_modules/@babel/helper-skip-transparent-expression-wrappers/node_modules/@babel/types/lib/utils/react/cleanJSXElementLiteralChild.js
immosquare-cleaner-0.1.51 node_modules/@babel/helper-annotate-as-pure/node_modules/@babel/types/lib/utils/react/cleanJSXElementLiteralChild.js
immosquare-cleaner-0.1.50 node_modules/@babel/helper-module-imports/node_modules/@babel/types/lib/utils/react/cleanJSXElementLiteralChild.js
immosquare-cleaner-0.1.50 node_modules/@babel/helper-optimise-call-expression/node_modules/@babel/types/lib/utils/react/cleanJSXElementLiteralChild.js
immosquare-cleaner-0.1.50 node_modules/@babel/helper-hoist-variables/node_modules/@babel/types/lib/utils/react/cleanJSXElementLiteralChild.js
immosquare-cleaner-0.1.50 node_modules/@babel/helper-member-expression-to-functions/node_modules/@babel/types/lib/utils/react/cleanJSXElementLiteralChild.js
immosquare-cleaner-0.1.50 node_modules/@babel/helper-simple-access/node_modules/@babel/types/lib/utils/react/cleanJSXElementLiteralChild.js
immosquare-cleaner-0.1.50 node_modules/@babel/helper-environment-visitor/node_modules/@babel/types/lib/utils/react/cleanJSXElementLiteralChild.js