flatlint 2.0.3 → 2.0.5

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.02.20, v2.0.5
2
+
3
+ feature:
4
+ - cd51fbe flatlint: convert-comma-to-semicolon: couple reports instead of one
5
+
6
+ 2025.02.19, v2.0.4
7
+
8
+ feature:
9
+ - 8883809 flatlint: add-missing-round-brace: exclude: export default
10
+
1
11
  2025.02.19, v2.0.3
2
12
 
3
13
  feature:
package/README.md CHANGED
@@ -374,4 +374,3 @@ const [code] = lint(`a && b = c`, {
374
374
  ## License
375
375
 
376
376
  MIT
377
-
@@ -64,4 +64,3 @@ function getTokensWithLocation(tokens) {
64
64
 
65
65
  return result;
66
66
  }
67
-
@@ -9,6 +9,9 @@ export const report = () => 'Add missing comma';
9
9
 
10
10
  export const match = () => ({
11
11
  '"__a"': (vars, path) => {
12
+ if (path.isNextKeyword())
13
+ return false;
14
+
12
15
  if (path.isPrevPunctuator(assign))
13
16
  return false;
14
17
 
@@ -6,13 +6,12 @@ import {
6
6
  isKeyword,
7
7
  isPunctuator,
8
8
  openRoundBrace,
9
- semicolon,
10
9
  } from '#types';
11
10
 
12
11
  export const report = () => 'Add missing round brace';
13
12
 
14
13
  export const match = () => ({
15
- '__a(__args': ({__args}, path) => {
14
+ '__a(__args': (vars, path) => {
16
15
  if (path.isCurrentPunctuator(closeRoundBrace))
17
16
  return false;
18
17
 
@@ -74,4 +73,3 @@ export const replace = () => ({
74
73
  '{__a} = __expr': '({__a} = __expr)',
75
74
  '__a;': '__a);',
76
75
  });
77
-
@@ -2,4 +2,3 @@ export const report = () => `Use ';' instead of ':'`;
2
2
  export const replace = () => ({
3
3
  '):': ');',
4
4
  });
5
-
@@ -19,6 +19,9 @@ export const match = () => ({
19
19
  '__a(__args),': (vars, path) => {
20
20
  const punctuators = [colon, spread];
21
21
 
22
+ if (path.isNextDeclarationKeyword())
23
+ return false;
24
+
22
25
  for (const token of path.getAllPrev()) {
23
26
  if (isOneOfPunctuators(token, punctuators))
24
27
  return false;
@@ -27,10 +27,16 @@ export const match = () => ({
27
27
  }
28
28
  },
29
29
  '__a: __expr;': (vars, path) => {
30
- for (const token of path.getAllPrev()) {
31
- if (isOneOfKeywords(token, ['class', 'readonly', 'static', 'implements']))
30
+ const keywords = [
31
+ 'class',
32
+ 'readonly',
33
+ 'static',
34
+ 'implements',
35
+ ];
36
+
37
+ for (const token of path.getAllPrev())
38
+ if (isOneOfKeywords(token, keywords))
32
39
  return false;
33
- }
34
40
 
35
41
  return true;
36
42
  },
@@ -41,6 +41,9 @@ export const match = () => ({
41
41
  return !path.isNext();
42
42
  },
43
43
  '__a(__args),': (vars, path) => {
44
+ if (path.isNextKeyword())
45
+ return false;
46
+
44
47
  if (!path.isNext())
45
48
  return true;
46
49
 
@@ -44,6 +44,10 @@ export const createPath = ({tokens, start, end}) => ({
44
44
  tokens,
45
45
  end,
46
46
  }),
47
+ isNextDeclarationKeyword: createIsNextDeclarationKeyword({
48
+ tokens,
49
+ end,
50
+ }),
47
51
  isNextPunctuator: createIsNextPunctuator({
48
52
  tokens,
49
53
  end,
@@ -123,6 +127,15 @@ const createIsNextKeyword = ({tokens, end}) => () => {
123
127
  return isKeyword(current);
124
128
  };
125
129
 
130
+ const createIsNextDeclarationKeyword = ({tokens, end}) => () => {
131
+ const current = getNext({
132
+ tokens,
133
+ end,
134
+ });
135
+
136
+ return isDeclarationKeyword(current);
137
+ };
138
+
126
139
  const createIsNextPunctuator = ({tokens, end}) => (punctuators) => {
127
140
  const current = getNext({
128
141
  tokens,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flatlint",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
4
4
  "description": "JavaScript tokens-based linter",
5
5
  "main": "lib/flatlint.js",
6
6
  "type": "module",