isml-linter 5.40.0 → 5.40.1
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 +7 -0
- package/package.json +1 -1
- package/src/isml_tree/ParseUtils.js +19 -2
- package/src/util/ExceptionUtils.js +24 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [5.40.1] - 2022-09-01
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- HTML-element embedded `<isif>` condition scenario;
|
|
7
|
+
- Added mechanism to prevent infinite loops in case of unexpected errors;
|
|
8
|
+
|
|
3
9
|
## [5.40.0] - 2022-02-05
|
|
4
10
|
|
|
5
11
|
### Added
|
|
@@ -1011,6 +1017,7 @@
|
|
|
1011
1017
|
### Added
|
|
1012
1018
|
- Linter is published;
|
|
1013
1019
|
|
|
1020
|
+
[5.40.0]: https://github.com/FabiowQuixada/isml-linter/compare/v5.40.0...v5.40.1
|
|
1014
1021
|
[5.40.0]: https://github.com/FabiowQuixada/isml-linter/compare/v5.39.4...v5.40.0
|
|
1015
1022
|
[5.39.4]: https://github.com/FabiowQuixada/isml-linter/compare/v5.39.3...v5.39.4
|
|
1016
1023
|
[5.39.3]: https://github.com/FabiowQuixada/isml-linter/compare/v5.39.2...v5.39.3
|
package/package.json
CHANGED
|
@@ -132,6 +132,15 @@ const parseNextElement = state => {
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
state.elementList.push(newElement);
|
|
135
|
+
|
|
136
|
+
if (newElement.type === 'htmlTag' && newElement.value.indexOf('<isif') >= 0 && newElement.value.indexOf('</isif') < 0) {
|
|
137
|
+
throw ExceptionUtils.invalidNestedIsifError(
|
|
138
|
+
newElement.tagType,
|
|
139
|
+
newElement.lineNumber,
|
|
140
|
+
newElement.globalPos,
|
|
141
|
+
state.templatePath
|
|
142
|
+
);
|
|
143
|
+
}
|
|
135
144
|
|
|
136
145
|
return newElement;
|
|
137
146
|
};
|
|
@@ -454,13 +463,21 @@ const getNewElement = state => {
|
|
|
454
463
|
|
|
455
464
|
const getElementList = (templateContent, templatePath, isCrlfLineBreak) => {
|
|
456
465
|
|
|
457
|
-
const state
|
|
458
|
-
const elementList
|
|
466
|
+
const state = getInitialState(templateContent, templatePath, isCrlfLineBreak);
|
|
467
|
+
const elementList = state.elementList;
|
|
468
|
+
let previousStateContent = state.remainingShadowContent;
|
|
459
469
|
|
|
460
470
|
do {
|
|
461
471
|
initLoopState(state);
|
|
462
472
|
parseNextElement(state);
|
|
463
473
|
finishLoopState(state);
|
|
474
|
+
|
|
475
|
+
if (previousStateContent.length === state.remainingShadowContent.length) {
|
|
476
|
+
throw ExceptionUtils.unkownError(templatePath);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
previousStateContent = state.remainingShadowContent;
|
|
480
|
+
|
|
464
481
|
} while (state.remainingShadowContent.length > 0);
|
|
465
482
|
|
|
466
483
|
adjustTrailingSpaces(state);
|
|
@@ -5,6 +5,7 @@ const types = {
|
|
|
5
5
|
UNKNOWN_ERROR : 'UNKNOWN_ERROR',
|
|
6
6
|
UNCLOSED_DEPRECATED_ISML_COMMENT : 'UNCLOSED_DEPRECATED_ISML_COMMENT',
|
|
7
7
|
INVALID_TEMPLATE : 'INVALID_TEMPLATE',
|
|
8
|
+
INVALID_NESTED_ISIF : 'INVALID_NESTED_ISIF',
|
|
8
9
|
INVALID_CHARACTER : 'INVALID_CHARACTER',
|
|
9
10
|
RULE_ERROR : 'RULE_ERROR',
|
|
10
11
|
NO_CONFIG : 'NO_CONFIG',
|
|
@@ -99,6 +100,18 @@ const invalidCharacterError = (character, lineNumber, globalPos, length, templat
|
|
|
99
100
|
};
|
|
100
101
|
};
|
|
101
102
|
|
|
103
|
+
const invalidNestedIsifError = (tagType, lineNumber, globalPos, templatePath) => {
|
|
104
|
+
return {
|
|
105
|
+
message : `An error occurred while parsing element "<${tagType}>" in line ${lineNumber}. Try moving the closing character ">" of the "<${tagType}>" element to outside of the "<isif>" condition.`,
|
|
106
|
+
templatePath : templatePath,
|
|
107
|
+
globalPos,
|
|
108
|
+
length : tagType.length,
|
|
109
|
+
lineNumber : lineNumber,
|
|
110
|
+
isCustom : true,
|
|
111
|
+
type : types.INVALID_NESTED_ISIF
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
|
|
102
115
|
const parseError = (elementType, lineNumber, globalPos, length, templatePath) => {
|
|
103
116
|
return {
|
|
104
117
|
message : `An unexpected error happened while parsing element ${elementType} at ${templatePath}:${lineNumber}.`,
|
|
@@ -111,6 +124,15 @@ const parseError = (elementType, lineNumber, globalPos, length, templatePath) =>
|
|
|
111
124
|
};
|
|
112
125
|
};
|
|
113
126
|
|
|
127
|
+
const unkownError = (templatePath) => {
|
|
128
|
+
return {
|
|
129
|
+
message : `An unexpected error happened while parsing template ${templatePath}. Please consider adding it to the ignore list for now.`,
|
|
130
|
+
templatePath : templatePath,
|
|
131
|
+
isCustom : true,
|
|
132
|
+
type : types.UNKNOWN_ERROR
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
|
|
114
136
|
const noConfigError = () => {
|
|
115
137
|
return {
|
|
116
138
|
message : `No configuration found. Please run the following command: ${Constants.EOL}${Constants.EOL}\t./node_modules/.bin/isml-linter --init${Constants.EOL}${Constants.EOL}`,
|
|
@@ -137,6 +159,8 @@ module.exports = {
|
|
|
137
159
|
parseError,
|
|
138
160
|
unbalancedQuotesError,
|
|
139
161
|
ruleApplianceError,
|
|
162
|
+
unkownError,
|
|
163
|
+
invalidNestedIsifError,
|
|
140
164
|
unclosedDeprecatedIsmlComment,
|
|
141
165
|
unbalancedElementError,
|
|
142
166
|
unexpectedClosingElementError,
|