flatlint 1.76.0 → 1.78.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.22, v1.78.0
2
+
3
+ feature:
4
+ - fd9ced0 flatlint: convert-comma-to-semicolon: exclude quote
5
+
6
+ 2025.01.22, v1.77.0
7
+
8
+ feature:
9
+ - e4d3929 flatlint: convert-comma-to-semicolon: array
10
+
1
11
  2025.01.22, v1.76.0
2
12
 
3
13
  feature:
@@ -1,4 +1,5 @@
1
1
  import {
2
+ closeCurlyBrace,
2
3
  closeRoundBrace,
3
4
  closeSquareBrace,
4
5
  colon,
@@ -14,20 +15,17 @@ import {
14
15
  export const report = () => 'Use semicolon instead of trailing comma';
15
16
  export const match = () => ({
16
17
  '__a(__args),': (vars, path) => {
17
- if (path.isNextKeyword())
18
- return true;
19
-
20
- const punctuators = [
21
- colon,
22
- spread,
23
- ];
18
+ const punctuators = [colon, spread];
24
19
 
25
20
  for (const token of path.getAllPrev()) {
26
21
  if (isOneOfPunctuators(token, punctuators))
27
22
  return false;
28
23
  }
29
24
 
30
- return true;
25
+ if (path.isNextPunctuator(closeCurlyBrace))
26
+ return true;
27
+
28
+ return path.isNextKeyword();
31
29
  },
32
30
  '__x __a = __expr,': check,
33
31
  '__x __a,': check,
@@ -40,6 +38,9 @@ export const match = () => ({
40
38
 
41
39
  return !path.isNextPunctuator(quote);
42
40
  },
41
+ '__a.__b = __expr,': ({__expr}, path) => {
42
+ return !path.isNextPunctuator(quote);
43
+ },
43
44
  });
44
45
 
45
46
  export const replace = () => ({
@@ -49,10 +50,9 @@ export const replace = () => ({
49
50
  '__a(__args),': '__a(__args);',
50
51
  'return __expr,': 'return __expr;',
51
52
  '__a.__b = __expr,': '__a.__b = __expr;',
52
- '__a.__b.__c = __expr,': '__a.__b.__c = __expr;',
53
53
  });
54
54
 
55
- const check = ({__x}, path) => {
55
+ const check = ({__x, __a}, path) => {
56
56
  if (!isOneOfKeywords(__x, ['var', 'let', 'const']))
57
57
  return false;
58
58
 
@@ -62,5 +62,6 @@ const check = ({__x}, path) => {
62
62
  if (path.isNextIdentifier('module'))
63
63
  return true;
64
64
 
65
- return path.isNextKeyword();
65
+ return path.isNextKeyword() && !path.isNextIdentifier('new');
66
66
  };
67
+
@@ -97,13 +97,13 @@ const createIsInsideTemplate = ({tokens, end}) => () => {
97
97
  return isTemplateMiddle(current);
98
98
  };
99
99
 
100
- const createIsNextKeyword = ({tokens, end}) => () => {
100
+ const createIsNextKeyword = ({tokens, end}) => (name) => {
101
101
  const current = next({
102
102
  tokens,
103
103
  end,
104
104
  });
105
105
 
106
- return isKeyword(current);
106
+ return isKeyword(current, name);
107
107
  };
108
108
 
109
109
  const createIsNextPunctuator = ({tokens, end}) => (punctuators) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flatlint",
3
- "version": "1.76.0",
3
+ "version": "1.78.0",
4
4
  "description": "JavaScript tokens-based linter",
5
5
  "main": "lib/flatlint.js",
6
6
  "type": "module",