isml-linter 5.39.1 → 5.40.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.
Files changed (61) hide show
  1. package/CHANGELOG.md +1177 -1142
  2. package/LICENSE +21 -21
  3. package/README.md +245 -245
  4. package/bin/isml-linter.js +32 -32
  5. package/ismllinter.config.js +33 -33
  6. package/package.json +53 -53
  7. package/scaffold_files/ismllinter.config.js +47 -47
  8. package/src/Builder.js +15 -15
  9. package/src/Constants.js +139 -139
  10. package/src/IsmlLinter.js +255 -255
  11. package/src/enums/ParseStatus.js +5 -5
  12. package/src/enums/SfccTagContainer.js +287 -287
  13. package/src/isml_tree/ContainerNode.js +38 -38
  14. package/src/isml_tree/IsmlNode.js +692 -658
  15. package/src/isml_tree/MaskUtils.js +421 -419
  16. package/src/isml_tree/ParseUtils.js +515 -434
  17. package/src/isml_tree/TreeBuilder.js +273 -271
  18. package/src/publicApi.js +24 -24
  19. package/src/rules/line_by_line/enforce-isprint.js +53 -53
  20. package/src/rules/line_by_line/enforce-require.js +35 -35
  21. package/src/rules/line_by_line/lowercase-filename.js +29 -29
  22. package/src/rules/line_by_line/max-lines.js +37 -37
  23. package/src/rules/line_by_line/no-br.js +36 -36
  24. package/src/rules/line_by_line/no-git-conflict.js +43 -43
  25. package/src/rules/line_by_line/no-import-package.js +34 -34
  26. package/src/rules/line_by_line/no-inline-style.js +34 -34
  27. package/src/rules/line_by_line/no-isscript.js +34 -34
  28. package/src/rules/line_by_line/no-space-only-lines.js +47 -47
  29. package/src/rules/line_by_line/no-tabs.js +38 -38
  30. package/src/rules/line_by_line/no-trailing-spaces.js +52 -52
  31. package/src/rules/prototypes/RulePrototype.js +79 -79
  32. package/src/rules/prototypes/SingleLineRulePrototype.js +47 -47
  33. package/src/rules/prototypes/TreeRulePrototype.js +84 -84
  34. package/src/rules/tree/align-isset.js +87 -87
  35. package/src/rules/tree/contextual-attrs.js +105 -105
  36. package/src/rules/tree/custom-tags.js +54 -54
  37. package/src/rules/tree/disallow-tags.js +39 -39
  38. package/src/rules/tree/empty-eof.js +66 -66
  39. package/src/rules/tree/enforce-security.js +85 -85
  40. package/src/rules/tree/eslint-to-isscript.js +179 -179
  41. package/src/rules/tree/indent.js +856 -853
  42. package/src/rules/tree/leading-iscache.js +39 -43
  43. package/src/rules/tree/leading-iscontent.js +35 -39
  44. package/src/rules/tree/max-depth.js +54 -54
  45. package/src/rules/tree/no-deprecated-attrs.js +67 -67
  46. package/src/rules/tree/no-embedded-isml.js +17 -17
  47. package/src/rules/tree/no-hardcode.js +51 -51
  48. package/src/rules/tree/no-iselse-slash.js +35 -35
  49. package/src/rules/tree/no-redundant-context.js +134 -134
  50. package/src/rules/tree/no-require-in-loop.js +63 -63
  51. package/src/rules/tree/one-element-per-line.js +82 -76
  52. package/src/util/CommandLineUtils.js +19 -19
  53. package/src/util/ConfigUtils.js +219 -219
  54. package/src/util/ConsoleUtils.js +327 -327
  55. package/src/util/CustomTagContainer.js +45 -45
  56. package/src/util/ExceptionUtils.js +149 -136
  57. package/src/util/FileUtils.js +79 -79
  58. package/src/util/GeneralUtils.js +60 -60
  59. package/src/util/NativeExtensionUtils.js +6 -6
  60. package/src/util/RuleUtils.js +295 -295
  61. package/src/util/TempRuleUtils.js +232 -232
@@ -1,43 +1,39 @@
1
- const TreeRulePrototype = require('../prototypes/TreeRulePrototype');
2
- const RuleUtils = require('../../util/TempRuleUtils');
3
- const Constants = require('../../Constants');
4
- const GeneralUtils = require('../../util/GeneralUtils');
5
-
6
- const TAG_TYPE = 'iscache';
7
- const ruleId = require('path').basename(__filename).slice(0, -3);
8
- const description = `<${TAG_TYPE}> tag should be on top of the template`;
9
-
10
- const Rule = Object.create(TreeRulePrototype);
11
-
12
- Rule.init(ruleId, description);
13
-
14
- Rule.isBroken = function(node) {
15
- let rootNode = node;
16
-
17
- while (rootNode.parent) {
18
- rootNode = rootNode.parent;
19
- }
20
-
21
- const isFirstNode = rootNode.children[0] && rootNode.children[0].isOfType(TAG_TYPE);
22
- const isAfterIscontentNode = rootNode.children[0] && rootNode.children[0].isOfType('iscontent') &&
23
- rootNode.children[1] && rootNode.children[1].isOfType(TAG_TYPE);
24
-
25
- return node.isOfType(TAG_TYPE) &&
26
- (!isFirstNode && !isAfterIscontentNode);
27
- };
28
-
29
- Rule.getFixedContent = function(rootNode) {
30
- if (!RuleUtils.isTypeAmongTheFirstElements(rootNode, TAG_TYPE)) {
31
- const isContentNode = RuleUtils.findNodeOfType(rootNode, TAG_TYPE);
32
-
33
- if (isContentNode) {
34
- isContentNode.parent.removeChild(isContentNode);
35
- isContentNode.head = isContentNode.head.trim() + Constants.EOL;
36
- rootNode.addChildNodeToPos(isContentNode, 0);
37
- }
38
- }
39
-
40
- return GeneralUtils.applyActiveLineBreaks(rootNode.toString());
41
- };
42
-
43
- module.exports = Rule;
1
+ const TreeRulePrototype = require('../prototypes/TreeRulePrototype');
2
+ const RuleUtils = require('../../util/TempRuleUtils');
3
+ const Constants = require('../../Constants');
4
+ const GeneralUtils = require('../../util/GeneralUtils');
5
+
6
+ const TAG_TYPE = 'iscache';
7
+ const ruleId = require('path').basename(__filename).slice(0, -3);
8
+ const description = `<${TAG_TYPE}> tag should be on top of the template`;
9
+
10
+ const Rule = Object.create(TreeRulePrototype);
11
+
12
+ Rule.init(ruleId, description);
13
+
14
+ Rule.isBroken = function(node) {
15
+ const rootNode = node.getRoot();
16
+
17
+ const isFirstNode = rootNode.children[0] && rootNode.children[0].isOfType(TAG_TYPE);
18
+ const isAfterIscontentNode = rootNode.children[0] && rootNode.children[0].isOfType('iscontent') &&
19
+ rootNode.children[1] && rootNode.children[1].isOfType(TAG_TYPE);
20
+
21
+ return node.isOfType(TAG_TYPE) &&
22
+ (!isFirstNode && !isAfterIscontentNode);
23
+ };
24
+
25
+ Rule.getFixedContent = function(rootNode) {
26
+ if (!RuleUtils.isTypeAmongTheFirstElements(rootNode, TAG_TYPE)) {
27
+ const isContentNode = RuleUtils.findNodeOfType(rootNode, TAG_TYPE);
28
+
29
+ if (isContentNode) {
30
+ isContentNode.parent.removeChild(isContentNode);
31
+ isContentNode.head = isContentNode.head.trim() + Constants.EOL;
32
+ rootNode.addChildNodeToPos(isContentNode, 0);
33
+ }
34
+ }
35
+
36
+ return GeneralUtils.applyActiveLineBreaks(rootNode.toString());
37
+ };
38
+
39
+ module.exports = Rule;
@@ -1,39 +1,35 @@
1
- const TreeRulePrototype = require('../prototypes/TreeRulePrototype');
2
- const Constants = require('../../Constants');
3
- const RuleUtils = require('../../util/TempRuleUtils');
4
- const GeneralUtils = require('../../util/GeneralUtils');
5
-
6
- const TAG_TYPE = 'iscontent';
7
- const ruleId = require('path').basename(__filename).slice(0, -3);
8
- const description = `<${TAG_TYPE}> tag should be the first in the template`;
9
-
10
- const Rule = Object.create(TreeRulePrototype);
11
-
12
- Rule.init(ruleId, description);
13
-
14
- Rule.isBroken = function(node) {
15
- let rootNode = node;
16
-
17
- while (rootNode.parent) {
18
- rootNode = rootNode.parent;
19
- }
20
-
21
- return node.isOfType(TAG_TYPE) &&
22
- rootNode.children[0].id !== node.id;
23
- };
24
-
25
- Rule.getFixedContent = function(rootNode) {
26
- if (!RuleUtils.isTypeAmongTheFirstElements(rootNode, TAG_TYPE)) {
27
- const isContentNode = RuleUtils.findNodeOfType(rootNode, TAG_TYPE);
28
-
29
- if (isContentNode) {
30
- isContentNode.parent.removeChild(isContentNode);
31
- isContentNode.head = isContentNode.head.trim() + Constants.EOL;
32
- rootNode.addChildNodeToPos(isContentNode, 0);
33
- }
34
- }
35
-
36
- return GeneralUtils.applyActiveLineBreaks(rootNode.toString());
37
- };
38
-
39
- module.exports = Rule;
1
+ const TreeRulePrototype = require('../prototypes/TreeRulePrototype');
2
+ const Constants = require('../../Constants');
3
+ const RuleUtils = require('../../util/TempRuleUtils');
4
+ const GeneralUtils = require('../../util/GeneralUtils');
5
+
6
+ const TAG_TYPE = 'iscontent';
7
+ const ruleId = require('path').basename(__filename).slice(0, -3);
8
+ const description = `<${TAG_TYPE}> tag should be the first in the template`;
9
+
10
+ const Rule = Object.create(TreeRulePrototype);
11
+
12
+ Rule.init(ruleId, description);
13
+
14
+ Rule.isBroken = function(node) {
15
+ const rootNode = node.getRoot();
16
+
17
+ return node.isOfType(TAG_TYPE) &&
18
+ rootNode.children[0].id !== node.id;
19
+ };
20
+
21
+ Rule.getFixedContent = function(rootNode) {
22
+ if (!RuleUtils.isTypeAmongTheFirstElements(rootNode, TAG_TYPE)) {
23
+ const isContentNode = RuleUtils.findNodeOfType(rootNode, TAG_TYPE);
24
+
25
+ if (isContentNode) {
26
+ isContentNode.parent.removeChild(isContentNode);
27
+ isContentNode.head = isContentNode.head.trim() + Constants.EOL;
28
+ rootNode.addChildNodeToPos(isContentNode, 0);
29
+ }
30
+ }
31
+
32
+ return GeneralUtils.applyActiveLineBreaks(rootNode.toString());
33
+ };
34
+
35
+ module.exports = Rule;
@@ -1,54 +1,54 @@
1
- const TreeRulePrototype = require('../prototypes/TreeRulePrototype');
2
- const ParseUtils = require('../../isml_tree/ParseUtils');
3
-
4
- const ruleId = require('path').basename(__filename).slice(0, -3);
5
- const description = 'max depth beyond allowed';
6
-
7
- const Rule = Object.create(TreeRulePrototype);
8
-
9
- Rule.init(ruleId, description);
10
-
11
- Rule.getDefaultAttrs = () => {
12
- return {
13
- value : 10
14
- };
15
- };
16
-
17
- Rule.isBroken = function(node) {
18
- const configMaxDepth = this.getConfigs().value;
19
- return !node.isContainer() && !node.isEmpty() && node.depth > configMaxDepth;
20
- };
21
-
22
- Rule.check = function(node, data) {
23
-
24
- const config = this.getConfigs();
25
- const occurrenceList = [];
26
-
27
- if (this.isBroken(node)) {
28
- const stringifiedNode = node.toString().trim();
29
- let length = stringifiedNode.length;
30
-
31
- if (data.isCrlfLineBreak) {
32
- length += ParseUtils.getLineBreakQty(stringifiedNode);
33
- }
34
-
35
- const error = this.getError(
36
- stringifiedNode,
37
- node.lineNumber,
38
- node.columnNumber,
39
- node.globalPos,
40
- length
41
- );
42
-
43
- occurrenceList.push(error);
44
- } else {
45
- for (let i = 0; i < node.children.length; i++) {
46
- const childrenResult = this.check(node.children[i], data);
47
- occurrenceList.push(...childrenResult);
48
- }
49
- }
50
-
51
- return this.return(node, occurrenceList, config);
52
- };
53
-
54
- module.exports = Rule;
1
+ const TreeRulePrototype = require('../prototypes/TreeRulePrototype');
2
+ const ParseUtils = require('../../isml_tree/ParseUtils');
3
+
4
+ const ruleId = require('path').basename(__filename).slice(0, -3);
5
+ const description = 'max depth beyond allowed';
6
+
7
+ const Rule = Object.create(TreeRulePrototype);
8
+
9
+ Rule.init(ruleId, description);
10
+
11
+ Rule.getDefaultAttrs = () => {
12
+ return {
13
+ value : 10
14
+ };
15
+ };
16
+
17
+ Rule.isBroken = function(node) {
18
+ const configMaxDepth = this.getConfigs().value;
19
+ return !node.isContainer() && !node.isEmpty() && node.depth > configMaxDepth;
20
+ };
21
+
22
+ Rule.check = function(node, data) {
23
+
24
+ const config = this.getConfigs();
25
+ const occurrenceList = [];
26
+
27
+ if (this.isBroken(node)) {
28
+ const stringifiedNode = node.toString().trim();
29
+ let length = stringifiedNode.length;
30
+
31
+ if (data.isCrlfLineBreak) {
32
+ length += ParseUtils.getLineBreakQty(stringifiedNode);
33
+ }
34
+
35
+ const error = this.getError(
36
+ stringifiedNode,
37
+ node.lineNumber,
38
+ node.columnNumber,
39
+ node.globalPos,
40
+ length
41
+ );
42
+
43
+ occurrenceList.push(error);
44
+ } else {
45
+ for (let i = 0; i < node.children.length; i++) {
46
+ const childrenResult = this.check(node.children[i], data);
47
+ occurrenceList.push(...childrenResult);
48
+ }
49
+ }
50
+
51
+ return this.return(node, occurrenceList, config);
52
+ };
53
+
54
+ module.exports = Rule;
@@ -1,67 +1,67 @@
1
- const TreeRulePrototype = require('../prototypes/TreeRulePrototype');
2
- const SfccTagContainer = require('../../enums/SfccTagContainer');
3
-
4
- const ruleId = require('path').basename(__filename).slice(0, -3);
5
- const description = 'Attribute label or value is deprecated';
6
-
7
- const Rule = Object.create(TreeRulePrototype);
8
-
9
- Rule.init(ruleId, description);
10
-
11
- Rule.isBroken = function(node) {
12
- if (!node.isIsmlTag()) {
13
- return false;
14
- }
15
-
16
- const attrList = node.getAttributeList();
17
- const nodeType = node.getType();
18
- const obj = SfccTagContainer[nodeType];
19
- let result = null;
20
-
21
- if (node.isStandardIsmlTag()) {
22
- attrList.some( nodeAttribute => {
23
- for (const sfccAttr in obj.attributes) {
24
- if (Object.prototype.hasOwnProperty.call(obj.attributes, sfccAttr) && nodeAttribute.name === sfccAttr) {
25
- const attr = obj.attributes[sfccAttr];
26
- const isValueDeprecated = attr.deprecatedValues &&
27
- attr.deprecatedValues.indexOf(nodeAttribute.value) >= 0;
28
-
29
- if (isValueDeprecated) {
30
- result = nodeAttribute;
31
- result.message = `"${nodeAttribute.value}" value is deprecated for "${nodeAttribute.name}" attribute`;
32
- return true;
33
- }
34
- }
35
- }
36
-
37
- return false;
38
- });
39
- }
40
-
41
- return result;
42
- };
43
-
44
- Rule.check = function(node, data) {
45
-
46
- const occurrenceList = this.checkChildren(node, data);
47
-
48
- const occurrence = this.isBroken(node);
49
- if (occurrence) {
50
- const error = this.getError(
51
- node.head.trim(),
52
- node.lineNumber,
53
- node.columnNumber + node.head.trim().indexOf(occurrence.fullContent),
54
- occurrence.attrGlobalPos,
55
- occurrence.length,
56
- occurrence.message
57
- );
58
-
59
- occurrenceList.push(error);
60
- }
61
-
62
- return node.isRoot() ?
63
- { occurrenceList } :
64
- occurrenceList;
65
- };
66
-
67
- module.exports = Rule;
1
+ const TreeRulePrototype = require('../prototypes/TreeRulePrototype');
2
+ const SfccTagContainer = require('../../enums/SfccTagContainer');
3
+
4
+ const ruleId = require('path').basename(__filename).slice(0, -3);
5
+ const description = 'Attribute label or value is deprecated';
6
+
7
+ const Rule = Object.create(TreeRulePrototype);
8
+
9
+ Rule.init(ruleId, description);
10
+
11
+ Rule.isBroken = function(node) {
12
+ if (!node.isIsmlTag()) {
13
+ return false;
14
+ }
15
+
16
+ const attrList = node.getAttributeList();
17
+ const nodeType = node.getType();
18
+ const obj = SfccTagContainer[nodeType];
19
+ let result = null;
20
+
21
+ if (node.isStandardIsmlTag()) {
22
+ attrList.some( nodeAttribute => {
23
+ for (const sfccAttr in obj.attributes) {
24
+ if (Object.prototype.hasOwnProperty.call(obj.attributes, sfccAttr) && nodeAttribute.name === sfccAttr) {
25
+ const attr = obj.attributes[sfccAttr];
26
+ const isValueDeprecated = attr.deprecatedValues &&
27
+ attr.deprecatedValues.indexOf(nodeAttribute.value) >= 0;
28
+
29
+ if (isValueDeprecated) {
30
+ result = nodeAttribute;
31
+ result.message = `"${nodeAttribute.value}" value is deprecated for "${nodeAttribute.name}" attribute`;
32
+ return true;
33
+ }
34
+ }
35
+ }
36
+
37
+ return false;
38
+ });
39
+ }
40
+
41
+ return result;
42
+ };
43
+
44
+ Rule.check = function(node, data) {
45
+
46
+ const occurrenceList = this.checkChildren(node, data);
47
+
48
+ const occurrence = this.isBroken(node);
49
+ if (occurrence) {
50
+ const error = this.getError(
51
+ node.head.trim(),
52
+ node.lineNumber,
53
+ node.columnNumber + node.head.trim().indexOf(occurrence.fullContent),
54
+ occurrence.attrGlobalPos,
55
+ occurrence.length,
56
+ occurrence.message
57
+ );
58
+
59
+ occurrenceList.push(error);
60
+ }
61
+
62
+ return node.isRoot() ?
63
+ { occurrenceList } :
64
+ occurrenceList;
65
+ };
66
+
67
+ module.exports = Rule;
@@ -1,17 +1,17 @@
1
- const TreeRulePrototype = require('../prototypes/TreeRulePrototype');
2
-
3
- const ruleId = require('path').basename(__filename).slice(0, -3);
4
- const description = 'Embedded ISML is not allowed';
5
-
6
- const Rule = Object.create(TreeRulePrototype);
7
-
8
- Rule.init(ruleId, description);
9
-
10
- Rule.isBroken = function(node) {
11
- return node.isHtmlTag() &&
12
- !node.isOfType('is') &&
13
- node.head.indexOf('<isprint') === -1 &&
14
- node.head.indexOf('<is') >= 0;
15
- };
16
-
17
- module.exports = Rule;
1
+ const TreeRulePrototype = require('../prototypes/TreeRulePrototype');
2
+
3
+ const ruleId = require('path').basename(__filename).slice(0, -3);
4
+ const description = 'Embedded ISML is not allowed';
5
+
6
+ const Rule = Object.create(TreeRulePrototype);
7
+
8
+ Rule.init(ruleId, description);
9
+
10
+ Rule.isBroken = function(node) {
11
+ return node.isHtmlTag() &&
12
+ !node.isOfType('is') &&
13
+ node.head.indexOf('<isprint') === -1 &&
14
+ node.head.indexOf('<is') >= 0;
15
+ };
16
+
17
+ module.exports = Rule;
@@ -1,51 +1,51 @@
1
- const TreeRulePrototype = require('../prototypes/TreeRulePrototype');
2
-
3
- const ruleId = require('path').basename(__filename).slice(0, -3);
4
- const description = 'Hardcoded string is not allowed';
5
-
6
- const Rule = Object.create(TreeRulePrototype);
7
-
8
- Rule.init(ruleId, description);
9
-
10
- Rule.getDefaultAttrs = () => {
11
- return {
12
- except : [],
13
- allowHtmlEntities : true
14
- };
15
- };
16
-
17
- Rule.isBroken = function(node) {
18
- const ruleExceptionList = this.getConfigs().except;
19
- const allowHtmlEntities = this.getConfigs().allowHtmlEntities;
20
- const isTagContent = isTagChild(node);
21
- const shouldCheckHead = node.isOfType('text') && !node.isExpression() && !isTagContent;
22
- const isTextAnHtmlEntity = node.head.trim().startsWith('&') && node.head.trim().endsWith(';');
23
- let nodeHead = node.head;
24
-
25
- if (!shouldCheckHead) {
26
- return false;
27
- }
28
-
29
- for (let i = 0; i < ruleExceptionList.length; i++) {
30
- const char = ruleExceptionList[i];
31
-
32
- nodeHead = nodeHead.split(char).join('');
33
- }
34
-
35
- if (allowHtmlEntities && isTextAnHtmlEntity) {
36
- return false;
37
- }
38
-
39
- return nodeHead.trim().length > 0;
40
- };
41
-
42
- const isTagChild = node => {
43
- const isCommentContent = node.parent && node.parent.isOfType('iscomment');
44
- const isIsscriptContent = node.parent && node.parent.isOfType('isscript');
45
- const isScriptContent = node.parent && node.parent.isOfType('script');
46
- const isStyleContent = node.parent && node.parent.isOfType('style');
47
-
48
- return isCommentContent || isIsscriptContent || isScriptContent || isStyleContent;
49
- };
50
-
51
- module.exports = Rule;
1
+ const TreeRulePrototype = require('../prototypes/TreeRulePrototype');
2
+
3
+ const ruleId = require('path').basename(__filename).slice(0, -3);
4
+ const description = 'Hardcoded string is not allowed';
5
+
6
+ const Rule = Object.create(TreeRulePrototype);
7
+
8
+ Rule.init(ruleId, description);
9
+
10
+ Rule.getDefaultAttrs = () => {
11
+ return {
12
+ except : [],
13
+ allowHtmlEntities : true
14
+ };
15
+ };
16
+
17
+ Rule.isBroken = function(node) {
18
+ const ruleExceptionList = this.getConfigs().except;
19
+ const allowHtmlEntities = this.getConfigs().allowHtmlEntities;
20
+ const isTagContent = isTagChild(node);
21
+ const shouldCheckHead = node.isOfType('text') && !node.isExpression() && !isTagContent;
22
+ const isTextAnHtmlEntity = node.head.trim().startsWith('&') && node.head.trim().endsWith(';');
23
+ let nodeHead = node.head;
24
+
25
+ if (!shouldCheckHead) {
26
+ return false;
27
+ }
28
+
29
+ for (let i = 0; i < ruleExceptionList.length; i++) {
30
+ const char = ruleExceptionList[i];
31
+
32
+ nodeHead = nodeHead.split(char).join('');
33
+ }
34
+
35
+ if (allowHtmlEntities && isTextAnHtmlEntity) {
36
+ return false;
37
+ }
38
+
39
+ return nodeHead.trim().length > 0;
40
+ };
41
+
42
+ const isTagChild = node => {
43
+ const isCommentContent = node.isDescendantOf('iscomment');
44
+ const isIsscriptContent = node.isDescendantOf('isscript');
45
+ const isScriptContent = node.isDescendantOf('script');
46
+ const isStyleContent = node.isDescendantOf('style');
47
+
48
+ return isCommentContent || isIsscriptContent || isScriptContent || isStyleContent;
49
+ };
50
+
51
+ module.exports = Rule;
@@ -1,35 +1,35 @@
1
- const TreeRulePrototype = require('../prototypes/TreeRulePrototype');
2
- const MaskUtils = require('../../isml_tree/MaskUtils');
3
- const GeneralUtils = require('../../util/GeneralUtils');
4
-
5
- const ruleId = require('path').basename(__filename).slice(0, -3);
6
- const description = 'Slash is not allowed for "iselse" nor "iselseif" tags';
7
-
8
- const Rule = Object.create(TreeRulePrototype);
9
-
10
- Rule.init(ruleId, description);
11
-
12
- Rule.isBroken = function(node) {
13
- return (node.isOfType('iselse') || node.isOfType('iselseif')) &&
14
- node.head.trim().endsWith('/>');
15
- };
16
-
17
- Rule.getFixedContent = function(node) {
18
- for (let i = 0; i < node.children.length; i++) {
19
- const child = node.children[i];
20
-
21
- if (child.isOfType('iselse') || child.isOfType('iselseif')) {
22
- const slashPos = MaskUtils.maskInBetween(child.head, '${', '}').lastIndexOf('/');
23
-
24
- if (slashPos >= 0) {
25
- child.head = child.head.slice(0, slashPos) + child.head.slice(slashPos + 1);
26
- }
27
- }
28
-
29
- this.getFixedContent(child);
30
- }
31
-
32
- return GeneralUtils.applyActiveLineBreaks(node.toString());
33
- };
34
-
35
- module.exports = Rule;
1
+ const TreeRulePrototype = require('../prototypes/TreeRulePrototype');
2
+ const MaskUtils = require('../../isml_tree/MaskUtils');
3
+ const GeneralUtils = require('../../util/GeneralUtils');
4
+
5
+ const ruleId = require('path').basename(__filename).slice(0, -3);
6
+ const description = 'Slash is not allowed for "iselse" nor "iselseif" tags';
7
+
8
+ const Rule = Object.create(TreeRulePrototype);
9
+
10
+ Rule.init(ruleId, description);
11
+
12
+ Rule.isBroken = function(node) {
13
+ return (node.isOfType('iselse') || node.isOfType('iselseif')) &&
14
+ node.head.trim().endsWith('/>');
15
+ };
16
+
17
+ Rule.getFixedContent = function(node) {
18
+ for (let i = 0; i < node.children.length; i++) {
19
+ const child = node.children[i];
20
+
21
+ if (child.isOfType('iselse') || child.isOfType('iselseif')) {
22
+ const slashPos = MaskUtils.maskInBetween(child.head, '${', '}').lastIndexOf('/');
23
+
24
+ if (slashPos >= 0) {
25
+ child.head = child.head.slice(0, slashPos) + child.head.slice(slashPos + 1);
26
+ }
27
+ }
28
+
29
+ this.getFixedContent(child);
30
+ }
31
+
32
+ return GeneralUtils.applyActiveLineBreaks(node.toString());
33
+ };
34
+
35
+ module.exports = Rule;