isml-linter 5.42.4 → 5.43.0

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,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [5.43.0] - 2023-01-31
4
+
5
+ ### Added
6
+ - "allowWhenDynamic" (default `true`) option to "[no-inline-style][no-inline-style-readme]" rule;
7
+
8
+ ### Fixed
9
+ - Rule-level ignore string with "/" character for directories;
10
+
3
11
  ## [5.42.4] - 2023-01-30
4
12
 
5
13
  ### Fixed
@@ -1080,6 +1088,7 @@
1080
1088
  ### Added
1081
1089
  - Linter is published;
1082
1090
 
1091
+ [5.43.0]: https://github.com/FabiowQuixada/isml-linter/compare/v5.42.4...v5.43.0
1083
1092
  [5.42.4]: https://github.com/FabiowQuixada/isml-linter/compare/v5.42.3...v5.42.4
1084
1093
  [5.42.3]: https://github.com/FabiowQuixada/isml-linter/compare/v5.42.2...v5.42.3
1085
1094
  [5.42.2]: https://github.com/FabiowQuixada/isml-linter/compare/v5.42.1...v5.42.2
@@ -1251,7 +1260,7 @@
1251
1260
  [strict-void-elements-readme]: <docs/rules/strict-void-elements.md>
1252
1261
  [disallow-tags-readme]: <docs/rules/disallow-tags.md>
1253
1262
  [no-br-readme]: <docs/rules/no-br.md>
1254
- [no-inline-style-readme]: <docs/rules/no-br.md>
1263
+ [no-inline-style-readme]: <docs/rules/no-inline-style.md>
1255
1264
  [no-isscript-readme]: <docs/rules/no-isscript.md>
1256
1265
  [enforce-security-readme]: <docs/rules/enforce-security.md>
1257
1266
  [no-hardcode-readme]: <docs/rules/no-hardcode.md>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isml-linter",
3
- "version": "5.42.4",
3
+ "version": "5.43.0",
4
4
  "author": "Fabiow Quixadá <ftquixada@gmail.com>",
5
5
  "license": "MIT",
6
6
  "main": "src/publicApi.js",
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 = templatePathArray[i];
229
- const templatePath = Array.isArray(templateData.pathData) || path.isAbsolute(templateName) || templateData.pathData === templateName ?
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 isIgnored = FileUtils.isIgnored(templatePath);
232
+ const shouldBeIgnored = FileUtils.shouldBeIgnored(templatePath);
233
233
 
234
- if (!isIgnored) {
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) { return line.indexOf('<isprint') === -1 && line.indexOf(occurrenceText) >= 0; };
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 = this.getConfigs().ignore;
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 templatePath.includes(ignore);
40
+ return formattedFilePath.includes(ignore);
40
41
  });
41
42
  }
42
43
 
@@ -59,12 +59,13 @@ const deleteDirectoryRecursively = dirPath => {
59
59
  return false;
60
60
  };
61
61
 
62
- const isIgnored = filePath => {
63
- const config = ConfigUtils.load();
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 filePath.indexOf(ignoredPath) >= 0;
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.isIgnored = isIgnored;
80
+ module.exports.shouldBeIgnored = shouldBeIgnored;