flatlint 2.4.0 → 2.5.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.03.11, v2.5.0
2
+
3
+ feature:
4
+ - 5ef987c flatlint: apply-import-order: add
5
+
1
6
  2025.03.07, v2.4.0
2
7
 
3
8
  feature:
package/README.md CHANGED
@@ -19,6 +19,15 @@ npm i flatlint
19
19
 
20
20
  ## Available fixes
21
21
 
22
+ <details><summary>apply import order</summary>
23
+
24
+ ```diff
25
+ -import {readFile}, fs from 'node:fs';
26
+ +import fs, {readFile} from 'node:fs';
27
+ ```
28
+
29
+ </details>
30
+
22
31
  <details><summary>assignment without parentheses after <code>&&</code></summary>
23
32
 
24
33
  ```diff
@@ -58,3 +58,4 @@ export function parseStringLiteral({i, token, tokens}) {
58
58
 
59
59
  return i;
60
60
  }
61
+
@@ -0,0 +1,5 @@
1
+ export const report = () => `Add 'const' to 'export'`;
2
+
3
+ export const replace = () => ({
4
+ 'import {__a}, __b from "__c"': 'import __b, {__a} from "__c"',
5
+ });
package/lib/plugins.js CHANGED
@@ -7,6 +7,7 @@ import * as addMissingQuote from './plugins/add-missing-quote/index.js';
7
7
  import * as addMissingSemicolon from './plugins/add-missing-semicolon/index.js';
8
8
  import * as addMissingComma from './plugins/add-missing-comma/index.js';
9
9
  import * as addConstToExport from './plugins/add-const-to-export/index.js';
10
+ import * as applyImportOrder from './plugins/apply-import-order/index.js';
10
11
  import * as convertCommaToSemicolon from './plugins/convert-comma-to-semicolon/index.js';
11
12
  import * as convertFromToRequire from './plugins/convert-from-to-require/index.js';
12
13
  import * as removeUselessComma from './plugins/remove-useless-comma/index.js';
@@ -18,7 +19,6 @@ import * as wrapAssignmentInParens from './plugins/wrap-assignment-in-parens/ind
18
19
 
19
20
  export const plugins = [
20
21
  ['add-missing-semicolon', addMissingSemicolon],
21
- ['remove-useless-comma', removeUselessComma],
22
22
  ['add-missing-arrow', addMissingArrow],
23
23
  ['add-missing-assign', addMissingAssign],
24
24
  ['add-missing-curly-brace', addMissingCurlyBrace],
@@ -27,9 +27,11 @@ export const plugins = [
27
27
  ['add-missing-comma', addMissingComma],
28
28
  ['add-missing-quote', addMissingQuote],
29
29
  ['add-const-to-export', addConstToExport],
30
+ ['apply-import-order', applyImportOrder],
30
31
  ['convert-comma-to-semicolon', convertCommaToSemicolon],
31
32
  ['convert-semicolon-to-comma', convertSemicolonToComma],
32
33
  ['convert-from-to-require', convertFromToRequire],
34
+ ['remove-useless-comma', removeUselessComma],
33
35
  ['remove-useless-round-brace', removeUselessRoundBrace],
34
36
  ['remove-useless-dot', removeUselessDot],
35
37
  ['remove-invalid-character', removeInvalidCharacter],
@@ -1,5 +1,19 @@
1
1
  import * as keyword from '@putout/operator-keyword';
2
2
 
3
+ const ARGS = '__args';
4
+ const EXPR = '__expr';
5
+ const ARRAY = '__array';
6
+ const ANY = '__';
7
+ const LINKED_NODE = /^__[a-z]$/;
8
+
9
+ const ALL = [
10
+ ANY,
11
+ LINKED_NODE,
12
+ ARRAY,
13
+ ARGS,
14
+ EXPR,
15
+ ];
16
+
3
17
  const {isArray} = Array;
4
18
  const maybeArray = (a) => isArray(a) ? a : [a];
5
19
  const isString = (a) => typeof a === 'string';
@@ -114,20 +128,7 @@ export const is = (str, array = ALL) => {
114
128
  return false;
115
129
  };
116
130
 
117
- const LINKED_NODE = /^__[a-z]$/;
118
- const ANY = '__';
119
131
  const QUOTE = /^['"]$/;
120
- const ARRAY = '__array';
121
- const EXPR = '__expr';
122
- const ARGS = '__args';
123
-
124
- const ALL = [
125
- ANY,
126
- LINKED_NODE,
127
- ARRAY,
128
- ARGS,
129
- EXPR,
130
- ];
131
132
 
132
133
  function check(str, item) {
133
134
  if (isString(item))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flatlint",
3
- "version": "2.4.0",
3
+ "version": "2.5.0",
4
4
  "description": "JavaScript tokens-based linter",
5
5
  "main": "lib/flatlint.js",
6
6
  "type": "module",
@@ -86,7 +86,6 @@
86
86
  "js-tokens": "^9.0.1"
87
87
  },
88
88
  "devDependencies": {
89
- "@putout/eslint-flat": "^2.0.0",
90
89
  "@putout/formatter-json": "^2.0.0",
91
90
  "@putout/test": "^12.0.1",
92
91
  "c8": "^10.1.2",