flatlint 2.0.1 → 2.0.3

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.02.19, v2.0.3
2
+
3
+ feature:
4
+ - 521f4eb flatlint: add-missing-round-brace: square braces
5
+
6
+ 2025.02.19, v2.0.2
7
+
8
+ feature:
9
+ - 97d1fc2 flatlint: add-missing-round-brace: exclude object property
10
+
1
11
  2025.02.17, v2.0.1
2
12
 
3
13
  fix:
@@ -52,6 +52,9 @@ export const collectArgs = ({currentTokenIndex, tokens}) => {
52
52
  }
53
53
  }
54
54
 
55
+ if (equal(token, semicolon) && !curlyBracesBalance)
56
+ break;
57
+
55
58
  if (curlyBracesBalance < 0)
56
59
  break;
57
60
 
@@ -13,11 +13,6 @@ export const report = () => 'Add missing round brace';
13
13
 
14
14
  export const match = () => ({
15
15
  '__a(__args': ({__args}, path) => {
16
- const last = __args.at(-1);
17
-
18
- if (isPunctuator(last, semicolon))
19
- return false;
20
-
21
16
  if (path.isCurrentPunctuator(closeRoundBrace))
22
17
  return false;
23
18
 
@@ -34,26 +29,29 @@ export const match = () => ({
34
29
  if (path.isPrevPunctuator(colon))
35
30
  return false;
36
31
 
37
- let balance = 1;
32
+ let result = true;
38
33
 
39
- for (const current of path.getAllPrev()) {
40
- if (isPunctuator(current, openRoundBrace))
41
- ++balance;
42
-
43
- if (isPunctuator(current, openRoundBrace))
44
- --balance;
45
-
46
- if (isKeyword(current))
47
- return false;
48
- }
34
+ for (const current of path.getAllPrev())
35
+ if (isKeyword(current)) {
36
+ result = false;
37
+ break;
38
+ }
49
39
 
50
- return balance;
40
+ return result;
51
41
  },
52
42
  '"__a"': (vars, path) => {
43
+ if (path.isNextPunctuator([
44
+ colon,
45
+ comma,
46
+ closeRoundBrace,
47
+ closeSquareBrace,
48
+ ]))
49
+ return false;
50
+
51
+ if (path.isPrevPunctuator(colon))
52
+ return false;
53
+
53
54
  for (const current of path.getAllPrev()) {
54
- if (path.isNextPunctuator([comma, closeRoundBrace, closeSquareBrace]))
55
- return false;
56
-
57
55
  if (isPunctuator(current, closeRoundBrace))
58
56
  return false;
59
57
 
@@ -76,3 +74,4 @@ export const replace = () => ({
76
74
  '{__a} = __expr': '({__a} = __expr)',
77
75
  '__a;': '__a);',
78
76
  });
77
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flatlint",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "JavaScript tokens-based linter",
5
5
  "main": "lib/flatlint.js",
6
6
  "type": "module",