flatlint 1.4.0 → 1.4.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 +5 -0
- package/lib/compare/compare.js +1 -1
- package/lib/runner/replacer.js +1 -1
- package/lib/tokenizer/index.js +11 -16
- package/lib/traverser/traverser.js +1 -1
- package/lib/{compare → types}/types.js +10 -0
- package/package.json +4 -1
package/ChangeLog
CHANGED
package/lib/compare/compare.js
CHANGED
package/lib/runner/replacer.js
CHANGED
package/lib/tokenizer/index.js
CHANGED
|
@@ -2,7 +2,9 @@ import tokenize from 'js-tokens';
|
|
|
2
2
|
import {
|
|
3
3
|
isNewLine,
|
|
4
4
|
isStringLiteral,
|
|
5
|
-
|
|
5
|
+
Punctuator,
|
|
6
|
+
StringLiteral,
|
|
7
|
+
} from '#types';
|
|
6
8
|
|
|
7
9
|
const isString = (a) => typeof a === 'string';
|
|
8
10
|
|
|
@@ -15,26 +17,19 @@ const closeQuotes = (tokens) => {
|
|
|
15
17
|
if (isStringLiteral(token)) {
|
|
16
18
|
const {closed, value} = token;
|
|
17
19
|
|
|
18
|
-
const quote =
|
|
19
|
-
type: 'Punctuator',
|
|
20
|
-
value: value.at(0),
|
|
21
|
-
};
|
|
22
|
-
|
|
20
|
+
const quote = Punctuator(value.at(0));
|
|
23
21
|
const newTokens = [];
|
|
24
22
|
|
|
25
23
|
if (closed) {
|
|
26
|
-
const literal =
|
|
27
|
-
value: value.slice(1, -1),
|
|
28
|
-
type: 'StringLiteral',
|
|
29
|
-
};
|
|
30
|
-
|
|
24
|
+
const literal = StringLiteral(value.slice(1, -1));
|
|
31
25
|
newTokens.push(quote, literal, quote);
|
|
32
|
-
} else {
|
|
33
|
-
const literal =
|
|
34
|
-
|
|
35
|
-
type: 'StringLiteral',
|
|
36
|
-
};
|
|
26
|
+
} else if (value.endsWith(';')) {
|
|
27
|
+
const literal = StringLiteral(value.slice(1, -1));
|
|
28
|
+
const semicolon = Punctuator(';');
|
|
37
29
|
|
|
30
|
+
newTokens.push(quote, literal, semicolon);
|
|
31
|
+
} else {
|
|
32
|
+
const literal = StringLiteral(value.slice(1));
|
|
38
33
|
newTokens.push(quote, literal);
|
|
39
34
|
}
|
|
40
35
|
|
|
@@ -8,6 +8,16 @@ export const isNewLine = ({type}) => type === 'LineTerminatorSequence';
|
|
|
8
8
|
export const notWhiteSpace = (a) => !isWhiteSpace(a);
|
|
9
9
|
export const isPunctuator = ({type}) => type === 'Punctuator';
|
|
10
10
|
|
|
11
|
+
export const StringLiteral = (value) => ({
|
|
12
|
+
type: 'StringLiteral',
|
|
13
|
+
value,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export const Punctuator = (value) => ({
|
|
17
|
+
type: 'Punctuator',
|
|
18
|
+
value,
|
|
19
|
+
});
|
|
20
|
+
|
|
11
21
|
export const is = (str, array = ALL) => {
|
|
12
22
|
for (const item of array) {
|
|
13
23
|
if (check(str, item))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flatlint",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "JavaScript tokens-based linter",
|
|
5
5
|
"main": "lib/flatlint.js",
|
|
6
6
|
"type": "module",
|
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
"#test": {
|
|
12
12
|
"default": "./lib/test/test.js"
|
|
13
13
|
},
|
|
14
|
+
"#types": {
|
|
15
|
+
"default": "./lib/types/types.js"
|
|
16
|
+
},
|
|
14
17
|
"#flatlint": {
|
|
15
18
|
"default": "./lib/flatlint.js"
|
|
16
19
|
}
|