flatlint 1.43.1 → 1.45.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.01.14, v1.45.0
2
+
3
+ feature:
4
+ - 2c72c37 flatlint: convert-comma-to-semicolon: openRoundBrace without closeRoundBrace
5
+
6
+ 2025.01.14, v1.44.0
7
+
8
+ feature:
9
+ - e8199e8 flatlint: add-missing-semicolon: exclude question mark
10
+
1
11
  2025.01.13, v1.43.1
2
12
 
3
13
  fix:
@@ -6,6 +6,7 @@ import {
6
6
  openCurlyBrace,
7
7
  closeRoundBrace,
8
8
  dot,
9
+ question,
9
10
  } from '#types';
10
11
 
11
12
  export const report = () => 'Add missing semicolon';
@@ -16,6 +17,7 @@ export const match = () => ({
16
17
  comma,
17
18
  semicolon,
18
19
  openCurlyBrace,
20
+ question,
19
21
  ];
20
22
 
21
23
  if (path.isNextPunctuator(punctuators))
@@ -36,6 +38,7 @@ export const match = () => ({
36
38
  closeRoundBrace,
37
39
  openCurlyBrace,
38
40
  dot,
41
+ question,
39
42
  ];
40
43
 
41
44
  if (path.isNextPunctuator(punctuators))
@@ -1,7 +1,9 @@
1
1
  import {
2
+ closeRoundBrace,
2
3
  colon,
3
4
  isOneOfKeywords,
4
5
  isPunctuator,
6
+ openRoundBrace,
5
7
  quote,
6
8
  } from '#types';
7
9
 
@@ -17,7 +19,12 @@ export const match = () => ({
17
19
  },
18
20
  '__x __a = __b,': check,
19
21
  '__x __a,': check,
20
- 'return __expr,': ({}, path) => !path.isNextPunctuator(quote),
22
+ 'return __expr,': ({__expr}, path) => {
23
+ if (isPunctuator(openRoundBrace, __expr) && !isPunctuator(closeRoundBrace, __expr))
24
+ return false;
25
+
26
+ return !path.isNextPunctuator(quote);
27
+ },
21
28
  });
22
29
 
23
30
  export const replace = () => ({
@@ -138,15 +138,7 @@ const createIsNextPunctuator = ({tokens, end}) => (punctuators) => {
138
138
  if (!current)
139
139
  return false;
140
140
 
141
- if (!punctuators)
142
- return isPunctuator(current);
143
-
144
- for (const punctuator of maybeArray(punctuators)) {
145
- if (isPunctuator(current, punctuator))
146
- return true;
147
- }
148
-
149
- return false;
141
+ return isPunctuator(current, punctuators);
150
142
  };
151
143
 
152
144
  const createIsPrevPunctuator = ({tokens, start, end}) => (punctuators) => {
@@ -1,3 +1,5 @@
1
+ const {isArray} = Array;
2
+ const maybeArray = (a) => isArray(a) ? a : [a];
1
3
  const isString = (a) => typeof a === 'string';
2
4
 
3
5
  export const isTemplateTail = (a) => a?.type === 'TemplateTail';
@@ -55,9 +57,12 @@ export const isPunctuator = (token, punctuator) => {
55
57
  if (!punctuator)
56
58
  return true;
57
59
 
58
- const punctuatorValue = punctuator.value;
60
+ for (const {value} of maybeArray(punctuator)) {
61
+ if (token.value === value)
62
+ return true;
63
+ }
59
64
 
60
- return token.value === punctuatorValue;
65
+ return false;
61
66
  };
62
67
 
63
68
  export const StringLiteral = (value) => ({
@@ -116,6 +121,7 @@ export const closeSquareBrace = Punctuator(']');
116
121
  export const colon = Punctuator(':');
117
122
  export const comma = Punctuator(',');
118
123
  export const dot = Punctuator('.');
124
+ export const question = Punctuator('?');
119
125
  export const more = Punctuator('>');
120
126
  export const assign = Punctuator('=');
121
127
  export const openRoundBrace = Punctuator('(');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flatlint",
3
- "version": "1.43.1",
3
+ "version": "1.45.0",
4
4
  "description": "JavaScript tokens-based linter",
5
5
  "main": "lib/flatlint.js",
6
6
  "type": "module",