isml-linter 5.40.0 → 5.40.3
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/.gitattributes +1 -0
- package/CHANGELOG.md +20 -0
- package/bin/isml-linter.js +32 -32
- package/package.json +1 -1
- package/src/isml_tree/ParseUtils.js +19 -2
- package/src/util/ExceptionUtils.js +24 -0
package/.gitattributes
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
bin/isml-linter.js text eol=lf
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [5.40.3] - 2022-09-12
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- [Issue #35][issue#35] - Manually set bin file linebreak to LF, as previous version didn't fix the issue;
|
|
7
|
+
|
|
8
|
+
## [5.40.2] - 2022-09-05
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- [Issue #35][issue#35] - Set bin file linebreak to LF;
|
|
12
|
+
|
|
13
|
+
## [5.40.1] - 2022-09-01
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
- HTML-element embedded `<isif>` condition scenario;
|
|
17
|
+
- Added mechanism to prevent infinite loops in case of unexpected errors;
|
|
18
|
+
|
|
3
19
|
## [5.40.0] - 2022-02-05
|
|
4
20
|
|
|
5
21
|
### Added
|
|
@@ -1011,6 +1027,9 @@
|
|
|
1011
1027
|
### Added
|
|
1012
1028
|
- Linter is published;
|
|
1013
1029
|
|
|
1030
|
+
[5.40.3]: https://github.com/FabiowQuixada/isml-linter/compare/v5.40.2...v5.40.3
|
|
1031
|
+
[5.40.2]: https://github.com/FabiowQuixada/isml-linter/compare/v5.40.1...v5.40.2
|
|
1032
|
+
[5.40.1]: https://github.com/FabiowQuixada/isml-linter/compare/v5.40.0...v5.40.1
|
|
1014
1033
|
[5.40.0]: https://github.com/FabiowQuixada/isml-linter/compare/v5.39.4...v5.40.0
|
|
1015
1034
|
[5.39.4]: https://github.com/FabiowQuixada/isml-linter/compare/v5.39.3...v5.39.4
|
|
1016
1035
|
[5.39.3]: https://github.com/FabiowQuixada/isml-linter/compare/v5.39.2...v5.39.3
|
|
@@ -1162,6 +1181,7 @@
|
|
|
1162
1181
|
[issue#29]: https://github.com/FabiowQuixada/isml-linter/issues/29
|
|
1163
1182
|
[issue#30]: https://github.com/FabiowQuixada/isml-linter/issues/30
|
|
1164
1183
|
[issue#31]: https://github.com/FabiowQuixada/isml-linter/issues/31
|
|
1184
|
+
[issue#35]: https://github.com/FabiowQuixada/isml-linter/issues/35
|
|
1165
1185
|
|
|
1166
1186
|
[cli-docs]: <docs/cli.md>
|
|
1167
1187
|
[api-docs]: <docs/api.md>
|
package/bin/isml-linter.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
require('../src/util/NativeExtensionUtils');
|
|
4
|
-
|
|
5
|
-
const CommandLineUtils = require('../src/util/CommandLineUtils');
|
|
6
|
-
const ConfigUtils = require('../src/util/ConfigUtils');
|
|
7
|
-
|
|
8
|
-
try {
|
|
9
|
-
const commandObj = CommandLineUtils.parseCommand();
|
|
10
|
-
|
|
11
|
-
if (!commandObj) {
|
|
12
|
-
process.exit(0);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (commandObj.options.indexOf('--init') >= 0) {
|
|
16
|
-
ConfigUtils.init();
|
|
17
|
-
process.exit(0);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const IsmlLinter = require('../src/publicApi');
|
|
21
|
-
const filePatternArray = commandObj.files;
|
|
22
|
-
const exitCode = IsmlLinter.build(filePatternArray);
|
|
23
|
-
|
|
24
|
-
if (commandObj.options.indexOf('--build') >= 0) {
|
|
25
|
-
process.exit(exitCode);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
} catch (e) {
|
|
29
|
-
const ConsoleUtils = require('../src/util/ConsoleUtils');
|
|
30
|
-
ConsoleUtils.printExceptionMsg(e.stack || e);
|
|
31
|
-
process.exit(1);
|
|
32
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
require('../src/util/NativeExtensionUtils');
|
|
4
|
+
|
|
5
|
+
const CommandLineUtils = require('../src/util/CommandLineUtils');
|
|
6
|
+
const ConfigUtils = require('../src/util/ConfigUtils');
|
|
7
|
+
|
|
8
|
+
try {
|
|
9
|
+
const commandObj = CommandLineUtils.parseCommand();
|
|
10
|
+
|
|
11
|
+
if (!commandObj) {
|
|
12
|
+
process.exit(0);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (commandObj.options.indexOf('--init') >= 0) {
|
|
16
|
+
ConfigUtils.init();
|
|
17
|
+
process.exit(0);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const IsmlLinter = require('../src/publicApi');
|
|
21
|
+
const filePatternArray = commandObj.files;
|
|
22
|
+
const exitCode = IsmlLinter.build(filePatternArray);
|
|
23
|
+
|
|
24
|
+
if (commandObj.options.indexOf('--build') >= 0) {
|
|
25
|
+
process.exit(exitCode);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
} catch (e) {
|
|
29
|
+
const ConsoleUtils = require('../src/util/ConsoleUtils');
|
|
30
|
+
ConsoleUtils.printExceptionMsg(e.stack || e);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
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,
|