flatlint 1.17.0 → 1.18.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.02, v1.18.0
2
+
3
+ feature:
4
+ - 99d6dbf flatlint: remove-useless-arrow: add
5
+
1
6
  2025.01.02, v1.17.0
2
7
 
3
8
  feature:
package/README.md CHANGED
@@ -110,6 +110,17 @@ const a = {
110
110
 
111
111
  </details>
112
112
 
113
+ <details><summary>Remove useless arrow</summary>
114
+
115
+ ```diff
116
+ -function parse(source) => {
117
+ +function parse(source) {
118
+ return source;
119
+ }
120
+ ```
121
+
122
+ </details>
123
+
113
124
  ## Template literals
114
125
 
115
126
  **FlatLint** uses language similar to 🐊[**PutoutScript**](https://github.com/coderaiser/putout/blob/master/docs/putout-script.md#-putoutscript).
@@ -1,4 +1,7 @@
1
- import {Punctuator} from '#types';
1
+ import {
2
+ CloseRoundBrace,
3
+ Punctuator,
4
+ } from '#types';
2
5
  import {equal} from './equal.js';
3
6
 
4
7
  export const collectArray = ({currentTokenIndex, tokens, nextTemplateToken = Punctuator(';')}) => {
@@ -9,6 +12,9 @@ export const collectArray = ({currentTokenIndex, tokens, nextTemplateToken = Pun
9
12
  for (; index < n; index++) {
10
13
  const token = tokens[index];
11
14
 
15
+ if (equal(token, CloseRoundBrace))
16
+ break;
17
+
12
18
  if (equal(token, nextTemplateToken))
13
19
  break;
14
20
 
@@ -0,0 +1,5 @@
1
+ export const report = () => 'Remove useless arrow';
2
+
3
+ export const replace = () => ({
4
+ 'function __a(__array) => {': 'function __a(__array) {',
5
+ });
@@ -53,3 +53,6 @@ export const isTemplateArray = (a) => a === ARRAY;
53
53
  export const isTemplateExpression = (a) => a === EXPR;
54
54
  export const isTemplateArrayToken = (a) => isIdentifier(a) && isTemplateArray(a.value);
55
55
  export const isTemplateExpressionToken = (a) => isIdentifier(a) && isTemplateExpression(a.value);
56
+
57
+ export const OpenRoundBrace = Punctuator('(');
58
+ export const CloseRoundBrace = Punctuator(')');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flatlint",
3
- "version": "1.17.0",
3
+ "version": "1.18.0",
4
4
  "description": "JavaScript tokens-based linter",
5
5
  "main": "lib/flatlint.js",
6
6
  "type": "module",