Skip to content

Commit

Permalink
Enforce eslint prefer-template (#346)
Browse files Browse the repository at this point in the history
  • Loading branch information
cjbarth authored Jul 18, 2023
1 parent fa2a403 commit 1eee0d0
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 149 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"eqeqeq": ["error", "smart"],
"no-var": "error",
"prefer-const": "error",
"prefer-template": "error",
"deprecation/deprecation": "warn",
"@typescript-eslint/no-non-null-assertion": "error",
"@typescript-eslint/no-unused-vars": "warn",
Expand Down
12 changes: 5 additions & 7 deletions src/c14n-canonicalization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,11 @@ export class C14nCanonicalization implements CanonicalizationOrTransformationAlg
}
}

return (
(isAfterDocument ? "\n" : "") +
"<!--" +
utils.encodeSpecialCharactersInText(node.data) +
"-->" +
(isBeforeDocument ? "\n" : "")
);
const afterDocument = isAfterDocument ? "\n" : "";
const beforeDocument = isBeforeDocument ? "\n" : "";
const encodedText = utils.encodeSpecialCharactersInText(node.data);

return `${afterDocument}<!--${encodedText}-->${beforeDocument}`;
}

/**
Expand Down
14 changes: 6 additions & 8 deletions src/exclusive-canonicalization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,11 @@ export class ExclusiveCanonicalization implements CanonicalizationOrTransformati
}
}

return (
(isAfterDocument ? "\n" : "") +
"<!--" +
utils.encodeSpecialCharactersInText(node.data) +
"-->" +
(isBeforeDocument ? "\n" : "")
);
const afterDocument = isAfterDocument ? "\n" : "";
const beforeDocument = isBeforeDocument ? "\n" : "";
const encodedText = utils.encodeSpecialCharactersInText(node.data);

return `${afterDocument}<!--${encodedText}-->${beforeDocument}`;
}

/**
Expand Down Expand Up @@ -293,7 +291,7 @@ export class ExclusiveCanonicalization implements CanonicalizationOrTransformati
if (prefix === ancestorNamespace.prefix) {
node.setAttributeNS(
"http://www.w3.org/2000/xmlns/",
"xmlns:" + prefix,
`xmlns:${prefix}`,
ancestorNamespace.namespaceURI
);
}
Expand Down
Loading

0 comments on commit 1eee0d0

Please sign in to comment.