isml-linter 5.43.7 → 5.43.9

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 CHANGED
@@ -1,31 +1,41 @@
1
1
  # Changelog
2
2
 
3
+ ## [5.43.9] - 2023-03-05
4
+
5
+ ### Fixed
6
+ - "leading-iscache" and "leading-iscontent" rules - update tree data after move nodes on autofix mode;
7
+
8
+ ## [5.43.8] - 2023-03-04
9
+
10
+ ### Fixed
11
+ - Identification of HTML tag attributes even when there is no blank space separating them;
12
+
3
13
  ## [5.43.7] - 2023-03-03
4
14
 
5
15
  ### Fixed
6
16
  - "indent" rule - keep tag type if previous element has trailing spaces;
7
-
17
+
8
18
  ## [5.43.6] - 2023-02-25
9
19
 
10
20
  ### Fixed
11
21
  - "indent" rule - don't add indentation to embbeded "isprint" tag if it's in the same line as previous attribute;
12
-
22
+
13
23
  ## [5.43.5] - 2023-02-21
14
24
 
15
25
  ### Fixed
16
26
  - "indent" rule - keep indentation of closing tag that is in same line as corresponding opening tag;
17
27
  - Tree build for an empty template;
18
-
28
+
19
29
  ## [5.43.4] - 2023-02-20
20
30
 
21
31
  ### Fixed
22
32
  - [Issue #39][issue#39] - Allow closing tag to be in the same line as corresponding opening tag last character;
23
-
33
+
24
34
  ## [5.43.3] - 2023-02-20
25
35
 
26
36
  ### Fixed
27
37
  - Issue that blocked process due to a missing return value in some rules;
28
-
38
+
29
39
  ## [5.43.2] - 2023-02-12
30
40
 
31
41
  ### Security
@@ -35,7 +45,7 @@
35
45
 
36
46
  ### Fixed
37
47
  - All line-by-line rules are applied, one after the other, without ovewriting the previous rule fixed content;
38
-
48
+
39
49
  ## [5.43.0] - 2023-01-31
40
50
 
41
51
  ### Added
@@ -43,7 +53,7 @@
43
53
 
44
54
  ### Fixed
45
55
  - Rule-level ignore string with "/" character for directories;
46
-
56
+
47
57
  ## [5.42.4] - 2023-01-30
48
58
 
49
59
  ### Fixed
@@ -1124,6 +1134,8 @@
1124
1134
  ### Added
1125
1135
  - Linter is published;
1126
1136
 
1137
+ [5.43.9]: https://github.com/FabiowQuixada/isml-linter/compare/v5.43.8...v5.43.9
1138
+ [5.43.8]: https://github.com/FabiowQuixada/isml-linter/compare/v5.43.7...v5.43.8
1127
1139
  [5.43.7]: https://github.com/FabiowQuixada/isml-linter/compare/v5.43.6...v5.43.7
1128
1140
  [5.43.6]: https://github.com/FabiowQuixada/isml-linter/compare/v5.43.5...v5.43.6
1129
1141
  [5.43.5]: https://github.com/FabiowQuixada/isml-linter/compare/v5.43.4...v5.43.5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isml-linter",
3
- "version": "5.43.7",
3
+ "version": "5.43.9",
4
4
  "author": "Fabiow Quixadá <ftquixada@gmail.com>",
5
5
  "license": "MIT",
6
6
  "main": "src/publicApi.js",
package/src/Constants.js CHANGED
@@ -40,6 +40,7 @@ const specComplexTemplatesDir = path.join(specIsmlTreeTemplateDir, 'com
40
40
  const specElementBalanceTemplatesDir = path.join(specIsmlTreeTemplateDir, 'element_balance');
41
41
  const specTailLineNumberTemplatesDir = path.join(specIsmlTreeTemplateDir, 'tail_line_number');
42
42
  const specAutofixTemplatesDir = path.join(specTemplateDir, 'autofix');
43
+ const specTreeRuleTemplatesDir = path.join(specTemplateDir, 'rules', 'tree');
43
44
  const rulesDir = path.join(linterModuleDir, 'src', 'rules');
44
45
  const lineByLineRulesDir = path.join(rulesDir, 'line_by_line');
45
46
  const treeRulesDir = path.join(rulesDir, 'tree');
@@ -102,6 +103,7 @@ module.exports = {
102
103
  specColumnNumberTemplateDir,
103
104
  specInvalidTemplateDir,
104
105
  specComplexTemplatesDir,
106
+ specTreeRuleTemplatesDir,
105
107
  specAutofixTemplatesDir,
106
108
  specElementBalanceTemplatesDir,
107
109
  specTailLineNumberTemplatesDir,
@@ -351,6 +351,9 @@ class IsmlNode {
351
351
  return !this.parent || this.parent.getLastChild() === this;
352
352
  }
353
353
 
354
+ // No position or line number is set. To get
355
+ // it, it is necessary to re-parse the tree.
356
+ // This is valid for all nodes;
354
357
  removeChild(node) {
355
358
  let index = null;
356
359
 
@@ -365,15 +368,27 @@ class IsmlNode {
365
368
 
366
369
  const removedNode = this.children[index];
367
370
  this.children.splice(index, 1);
371
+
372
+ for (let i = 0; i < this.children.length; i++) {
373
+ const child = this.children[index];
374
+ child.childNo = i;
375
+ }
376
+
368
377
  return removedNode;
369
378
  }
370
379
 
371
380
  // No position or line number is set. To get
372
- // it, it is necessary to re-parse the tree;
381
+ // it, it is necessary to re-parse the tree.
382
+ // This is valid for all nodes;
373
383
  addChildNodeToPos(node, index) {
374
384
  node.parent = this;
375
385
  node.depth = this.depth + 1;
376
386
  this.children.splice(index, 0, node);
387
+
388
+ for (let i = 0; i < this.children.length; i++) {
389
+ const child = this.children[i];
390
+ child.childNo = i;
391
+ }
377
392
  }
378
393
 
379
394
  getRoot() {
@@ -450,7 +465,7 @@ const getAttributes = node => {
450
465
  const firstSpaceAfterTagPos = ParseUtils.getFirstEmptyCharPos(trimmedHead);
451
466
  const leadingEmptySpaceQty = ParseUtils.getNextNonEmptyCharPos(nodeHead);
452
467
  const afterTagContent = nodeHead.substring(leadingEmptySpaceQty + firstSpaceAfterTagPos);
453
- const rawAttributeList = getStringifiedAttributeArray(afterTagContent);
468
+ const rawAttributeList = getStringifiedAttributeArray(afterTagContent.trim());
454
469
  const attributeList = [];
455
470
 
456
471
  for (let i = 0; i < rawAttributeList.length; i++) {
@@ -500,6 +515,7 @@ const getStringifiedAttributeArray = content => {
500
515
 
501
516
  const maskedAttributeList = maskedContent
502
517
  .replace(/><+/g, '> <')
518
+ .replace(/"</g, '" <')
503
519
  .replace(/\s\s+/g, ' ')
504
520
  .split(' ')
505
521
  .filter(attr => attr);
@@ -509,6 +525,8 @@ const getStringifiedAttributeArray = content => {
509
525
  attrStartPosList.push(i);
510
526
  } else if (maskedContent[i - 1] === ' ' && maskedContent[i] !== ' ' || maskedContent[i - 1] === '>' && maskedContent[i] === '<') {
511
527
  attrStartPosList.push(i);
528
+ } else if (maskedContent[i - 1] === '"' && maskedContent[i] === '<') {
529
+ attrStartPosList.push(i + 1);
512
530
  }
513
531
  }
514
532
 
@@ -35,4 +35,11 @@ Rule.getFixedContent = function(rootNode) {
35
35
  return rootNode.toString();
36
36
  };
37
37
 
38
+ Rule.fixContent = function(rootNode) {
39
+ return {
40
+ rootNode,
41
+ fixedContent : this.getFixedContent(rootNode)
42
+ };
43
+ };
44
+
38
45
  module.exports = Rule;
@@ -31,4 +31,11 @@ Rule.getFixedContent = function(rootNode) {
31
31
  return rootNode.toString();
32
32
  };
33
33
 
34
+ Rule.fixContent = function(rootNode) {
35
+ return {
36
+ rootNode,
37
+ fixedContent : this.getFixedContent(rootNode)
38
+ };
39
+ };
40
+
34
41
  module.exports = Rule;