flatlint 5.5.0 → 5.7.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,15 @@
1
+ 2026.06.03, v5.7.0
2
+
3
+ feature:
4
+ - 3736e1b flatlint: supertape v13.2.0
5
+ - bec8705 flatlint: montag v2.0.1
6
+ - 3693318 flatlint: add-missing-round-brace: nested array
7
+
8
+ 2026.04.19, v5.6.0
9
+
10
+ feature:
11
+ - 85de5fa flatlint: __tmpl: add support
12
+
1
13
  2026.04.19, v5.5.0
2
14
 
3
15
  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
+
@@ -19,6 +19,7 @@ export const match = () => ({
19
19
 
20
20
  return !path.isNextPunctuator(closeRoundBrace);
21
21
  },
22
+ '__a(__b, __array]': (vars, path) => !path.isNextPunctuator([closeRoundBrace, comma]),
22
23
  'if (__a(__args)': (vars, path) => {
23
24
  return path.isNextKeyword();
24
25
  },
@@ -94,6 +95,7 @@ export const match = () => ({
94
95
 
95
96
  export const replace = () => ({
96
97
  'if __a > __b': 'if (__a > __b)',
98
+ '__a(__b, __array]': '__a(__b, __array])',
97
99
  '__a(__args': '__a(__args)',
98
100
  'if (__a.__b(__args) {': 'if (__a.__b(__args)) {',
99
101
  'if (__a(__args) {': 'if (__a(__args)) {',
@@ -117,4 +117,5 @@ export const replace = () => ({
117
117
  '=> __a.__b(__c, __d);': '=> __a.__b(__c, __d),',
118
118
  '";': '",',
119
119
  ';': '',
120
+ '__tmpl;': '__tmpl,',
120
121
  });
@@ -1,4 +1,4 @@
1
- import montag from 'montag';
1
+ import {montag} from 'montag';
2
2
 
3
3
  export const report = () => 'Remove useless curly braces from ImportDeclaration';
4
4
 
@@ -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.5.0",
3
+ "version": "5.7.0",
4
4
  "description": "JavaScript tokens-based linter",
5
5
  "main": "lib/flatlint.js",
6
6
  "type": "module",
@@ -63,7 +63,7 @@
63
63
  "@putout/engine-loader": "^17.0.4",
64
64
  "@putout/operator-keyword": "^5.0.0",
65
65
  "js-tokens": "^10.0.0",
66
- "montag": "^1.2.1",
66
+ "montag": "^2.0.1",
67
67
  "obug": "^2.1.1"
68
68
  },
69
69
  "devDependencies": {
@@ -75,7 +75,7 @@
75
75
  "nodemon": "^3.0.1",
76
76
  "putout": "^42.0.3",
77
77
  "superc8": "^12.3.1",
78
- "supertape": "^12.0.0"
78
+ "supertape": "^13.2.0"
79
79
  },
80
80
  "engines": {
81
81
  "node": ">=22"
File without changes
File without changes