isml-linter 5.42.4 → 5.43.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
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [5.43.1] - 2023-02-11
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- All line-by-line rules are applied, one after the other, without ovewriting the previous rule fixed content;
|
|
7
|
+
|
|
8
|
+
## [5.43.0] - 2023-01-31
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- "allowWhenDynamic" (default `true`) option to "[no-inline-style][no-inline-style-readme]" rule;
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
- Rule-level ignore string with "/" character for directories;
|
|
15
|
+
|
|
3
16
|
## [5.42.4] - 2023-01-30
|
|
4
17
|
|
|
5
18
|
### Fixed
|
|
@@ -1080,6 +1093,8 @@
|
|
|
1080
1093
|
### Added
|
|
1081
1094
|
- Linter is published;
|
|
1082
1095
|
|
|
1096
|
+
[5.43.1]: https://github.com/FabiowQuixada/isml-linter/compare/v5.43.0...v5.43.1
|
|
1097
|
+
[5.43.0]: https://github.com/FabiowQuixada/isml-linter/compare/v5.42.4...v5.43.0
|
|
1083
1098
|
[5.42.4]: https://github.com/FabiowQuixada/isml-linter/compare/v5.42.3...v5.42.4
|
|
1084
1099
|
[5.42.3]: https://github.com/FabiowQuixada/isml-linter/compare/v5.42.2...v5.42.3
|
|
1085
1100
|
[5.42.2]: https://github.com/FabiowQuixada/isml-linter/compare/v5.42.1...v5.42.2
|
|
@@ -1251,7 +1266,7 @@
|
|
|
1251
1266
|
[strict-void-elements-readme]: <docs/rules/strict-void-elements.md>
|
|
1252
1267
|
[disallow-tags-readme]: <docs/rules/disallow-tags.md>
|
|
1253
1268
|
[no-br-readme]: <docs/rules/no-br.md>
|
|
1254
|
-
[no-inline-style-readme]: <docs/rules/no-
|
|
1269
|
+
[no-inline-style-readme]: <docs/rules/no-inline-style.md>
|
|
1255
1270
|
[no-isscript-readme]: <docs/rules/no-isscript.md>
|
|
1256
1271
|
[enforce-security-readme]: <docs/rules/enforce-security.md>
|
|
1257
1272
|
[no-hardcode-readme]: <docs/rules/no-hardcode.md>
|
package/package.json
CHANGED
package/src/IsmlLinter.js
CHANGED
|
@@ -225,13 +225,13 @@ Linter.run = (pathData, content, data = {}) => {
|
|
|
225
225
|
const lintStartTime = new Date();
|
|
226
226
|
|
|
227
227
|
for (let i = 0; i < templatePathArray.length; i++) {
|
|
228
|
-
const templateName
|
|
229
|
-
const templatePath
|
|
228
|
+
const templateName = templatePathArray[i];
|
|
229
|
+
const templatePath = Array.isArray(templateData.pathData) || path.isAbsolute(templateName) || templateData.pathData === templateName ?
|
|
230
230
|
templateName :
|
|
231
231
|
path.join(templateData.pathData, templateName);
|
|
232
|
-
const
|
|
232
|
+
const shouldBeIgnored = FileUtils.shouldBeIgnored(templatePath);
|
|
233
233
|
|
|
234
|
-
if (!
|
|
234
|
+
if (!shouldBeIgnored) {
|
|
235
235
|
const templateResults = parseAndPossiblyFixTemplate(templatePath, data, content, templateName);
|
|
236
236
|
|
|
237
237
|
finalResult = merge(finalResult, templateResults);
|
|
@@ -8,7 +8,37 @@ const Rule = Object.create(SingleLineRulePrototype);
|
|
|
8
8
|
|
|
9
9
|
Rule.init(ruleId, description);
|
|
10
10
|
|
|
11
|
-
Rule.isBroken = function(line) {
|
|
11
|
+
Rule.isBroken = function(line) {
|
|
12
|
+
const shouldAllowWhenDynamic = this.getConfigs().allowWhenDynamic;
|
|
13
|
+
|
|
14
|
+
if (line.indexOf(occurrenceText) >= 0) {
|
|
15
|
+
if (shouldAllowWhenDynamic && line.indexOf('${') >= 0) {
|
|
16
|
+
const attributePos = line.indexOf(occurrenceText);
|
|
17
|
+
const tagClosingCharPos = line.substring(attributePos).indexOf('>');
|
|
18
|
+
const expressionPos = line.substring(tagClosingCharPos).indexOf('${');
|
|
19
|
+
|
|
20
|
+
if (attributePos >= 0 && tagClosingCharPos >= 0 && expressionPos >= 0 &&
|
|
21
|
+
attributePos < tagClosingCharPos && tagClosingCharPos < expressionPos
|
|
22
|
+
) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (attributePos === -1 || tagClosingCharPos === -1 || expressionPos === -1) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return line.indexOf('<isprint') === -1;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return false;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
Rule.getDefaultAttrs = () => {
|
|
38
|
+
return {
|
|
39
|
+
allowWhenDynamic: true
|
|
40
|
+
};
|
|
41
|
+
};
|
|
12
42
|
|
|
13
43
|
Rule.getColumnNumber = function(line) {
|
|
14
44
|
return Math.max(line.indexOf(occurrenceText), 0) + 2;
|
|
@@ -32,11 +32,12 @@ const RulePrototype = {
|
|
|
32
32
|
},
|
|
33
33
|
|
|
34
34
|
shouldIgnore(templatePath) {
|
|
35
|
-
const ignoreArray
|
|
35
|
+
const ignoreArray = this.getConfigs().ignore;
|
|
36
|
+
const formattedFilePath = templatePath.replaceAll('\\', '/');
|
|
36
37
|
|
|
37
38
|
if (ignoreArray) {
|
|
38
39
|
return ignoreArray.some( ignore => {
|
|
39
|
-
return
|
|
40
|
+
return formattedFilePath.includes(ignore);
|
|
40
41
|
});
|
|
41
42
|
}
|
|
42
43
|
|
package/src/util/FileUtils.js
CHANGED
|
@@ -59,12 +59,13 @@ const deleteDirectoryRecursively = dirPath => {
|
|
|
59
59
|
return false;
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
const
|
|
63
|
-
const config
|
|
62
|
+
const shouldBeIgnored = filePath => {
|
|
63
|
+
const config = ConfigUtils.load();
|
|
64
|
+
const formattedFilePath = filePath.replaceAll('\\', '/');
|
|
64
65
|
|
|
65
|
-
return config.ignore && config.ignore.some( ignoredPath => {
|
|
66
|
-
return
|
|
67
|
-
});
|
|
66
|
+
return !!(config.ignore && config.ignore.some( ignoredPath => {
|
|
67
|
+
return formattedFilePath.indexOf(ignoredPath) >= 0;
|
|
68
|
+
}));
|
|
68
69
|
};
|
|
69
70
|
|
|
70
71
|
const fileExists = filePath => fs.existsSync(filePath);
|
|
@@ -76,4 +77,4 @@ module.exports.createDirIfDoesNotExist = createDirIfDoesNotExist;
|
|
|
76
77
|
module.exports.deleteFile = deleteFile;
|
|
77
78
|
module.exports.deleteDirectoryRecursively = deleteDirectoryRecursively;
|
|
78
79
|
module.exports.createClientDir = createClientDir;
|
|
79
|
-
module.exports.
|
|
80
|
+
module.exports.shouldBeIgnored = shouldBeIgnored;
|
package/src/util/RuleUtils.js
CHANGED
|
@@ -77,7 +77,7 @@ const fixTemplateOrReportIssues = (config, ruleResult, templatePath, templateRes
|
|
|
77
77
|
}
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
-
const fixTemplateOrReportIssuesForRuleList = (ruleArray, templatePath,
|
|
80
|
+
const fixTemplateOrReportIssuesForRuleList = (ruleArray, templatePath, rootNodeOrTemplateContent, config, data) => {
|
|
81
81
|
const templateResults = {
|
|
82
82
|
fixed : false,
|
|
83
83
|
errors : {},
|
|
@@ -86,13 +86,20 @@ const fixTemplateOrReportIssuesForRuleList = (ruleArray, templatePath, root, con
|
|
|
86
86
|
data
|
|
87
87
|
};
|
|
88
88
|
|
|
89
|
+
let tempRootNodeOrTemplateContent = rootNodeOrTemplateContent;
|
|
90
|
+
|
|
89
91
|
for (let i = 0; i < ruleArray.length; i++) {
|
|
90
92
|
const rule = ruleArray[i];
|
|
91
93
|
if (!rule.shouldIgnore(templatePath)) {
|
|
92
94
|
try {
|
|
93
95
|
ConsoleUtils.displayVerboseMessage(`Applying "${rule.id}" rule`, 1);
|
|
94
|
-
const ruleResults = rule.check(
|
|
96
|
+
const ruleResults = rule.check(tempRootNodeOrTemplateContent, templateResults.data);
|
|
95
97
|
templateResults.finalContent = ruleResults.fixedContent;
|
|
98
|
+
|
|
99
|
+
if (typeof rootNodeOrTemplateContent === 'string') {
|
|
100
|
+
tempRootNodeOrTemplateContent = ruleResults.fixedContent;
|
|
101
|
+
}
|
|
102
|
+
|
|
96
103
|
fixTemplateOrReportIssues(config, ruleResults, templatePath, templateResults, rule);
|
|
97
104
|
|
|
98
105
|
} catch (error) {
|