isml-linter 5.39.3 → 5.39.4

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 +1167 -1159
  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 +684 -684
  15. package/src/isml_tree/MaskUtils.js +421 -421
  16. package/src/isml_tree/ParseUtils.js +514 -506
  17. package/src/isml_tree/TreeBuilder.js +273 -273
  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 +853 -853
  42. package/src/rules/tree/leading-iscache.js +39 -39
  43. package/src/rules/tree/leading-iscontent.js +35 -35
  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 +76 -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 -149
  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,53 +1,53 @@
1
- const SingleLineRulePrototype = require('../prototypes/SingleLineRulePrototype');
2
- const ParseUtils = require('../../isml_tree/ParseUtils');
3
-
4
- const ruleId = require('path').basename(__filename).slice(0, -3);
5
- const description = 'Wrap expression in <isprint> tag';
6
-
7
- const Rule = Object.create(SingleLineRulePrototype);
8
-
9
- Rule.init(ruleId, description);
10
-
11
- Rule.isBroken = function(line) {
12
- return (line.indexOf('>${') >= 0 ||
13
- line.indexOf(' ${') >= 0 ||
14
- line.indexOf('"${') >= 0) &&
15
- line.indexOf('<isprint value="${') === -1 ||
16
- line.indexOf('${') === 0;
17
- };
18
-
19
- Rule.getColumnNumber = function(line) {
20
- return Math.max(ParseUtils.getNextNonEmptyCharPos(line), 0) + 1;
21
- };
22
-
23
- Rule.getFirstOccurrence = function(line) {
24
-
25
- let result = null;
26
-
27
- if (this.isBroken(line)) {
28
-
29
- let matchPos = -1;
30
-
31
- if (line.indexOf('>${') >= 0) {
32
- matchPos = line.indexOf('>${') + 1;
33
- } else if (line.indexOf(' ${') >= 0) {
34
- matchPos = line.indexOf(' ${') + 1;
35
- } else if (line.indexOf('"${') >= 0 && line.indexOf('<isprint value="${') === -1) {
36
- matchPos = line.indexOf('"${') + 1;
37
- } else if (line.indexOf('${') === 0) {
38
- matchPos = 0;
39
- }
40
-
41
- const temp = line.substring(matchPos);
42
-
43
- result = {
44
- globalPos : matchPos,
45
- columnNumber: 'aa',
46
- length : temp.indexOf('}') + 1
47
- };
48
- }
49
-
50
- return result;
51
- };
52
-
53
- module.exports = Rule;
1
+ const SingleLineRulePrototype = require('../prototypes/SingleLineRulePrototype');
2
+ const ParseUtils = require('../../isml_tree/ParseUtils');
3
+
4
+ const ruleId = require('path').basename(__filename).slice(0, -3);
5
+ const description = 'Wrap expression in <isprint> tag';
6
+
7
+ const Rule = Object.create(SingleLineRulePrototype);
8
+
9
+ Rule.init(ruleId, description);
10
+
11
+ Rule.isBroken = function(line) {
12
+ return (line.indexOf('>${') >= 0 ||
13
+ line.indexOf(' ${') >= 0 ||
14
+ line.indexOf('"${') >= 0) &&
15
+ line.indexOf('<isprint value="${') === -1 ||
16
+ line.indexOf('${') === 0;
17
+ };
18
+
19
+ Rule.getColumnNumber = function(line) {
20
+ return Math.max(ParseUtils.getNextNonEmptyCharPos(line), 0) + 1;
21
+ };
22
+
23
+ Rule.getFirstOccurrence = function(line) {
24
+
25
+ let result = null;
26
+
27
+ if (this.isBroken(line)) {
28
+
29
+ let matchPos = -1;
30
+
31
+ if (line.indexOf('>${') >= 0) {
32
+ matchPos = line.indexOf('>${') + 1;
33
+ } else if (line.indexOf(' ${') >= 0) {
34
+ matchPos = line.indexOf(' ${') + 1;
35
+ } else if (line.indexOf('"${') >= 0 && line.indexOf('<isprint value="${') === -1) {
36
+ matchPos = line.indexOf('"${') + 1;
37
+ } else if (line.indexOf('${') === 0) {
38
+ matchPos = 0;
39
+ }
40
+
41
+ const temp = line.substring(matchPos);
42
+
43
+ result = {
44
+ globalPos : matchPos,
45
+ columnNumber: 'aa',
46
+ length : temp.indexOf('}') + 1
47
+ };
48
+ }
49
+
50
+ return result;
51
+ };
52
+
53
+ module.exports = Rule;
@@ -1,35 +1,35 @@
1
- const SingleLineRulePrototype = require('../prototypes/SingleLineRulePrototype');
2
-
3
- const ruleId = require('path').basename(__filename).slice(0, -3);
4
- const description = 'Avoid direct call to the "dw" package, use "require()" instead';
5
- const regex = /dw\.[A-Za-z]+\.[A-Za-z]+(\.|;)/;
6
-
7
- const Rule = Object.create(SingleLineRulePrototype);
8
-
9
- Rule.init(ruleId, description);
10
-
11
- Rule.isBroken = function(line) { return line.match(regex); };
12
-
13
- Rule.getColumnNumber = function(line) {
14
- return Math.max(line.indexOf('dw.'), 0) + 1;
15
- };
16
-
17
- Rule.getFirstOccurrence = function(line) {
18
-
19
- let result = null;
20
-
21
- if (this.isBroken(line)) {
22
-
23
- const temp = regex.exec(line);
24
- const matchPos = temp.index;
25
-
26
- result = {
27
- globalPos : matchPos,
28
- length : temp[0].length - 1
29
- };
30
- }
31
-
32
- return result;
33
- };
34
-
35
- module.exports = Rule;
1
+ const SingleLineRulePrototype = require('../prototypes/SingleLineRulePrototype');
2
+
3
+ const ruleId = require('path').basename(__filename).slice(0, -3);
4
+ const description = 'Avoid direct call to the "dw" package, use "require()" instead';
5
+ const regex = /dw\.[A-Za-z]+\.[A-Za-z]+(\.|;)/;
6
+
7
+ const Rule = Object.create(SingleLineRulePrototype);
8
+
9
+ Rule.init(ruleId, description);
10
+
11
+ Rule.isBroken = function(line) { return line.match(regex); };
12
+
13
+ Rule.getColumnNumber = function(line) {
14
+ return Math.max(line.indexOf('dw.'), 0) + 1;
15
+ };
16
+
17
+ Rule.getFirstOccurrence = function(line) {
18
+
19
+ let result = null;
20
+
21
+ if (this.isBroken(line)) {
22
+
23
+ const temp = regex.exec(line);
24
+ const matchPos = temp.index;
25
+
26
+ result = {
27
+ globalPos : matchPos,
28
+ length : temp[0].length - 1
29
+ };
30
+ }
31
+
32
+ return result;
33
+ };
34
+
35
+ module.exports = Rule;
@@ -1,29 +1,29 @@
1
- const SingleLineRulePrototype = require('../prototypes/SingleLineRulePrototype');
2
-
3
- const ruleId = require('path').basename(__filename).slice(0, -3);
4
- const description = 'Template file name must be lowercase';
5
-
6
- const Rule = Object.create(SingleLineRulePrototype);
7
-
8
- Rule.init(ruleId, description);
9
-
10
- Rule.isBroken = function(fileName) { return fileName !== fileName.toLowerCase(); };
11
-
12
- Rule.getColumnNumber = function() {
13
- return 1;
14
- };
15
-
16
- Rule.check = function(fileName, templateContent) {
17
- const result = {
18
- occurrenceList : []
19
- };
20
-
21
- if (this.isBroken(fileName)) {
22
- const error = this.getError('', 0, -1, 0, templateContent.length);
23
- result.occurrenceList.push(error);
24
- }
25
-
26
- return result;
27
- };
28
-
29
- module.exports = Rule;
1
+ const SingleLineRulePrototype = require('../prototypes/SingleLineRulePrototype');
2
+
3
+ const ruleId = require('path').basename(__filename).slice(0, -3);
4
+ const description = 'Template file name must be lowercase';
5
+
6
+ const Rule = Object.create(SingleLineRulePrototype);
7
+
8
+ Rule.init(ruleId, description);
9
+
10
+ Rule.isBroken = function(fileName) { return fileName !== fileName.toLowerCase(); };
11
+
12
+ Rule.getColumnNumber = function() {
13
+ return 1;
14
+ };
15
+
16
+ Rule.check = function(fileName, templateContent) {
17
+ const result = {
18
+ occurrenceList : []
19
+ };
20
+
21
+ if (this.isBroken(fileName)) {
22
+ const error = this.getError('', 0, -1, 0, templateContent.length);
23
+ result.occurrenceList.push(error);
24
+ }
25
+
26
+ return result;
27
+ };
28
+
29
+ module.exports = Rule;
@@ -1,37 +1,37 @@
1
- const SingleLineRulePrototype = require('../prototypes/SingleLineRulePrototype');
2
- const Constants = require('../../Constants');
3
- const GeneralUtils = require('../../util/GeneralUtils');
4
-
5
- const ruleId = require('path').basename(__filename).slice(0, -3);
6
- const description = 'Template has more lines than allowed';
7
-
8
- const Rule = Object.create(SingleLineRulePrototype);
9
-
10
- Rule.getDefaultAttrs = () => {
11
- return {
12
- max : 350
13
- };
14
- };
15
-
16
- Rule.init(ruleId, description);
17
-
18
- Rule.getColumnNumber = function() {
19
- return 1;
20
- };
21
-
22
- Rule.check = function(templateContent) {
23
-
24
- const maxLines = this.getConfigs().max;
25
- const lineArray = GeneralUtils.toLF(templateContent).split(Constants.EOL);
26
- const columnNumber = this.getColumnNumber();
27
- const occurrenceList = [];
28
-
29
- if (lineArray.length > maxLines) {
30
- const error = this.getError(lineArray[0], 1, columnNumber, 0, 0);
31
- occurrenceList.push(error);
32
- }
33
-
34
- return { occurrenceList };
35
- };
36
-
37
- module.exports = Rule;
1
+ const SingleLineRulePrototype = require('../prototypes/SingleLineRulePrototype');
2
+ const Constants = require('../../Constants');
3
+ const GeneralUtils = require('../../util/GeneralUtils');
4
+
5
+ const ruleId = require('path').basename(__filename).slice(0, -3);
6
+ const description = 'Template has more lines than allowed';
7
+
8
+ const Rule = Object.create(SingleLineRulePrototype);
9
+
10
+ Rule.getDefaultAttrs = () => {
11
+ return {
12
+ max : 350
13
+ };
14
+ };
15
+
16
+ Rule.init(ruleId, description);
17
+
18
+ Rule.getColumnNumber = function() {
19
+ return 1;
20
+ };
21
+
22
+ Rule.check = function(templateContent) {
23
+
24
+ const maxLines = this.getConfigs().max;
25
+ const lineArray = GeneralUtils.toLF(templateContent).split(Constants.EOL);
26
+ const columnNumber = this.getColumnNumber();
27
+ const occurrenceList = [];
28
+
29
+ if (lineArray.length > maxLines) {
30
+ const error = this.getError(lineArray[0], 1, columnNumber, 0, 0);
31
+ occurrenceList.push(error);
32
+ }
33
+
34
+ return { occurrenceList };
35
+ };
36
+
37
+ module.exports = Rule;
@@ -1,36 +1,36 @@
1
- const SingleLineRulePrototype = require('../prototypes/SingleLineRulePrototype');
2
-
3
- const ruleId = require('path').basename(__filename).slice(0, -3);
4
- const description = 'Avoid using <br/> tags, use css instead';
5
- const occurrenceText = '<br';
6
-
7
- const Rule = Object.create(SingleLineRulePrototype);
8
-
9
- Rule.init(ruleId, description);
10
-
11
- Rule.isBroken = function(line) { return line.indexOf(occurrenceText) >= 0; };
12
-
13
- Rule.getColumnNumber = function(line) {
14
- return Math.max(line.indexOf('<br'), 0) + 1;
15
- };
16
-
17
- Rule.getFirstOccurrence = function(line) {
18
-
19
- let result = null;
20
-
21
- if (this.isBroken(line)) {
22
-
23
- const matchPos = line.indexOf(occurrenceText);
24
- const temp = line.substring(line.indexOf(occurrenceText));
25
- const matchLength = temp.indexOf('>') + 1;
26
-
27
- result = {
28
- globalPos : matchPos,
29
- length : matchLength
30
- };
31
- }
32
-
33
- return result;
34
- };
35
-
36
- module.exports = Rule;
1
+ const SingleLineRulePrototype = require('../prototypes/SingleLineRulePrototype');
2
+
3
+ const ruleId = require('path').basename(__filename).slice(0, -3);
4
+ const description = 'Avoid using <br/> tags, use css instead';
5
+ const occurrenceText = '<br';
6
+
7
+ const Rule = Object.create(SingleLineRulePrototype);
8
+
9
+ Rule.init(ruleId, description);
10
+
11
+ Rule.isBroken = function(line) { return line.indexOf(occurrenceText) >= 0; };
12
+
13
+ Rule.getColumnNumber = function(line) {
14
+ return Math.max(line.indexOf('<br'), 0) + 1;
15
+ };
16
+
17
+ Rule.getFirstOccurrence = function(line) {
18
+
19
+ let result = null;
20
+
21
+ if (this.isBroken(line)) {
22
+
23
+ const matchPos = line.indexOf(occurrenceText);
24
+ const temp = line.substring(line.indexOf(occurrenceText));
25
+ const matchLength = temp.indexOf('>') + 1;
26
+
27
+ result = {
28
+ globalPos : matchPos,
29
+ length : matchLength
30
+ };
31
+ }
32
+
33
+ return result;
34
+ };
35
+
36
+ module.exports = Rule;
@@ -1,43 +1,43 @@
1
- const SingleLineRulePrototype = require('../prototypes/SingleLineRulePrototype');
2
-
3
- const ruleId = require('path').basename(__filename).slice(0, -3);
4
- const description = 'Unresolved Git conflict';
5
- const occurrenceText1 = '<<<<<<< HEAD';
6
- const occurrenceText2 = '=======';
7
-
8
- const Rule = Object.create(SingleLineRulePrototype);
9
-
10
- Rule.init(ruleId, description);
11
-
12
- Rule.isBroken = function(line) { return line === occurrenceText1 || line === occurrenceText2; };
13
-
14
- Rule.getColumnNumber = function() {
15
- return 1;
16
- };
17
-
18
- Rule.getFirstOccurrence = function(line) {
19
-
20
- let result = null;
21
-
22
- if (this.isBroken(line)) {
23
-
24
- let occurrenceText = null;
25
-
26
- if (line === occurrenceText1) {
27
- occurrenceText = occurrenceText1;
28
- } else if (line === occurrenceText2) {
29
- occurrenceText = occurrenceText2;
30
- }
31
-
32
- const matchPos = line.indexOf(occurrenceText);
33
-
34
- result = {
35
- globalPos : matchPos,
36
- length : occurrenceText.length
37
- };
38
- }
39
-
40
- return result;
41
- };
42
-
43
- module.exports = Rule;
1
+ const SingleLineRulePrototype = require('../prototypes/SingleLineRulePrototype');
2
+
3
+ const ruleId = require('path').basename(__filename).slice(0, -3);
4
+ const description = 'Unresolved Git conflict';
5
+ const occurrenceText1 = '<<<<<<< HEAD';
6
+ const occurrenceText2 = '=======';
7
+
8
+ const Rule = Object.create(SingleLineRulePrototype);
9
+
10
+ Rule.init(ruleId, description);
11
+
12
+ Rule.isBroken = function(line) { return line === occurrenceText1 || line === occurrenceText2; };
13
+
14
+ Rule.getColumnNumber = function() {
15
+ return 1;
16
+ };
17
+
18
+ Rule.getFirstOccurrence = function(line) {
19
+
20
+ let result = null;
21
+
22
+ if (this.isBroken(line)) {
23
+
24
+ let occurrenceText = null;
25
+
26
+ if (line === occurrenceText1) {
27
+ occurrenceText = occurrenceText1;
28
+ } else if (line === occurrenceText2) {
29
+ occurrenceText = occurrenceText2;
30
+ }
31
+
32
+ const matchPos = line.indexOf(occurrenceText);
33
+
34
+ result = {
35
+ globalPos : matchPos,
36
+ length : occurrenceText.length
37
+ };
38
+ }
39
+
40
+ return result;
41
+ };
42
+
43
+ module.exports = Rule;
@@ -1,34 +1,34 @@
1
- const SingleLineRulePrototype = require('../prototypes/SingleLineRulePrototype');
2
-
3
- const ruleId = require('path').basename(__filename).slice(0, -3);
4
- const description = 'Avoid using importPackage()';
5
- const occurrenceText = 'importPackage';
6
-
7
- const Rule = Object.create(SingleLineRulePrototype);
8
-
9
- Rule.init(ruleId, description);
10
-
11
- Rule.isBroken = function(line) { return line.indexOf(occurrenceText) >= 0; };
12
-
13
- Rule.getColumnNumber = function(line) {
14
- return Math.max(line.indexOf('importPackage('), 0) + 1;
15
- };
16
-
17
- Rule.getFirstOccurrence = function(line) {
18
-
19
- let result = null;
20
-
21
- if (this.isBroken(line)) {
22
-
23
- const matchPos = line.indexOf(occurrenceText);
24
-
25
- result = {
26
- globalPos : matchPos,
27
- length : occurrenceText.length
28
- };
29
- }
30
-
31
- return result;
32
- };
33
-
34
- module.exports = Rule;
1
+ const SingleLineRulePrototype = require('../prototypes/SingleLineRulePrototype');
2
+
3
+ const ruleId = require('path').basename(__filename).slice(0, -3);
4
+ const description = 'Avoid using importPackage()';
5
+ const occurrenceText = 'importPackage';
6
+
7
+ const Rule = Object.create(SingleLineRulePrototype);
8
+
9
+ Rule.init(ruleId, description);
10
+
11
+ Rule.isBroken = function(line) { return line.indexOf(occurrenceText) >= 0; };
12
+
13
+ Rule.getColumnNumber = function(line) {
14
+ return Math.max(line.indexOf('importPackage('), 0) + 1;
15
+ };
16
+
17
+ Rule.getFirstOccurrence = function(line) {
18
+
19
+ let result = null;
20
+
21
+ if (this.isBroken(line)) {
22
+
23
+ const matchPos = line.indexOf(occurrenceText);
24
+
25
+ result = {
26
+ globalPos : matchPos,
27
+ length : occurrenceText.length
28
+ };
29
+ }
30
+
31
+ return result;
32
+ };
33
+
34
+ module.exports = Rule;
@@ -1,34 +1,34 @@
1
- const SingleLineRulePrototype = require('../prototypes/SingleLineRulePrototype');
2
-
3
- const ruleId = require('path').basename(__filename).slice(0, -3);
4
- const description = 'Avoid using inline style';
5
- const occurrenceText = 'style="';
6
-
7
- const Rule = Object.create(SingleLineRulePrototype);
8
-
9
- Rule.init(ruleId, description);
10
-
11
- Rule.isBroken = function(line) { return line.indexOf('<isprint') === -1 && line.indexOf(occurrenceText) >= 0; };
12
-
13
- Rule.getColumnNumber = function(line) {
14
- return Math.max(line.indexOf(occurrenceText), 0) + 1;
15
- };
16
-
17
- Rule.getFirstOccurrence = function(line) {
18
-
19
- let result = null;
20
-
21
- if (this.isBroken(line)) {
22
-
23
- const matchPos = line.indexOf(occurrenceText);
24
-
25
- result = {
26
- globalPos : matchPos,
27
- length : occurrenceText.length - 2
28
- };
29
- }
30
-
31
- return result;
32
- };
33
-
34
- module.exports = Rule;
1
+ const SingleLineRulePrototype = require('../prototypes/SingleLineRulePrototype');
2
+
3
+ const ruleId = require('path').basename(__filename).slice(0, -3);
4
+ const description = 'Avoid using inline style';
5
+ const occurrenceText = 'style="';
6
+
7
+ const Rule = Object.create(SingleLineRulePrototype);
8
+
9
+ Rule.init(ruleId, description);
10
+
11
+ Rule.isBroken = function(line) { return line.indexOf('<isprint') === -1 && line.indexOf(occurrenceText) >= 0; };
12
+
13
+ Rule.getColumnNumber = function(line) {
14
+ return Math.max(line.indexOf(occurrenceText), 0) + 1;
15
+ };
16
+
17
+ Rule.getFirstOccurrence = function(line) {
18
+
19
+ let result = null;
20
+
21
+ if (this.isBroken(line)) {
22
+
23
+ const matchPos = line.indexOf(occurrenceText);
24
+
25
+ result = {
26
+ globalPos : matchPos,
27
+ length : occurrenceText.length - 2
28
+ };
29
+ }
30
+
31
+ return result;
32
+ };
33
+
34
+ module.exports = Rule;