flatlint 2.1.7 → 2.3.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,13 @@
1
+ 2025.03.07, v2.3.0
2
+
3
+ feature:
4
+ - 21cb416 remove-useless-round-brace: false positive
5
+
6
+ 2025.03.07, v2.2.0
7
+
8
+ feature:
9
+ - 6b6118a flatlint: add-missing-round-brace: improve support
10
+
1
11
  2025.03.01, v2.1.7
2
12
 
3
13
  feature:
@@ -39,18 +39,16 @@ export const collectArgs = ({currentTokenIndex, tokens}) => {
39
39
  if (equal(token, openCurlyBrace))
40
40
  ++curlyBracesBalance;
41
41
 
42
- if (equal(token, closeCurlyBrace)) {
42
+ if (equal(token, closeCurlyBrace))
43
43
  --curlyBracesBalance;
44
- const next = getNext({
45
- tokens,
46
- end: index + 1,
47
- });
48
-
49
- if (isIdentifier(next)) {
50
- ++index;
51
- break;
52
- }
53
- }
44
+ //const next = getNext({
45
+ // tokens,
46
+ // end: index + 1,
47
+ //});
48
+ // if (isIdentifier(next)) {
49
+ // ++index;
50
+ // break;
51
+ // }
54
52
 
55
53
  if (equal(token, semicolon) && !curlyBracesBalance)
56
54
  break;
@@ -70,3 +68,4 @@ export const collectArgs = ({currentTokenIndex, tokens}) => {
70
68
  --index,
71
69
  ];
72
70
  };
71
+
@@ -1,4 +1,5 @@
1
1
  import {
2
+ assign,
2
3
  closeRoundBrace,
3
4
  closeSquareBrace,
4
5
  colon,
@@ -6,12 +7,13 @@ import {
6
7
  isKeyword,
7
8
  isPunctuator,
8
9
  openRoundBrace,
10
+ semicolon,
9
11
  } from '#types';
10
12
 
11
13
  export const report = () => 'Add missing round brace';
12
14
 
13
15
  export const match = () => ({
14
- '__a(__args': (vars, path) => {
16
+ '__a(__args': ({__a, __args}, path) => {
15
17
  if (path.isCurrentPunctuator(closeRoundBrace))
16
18
  return false;
17
19
 
@@ -60,6 +62,12 @@ export const match = () => ({
60
62
 
61
63
  return false;
62
64
  },
65
+ '}': (vars, path) => {
66
+ if (path.isNextKeyword())
67
+ return false;
68
+
69
+ return path.isNextCompare('__a(');
70
+ },
63
71
  });
64
72
 
65
73
  export const replace = () => ({
@@ -72,4 +80,6 @@ export const replace = () => ({
72
80
  '{__a} = __expr;': '({__a} = __expr);',
73
81
  '{__a} = __expr': '({__a} = __expr)',
74
82
  '__a;': '__a);',
83
+ '}': '})',
75
84
  });
85
+
@@ -34,9 +34,6 @@ export const match = () => ({
34
34
 
35
35
  if (isPunctuator(current, closeRoundBrace))
36
36
  --balance;
37
-
38
- if (isKeyword(current, 'if'))
39
- break;
40
37
  }
41
38
 
42
39
  return !balance;
@@ -9,9 +9,6 @@ export const isNoSubstitutionTemplate = (a) => a?.type === 'NoSubstitutionTempla
9
9
  export const isTemplateTail = (a) => a?.type === 'TemplateTail';
10
10
  export const isWhiteSpace = ({type}) => type === 'WhiteSpace';
11
11
  export const isIdentifier = (token, newToken) => {
12
- if (!token)
13
- return false;
14
-
15
12
  const {type} = token;
16
13
  const is = type === 'IdentifierName' || type === 'PrivateIdentifier';
17
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flatlint",
3
- "version": "2.1.7",
3
+ "version": "2.3.0",
4
4
  "description": "JavaScript tokens-based linter",
5
5
  "main": "lib/flatlint.js",
6
6
  "type": "module",