flatlint 1.54.1 → 1.55.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.17, v1.55.0
2
+
3
+ feature:
4
+ - 8d3ee0b flatlint: remove-useless-semicolon -> convert-semicolon-to-comma
5
+
1
6
  2025.01.17, v1.54.1
2
7
 
3
8
  feature:
package/README.md CHANGED
@@ -137,7 +137,7 @@ import {
137
137
 
138
138
  </details>
139
139
 
140
- <details><summary>remove useless semicolon</summary>
140
+ <details><summary>convert semicolon to comma</summary>
141
141
 
142
142
  ```diff
143
143
  const a = {
@@ -9,9 +9,6 @@ export const report = () => 'Add missing round brace';
9
9
 
10
10
  export const match = () => ({
11
11
  '(__args) {': ({__args}) => {
12
- if (isPunctuator(arrow, __args))
13
- return false;
14
-
15
12
  if (!isPunctuator(openRoundBrace, __args))
16
13
  return false;
17
14
 
@@ -13,7 +13,7 @@ import {
13
13
  export const report = () => 'Add missing semicolon';
14
14
 
15
15
  export const match = () => ({
16
- 'const __a = __expr': (vars, path) => {
16
+ 'const __a = __expr': ({__expr}, path) => {
17
17
  const punctuators = [
18
18
  comma,
19
19
  semicolon,
@@ -21,6 +21,9 @@ export const match = () => ({
21
21
  question,
22
22
  ];
23
23
 
24
+ if (isPunctuator(openCurlyBrace, __expr))
25
+ return false;
26
+
24
27
  if (path.isNextPunctuator(punctuators))
25
28
  return false;
26
29
 
@@ -1,6 +1,6 @@
1
1
  import {isIdentifier} from '#types';
2
2
 
3
- export const report = () => 'Remove useless semicolon';
3
+ export const report = () => `Use ',' instead of ';'`;
4
4
 
5
5
  export const match = () => ({
6
6
  '__a: __expr;': (vars, path) => {
@@ -15,5 +15,4 @@ export const match = () => ({
15
15
 
16
16
  export const replace = () => ({
17
17
  '__a: __expr;': '__a: __expr,',
18
- 'export;': 'export',
19
18
  });
package/lib/plugins.js CHANGED
@@ -11,7 +11,7 @@ import * as convertFromToRequire from './plugins/convert-from-to-require/index.j
11
11
  import * as removeUselessComma from './plugins/remove-useless-comma/index.js';
12
12
  import * as removeInvalidCharacter from './plugins/remove-invalid-character/index.js';
13
13
  import * as removeUselessRoundBrace from './plugins/remove-useless-round-brace/index.js';
14
- import * as removeUselessSemicolon from './plugins/remove-useless-semicolon/index.js';
14
+ import * as convertSemicolonToComma from './plugins/convert-semicolon-to-comma/index.js';
15
15
  import * as wrapAssignmentInParens from './plugins/wrap-assignment-in-parens/index.js';
16
16
 
17
17
  export const plugins = [
@@ -24,9 +24,9 @@ export const plugins = [
24
24
  ['add-missing-quote', addMissingQuote],
25
25
  ['add-const-to-export', addConstToExport],
26
26
  ['convert-comma-to-semicolon', convertCommaToSemicolon],
27
+ ['convert-semicolon-to-comma', convertSemicolonToComma],
27
28
  ['convert-from-to-require', convertFromToRequire],
28
29
  ['remove-useless-round-brace', removeUselessRoundBrace],
29
- ['remove-useless-semicolon', removeUselessSemicolon],
30
30
  ['remove-useless-comma', removeUselessComma],
31
31
  ['remove-invalid-character', removeInvalidCharacter],
32
32
  ['wrap-assignment-in-parens', wrapAssignmentInParens],
@@ -47,33 +47,12 @@ export const createPath = ({tokens, start, end}) => ({
47
47
  tokens,
48
48
  start,
49
49
  }),
50
- isPrevPunctuator: createIsPrevPunctuator({
51
- tokens,
52
- start,
53
- end,
54
- }),
55
50
  isCurrentPunctuator: createIsNextPunctuator({
56
51
  tokens,
57
52
  end: end - 1,
58
53
  }),
59
54
  });
60
55
 
61
- const prev = ({tokens, start, end}) => {
62
- let i = end + 1;
63
-
64
- while (--i >= start) {
65
- const token = tokens[i];
66
-
67
- if (isNewLine(token))
68
- continue;
69
-
70
- if (isWhiteSpace(token))
71
- continue;
72
-
73
- return token;
74
- }
75
- };
76
-
77
56
  const next = ({tokens, end}) => {
78
57
  let i = end - 1;
79
58
 
@@ -145,24 +124,6 @@ const createIsNextPunctuator = ({tokens, end}) => (punctuators) => {
145
124
  return isPunctuator(current, punctuators);
146
125
  };
147
126
 
148
- const createIsPrevPunctuator = ({tokens, start, end}) => (punctuators) => {
149
- const current = prev({
150
- tokens,
151
- start,
152
- end,
153
- });
154
-
155
- if (!current)
156
- return false;
157
-
158
- for (const punctuator of maybeArray(punctuators)) {
159
- if (isPunctuator(current, punctuator))
160
- return true;
161
- }
162
-
163
- return false;
164
- };
165
-
166
127
  const createIsPrevIdentifier = ({tokens, start}) => (value) => {
167
128
  const SPACE = 1;
168
129
  const FUNCTION = 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flatlint",
3
- "version": "1.54.1",
3
+ "version": "1.55.0",
4
4
  "description": "JavaScript tokens-based linter",
5
5
  "main": "lib/flatlint.js",
6
6
  "type": "module",