flatlint 1.44.0 → 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,8 @@
1
+ 2025.01.14, v1.45.0
2
+
3
+ feature:
4
+ - 2c72c37 flatlint: convert-comma-to-semicolon: openRoundBrace without closeRoundBrace
5
+
1
6
  2025.01.14, v1.44.0
2
7
 
3
8
  feature:
@@ -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) => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flatlint",
3
- "version": "1.44.0",
3
+ "version": "1.45.0",
4
4
  "description": "JavaScript tokens-based linter",
5
5
  "main": "lib/flatlint.js",
6
6
  "type": "module",