flatlint 2.3.0 → 2.3.2

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.2
2
+
3
+ fix:
4
+ - 5bfd266 add-missing-arrow: getter
5
+
6
+ 2025.03.07, v2.3.1
7
+
8
+ feature:
9
+ - ee13720 flatlint: add-missing-round-brace: exclude if
10
+
1
11
  2025.03.07, v2.3.0
2
12
 
3
13
  feature:
@@ -1,10 +1,8 @@
1
1
  import {
2
2
  closeCurlyBrace,
3
3
  closeRoundBrace,
4
- isIdentifier,
5
4
  isNewLine,
6
5
  isOneOfPunctuators,
7
- getNext,
8
6
  NOT_OK,
9
7
  OK,
10
8
  openCurlyBrace,
@@ -41,14 +39,6 @@ export const collectArgs = ({currentTokenIndex, tokens}) => {
41
39
 
42
40
  if (equal(token, closeCurlyBrace))
43
41
  --curlyBracesBalance;
44
- //const next = getNext({
45
- // tokens,
46
- // end: index + 1,
47
- //});
48
- // if (isIdentifier(next)) {
49
- // ++index;
50
- // break;
51
- // }
52
42
 
53
43
  if (equal(token, semicolon) && !curlyBracesBalance)
54
44
  break;
@@ -68,4 +58,3 @@ export const collectArgs = ({currentTokenIndex, tokens}) => {
68
58
  --index,
69
59
  ];
70
60
  };
71
-
@@ -1,5 +1,4 @@
1
1
  import {
2
- assign,
3
2
  closeRoundBrace,
4
3
  closeSquareBrace,
5
4
  colon,
@@ -7,13 +6,12 @@ import {
7
6
  isKeyword,
8
7
  isPunctuator,
9
8
  openRoundBrace,
10
- semicolon,
11
9
  } from '#types';
12
10
 
13
11
  export const report = () => 'Add missing round brace';
14
12
 
15
13
  export const match = () => ({
16
- '__a(__args': ({__a, __args}, path) => {
14
+ '__a(__args': (vars, path) => {
17
15
  if (path.isCurrentPunctuator(closeRoundBrace))
18
16
  return false;
19
17
 
@@ -66,6 +64,11 @@ export const match = () => ({
66
64
  if (path.isNextKeyword())
67
65
  return false;
68
66
 
67
+ for (const token of path.getAllPrev()) {
68
+ if (isKeyword(token, 'if'))
69
+ return false;
70
+ }
71
+
69
72
  return path.isNextCompare('__a(');
70
73
  },
71
74
  });
@@ -82,4 +85,3 @@ export const replace = () => ({
82
85
  '__a;': '__a);',
83
86
  '}': '})',
84
87
  });
85
-
@@ -2,7 +2,6 @@ import {
2
2
  closeRoundBrace,
3
3
  hasRoundBraces,
4
4
  isBalancedRoundBraces,
5
- isKeyword,
6
5
  isPunctuator,
7
6
  openRoundBrace,
8
7
  } from '#types';
@@ -28,18 +28,23 @@ export const isNumericLiteral = ({type}) => type === 'NumericLiteral';
28
28
  export const isNewLine = ({type}) => type === 'LineTerminatorSequence';
29
29
  export const isMultilineComment = ({type}) => type === 'MultiLineComment';
30
30
 
31
- export const isKeyword = (token, name) => {
31
+ export const isKeyword = (token, names) => {
32
32
  if (!token)
33
33
  return false;
34
34
 
35
- const {value} = token;
36
- const is = keyword.isKeyword(value);
37
- const isTS = keyword.isTSKeyword(value);
38
-
39
- if (!is && !isTS)
40
- return false;
35
+ for (const name of maybeArray(names)) {
36
+ const {value} = token;
37
+ const is = keyword.isKeyword(value);
38
+ const isTS = keyword.isTSKeyword(value);
39
+
40
+ if (!is && !isTS)
41
+ return false;
42
+
43
+ if (isIdentifier(token, name))
44
+ return true;
45
+ }
41
46
 
42
- return isIdentifier(token, name);
47
+ return false;
43
48
  };
44
49
 
45
50
  export const isDeclarationKeyword = (token, name) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flatlint",
3
- "version": "2.3.0",
3
+ "version": "2.3.2",
4
4
  "description": "JavaScript tokens-based linter",
5
5
  "main": "lib/flatlint.js",
6
6
  "type": "module",