flatlint 1.1.0 → 1.2.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
CHANGED
package/README.md
CHANGED
package/lib/compare/compare.js
CHANGED
|
@@ -2,9 +2,7 @@ import {prepare} from '../tokenizer/index.js';
|
|
|
2
2
|
import {
|
|
3
3
|
isId,
|
|
4
4
|
isIdentifier,
|
|
5
|
-
isNewLine,
|
|
6
5
|
isPunctuator,
|
|
7
|
-
isWhiteSpace,
|
|
8
6
|
} from './types.js';
|
|
9
7
|
|
|
10
8
|
export const compare = (source, template) => {
|
|
@@ -17,31 +15,11 @@ export const compare = (source, template) => {
|
|
|
17
15
|
let end = 0;
|
|
18
16
|
|
|
19
17
|
for (let index = 0; index < n; index++) {
|
|
20
|
-
let tokenDelta = 0;
|
|
21
|
-
let templateDelta = 0;
|
|
22
|
-
|
|
23
18
|
for (let templateIndex = 0; templateIndex < templateTokensLength; templateIndex++) {
|
|
24
|
-
const currentTokenIndex = index + templateIndex
|
|
25
|
-
|
|
26
|
-
if (currentTokenIndex === n + 1)
|
|
27
|
-
break;
|
|
28
|
-
|
|
29
|
-
const templateToken = templateTokens[templateIndex - templateDelta];
|
|
19
|
+
const currentTokenIndex = index + templateIndex;
|
|
20
|
+
const templateToken = templateTokens[templateIndex];
|
|
30
21
|
const currentToken = tokens[currentTokenIndex];
|
|
31
22
|
|
|
32
|
-
if (isWhiteSpace(currentToken)) {
|
|
33
|
-
++templateDelta;
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (isWhiteSpace(templateToken)) {
|
|
38
|
-
++tokenDelta;
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (isNewLine(currentToken))
|
|
43
|
-
continue;
|
|
44
|
-
|
|
45
23
|
if (!compareAll(currentToken, templateToken)) {
|
|
46
24
|
isEqual = false;
|
|
47
25
|
break;
|
|
@@ -49,7 +27,7 @@ export const compare = (source, template) => {
|
|
|
49
27
|
|
|
50
28
|
isEqual = true;
|
|
51
29
|
start = index;
|
|
52
|
-
end = currentTokenIndex
|
|
30
|
+
end = currentTokenIndex;
|
|
53
31
|
}
|
|
54
32
|
|
|
55
33
|
if (isEqual)
|
package/lib/tokenizer/index.js
CHANGED
|
@@ -20,10 +20,8 @@ function getTokensWithLocation(tokens) {
|
|
|
20
20
|
const result = [];
|
|
21
21
|
|
|
22
22
|
for (const token of tokens) {
|
|
23
|
-
if (isNewLine(token))
|
|
23
|
+
if (isNewLine(token))
|
|
24
24
|
++line;
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
25
|
|
|
28
26
|
result.push({
|
|
29
27
|
...token,
|
|
@@ -32,6 +30,9 @@ function getTokensWithLocation(tokens) {
|
|
|
32
30
|
});
|
|
33
31
|
|
|
34
32
|
column += token.value.length;
|
|
33
|
+
|
|
34
|
+
if (isNewLine(token))
|
|
35
|
+
column = 1;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
return result;
|