flatlint 2.0.2 → 2.0.4

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.4
2
+
3
+ feature:
4
+ - 8883809 flatlint: add-missing-round-brace: exclude: export default
5
+
6
+ 2025.02.19, v2.0.3
7
+
8
+ feature:
9
+ - 521f4eb flatlint: add-missing-round-brace: square braces
10
+
1
11
  2025.02.19, v2.0.2
2
12
 
3
13
  feature:
package/README.md CHANGED
@@ -374,4 +374,3 @@ const [code] = lint(`a && b = c`, {
374
374
  ## License
375
375
 
376
376
  MIT
377
-
@@ -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
 
@@ -64,4 +64,3 @@ function getTokensWithLocation(tokens) {
64
64
 
65
65
  return result;
66
66
  }
67
-
@@ -9,6 +9,9 @@ export const report = () => 'Add missing comma';
9
9
 
10
10
  export const match = () => ({
11
11
  '"__a"': (vars, path) => {
12
+ if (path.isNextKeyword())
13
+ return false;
14
+
12
15
  if (path.isPrevPunctuator(assign))
13
16
  return false;
14
17
 
@@ -6,18 +6,12 @@ import {
6
6
  isKeyword,
7
7
  isPunctuator,
8
8
  openRoundBrace,
9
- semicolon,
10
9
  } from '#types';
11
10
 
12
11
  export const report = () => 'Add missing round brace';
13
12
 
14
13
  export const match = () => ({
15
- '__a(__args': ({__args}, path) => {
16
- const last = __args.at(-1);
17
-
18
- if (isPunctuator(last, semicolon))
19
- return false;
20
-
14
+ '__a(__args': (vars, path) => {
21
15
  if (path.isCurrentPunctuator(closeRoundBrace))
22
16
  return false;
23
17
 
@@ -34,23 +28,23 @@ export const match = () => ({
34
28
  if (path.isPrevPunctuator(colon))
35
29
  return false;
36
30
 
37
- let balance = 1;
31
+ let result = true;
38
32
 
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
- }
33
+ for (const current of path.getAllPrev())
34
+ if (isKeyword(current)) {
35
+ result = false;
36
+ break;
37
+ }
49
38
 
50
- return balance;
39
+ return result;
51
40
  },
52
41
  '"__a"': (vars, path) => {
53
- if (path.isNextPunctuator([colon, comma, closeRoundBrace, closeSquareBrace]))
42
+ if (path.isNextPunctuator([
43
+ colon,
44
+ comma,
45
+ closeRoundBrace,
46
+ closeSquareBrace,
47
+ ]))
54
48
  return false;
55
49
 
56
50
  if (path.isPrevPunctuator(colon))
@@ -2,4 +2,3 @@ export const report = () => `Use ';' instead of ':'`;
2
2
  export const replace = () => ({
3
3
  '):': ');',
4
4
  });
5
-
@@ -27,10 +27,16 @@ export const match = () => ({
27
27
  }
28
28
  },
29
29
  '__a: __expr;': (vars, path) => {
30
- for (const token of path.getAllPrev()) {
31
- if (isOneOfKeywords(token, ['class', 'readonly', 'static', 'implements']))
30
+ const keywords = [
31
+ 'class',
32
+ 'readonly',
33
+ 'static',
34
+ 'implements',
35
+ ];
36
+
37
+ for (const token of path.getAllPrev())
38
+ if (isOneOfKeywords(token, keywords))
32
39
  return false;
33
- }
34
40
 
35
41
  return true;
36
42
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flatlint",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "JavaScript tokens-based linter",
5
5
  "main": "lib/flatlint.js",
6
6
  "type": "module",