flatlint 4.2.0 → 4.3.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.01.27, v4.3.1
2
+
3
+ feature:
4
+ - 78d19d3 flatlint: split-namespace-with-specifiers: couple
5
+
6
+ 2026.01.26, v4.3.0
7
+
8
+ feature:
9
+ - e4d86e4 flatlint: eslint-plugin-putout v30.0.1
10
+ - 8a4971d flatlint: split-namespace-with-specifier: add
11
+
1
12
  2026.01.12, v4.2.0
2
13
 
3
14
  feature:
package/README.md CHANGED
@@ -371,6 +371,16 @@ const a = class {
371
371
 
372
372
  </details>
373
373
 
374
+ <details><summary>split <code>namespace</code> with <code>specifiers</code></summary>
375
+
376
+ ```diff
377
+ -import * as plugin, {CUT} from './plugin.js';
378
+ +import as plugin from './plugin.js';
379
+ +const {CUT} = plugin;
380
+ ```
381
+
382
+ </details>
383
+
374
384
  ## Template literals
375
385
 
376
386
  **FlatLint** uses language similar to 🐊[**PutoutScript**](https://github.com/coderaiser/putout/blob/master/docs/putout-script.md#-putoutscript).
@@ -15,18 +15,20 @@ const maybeArray = (a) => isArray(a) ? a : [a];
15
15
 
16
16
  const {entries} = Object;
17
17
 
18
+ const createAddWay = (ways) => ({value, index}) => {
19
+ if (is(value)) {
20
+ ways[value] = ways[value] || [];
21
+ ways[value].push(index);
22
+ }
23
+ };
24
+
18
25
  export function findVarsWays(tokens) {
19
26
  const ways = {};
27
+ const add = createAddWay(ways);
20
28
 
21
29
  traverse(tokens, {
22
- Identifier({value, index}) {
23
- if (is(value))
24
- ways[value] = index;
25
- },
26
- StringLiteral({value, index}) {
27
- if (is(value))
28
- ways[value] = index;
29
- },
30
+ Identifier: add,
31
+ StringLiteral: add,
30
32
  });
31
33
 
32
34
  return ways;
@@ -71,7 +73,9 @@ export function getValues(tokens, waysFrom) {
71
73
  }
72
74
 
73
75
  export function setValues({to, waysTo, values}) {
74
- for (const [name, index] of entries(waysTo)) {
76
+ const namesWithIndexes = getNamesWithIndexes(waysTo);
77
+
78
+ for (const [name, index] of namesWithIndexes) {
75
79
  const current = maybeArray(values[name]);
76
80
  to.splice(index, 1, ...current);
77
81
  }
@@ -83,3 +87,15 @@ export function getCurrentValues({from, start, end, tokens}) {
83
87
 
84
88
  return getValues(current, waysFrom);
85
89
  }
90
+
91
+ function getNamesWithIndexes(waysTo) {
92
+ const namesWithIndexes = [];
93
+
94
+ for (const [name, ways] of entries(waysTo)) {
95
+ for (const index of ways) {
96
+ namesWithIndexes.push([name, index]);
97
+ }
98
+ }
99
+
100
+ return namesWithIndexes;
101
+ }
@@ -0,0 +1,7 @@
1
+ export const report = () => `Split 'namespace' with 'specifiers'`;
2
+
3
+ export const replace = () => ({
4
+ 'import * as __a, {__b} from "__c"': 'import * as __a from "__c";\nconst {__b} = __a;',
5
+ 'import * as __a, {__b, __c} from "__d"': 'import * as __a from "__d";\nconst {__b, __c} = __a;',
6
+ 'import * as __a, {__b, __c, __d} from "__e"': 'import * as __a from "__e";\nconst {__b, __c, __d} = __a;',
7
+ });
package/lib/plugins.js CHANGED
@@ -19,6 +19,7 @@ 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';
22
+ import * as splitNamespaceWithSpecifiers from './plugins/split-namespace-with-specifiers/index.js';
22
23
  import * as convertSemicolonToComma from './plugins/convert-semicolon-to-comma/index.js';
23
24
  import * as convertColonToComma from './plugins/convert-colon-to-comma/index.js';
24
25
  import * as convertColonToSemicolon from './plugins/convert-colon-to-semicolon/index.js';
@@ -53,5 +54,6 @@ export const plugins = [
53
54
  ['remove-useless-assign', removeUselessAssign],
54
55
  ['remove-useless-dot', removeUselessDot],
55
56
  ['remove-invalid-character', removeInvalidCharacter],
57
+ ['split-namespace-with-specifiers', splitNamespaceWithSpecifiers],
56
58
  ['wrap-assignment-in-parens', wrapAssignmentInParens],
57
59
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flatlint",
3
- "version": "4.2.0",
3
+ "version": "4.3.1",
4
4
  "description": "JavaScript tokens-based linter",
5
5
  "main": "lib/flatlint.js",
6
6
  "type": "module",
@@ -86,7 +86,7 @@
86
86
  "@putout/test": "^15.0.0",
87
87
  "c8": "^10.1.2",
88
88
  "eslint": "^9.7.0",
89
- "eslint-plugin-putout": "^29.0.2",
89
+ "eslint-plugin-putout": "^30.0.1",
90
90
  "madrun": "^12.1.0",
91
91
  "mock-require": "^3.0.3",
92
92
  "montag": "^1.0.0",