isml-linter 5.43.5 → 5.43.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -1
- package/package.json +1 -1
- package/src/isml_tree/IsmlNode.js +15 -12
- package/src/rules/tree/indent.js +20 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [5.43.7] - 2023-03-03
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- "indent" rule - keep tag type if previous element has trailing spaces;
|
|
7
|
+
|
|
8
|
+
## [5.43.6] - 2023-02-25
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- "indent" rule - don't add indentation to embbeded "isprint" tag if it's in the same line as previous attribute;
|
|
12
|
+
|
|
3
13
|
## [5.43.5] - 2023-02-21
|
|
4
14
|
|
|
5
15
|
### Fixed
|
|
6
|
-
- "indent"
|
|
16
|
+
- "indent" rule - keep indentation of closing tag that is in same line as corresponding opening tag;
|
|
7
17
|
- Tree build for an empty template;
|
|
8
18
|
|
|
9
19
|
## [5.43.4] - 2023-02-20
|
|
@@ -1114,6 +1124,8 @@
|
|
|
1114
1124
|
### Added
|
|
1115
1125
|
- Linter is published;
|
|
1116
1126
|
|
|
1127
|
+
[5.43.7]: https://github.com/FabiowQuixada/isml-linter/compare/v5.43.6...v5.43.7
|
|
1128
|
+
[5.43.6]: https://github.com/FabiowQuixada/isml-linter/compare/v5.43.5...v5.43.6
|
|
1117
1129
|
[5.43.5]: https://github.com/FabiowQuixada/isml-linter/compare/v5.43.4...v5.43.5
|
|
1118
1130
|
[5.43.4]: https://github.com/FabiowQuixada/isml-linter/compare/v5.43.3...v5.43.4
|
|
1119
1131
|
[5.43.3]: https://github.com/FabiowQuixada/isml-linter/compare/v5.43.2...v5.43.3
|
package/package.json
CHANGED
|
@@ -445,16 +445,16 @@ const privateToString = (node, stream = '') => {
|
|
|
445
445
|
};
|
|
446
446
|
|
|
447
447
|
const getAttributes = node => {
|
|
448
|
-
const trimmedHead
|
|
449
|
-
const nodeHead
|
|
450
|
-
const firstSpaceAfterTagPos
|
|
451
|
-
const leadingEmptySpaceQty
|
|
452
|
-
const afterTagContent
|
|
453
|
-
const
|
|
454
|
-
const attributeList
|
|
455
|
-
|
|
456
|
-
for (let i = 0; i <
|
|
457
|
-
const attr = parseAttribute(node,
|
|
448
|
+
const trimmedHead = node.head.trim();
|
|
449
|
+
const nodeHead = trimmedHead.substring(1, trimmedHead.length - 1);
|
|
450
|
+
const firstSpaceAfterTagPos = ParseUtils.getFirstEmptyCharPos(trimmedHead);
|
|
451
|
+
const leadingEmptySpaceQty = ParseUtils.getNextNonEmptyCharPos(nodeHead);
|
|
452
|
+
const afterTagContent = nodeHead.substring(leadingEmptySpaceQty + firstSpaceAfterTagPos);
|
|
453
|
+
const rawAttributeList = getStringifiedAttributeArray(afterTagContent);
|
|
454
|
+
const attributeList = [];
|
|
455
|
+
|
|
456
|
+
for (let i = 0; i < rawAttributeList.length; i++) {
|
|
457
|
+
const attr = parseAttribute(node, rawAttributeList, attributeList, i);
|
|
458
458
|
attributeList.push(attr);
|
|
459
459
|
}
|
|
460
460
|
|
|
@@ -525,8 +525,8 @@ const getStringifiedAttributeArray = content => {
|
|
|
525
525
|
return result;
|
|
526
526
|
};
|
|
527
527
|
|
|
528
|
-
const parseAttribute = (node,
|
|
529
|
-
const attribute =
|
|
528
|
+
const parseAttribute = (node, rawAttributeList, resultingAttributeList, index) => {
|
|
529
|
+
const attribute = rawAttributeList[index];
|
|
530
530
|
const isAttributeANestedIsmlTag = attribute.startsWith('<is');
|
|
531
531
|
const isExpressionAttribute = attribute.startsWith('${') && attribute.endsWith('}');
|
|
532
532
|
const trimmedAttribute = attribute.trim();
|
|
@@ -547,6 +547,7 @@ const parseAttribute = (node, attributeList, index) => {
|
|
|
547
547
|
const isFirstValueInSameLineAsAttributeName = value && ParseUtils.getLeadingLineBreakQty(value) === 0;
|
|
548
548
|
const quoteChar = getQuoteChar(trimmedAttribute);
|
|
549
549
|
const attributeNameFirstLine = name.split(Constants.EOL)[0];
|
|
550
|
+
const isInSameLineAsPreviousAttribute = index >= 1 && resultingAttributeList[index - 1].lineNumber === lineNumber;
|
|
550
551
|
|
|
551
552
|
const columnNumber = isInSameLineAsTagName ?
|
|
552
553
|
node.columnNumber + leadingContent.length :
|
|
@@ -572,6 +573,7 @@ const parseAttribute = (node, attributeList, index) => {
|
|
|
572
573
|
isInSameLineAsTagName,
|
|
573
574
|
isFirstInLine,
|
|
574
575
|
isFirstValueInSameLineAsAttributeName,
|
|
576
|
+
isInSameLineAsPreviousAttribute,
|
|
575
577
|
isExpressionAttribute,
|
|
576
578
|
hasMultilineValue,
|
|
577
579
|
isNestedIsmlTag : isAttributeANestedIsmlTag,
|
|
@@ -594,6 +596,7 @@ const parseAttribute = (node, attributeList, index) => {
|
|
|
594
596
|
isInSameLineAsTagName,
|
|
595
597
|
isFirstInLine,
|
|
596
598
|
isFirstValueInSameLineAsAttributeName,
|
|
599
|
+
isInSameLineAsPreviousAttribute,
|
|
597
600
|
isExpressionAttribute,
|
|
598
601
|
hasMultilineValue,
|
|
599
602
|
isNestedIsmlTag: isAttributeANestedIsmlTag,
|
package/src/rules/tree/indent.js
CHANGED
|
@@ -441,21 +441,24 @@ const addIndentationToText = node => {
|
|
|
441
441
|
};
|
|
442
442
|
|
|
443
443
|
const getIndentedNestedIsmlContent = (attribute, nodeIndentation, attributeOffset) => {
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
const fixedContent = Rule.getFixedContent(attributeRootNode);
|
|
444
|
+
const attributeRootNode = TreeBuilder.parse(attribute.fullContent, null, null, true);
|
|
445
|
+
const fixedContent = Rule.getFixedContent(attributeRootNode);
|
|
447
446
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
return Constants.EOL + nodeIndentation + attributeOffset + line;
|
|
453
|
-
}
|
|
447
|
+
return fixedContent
|
|
448
|
+
.split(Constants.EOL)
|
|
449
|
+
.map( (line, i) => {
|
|
450
|
+
const shouldAddLineBreak = i === 0 && attribute.isFirstInLine && !attribute.isInSameLineAsTagName && attribute.index !== 0;
|
|
454
451
|
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
452
|
+
if (attribute.isInSameLineAsPreviousAttribute) {
|
|
453
|
+
return ' ' + line;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
return (shouldAddLineBreak ? Constants.EOL : '')
|
|
457
|
+
+ nodeIndentation
|
|
458
|
+
+ attributeOffset
|
|
459
|
+
+ line;
|
|
460
|
+
})
|
|
461
|
+
.join(Constants.EOL);
|
|
459
462
|
};
|
|
460
463
|
|
|
461
464
|
const getTreeBuiltAttributeIndentedValue = (attribute, nodeIndentation, attributeOffset) => {
|
|
@@ -616,17 +619,18 @@ const addIndentation = (node, isOpeningTag) => {
|
|
|
616
619
|
const nodeIndentation = node.isInSameLineAsParent() && isOpeningTag ? '' : Rule.getIndentation(node.depth - 1);
|
|
617
620
|
const attributeOffset = Rule.getAttributeIndentationOffset();
|
|
618
621
|
const attributeList = node.getAttributeList();
|
|
622
|
+
const leadingLineBreakQty = ParseUtils.getLeadingLineBreakQty(node.head);
|
|
619
623
|
let contentResult = '';
|
|
620
624
|
|
|
621
625
|
if (isOpeningTag) {
|
|
622
626
|
const shouldAddIndentationToClosingChar = shouldAddIndentationToClosingChars(node);
|
|
623
627
|
const closingChars = getClosingChars(node);
|
|
624
|
-
const tagNameEndPos =
|
|
628
|
+
const tagNameEndPos = leadingLineBreakQty
|
|
625
629
|
+ ParseUtils.getFirstEmptyCharPos(node.head.trim()) + 1;
|
|
626
630
|
|
|
627
631
|
if (ParseUtils.getLineBreakQty(node.head.trim()) > 0 || shouldAddIndentationToClosingChar && node.isSelfClosing()) {
|
|
628
632
|
contentResult = attributeList.length > 0 ?
|
|
629
|
-
node.head.substring(0, tagNameEndPos).trimStart() :
|
|
633
|
+
node.head.trimStart().substring(0, tagNameEndPos - leadingLineBreakQty).trimStart() :
|
|
630
634
|
node.head.trimStart();
|
|
631
635
|
|
|
632
636
|
for (let i = 0; i < attributeList.length; i++) {
|
|
@@ -659,7 +663,7 @@ const removeAllIndentation = node => {
|
|
|
659
663
|
if (!node.isRoot() && !node.isContainer() && !node.parent.isOneOfTypes(['isscript', 'script'])) {
|
|
660
664
|
|
|
661
665
|
const shouldRemoveHeadIndentation = node.head && !node.isInSameLineAsPreviousSibling() && !node.isInSameLineAsParent() && !(node.lineNumber === node.parent.endLineNumber);
|
|
662
|
-
const shouldRemoveTailIndentation = node.tail && !(node.hasChildren() && node.getLastChild().lineNumber === node.tailLineNumber);
|
|
666
|
+
const shouldRemoveTailIndentation = !!(node.tail && !(node.hasChildren() && node.getLastChild().lineNumber === node.tailLineNumber));
|
|
663
667
|
|
|
664
668
|
if (shouldRemoveHeadIndentation) {
|
|
665
669
|
node.head = removeIndentation(node.head);
|