isml-linter 5.40.3 → 5.40.5
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,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [5.40.5] - 2023-01-15
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- Disallow void elements closing tags;
|
|
7
|
+
- Minor output messages improvement;
|
|
8
|
+
|
|
9
|
+
## [5.40.4] - 2023-01-15
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
- Invalid ">" character detection;
|
|
13
|
+
- Invalid element issue length;
|
|
14
|
+
- "no-inline-style" rule;
|
|
15
|
+
|
|
3
16
|
## [5.40.3] - 2022-09-12
|
|
4
17
|
|
|
5
18
|
### Fixed
|
|
@@ -1027,6 +1040,8 @@
|
|
|
1027
1040
|
### Added
|
|
1028
1041
|
- Linter is published;
|
|
1029
1042
|
|
|
1043
|
+
[5.40.5]: https://github.com/FabiowQuixada/isml-linter/compare/v5.40.4...v5.40.5
|
|
1044
|
+
[5.40.4]: https://github.com/FabiowQuixada/isml-linter/compare/v5.40.3...v5.40.4
|
|
1030
1045
|
[5.40.3]: https://github.com/FabiowQuixada/isml-linter/compare/v5.40.2...v5.40.3
|
|
1031
1046
|
[5.40.2]: https://github.com/FabiowQuixada/isml-linter/compare/v5.40.1...v5.40.2
|
|
1032
1047
|
[5.40.1]: https://github.com/FabiowQuixada/isml-linter/compare/v5.40.0...v5.40.1
|
package/package.json
CHANGED
|
@@ -103,6 +103,9 @@ const checkBalance = (node, templatePath) => {
|
|
|
103
103
|
};
|
|
104
104
|
|
|
105
105
|
const parseNextElement = state => {
|
|
106
|
+
const ConfigUtils = require('../util/ConfigUtils');
|
|
107
|
+
|
|
108
|
+
const config = ConfigUtils.load();
|
|
106
109
|
const newElement = getNewElement(state);
|
|
107
110
|
|
|
108
111
|
const trimmedElement = newElement.value.trim();
|
|
@@ -125,7 +128,8 @@ const parseNextElement = state => {
|
|
|
125
128
|
parseTextElement(state, newElement);
|
|
126
129
|
}
|
|
127
130
|
|
|
128
|
-
newElement.columnNumber
|
|
131
|
+
newElement.columnNumber = getElementColumnNumber(newElement, state);
|
|
132
|
+
newElement.isVoidElement = !config.disableHtml5 && Constants.voidElementsArray.indexOf(newElement.tagType) >= 0;
|
|
129
133
|
|
|
130
134
|
if (state.isCrlfLineBreak) {
|
|
131
135
|
newElement.globalPos += newElement.lineNumber - 1;
|
|
@@ -140,6 +144,14 @@ const parseNextElement = state => {
|
|
|
140
144
|
newElement.globalPos,
|
|
141
145
|
state.templatePath
|
|
142
146
|
);
|
|
147
|
+
} else if (newElement.value.trim() === '>') {
|
|
148
|
+
throw ExceptionUtils.invalidCharacterError(
|
|
149
|
+
'>',
|
|
150
|
+
newElement.lineNumber,
|
|
151
|
+
newElement.globalPos,
|
|
152
|
+
1,
|
|
153
|
+
state.templatePath
|
|
154
|
+
);
|
|
143
155
|
}
|
|
144
156
|
|
|
145
157
|
return newElement;
|
|
@@ -110,7 +110,17 @@ const parseContainerElements = (element, currentParent, newNode, templatePath) =
|
|
|
110
110
|
|
|
111
111
|
const parseNonContainerElements = (element, currentParent, newNode, templatePath) => {
|
|
112
112
|
if (element.isSelfClosing) {
|
|
113
|
-
|
|
113
|
+
if (element.isClosingTag && element.isVoidElement) {
|
|
114
|
+
throw ExceptionUtils.voidElementClosingTag(
|
|
115
|
+
element.tagType,
|
|
116
|
+
element.lineNumber,
|
|
117
|
+
element.globalPos,
|
|
118
|
+
element.value.trim().length,
|
|
119
|
+
templatePath
|
|
120
|
+
);
|
|
121
|
+
} else {
|
|
122
|
+
currentParent.addChild(newNode);
|
|
123
|
+
}
|
|
114
124
|
} else if (!element.isClosingTag && element.tagType !== 'isif') {
|
|
115
125
|
currentParent.addChild(newNode);
|
|
116
126
|
|
|
@@ -2,7 +2,7 @@ const SingleLineRulePrototype = require('../prototypes/SingleLineRulePrototype')
|
|
|
2
2
|
|
|
3
3
|
const ruleId = require('path').basename(__filename).slice(0, -3);
|
|
4
4
|
const description = 'Avoid using inline style';
|
|
5
|
-
const occurrenceText = 'style="';
|
|
5
|
+
const occurrenceText = ' style="';
|
|
6
6
|
|
|
7
7
|
const Rule = Object.create(SingleLineRulePrototype);
|
|
8
8
|
|
|
@@ -11,7 +11,7 @@ Rule.init(ruleId, description);
|
|
|
11
11
|
Rule.isBroken = function(line) { return line.indexOf('<isprint') === -1 && line.indexOf(occurrenceText) >= 0; };
|
|
12
12
|
|
|
13
13
|
Rule.getColumnNumber = function(line) {
|
|
14
|
-
return Math.max(line.indexOf(occurrenceText), 0) +
|
|
14
|
+
return Math.max(line.indexOf(occurrenceText), 0) + 2;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
Rule.getFirstOccurrence = function(line) {
|
|
@@ -23,8 +23,8 @@ Rule.getFirstOccurrence = function(line) {
|
|
|
23
23
|
const matchPos = line.indexOf(occurrenceText);
|
|
24
24
|
|
|
25
25
|
result = {
|
|
26
|
-
globalPos : matchPos,
|
|
27
|
-
length : occurrenceText.length -
|
|
26
|
+
globalPos : matchPos + 1,
|
|
27
|
+
length : occurrenceText.length - 3
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -7,6 +7,7 @@ const types = {
|
|
|
7
7
|
INVALID_TEMPLATE : 'INVALID_TEMPLATE',
|
|
8
8
|
INVALID_NESTED_ISIF : 'INVALID_NESTED_ISIF',
|
|
9
9
|
INVALID_CHARACTER : 'INVALID_CHARACTER',
|
|
10
|
+
VOID_ELEMENT_CLOSING_TAG : 'VOID_ELEMENT_CLOSING_TAG',
|
|
10
11
|
RULE_ERROR : 'RULE_ERROR',
|
|
11
12
|
NO_CONFIG : 'NO_CONFIG',
|
|
12
13
|
};
|
|
@@ -100,12 +101,24 @@ const invalidCharacterError = (character, lineNumber, globalPos, length, templat
|
|
|
100
101
|
};
|
|
101
102
|
};
|
|
102
103
|
|
|
104
|
+
const voidElementClosingTag = (element, lineNumber, globalPos, length, templatePath) => {
|
|
105
|
+
return {
|
|
106
|
+
message : `"<${element}>" is a void element, and as such, should not have a corresponding closing tag`,
|
|
107
|
+
templatePath : templatePath,
|
|
108
|
+
globalPos,
|
|
109
|
+
length,
|
|
110
|
+
lineNumber : lineNumber,
|
|
111
|
+
isCustom : true,
|
|
112
|
+
type : types.VOID_ELEMENT_CLOSING_TAG
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
|
|
103
116
|
const invalidNestedIsifError = (tagType, lineNumber, globalPos, templatePath) => {
|
|
104
117
|
return {
|
|
105
118
|
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
119
|
templatePath : templatePath,
|
|
107
120
|
globalPos,
|
|
108
|
-
length : tagType.length,
|
|
121
|
+
length : tagType.length + 1,
|
|
109
122
|
lineNumber : lineNumber,
|
|
110
123
|
isCustom : true,
|
|
111
124
|
type : types.INVALID_NESTED_ISIF
|
|
@@ -135,14 +148,14 @@ const unkownError = (templatePath) => {
|
|
|
135
148
|
|
|
136
149
|
const noConfigError = () => {
|
|
137
150
|
return {
|
|
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}`,
|
|
151
|
+
message : `No ISML Linter configuration file found. Please run the following command: ${Constants.EOL}${Constants.EOL}\t./node_modules/.bin/isml-linter --init${Constants.EOL}${Constants.EOL}`,
|
|
139
152
|
isCustom : true
|
|
140
153
|
};
|
|
141
154
|
};
|
|
142
155
|
|
|
143
156
|
const noEslintConfigError = () => {
|
|
144
157
|
return {
|
|
145
|
-
message : 'No
|
|
158
|
+
message : 'No ESLint configuration file found. Please add an ESLint configuration file and try again.',
|
|
146
159
|
isCustom : true
|
|
147
160
|
};
|
|
148
161
|
};
|
|
@@ -160,6 +173,7 @@ module.exports = {
|
|
|
160
173
|
unbalancedQuotesError,
|
|
161
174
|
ruleApplianceError,
|
|
162
175
|
unkownError,
|
|
176
|
+
voidElementClosingTag,
|
|
163
177
|
invalidNestedIsifError,
|
|
164
178
|
unclosedDeprecatedIsmlComment,
|
|
165
179
|
unbalancedElementError,
|