Skip to content

Commit

Permalink
Merge pull request #81 from NullVoxPopuli/remove-uncessary-code
Browse files Browse the repository at this point in the history
remove unnecessary code
  • Loading branch information
NullVoxPopuli authored Mar 15, 2024
2 parents 2daef64 + 114cbd1 commit 23a03c2
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/parser/transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,21 +566,16 @@ module.exports.transformForLint = function transformForLint(code) {
*/
const result = processor.parse(code);
for (const tplInfo of result.reverse()) {
const specialChars = [...tplInfo.contents].reduce(
(prev, curr) => (prev + ['`', '$'].includes(curr.codePointAt(0)) ? 1 : 0),
0
);
const content = tplInfo.contents.replace(/`/g, '\\`').replace(/\$/g, '\\$');
if (tplInfo.type === 'class-member') {
const tplLength = tplInfo.range.end - tplInfo.range.start;
const spaces =
tplLength - byteLength(content) - 'static{`'.length - '`}'.length - specialChars;
const spaces = tplLength - byteLength(content) - 'static{`'.length - '`}'.length;
const total = content + ' '.repeat(spaces);
const replacementCode = `static{\`${total}\`}`;
jsCode = replaceRange(jsCode, tplInfo.range.start, tplInfo.range.end, replacementCode);
} else {
const tplLength = tplInfo.range.end - tplInfo.range.start;
const spaces = tplLength - byteLength(content) - '`'.length - '`'.length - specialChars;
const spaces = tplLength - byteLength(content) - '`'.length - '`'.length;
const total = content + ' '.repeat(spaces);
const replacementCode = `\`${total}\``;
jsCode = replaceRange(jsCode, tplInfo.range.start, tplInfo.range.end, replacementCode);
Expand Down

0 comments on commit 23a03c2

Please sign in to comment.