flatlint 1.97.1 → 1.98.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.03, v1.98.0
2
+
3
+ feature:
4
+ - 2a067ca flatlint: startLine: add
5
+
1
6
  2025.02.03, v1.97.1
2
7
 
3
8
  fix:
package/README.md CHANGED
@@ -321,6 +321,7 @@ When you want to use custom plugins:
321
321
  import {lint} from 'flatlint';
322
322
 
323
323
  const [code] = lint(`a && b = c`, {
324
+ startLine: 1,
324
325
  plugins: [
325
326
  ['wrap-assignment-in-parens', {
326
327
  report: () => `Wrap the assignment in parentheses after '&&'`,
package/lib/flatlint.js CHANGED
@@ -4,18 +4,25 @@ import {run} from '#runner';
4
4
  import {print} from '#printer';
5
5
 
6
6
  export function lint(source, overrides = {}) {
7
- const {fix = true, plugins: pluginNames = []} = overrides;
7
+ const {
8
+ startLine = 1,
9
+ fix = true,
10
+ plugins: pluginNames = [],
11
+ } = overrides;
12
+
8
13
  const plugins = loadPlugins({
9
14
  pluginNames,
10
15
  });
11
16
 
12
17
  const tokens = parse(source);
13
18
 
14
- const places = run(tokens, {
19
+ const rawPlaces = run(tokens, {
15
20
  plugins,
16
21
  fix,
17
22
  });
18
23
 
24
+ const places = rawPlaces.map(addStartLine(startLine));
25
+
19
26
  if (!fix)
20
27
  return [source, places];
21
28
 
@@ -24,3 +31,15 @@ export function lint(source, overrides = {}) {
24
31
  places,
25
32
  ];
26
33
  }
34
+
35
+ const addStartLine = (startLine) => (a) => {
36
+ const {line, column} = a.position;
37
+
38
+ return {
39
+ ...a,
40
+ position: {
41
+ column,
42
+ line: startLine + line - 1,
43
+ },
44
+ };
45
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flatlint",
3
- "version": "1.97.1",
3
+ "version": "1.98.0",
4
4
  "description": "JavaScript tokens-based linter",
5
5
  "main": "lib/flatlint.js",
6
6
  "type": "module",