flatlint 5.1.0 → 5.2.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,14 @@
1
+ 2026.03.14, v5.2.1
2
+
3
+ feature:
4
+ - 961c259 flatlint: convert-colon-to-semicolon: type: exclude
5
+
6
+ 2026.03.11, v5.2.0
7
+
8
+ feature:
9
+ - 282978f flatlint: add-missing-round-brace: remove-useless-assign: improve support
10
+ - 111269b flatlint: superc8 v12.3.1
11
+
1
12
  2026.02.18, v5.1.0
2
13
 
3
14
  feature:
@@ -56,4 +56,3 @@ export const compare = (source, template, {index = 0} = {}) => {
56
56
 
57
57
  return [NOT_OK];
58
58
  };
59
-
@@ -22,7 +22,7 @@ export const match = () => ({
22
22
  'if (__a(__args)': (vars, path) => {
23
23
  return path.isNextKeyword();
24
24
  },
25
- '{__a} = __expr;': (vars, path) => !path.isPrevDeclarationKeyword(),
25
+ '{__a} = __expr;': (vars, path) => !path.isPrevAnyDeclarationKeyword(),
26
26
  '{__a} = __expr': (vars, path) => {
27
27
  return path.isNextKeyword();
28
28
  },
@@ -1,4 +1,12 @@
1
1
  export const report = () => `Use ';' instead of ':'`;
2
+ export const match = () => ({
3
+ '):': (vars, path) => {
4
+ if (!path.isNext())
5
+ return true;
6
+
7
+ return path.isNextKeyword();
8
+ },
9
+ });
2
10
  export const replace = () => ({
3
11
  '):': ');',
4
12
  });
@@ -13,7 +13,7 @@ export const report = () => `Remove useless ','`;
13
13
  export const match = () => ({
14
14
  '__a(__args) {},': (vars, path) => {
15
15
  for (const token of path.getAllPrev()) {
16
- if (isIdentifier(token, 'class'))
16
+ if (isIdentifier(token, {name: 'class'}))
17
17
  return true;
18
18
  }
19
19
 
package/lib/plugins.js CHANGED
@@ -1,3 +1,4 @@
1
+ import * as removeUselessAssign from '#plugin-remove-useless-assign';
1
2
  import * as addMissingArrow from './plugins/add-missing-arrow/index.js';
2
3
  import * as addMissingAssign from './plugins/add-missing-assign/index.js';
3
4
  import * as addMissingCurlyBrace from './plugins/add-missing-curly-brace/index.js';
@@ -15,7 +16,6 @@ import * as convertCommaToSemicolon from './plugins/convert-comma-to-semicolon/i
15
16
  import * as convertFromToRequire from './plugins/convert-from-to-require/index.js';
16
17
  import * as removeUselessComma from './plugins/remove-useless-comma/index.js';
17
18
  import * as removeUselessArrow from './plugins/remove-useless-arrow/index.js';
18
- import * as removeUselessAssign from './plugins/remove-useless-assign/index.js';
19
19
  import * as removeUselessDot from './plugins/remove-useless-dot/index.js';
20
20
  import * as removeInvalidCharacter from './plugins/remove-invalid-character/index.js';
21
21
  import * as removeUselessRoundBrace from './plugins/remove-useless-round-brace/index.js';
@@ -12,6 +12,7 @@ import {
12
12
  isNewLine,
13
13
  isWhiteSpace,
14
14
  isTemplateHead,
15
+ isAnyDeclarationKeyword,
15
16
  } from '#types';
16
17
  import {equalTemplate} from '../compare/equal.js';
17
18
 
@@ -39,6 +40,10 @@ export const createPath = ({tokens, start, end}) => ({
39
40
  tokens,
40
41
  start,
41
42
  }),
43
+ isPrevAnyDeclarationKeyword: createIsPrevAnyDeclarationKeyword({
44
+ tokens,
45
+ start,
46
+ }),
42
47
  isPrevKeyword: createIsPrevKeyword({
43
48
  tokens,
44
49
  start,
@@ -185,6 +190,15 @@ const createGetPrev = ({tokens, start}) => () => {
185
190
  });
186
191
  };
187
192
 
193
+ const createIsPrevAnyDeclarationKeyword = ({tokens, start}) => () => {
194
+ const prev = getPrev({
195
+ tokens,
196
+ start,
197
+ });
198
+
199
+ return isAnyDeclarationKeyword(prev);
200
+ };
201
+
188
202
  const createIsPrevDeclarationKeyword = ({tokens, start}) => () => {
189
203
  const prev = getPrev({
190
204
  tokens,
@@ -37,7 +37,7 @@ export const isIdentifier = (token, newToken) => {
37
37
  if (!newToken)
38
38
  return true;
39
39
 
40
- const newValue = newToken.value || newToken;
40
+ const newValue = newToken.name || newToken.value || newToken;
41
41
 
42
42
  return newValue === token.value;
43
43
  };
@@ -68,9 +68,6 @@ export const isKeyword = (token, names) => {
68
68
  };
69
69
 
70
70
  export const isDeclarationKeyword = (token, name) => {
71
- if (!token)
72
- return false;
73
-
74
71
  const {value} = token;
75
72
 
76
73
  if (!keyword.isDeclarationKeyword(value))
@@ -79,6 +76,18 @@ export const isDeclarationKeyword = (token, name) => {
79
76
  return isIdentifier(token, name);
80
77
  };
81
78
 
79
+ export const isAnyDeclarationKeyword = (token) => {
80
+ if (!token)
81
+ return false;
82
+
83
+ const {value} = token;
84
+
85
+ if (keyword.isDeclarationKeyword(value))
86
+ return true;
87
+
88
+ return keyword.isModuleDeclarationKeyword(value);
89
+ };
90
+
82
91
  export const isOneOfIdentifiers = (token, keywords) => {
83
92
  for (const keyword of keywords) {
84
93
  if (isIdentifier(token, keyword))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flatlint",
3
- "version": "5.1.0",
3
+ "version": "5.2.1",
4
4
  "description": "JavaScript tokens-based linter",
5
5
  "main": "lib/flatlint.js",
6
6
  "type": "module",
@@ -17,7 +17,8 @@
17
17
  "#compare": "./lib/compare/compare.js",
18
18
  "#compare/values": "./lib/compare/values.js",
19
19
  "#runner": "./lib/runner/runner.js",
20
- "#flatlint": "./lib/flatlint.js"
20
+ "#flatlint": "./lib/flatlint.js",
21
+ "#plugin-remove-useless-assign": "./lib/plugins/remove-useless-assign/index.js"
21
22
  },
22
23
  "scripts": {
23
24
  "lint": "madrun lint",
@@ -66,7 +67,6 @@
66
67
  },
67
68
  "devDependencies": {
68
69
  "@putout/test": "^15.0.0",
69
- "c8": "^10.1.2",
70
70
  "eslint": "^10.0.0",
71
71
  "eslint-plugin-putout": "^31.0.0",
72
72
  "madrun": "^13.0.0",
@@ -74,6 +74,7 @@
74
74
  "montag": "^1.0.0",
75
75
  "nodemon": "^3.0.1",
76
76
  "putout": "^42.0.3",
77
+ "superc8": "^12.3.1",
77
78
  "supertape": "^12.0.0"
78
79
  },
79
80
  "engines": {