isml-linter 5.42.3 → 5.43.0

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,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [5.43.0] - 2023-01-31
4
+
5
+ ### Added
6
+ - "allowWhenDynamic" (default `true`) option to "[no-inline-style][no-inline-style-readme]" rule;
7
+
8
+ ### Fixed
9
+ - Rule-level ignore string with "/" character for directories;
10
+
11
+ ## [5.42.4] - 2023-01-30
12
+
13
+ ### Fixed
14
+ - "indent" rule fix - multiline self-closing HTML conditional comment;
15
+ - "indent" rule fix - closing tag after closing "isif" tag;
16
+
3
17
  ## [5.42.3] - 2023-01-29
4
18
 
5
19
  ### Fixed
@@ -1074,6 +1088,8 @@
1074
1088
  ### Added
1075
1089
  - Linter is published;
1076
1090
 
1091
+ [5.43.0]: https://github.com/FabiowQuixada/isml-linter/compare/v5.42.4...v5.43.0
1092
+ [5.42.4]: https://github.com/FabiowQuixada/isml-linter/compare/v5.42.3...v5.42.4
1077
1093
  [5.42.3]: https://github.com/FabiowQuixada/isml-linter/compare/v5.42.2...v5.42.3
1078
1094
  [5.42.2]: https://github.com/FabiowQuixada/isml-linter/compare/v5.42.1...v5.42.2
1079
1095
  [5.42.1]: https://github.com/FabiowQuixada/isml-linter/compare/v5.42.0...v5.42.1
@@ -1244,7 +1260,7 @@
1244
1260
  [strict-void-elements-readme]: <docs/rules/strict-void-elements.md>
1245
1261
  [disallow-tags-readme]: <docs/rules/disallow-tags.md>
1246
1262
  [no-br-readme]: <docs/rules/no-br.md>
1247
- [no-inline-style-readme]: <docs/rules/no-br.md>
1263
+ [no-inline-style-readme]: <docs/rules/no-inline-style.md>
1248
1264
  [no-isscript-readme]: <docs/rules/no-isscript.md>
1249
1265
  [enforce-security-readme]: <docs/rules/enforce-security.md>
1250
1266
  [no-hardcode-readme]: <docs/rules/no-hardcode.md>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isml-linter",
3
- "version": "5.42.3",
3
+ "version": "5.43.0",
4
4
  "author": "Fabiow Quixadá <ftquixada@gmail.com>",
5
5
  "license": "MIT",
6
6
  "main": "src/publicApi.js",
package/src/IsmlLinter.js CHANGED
@@ -225,13 +225,13 @@ Linter.run = (pathData, content, data = {}) => {
225
225
  const lintStartTime = new Date();
226
226
 
227
227
  for (let i = 0; i < templatePathArray.length; i++) {
228
- const templateName = templatePathArray[i];
229
- const templatePath = Array.isArray(templateData.pathData) || path.isAbsolute(templateName) || templateData.pathData === templateName ?
228
+ const templateName = templatePathArray[i];
229
+ const templatePath = Array.isArray(templateData.pathData) || path.isAbsolute(templateName) || templateData.pathData === templateName ?
230
230
  templateName :
231
231
  path.join(templateData.pathData, templateName);
232
- const isIgnored = FileUtils.isIgnored(templatePath);
232
+ const shouldBeIgnored = FileUtils.shouldBeIgnored(templatePath);
233
233
 
234
- if (!isIgnored) {
234
+ if (!shouldBeIgnored) {
235
235
  const templateResults = parseAndPossiblyFixTemplate(templatePath, data, content, templateName);
236
236
 
237
237
  finalResult = merge(finalResult, templateResults);
@@ -404,12 +404,11 @@ class IsmlNode {
404
404
  indentation += ' ';
405
405
  }
406
406
 
407
- // if(this.isRoot()) {
408
- // console.log('Depth\t :: LineNumber\t :: Content');
409
- // }
407
+ if(this.isRoot()) {
408
+ console.log('Depth\t :: LineNumber\t :: Content');
409
+ }
410
410
 
411
- // console.log(this.depth + '\t :: ' + this.lineNumber + '\t\t :: ' + indentation + getDisplayText(this));
412
- console.log(this.depth + ' :: ' + this.lineNumber + ' :: ' + indentation + getDisplayText(this));
411
+ console.log(this.depth + '\t :: ' + this.lineNumber + '\t\t :: ' + indentation + getDisplayText(this));
413
412
 
414
413
  for (let i = 0; i < this.children.length; i++) {
415
414
  this.children[i].print();
@@ -8,7 +8,37 @@ const Rule = Object.create(SingleLineRulePrototype);
8
8
 
9
9
  Rule.init(ruleId, description);
10
10
 
11
- Rule.isBroken = function(line) { return line.indexOf('<isprint') === -1 && line.indexOf(occurrenceText) >= 0; };
11
+ Rule.isBroken = function(line) {
12
+ const shouldAllowWhenDynamic = this.getConfigs().allowWhenDynamic;
13
+
14
+ if (line.indexOf(occurrenceText) >= 0) {
15
+ if (shouldAllowWhenDynamic && line.indexOf('${') >= 0) {
16
+ const attributePos = line.indexOf(occurrenceText);
17
+ const tagClosingCharPos = line.substring(attributePos).indexOf('>');
18
+ const expressionPos = line.substring(tagClosingCharPos).indexOf('${');
19
+
20
+ if (attributePos >= 0 && tagClosingCharPos >= 0 && expressionPos >= 0 &&
21
+ attributePos < tagClosingCharPos && tagClosingCharPos < expressionPos
22
+ ) {
23
+ return true;
24
+ }
25
+
26
+ if (attributePos === -1 || tagClosingCharPos === -1 || expressionPos === -1) {
27
+ return false;
28
+ }
29
+ }
30
+
31
+ return line.indexOf('<isprint') === -1;
32
+ }
33
+
34
+ return false;
35
+ };
36
+
37
+ Rule.getDefaultAttrs = () => {
38
+ return {
39
+ allowWhenDynamic: true
40
+ };
41
+ };
12
42
 
13
43
  Rule.getColumnNumber = function(line) {
14
44
  return Math.max(line.indexOf(occurrenceText), 0) + 2;
@@ -32,11 +32,12 @@ const RulePrototype = {
32
32
  },
33
33
 
34
34
  shouldIgnore(templatePath) {
35
- const ignoreArray = this.getConfigs().ignore;
35
+ const ignoreArray = this.getConfigs().ignore;
36
+ const formattedFilePath = templatePath.replaceAll('\\', '/');
36
37
 
37
38
  if (ignoreArray) {
38
39
  return ignoreArray.some( ignore => {
39
- return templatePath.includes(ignore);
40
+ return formattedFilePath.includes(ignore);
40
41
  });
41
42
  }
42
43
 
@@ -613,7 +613,7 @@ const addIndentation = (node, isOpeningTag) => {
613
613
  const fullLeadingContent = content.substring(0, startingPos);
614
614
  const preLineBreakContent = fullLeadingContent.substring(0, fullLeadingContent.lastIndexOf(Constants.EOL) + 1);
615
615
  const fullTrailingContent = content.substring(endingPos);
616
- let nodeIndentation = node.isInSameLineAsParent() && isOpeningTag ? '' : Rule.getIndentation(node.depth - 1);
616
+ const nodeIndentation = node.isInSameLineAsParent() && isOpeningTag ? '' : Rule.getIndentation(node.depth - 1);
617
617
  const attributeOffset = Rule.getAttributeIndentationOffset();
618
618
  const attributeList = node.getAttributeList();
619
619
  let contentResult = '';
@@ -641,21 +641,15 @@ const addIndentation = (node, isOpeningTag) => {
641
641
  } else {
642
642
  contentResult = node.head.trim();
643
643
  }
644
- } else {
645
- const nodeLastChild = node.getLastChild();
646
-
647
- if (nodeLastChild) {
648
- const lastChildLineNumber = nodeLastChild.isContainer() ?
649
- nodeLastChild.getLastChild().getLastLineNumber() :
650
- nodeLastChild.getLastLineNumber();
651
644
 
652
- if (node.tailLineNumber === lastChildLineNumber) {
653
- contentResult = Constants.EOL + nodeIndentation;
654
- nodeIndentation = '';
655
- }
645
+ if (node.isOfType('html_conditional_comment')) {
646
+ contentResult = contentResult
647
+ .split(Constants.EOL)
648
+ .map((line, i) => i > 0 ? nodeIndentation + line : line)
649
+ .join(Constants.EOL);
656
650
  }
657
-
658
- contentResult += node.tail.trim();
651
+ } else {
652
+ contentResult = node.tail.trim();
659
653
  }
660
654
 
661
655
  return preLineBreakContent + nodeIndentation + contentResult + fullTrailingContent;
@@ -59,12 +59,13 @@ const deleteDirectoryRecursively = dirPath => {
59
59
  return false;
60
60
  };
61
61
 
62
- const isIgnored = filePath => {
63
- const config = ConfigUtils.load();
62
+ const shouldBeIgnored = filePath => {
63
+ const config = ConfigUtils.load();
64
+ const formattedFilePath = filePath.replaceAll('\\', '/');
64
65
 
65
- return config.ignore && config.ignore.some( ignoredPath => {
66
- return filePath.indexOf(ignoredPath) >= 0;
67
- });
66
+ return !!(config.ignore && config.ignore.some( ignoredPath => {
67
+ return formattedFilePath.indexOf(ignoredPath) >= 0;
68
+ }));
68
69
  };
69
70
 
70
71
  const fileExists = filePath => fs.existsSync(filePath);
@@ -76,4 +77,4 @@ module.exports.createDirIfDoesNotExist = createDirIfDoesNotExist;
76
77
  module.exports.deleteFile = deleteFile;
77
78
  module.exports.deleteDirectoryRecursively = deleteDirectoryRecursively;
78
79
  module.exports.createClientDir = createClientDir;
79
- module.exports.isIgnored = isIgnored;
80
+ module.exports.shouldBeIgnored = shouldBeIgnored;