flatlint 1.33.0 → 1.35.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.10, v1.35.0
2
+
3
+ feature:
4
+ - aeb79de flatlint: add-missing-semicolon: open round brace
5
+
6
+ 2025.01.10, v1.34.0
7
+
8
+ feature:
9
+ - 49aadee flatlint: convert-comma-to-semicolon: import
10
+
1
11
  2025.01.10, v1.33.0
2
12
 
3
13
  feature:
package/README.md CHANGED
@@ -29,6 +29,9 @@ function x() {
29
29
  - return m,
30
30
  + return m;
31
31
  }
32
+
33
+ -import a from 'a',
34
+ +import a from 'a';
32
35
  ```
33
36
 
34
37
  </details>
@@ -2,6 +2,7 @@ import {
2
2
  closeCurlyBrace,
3
3
  closeRoundBrace,
4
4
  comma,
5
+ openCurlyBrace,
5
6
  openRoundBrace,
6
7
  semicolon,
7
8
  } from '#types';
@@ -11,6 +12,7 @@ export const collectExpression = ({currentTokenIndex, tokens, nextTemplateToken
11
12
  const n = tokens.length;
12
13
  let index = currentTokenIndex;
13
14
  let roundBracesBalance = 0;
15
+ let curlyBracesBalance = 0;
14
16
 
15
17
  for (; index < n; index++) {
16
18
  const token = tokens[index];
@@ -24,17 +26,23 @@ export const collectExpression = ({currentTokenIndex, tokens, nextTemplateToken
24
26
  if (equal(token, nextTemplateToken))
25
27
  break;
26
28
 
27
- if (equal(token, closeCurlyBrace))
28
- break;
29
-
30
29
  if (equal(token, openRoundBrace))
31
30
  ++roundBracesBalance;
32
31
 
33
32
  if (equal(token, closeRoundBrace))
34
33
  --roundBracesBalance;
35
34
 
35
+ if (equal(token, openCurlyBrace))
36
+ ++curlyBracesBalance;
37
+
38
+ if (equal(token, closeCurlyBrace))
39
+ --curlyBracesBalance;
40
+
36
41
  if (roundBracesBalance < 0)
37
42
  break;
43
+
44
+ if (curlyBracesBalance < 0)
45
+ break;
38
46
  }
39
47
 
40
48
  return --index;
@@ -4,6 +4,7 @@ import {
4
4
  semicolon,
5
5
  arrow,
6
6
  openCurlyBrace,
7
+ closeRoundBrace,
7
8
  } from '#types';
8
9
 
9
10
  export const report = () => 'Add missing semicolon';
@@ -27,13 +28,15 @@ export const match = () => ({
27
28
  return true;
28
29
  },
29
30
  '__a(__args)': (vars, path) => {
30
- if (path.isNextPunctuator(comma))
31
- return false;
32
-
33
- if (path.isNextPunctuator(semicolon))
34
- return false;
35
-
36
- if (path.isNextPunctuator(arrow))
31
+ const punctuators = [
32
+ comma,
33
+ semicolon,
34
+ arrow,
35
+ closeRoundBrace,
36
+ openCurlyBrace,
37
+ ];
38
+
39
+ if (path.isNextPunctuator(punctuators))
37
40
  return false;
38
41
 
39
42
  if (path.isNextPunctuator(openCurlyBrace))
@@ -17,6 +17,7 @@ export const match = () => ({
17
17
  });
18
18
 
19
19
  export const replace = () => ({
20
+ 'from "__a",': 'from "__a";',
20
21
  'var __a,': 'var __a;',
21
22
  'let __a,': 'let __a;',
22
23
  'var __a = __b,': 'var __a = __b;',
@@ -6,6 +6,9 @@ import {
6
6
  isWhiteSpace,
7
7
  } from '#types';
8
8
 
9
+ const {isArray} = Array;
10
+ const maybeArray = (a) => isArray(a) ? a : [a];
11
+
9
12
  export const createPath = ({tokens, start, end}) => ({
10
13
  tokens,
11
14
  start,
@@ -88,7 +91,7 @@ const createIsNextOperator = ({tokens, end}) => () => {
88
91
  return isOperator(current);
89
92
  };
90
93
 
91
- const createIsNextPunctuator = ({tokens, end}) => (punctuator) => {
94
+ const createIsNextPunctuator = ({tokens, end}) => (punctuators) => {
92
95
  const current = next({
93
96
  tokens,
94
97
  end,
@@ -97,7 +100,12 @@ const createIsNextPunctuator = ({tokens, end}) => (punctuator) => {
97
100
  if (!current)
98
101
  return false;
99
102
 
100
- return isPunctuator(current, punctuator);
103
+ for (const punctuator of maybeArray(punctuators)) {
104
+ if (isPunctuator(current, punctuator))
105
+ return true;
106
+ }
107
+
108
+ return false;
101
109
  };
102
110
 
103
111
  const createIsPrevIdentifier = ({tokens, start}) => (value) => {
@@ -127,3 +135,4 @@ const createGetAllNext = ({tokens, end}) => function*() {
127
135
  yield current;
128
136
  }
129
137
  };
138
+
@@ -21,6 +21,7 @@ export const isOperator = (token) => {
21
21
  'let',
22
22
  'const',
23
23
  'export',
24
+ 'from',
24
25
  ];
25
26
 
26
27
  for (const operator of operators) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flatlint",
3
- "version": "1.33.0",
3
+ "version": "1.35.0",
4
4
  "description": "JavaScript tokens-based linter",
5
5
  "main": "lib/flatlint.js",
6
6
  "type": "module",