flatlint 5.5.0 → 5.6.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 +5 -0
- package/README.md +4 -0
- package/lib/compare/matchers/__tmpl.js +25 -0
- package/lib/compare/matchers/index.js +5 -3
- package/lib/compare/values.js +10 -3
- package/lib/plugins/convert-semicolon-to-comma/index.js +1 -0
- package/lib/types/types.js +3 -0
- package/package.json +1 -1
- /package/lib/compare/matchers/{args.js → __args.js} +0 -0
- /package/lib/compare/matchers/{array.js → __array.js} +0 -0
- /package/lib/compare/matchers/{expression.js → __expr.js} +0 -0
package/ChangeLog
CHANGED
package/README.md
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isTemplateTail,
|
|
3
|
+
isTemplateTmpl,
|
|
4
|
+
OK,
|
|
5
|
+
} from '#types';
|
|
6
|
+
|
|
7
|
+
export const test = isTemplateTmpl;
|
|
8
|
+
|
|
9
|
+
export const collect = ({currentTokenIndex, tokens}) => {
|
|
10
|
+
let index = currentTokenIndex;
|
|
11
|
+
|
|
12
|
+
const n = tokens.length;
|
|
13
|
+
|
|
14
|
+
for (; index < n; index++) {
|
|
15
|
+
const token = tokens[index];
|
|
16
|
+
|
|
17
|
+
if (isTemplateTail(token))
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return [
|
|
22
|
+
OK,
|
|
23
|
+
index,
|
|
24
|
+
];
|
|
25
|
+
};
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import {isIdentifier} from '#types';
|
|
2
|
-
import * as argsMatcher from './
|
|
3
|
-
import * as arrayMatcher from './
|
|
4
|
-
import * as expressionMatcher from './
|
|
2
|
+
import * as argsMatcher from './__args.js';
|
|
3
|
+
import * as arrayMatcher from './__array.js';
|
|
4
|
+
import * as expressionMatcher from './__expr.js';
|
|
5
|
+
import * as tmplMatcher from './__tmpl.js';
|
|
5
6
|
|
|
6
7
|
export const matchers = [
|
|
7
8
|
argsMatcher,
|
|
8
9
|
arrayMatcher,
|
|
9
10
|
expressionMatcher,
|
|
11
|
+
tmplMatcher,
|
|
10
12
|
].map(createMatcher);
|
|
11
13
|
|
|
12
14
|
function createMatcher({test, collect, testToken}) {
|
package/lib/compare/values.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {traverse} from '#traverser';
|
|
2
2
|
import {prepare} from '#parser';
|
|
3
3
|
import {is} from '#types';
|
|
4
|
-
import * as arrayMatcher from './matchers/
|
|
5
|
-
import * as expressionMatcher from './matchers/
|
|
6
|
-
import * as argsMatcher from './matchers/
|
|
4
|
+
import * as arrayMatcher from './matchers/__array.js';
|
|
5
|
+
import * as expressionMatcher from './matchers/__expr.js';
|
|
6
|
+
import * as argsMatcher from './matchers/__args.js';
|
|
7
|
+
import * as tmplMatcher from './matchers/__tmpl.js';
|
|
7
8
|
|
|
8
9
|
const {isArray} = Array;
|
|
9
10
|
const maybeArray = (a) => isArray(a) ? a : [a];
|
|
@@ -51,6 +52,11 @@ export function getValues(tokens, waysFrom) {
|
|
|
51
52
|
currentTokenIndex: index,
|
|
52
53
|
tokens,
|
|
53
54
|
});
|
|
55
|
+
} else if (tmplMatcher.test(name)) {
|
|
56
|
+
[ok, end] = tmplMatcher.collect({
|
|
57
|
+
currentTokenIndex: index,
|
|
58
|
+
tokens,
|
|
59
|
+
});
|
|
54
60
|
} else {
|
|
55
61
|
values[name] = tokens[index];
|
|
56
62
|
continue;
|
|
@@ -94,3 +100,4 @@ function getNamesWithIndexes(waysTo) {
|
|
|
94
100
|
|
|
95
101
|
return namesWithIndexes;
|
|
96
102
|
}
|
|
103
|
+
|
package/lib/types/types.js
CHANGED
|
@@ -2,6 +2,7 @@ import * as keyword from '@putout/operator-keyword';
|
|
|
2
2
|
|
|
3
3
|
const ARGS = '__args';
|
|
4
4
|
const EXPR = '__expr';
|
|
5
|
+
const TMPL = '__tmpl';
|
|
5
6
|
const ARRAY = '__array';
|
|
6
7
|
const ANY = '__';
|
|
7
8
|
const LINKED_NODE = /^__[a-z]$/;
|
|
@@ -12,6 +13,7 @@ const ALL = [
|
|
|
12
13
|
ARRAY,
|
|
13
14
|
ARGS,
|
|
14
15
|
EXPR,
|
|
16
|
+
TMPL,
|
|
15
17
|
];
|
|
16
18
|
|
|
17
19
|
const {isArray} = Array;
|
|
@@ -148,6 +150,7 @@ export const isQuote = (a) => QUOTE.test(a);
|
|
|
148
150
|
export const isTemplateArray = (a) => a === ARRAY;
|
|
149
151
|
export const isTemplateExpression = (a) => a === EXPR;
|
|
150
152
|
export const isTemplateArgs = (a) => a === ARGS;
|
|
153
|
+
export const isTemplateTmpl = (a) => a === TMPL;
|
|
151
154
|
|
|
152
155
|
export const bitwiseAnd = Punctuator('&');
|
|
153
156
|
export const arrow = Punctuator('=>');
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|