flatlint 1.92.0 → 1.93.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.02.01, v1.93.0
2
+
3
+ feature:
4
+ - 1141c03 flatlint: add-missing-round-brace: exclude declaration
5
+
1
6
  2025.02.01, v1.92.0
2
7
 
3
8
  feature:
@@ -1,4 +1,7 @@
1
- import {closeRoundBrace} from '#types';
1
+ import {
2
+ closeRoundBrace,
3
+ isDeclarationKeyword,
4
+ } from '#types';
2
5
 
3
6
  export const report = () => 'Add missing round brace';
4
7
 
@@ -12,6 +15,9 @@ export const match = () => ({
12
15
  'if (__a(__args)': (vars, path) => {
13
16
  return path.isNextKeyword();
14
17
  },
18
+ '{__a} = __expr;': (vars, path) => {
19
+ return !path.isPrevDeclarationKeyword();
20
+ },
15
21
  });
16
22
 
17
23
  export const replace = () => ({
@@ -7,6 +7,7 @@ import {
7
7
  isNoSubstitutionTemplate,
8
8
  getNext,
9
9
  getPrev,
10
+ isDeclarationKeyword,
10
11
  } from '#types';
11
12
 
12
13
  export const createPath = ({tokens, start, end}) => ({
@@ -25,6 +26,10 @@ export const createPath = ({tokens, start, end}) => ({
25
26
  tokens,
26
27
  start,
27
28
  }),
29
+ isPrevDeclarationKeyword: createIsPrevDeclarationKeyword({
30
+ tokens,
31
+ start,
32
+ }),
28
33
  isNextKeyword: createIsNextKeyword({
29
34
  tokens,
30
35
  end,
@@ -114,6 +119,15 @@ const createGetPrev = ({tokens, start}) => () => {
114
119
  });
115
120
  };
116
121
 
122
+ const createIsPrevDeclarationKeyword = ({tokens, start}) => () => {
123
+ const prev = getPrev({
124
+ tokens,
125
+ start,
126
+ });
127
+
128
+ return isDeclarationKeyword(prev);
129
+ };
130
+
117
131
  const createIsPrevPunctuator = ({tokens, start}) => (punctuators) => {
118
132
  const current = getPrev({
119
133
  tokens,
@@ -40,6 +40,9 @@ export const isKeyword = (token, name) => {
40
40
  };
41
41
 
42
42
  export const isDeclarationKeyword = (token, name) => {
43
+ if (!token)
44
+ return false;
45
+
43
46
  const {value} = token;
44
47
 
45
48
  if (!keyword.isDeclarationKeyword(value))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flatlint",
3
- "version": "1.92.0",
3
+ "version": "1.93.0",
4
4
  "description": "JavaScript tokens-based linter",
5
5
  "main": "lib/flatlint.js",
6
6
  "type": "module",