flatlint 1.90.0 → 1.90.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 CHANGED
@@ -1,3 +1,8 @@
1
+ 2025.01.31, v1.90.1
2
+
3
+ feature:
4
+ - a1794be flatlint: compare: simplify
5
+
1
6
  2025.01.31, v1.90.0
2
7
 
3
8
  feature:
@@ -36,13 +36,7 @@ export const compare = (source, template, {index = 0} = {}) => {
36
36
  for (const [templateIndex] of templateTokens.entries()) {
37
37
  let currentTokenIndex = index + templateIndex - skip;
38
38
 
39
- /* c8 ignore start */
40
- if (indexCheck > index + 1)
41
- throw Error(`index should never decrease more then on one: ${index} > ${indexCheck}`);
42
-
43
- if (index < 0)
44
- throw Error(`index should never be < zero: ${index}`);
45
- /* c8 ignore end */
39
+ checkIndexes(index, indexCheck);
46
40
 
47
41
  if (currentTokenIndex > n)
48
42
  return [NOT_OK];
@@ -74,10 +68,10 @@ export const compare = (source, template, {index = 0} = {}) => {
74
68
  nextTemplateToken: templateTokens[templateIndex + 1],
75
69
  });
76
70
 
77
- if (indexOfExpressionEnd >= n) {
78
- end = indexOfExpressionEnd;
79
- currentTokenIndex = end;
80
- } else if (templateIndex === templateTokensLength - 1) {
71
+ const sameTokensIndex = templateIndex === templateTokensLength - 1;
72
+ const outOfBound = indexOfExpressionEnd >= n;
73
+
74
+ if (outOfBound || sameTokensIndex) {
81
75
  end = indexOfExpressionEnd;
82
76
  currentTokenIndex = end;
83
77
  } else {
@@ -135,3 +129,13 @@ function compareAll(a, b) {
135
129
 
136
130
  return false;
137
131
  }
132
+
133
+ function checkIndexes(index, indexCheck) {
134
+ /* c8 ignore start */
135
+ if (indexCheck > index + 1)
136
+ throw Error(`index should never decrease more then on one: ${index} > ${indexCheck}`);
137
+
138
+ if (index < 0)
139
+ throw Error(`index should never be < zero: ${index}`);
140
+ /* c8 ignore end */
141
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flatlint",
3
- "version": "1.90.0",
3
+ "version": "1.90.1",
4
4
  "description": "JavaScript tokens-based linter",
5
5
  "main": "lib/flatlint.js",
6
6
  "type": "module",