flatlint 1.47.1 → 1.49.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,13 @@
1
+ 2025.01.14, v1.49.0
2
+
3
+ feature:
4
+ - ffade65 flatlint: remove-useless-comma: exclude: property
5
+
6
+ 2025.01.14, v1.48.0
7
+
8
+ feature:
9
+ - a1c3d85 flatlint: add-missing-comma: exclude typeof
10
+
1
11
  2025.01.14, v1.47.1
2
12
 
3
13
  fix:
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  closeCurlyBrace,
3
+ colon,
3
4
  isIdentifier,
4
5
  isPunctuator,
5
6
  openSquireBrace,
@@ -30,6 +31,14 @@ export const match = () => ({
30
31
 
31
32
  return path.isNextIdentifier('const');
32
33
  },
34
+ '}),': (vars, path) => {
35
+ for (const token of path.getAllPrev()) {
36
+ if (isPunctuator(token, colon))
37
+ return false;
38
+ }
39
+
40
+ return !path.isNext();
41
+ },
33
42
  });
34
43
 
35
44
  export const replace = () => ({
@@ -4,14 +4,19 @@ const isString = (a) => typeof a === 'string';
4
4
 
5
5
  export const isTemplateTail = (a) => a?.type === 'TemplateTail';
6
6
  export const isWhiteSpace = ({type}) => type === 'WhiteSpace';
7
- export const isIdentifier = (token, value = token.value) => {
7
+ export const isIdentifier = (token, newToken) => {
8
8
  const {type} = token;
9
9
  const is = type === 'IdentifierName';
10
10
 
11
11
  if (!is)
12
12
  return false;
13
13
 
14
- return value === token.value;
14
+ if (!newToken)
15
+ return true;
16
+
17
+ const newValue = newToken.value || newToken;
18
+
19
+ return newValue === token.value;
15
20
  };
16
21
 
17
22
  export const isStringLiteral = ({type}) => type === 'StringLiteral';
@@ -31,6 +36,7 @@ export const isKeyword = (token) => {
31
36
  'return',
32
37
  'function',
33
38
  'of',
39
+ 'typeof',
34
40
  ];
35
41
 
36
42
  for (const keyword of keywords) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flatlint",
3
- "version": "1.47.1",
3
+ "version": "1.49.0",
4
4
  "description": "JavaScript tokens-based linter",
5
5
  "main": "lib/flatlint.js",
6
6
  "type": "module",