flatlint 1.42.1 → 1.43.1

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.13, v1.43.1
2
+
3
+ fix:
4
+ - 9983889 flatlint: add-missing-comma: exclude: for-of
5
+
6
+ 2025.01.13, v1.43.0
7
+
8
+ feature:
9
+ - 2c1b64c flatlint: add missing arrow: add
10
+
1
11
  2025.01.13, v1.42.1
2
12
 
3
13
  fix:
package/README.md CHANGED
@@ -76,6 +76,15 @@ import {
76
76
 
77
77
  </details>
78
78
 
79
+ <details><summary>add missing arrow <code>'=>'</code></summary>
80
+
81
+ ```diff
82
+ -const a = (b, c) {};
83
+ +const a = (b, c) => {};
84
+ ```
85
+
86
+ </details>
87
+
79
88
  <details><summary>add <code>const</code> to <code>export</code></summary>
80
89
 
81
90
  ```diff
@@ -34,6 +34,9 @@ export const compare = (source, template, {index = 0} = {}) => {
34
34
  for (let templateIndex = 0; templateIndex < templateTokensLength; templateIndex++) {
35
35
  let currentTokenIndex = index + templateIndex - skip;
36
36
 
37
+ if (currentTokenIndex > n)
38
+ return [NOT_OK];
39
+
37
40
  const templateToken = templateTokens[templateIndex];
38
41
  const currentToken = tokens[currentTokenIndex];
39
42
 
@@ -0,0 +1,28 @@
1
+ import {
2
+ colon,
3
+ isOneOfKeywords,
4
+ isPunctuator,
5
+ openCurlyBrace,
6
+ } from '#types';
7
+
8
+ export const report = () => `Add missing '=>'`;
9
+
10
+ export const match = () => ({
11
+ '(__args) {': (vars, path) => {
12
+ for (const current of path.getAllPrev()) {
13
+ if (isPunctuator(current, colon))
14
+ return true;
15
+
16
+ if (isPunctuator(current, openCurlyBrace))
17
+ return false;
18
+
19
+ if (isOneOfKeywords(current, ['if', 'function']))
20
+ return false;
21
+ }
22
+
23
+ return true;
24
+ },
25
+ });
26
+ export const replace = () => ({
27
+ '(__args) {': '(__args) => {',
28
+ });
package/lib/plugins.js CHANGED
@@ -1,4 +1,4 @@
1
- import * as wrapAssignmentInParens from './plugins/wrap-assignment-in-parens/index.js';
1
+ import * as addMissingArrow from './plugins/add-missing-arrow/index.js';
2
2
  import * as addMissingRoundBraces from './plugins/add-missing-round-braces/index.js';
3
3
  import * as addMissingSquireBrace from './plugins/add-missing-square-brace/index.js';
4
4
  import * as addMissingQuote from './plugins/add-missing-quote/index.js';
@@ -10,9 +10,10 @@ import * as convertFromToRequire from './plugins/convert-from-to-require/index.j
10
10
  import * as removeUselessRoundBrace from './plugins/remove-useless-round-brace/index.js';
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
+ import * as wrapAssignmentInParens from './plugins/wrap-assignment-in-parens/index.js';
13
14
 
14
15
  export const plugins = [
15
- ['wrap-assignment-in-parens', wrapAssignmentInParens],
16
+ ['add-missing-arrow', addMissingArrow],
16
17
  ['add-missing-round-braces', addMissingRoundBraces],
17
18
  ['add-missing-squire-brace', addMissingSquireBrace],
18
19
  ['add-missing-semicolon', addMissingSemicolon],
@@ -24,4 +25,5 @@ export const plugins = [
24
25
  ['remove-useless-round-brace', removeUselessRoundBrace],
25
26
  ['remove-useless-comma', removeUselessComma],
26
27
  ['remove-invalid-character', removeInvalidCharacter],
28
+ ['wrap-assignment-in-parens', wrapAssignmentInParens],
27
29
  ];
@@ -28,6 +28,7 @@ export const isKeyword = (token) => {
28
28
  'import',
29
29
  'return',
30
30
  'function',
31
+ 'of',
31
32
  ];
32
33
 
33
34
  for (const keyword of keywords) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flatlint",
3
- "version": "1.42.1",
3
+ "version": "1.43.1",
4
4
  "description": "JavaScript tokens-based linter",
5
5
  "main": "lib/flatlint.js",
6
6
  "type": "module",