flatlint 5.4.1 → 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 CHANGED
@@ -1,3 +1,14 @@
1
+ 2026.04.19, v5.6.0
2
+
3
+ feature:
4
+ - 85de5fa flatlint: __tmpl: add support
5
+
6
+ 2026.04.19, v5.5.0
7
+
8
+ feature:
9
+ - a175cf3 flatlint: add-missing-square-brace: false positive
10
+ - d7a8e48 flatlint: convert-semicolon-to-comma: after string literal
11
+
1
12
  2026.04.04, v5.4.1
2
13
 
3
14
  feature:
package/README.md CHANGED
@@ -422,6 +422,10 @@ Collects arguments of function when exists.
422
422
 
423
423
  Collects everything that looks like expression.
424
424
 
425
+ ### `__tmpl`
426
+
427
+ Collects template literal
428
+
425
429
  ## API
426
430
 
427
431
  ```js
@@ -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 './args.js';
3
- import * as arrayMatcher from './array.js';
4
- import * as expressionMatcher from './expression.js';
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}) {
@@ -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/array.js';
5
- import * as expressionMatcher from './matchers/expression.js';
6
- import * as argsMatcher from './matchers/args.js';
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
+
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  closeCurlyBrace,
3
+ closeSquareBrace,
3
4
  isPunctuator,
4
5
  } from '#types';
5
6
 
@@ -7,8 +8,12 @@ export const report = () => 'Add missing square brace';
7
8
 
8
9
  export const match = () => ({
9
10
  '["__a"': (vars, path) => !path.isNext(),
10
- '[__array;': ({__array}) => {
11
+ '[__array;': ({__array}, path) => {
11
12
  const last = __array.at(-1);
13
+
14
+ if (path.isNextPunctuator(closeSquareBrace))
15
+ return false;
16
+
12
17
  return !isPunctuator(last, closeCurlyBrace);
13
18
  },
14
19
  });
@@ -99,6 +99,9 @@ export const match = () => ({
99
99
  return path.isNextPunctuator(closeCurlyBrace);
100
100
  },
101
101
  '";': (vars, path) => {
102
+ if (path.isNextPunctuator(closeSquareBrace))
103
+ return true;
104
+
102
105
  return path.isNextPunctuator(quote);
103
106
  },
104
107
  ';': (vars, path) => {
@@ -114,4 +117,5 @@ export const replace = () => ({
114
117
  '=> __a.__b(__c, __d);': '=> __a.__b(__c, __d),',
115
118
  '";': '",',
116
119
  ';': '',
120
+ '__tmpl;': '__tmpl,',
117
121
  });
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flatlint",
3
- "version": "5.4.1",
3
+ "version": "5.6.0",
4
4
  "description": "JavaScript tokens-based linter",
5
5
  "main": "lib/flatlint.js",
6
6
  "type": "module",
File without changes
File without changes