putout 42.6.0 → 42.7.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,29 @@
1
+ 2026.06.18, v42.7.0
2
+
3
+ fix:
4
+ - 3b465e12f @putout/plugin-markdown: simplify
5
+ - 4031967e1 @putout/plugin-markdown: npmignore: fixture
6
+ - 7b7fb253b @putout/test: noTransform: extensionFix
7
+
8
+ feature:
9
+ - 94a3fdcc2 putout: add types
10
+ - 0d04bc6d2 @putotu/plugin-printer: add-missing-arrow-to-type-checker
11
+ - 9b55a8a04 @putout/plugin-convert-throw: drop support of 🐊 < 42
12
+ - 0e85d9564 eslint-plugin-putout: @babel/plugin-syntax-typescript v8.0.0
13
+ - 4cba16d5e eslint-plugin-putout: @babel/core v8.0.0
14
+ - 42dffd472 @putout/plugin-github: set-contents-permissions: exists, not write
15
+ - 44d68381e @putout/plugin-github: set-contents-permissions: report
16
+ - 02596465e @putout/plugin-github: set-contents-permissions
17
+ - 5c08b01a2 @putout/plugin-for-of: for-each: return: exclude (putoutjs/minify#31)
18
+ - 428d81d03 @putout/plugin-markdown: h1-6 -> heading
19
+ - 316a1ec0d @putout/plugin-markdown: remove-trailing-whitespaces-from-heading
20
+ - 8f897c666 @putout/plugin-markdown: remove-dependencies-status-badge
21
+ - 8dd6d4f0d @putout/plugin-putout: convert-traverse-to-super-traverse
22
+ - 95e5435f5 @putout/plugin-putout: declare: superTraverse
23
+ - 1cee4ff4b @putout/traverse: superTraverse
24
+ - 20f556566 @putout/plugin-markdown: split-link-with-title
25
+ - 0e9b89571 @putout/test: noTransform: extensionFix
26
+
1
27
  2026.06.13, v42.6.0
2
28
 
3
29
  fix:
package/lib/index.d.ts ADDED
@@ -0,0 +1,61 @@
1
+ import {File, Program} from '@putout/babel';
2
+ import {PutoutPlugin} from '../types/plugins.ts';
3
+
4
+ export declare function parse(source: string): Program;
5
+ export {traverse} from '@putout/babel';
6
+
7
+ type PutoutReturn = {
8
+ code: string;
9
+ places: Place[];
10
+ };
11
+
12
+ export interface ParseOptions {
13
+ parser?: 'babel' | 'acorn' | 'espree' | 'esprima' | 'tenko';
14
+ printer?: 'putout' | 'babel';
15
+ isTS?: boolean;
16
+ isJSX?: boolean;
17
+ }
18
+
19
+ type RuleState = 'on' | 'off' | boolean;
20
+ type RuleOptions = Record<string, unknown>;
21
+
22
+ type RuleTuple =
23
+ | [RuleState]
24
+ | [RuleState, RuleOptions]
25
+ | [RuleState, string, RuleOptions]; // [state, message, options] — кастомный текст сообщения
26
+
27
+ type RuleValue = RuleState | RuleTuple;
28
+
29
+ export type Rules = Record<string, RuleValue>;
30
+
31
+ export type TransformOptions = {
32
+ plugins?: (string | [string, Record<string, unknown>] | [string, PutoutPlugin])[];
33
+ rules?: Rules;
34
+ fix?: boolean;
35
+ fixCount?: number;
36
+ parser?: string;
37
+ printer?: string;
38
+ };
39
+
40
+ type Options = ParseOptions & TransformOptions;
41
+
42
+ export default function putout(source: string, options: Options): PutoutReturn;
43
+
44
+ export interface PrintOptions {
45
+ printer?: 'putout' | 'babel' | [string, Record<string, unknown>];
46
+ }
47
+
48
+ export function print(ast: File, options?: PrintOptions): string;
49
+
50
+ export interface Place {
51
+ rule: string;
52
+ message: string;
53
+ position: {line: number; column: number};
54
+ }
55
+
56
+ export function transform(ast: File, options?: TransformOptions): Place[];
57
+ export function transformAsync(ast: File, options?: TransformOptions): Promise<Place[]>;
58
+ export function findPlaces(ast: File, options?: TransformOptions): Place[];
59
+ export function findPlacesAsync(ast: File, options?: TransformOptions): Promise<Place[]>;
60
+
61
+ export function codeframe(args: {source: string; error: {message: string; loc?: unknown}; highlightCode?: boolean}): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "putout",
3
- "version": "42.6.0",
3
+ "version": "42.7.0",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "🐊 Pluggable and configurable code transformer with built-in ESLint, Babel and support of js, jsx, typescript, flow, markdown, yaml and json",
@@ -35,11 +35,10 @@
35
35
  "scripts": {
36
36
  "wisdom": "madrun wisdom",
37
37
  "test": "madrun test",
38
- "test:raw": "madrun test:raw",
38
+ "test:dts": "madrun test:dts",
39
39
  "watch:test": "madrun watch:test",
40
40
  "scheme": "madrun scheme",
41
41
  "lint": "madrun lint",
42
- "oldlint": "madrun oldlint",
43
42
  "fresh:lint": "madrun fresh:lint",
44
43
  "fix:lint": "madrun fix:lint",
45
44
  "fix:lint:fresh": "madrun fix:lint:fresh",
@@ -221,6 +220,7 @@
221
220
  "@putout/eslint-flat": "^4.0.0",
222
221
  "@putout/plugin-apply-entries": "^3.0.0",
223
222
  "@putout/test": "^15.1.0",
223
+ "check-dts": "^1.0.0",
224
224
  "currify": "^4.0.0",
225
225
  "eslint": "^10.0.0",
226
226
  "eslint-plugin-putout": "^31.0.0",
@@ -0,0 +1,38 @@
1
+ import {NodePath} from '@putout/babel';
2
+
3
+ export type Traverse = (helpers: {
4
+ push: (path: NodePath) => void;
5
+ store: (key?: string, value?: unknown) => unknown;
6
+ listStore: (path?: NodePath) => NodePath[];
7
+ pathStore: (path?: NodePath) => NodePath[];
8
+ }) => Record<string, (path: NodePath) => void>;
9
+
10
+ export interface PutoutPlugin {
11
+ report: Report;
12
+ replace?: Replace;
13
+ fix?: Fix;
14
+ include?: Include;
15
+ exclude?: Exclude;
16
+ filter?: Filter;
17
+ traverse?: Traverse;
18
+ }
19
+
20
+ export type Report = () => string;
21
+
22
+ export type Include = () => string[];
23
+ export type Exclude = () => string[] | (() => boolean);
24
+
25
+ export interface PluginOptions {
26
+ options?: Record<string, unknown>;
27
+ }
28
+
29
+ export type Filter = (path: NodePath, options: PluginOptions) => boolean;
30
+ export type Fix = (path: NodePath, options: PluginOptions) => void;
31
+
32
+ type ReplaceResolver = (
33
+ vars: Record<string, Node>,
34
+ path: NodePath,
35
+ ) => string | NodePath | '';
36
+
37
+ export type Replace = () => Record<string, string | ReplaceResolver>;
38
+