isml-linter 5.43.5 → 5.43.6
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 +6 -0
- package/package.json +1 -1
- package/src/isml_tree/IsmlNode.js +15 -12
- package/src/rules/tree/indent.js +16 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [5.43.6] - 2023-02-25
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- "indent" Rule - don't add indentation to embbeded "isprint" tag if it's in the same line as previous attribute;
|
|
7
|
+
|
|
3
8
|
## [5.43.5] - 2023-02-21
|
|
4
9
|
|
|
5
10
|
### Fixed
|
|
@@ -1114,6 +1119,7 @@
|
|
|
1114
1119
|
### Added
|
|
1115
1120
|
- Linter is published;
|
|
1116
1121
|
|
|
1122
|
+
[5.43.6]: https://github.com/FabiowQuixada/isml-linter/compare/v5.43.5...v5.43.6
|
|
1117
1123
|
[5.43.5]: https://github.com/FabiowQuixada/isml-linter/compare/v5.43.4...v5.43.5
|
|
1118
1124
|
[5.43.4]: https://github.com/FabiowQuixada/isml-linter/compare/v5.43.3...v5.43.4
|
|
1119
1125
|
[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) => {
|