Skip to content

Commit 1b925c2

Browse files
authored
Merge pull request #46 from buildo/fix-jsx-print
Replace astring with recast
2 parents 435c1e9 + 9ed7e9c commit 1b925c2

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
],
2626
"dependencies": {
2727
"@typescript-eslint/experimental-utils": "^4.11.1",
28-
"astring": "^1.4.3",
2928
"estraverse": "^5.2.0",
30-
"fp-ts": "^2.9.3"
29+
"fp-ts": "^2.9.3",
30+
"recast": "^0.20.4"
3131
},
3232
"devDependencies": {
3333
"@types/astring": "^1.3.0",

src/utils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
TSESTree,
66
ESLintUtils,
77
} from "@typescript-eslint/experimental-utils";
8-
import { generate } from "astring";
8+
import * as recast from "recast";
99
import { visitorKeys as tsVisitorKeys } from "@typescript-eslint/typescript-estree";
1010
import { array, option, apply } from "fp-ts";
1111
import { pipe } from "fp-ts/function";
@@ -153,7 +153,7 @@ export function getAdjacentCombinators<
153153
}
154154

155155
export function prettyPrint(node: TSESTree.Node): string {
156-
return generate(node as any);
156+
return recast.prettyPrint(node).code;
157157
}
158158

159159
export function inferIndent(node: TSESTree.Node): string {

yarn.lock

+23-1
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,13 @@ assign-symbols@^1.0.0:
841841
resolved "https://registry.yarnpkg.com/assign-symbols/-/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367"
842842
integrity sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=
843843

844+
845+
version "0.14.2"
846+
resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.14.2.tgz#600b882df8583e3cd4f2df5fa20fa83759d4bdfd"
847+
integrity sha512-O0yuUDnZeQDL+ncNGlJ78BiO4jnYI3bvMsD5prT0/nsgijG/LpNBIr63gTjVTNsiGkgQhiyCShTgxt8oXOrklA==
848+
dependencies:
849+
tslib "^2.0.1"
850+
844851
astral-regex@^2.0.0:
845852
version "2.0.0"
846853
resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-2.0.0.tgz#483143c567aeed4785759c0865786dc77d7d2e31"
@@ -1484,7 +1491,7 @@ espree@^7.3.0, espree@^7.3.1:
14841491
acorn-jsx "^5.3.1"
14851492
eslint-visitor-keys "^1.3.0"
14861493

1487-
esprima@^4.0.0, esprima@^4.0.1:
1494+
esprima@^4.0.0, esprima@^4.0.1, esprima@~4.0.0:
14881495
version "4.0.1"
14891496
resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71"
14901497
integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==
@@ -3257,6 +3264,16 @@ read-pkg@^5.2.0:
32573264
parse-json "^5.0.0"
32583265
type-fest "^0.6.0"
32593266

3267+
recast@^0.20.4:
3268+
version "0.20.4"
3269+
resolved "https://registry.yarnpkg.com/recast/-/recast-0.20.4.tgz#db55983eac70c46b3fff96c8e467d65ffb4a7abc"
3270+
integrity sha512-6qLIBGGRcwjrTZGIiBpJVC/NeuXpogXNyRQpqU1zWPUigCphvApoCs9KIwDYh1eDuJ6dAFlQoi/QUyE5KQ6RBQ==
3271+
dependencies:
3272+
ast-types "0.14.2"
3273+
esprima "~4.0.0"
3274+
source-map "~0.6.1"
3275+
tslib "^2.0.1"
3276+
32603277
regex-not@^1.0.0, regex-not@^1.0.2:
32613278
version "1.0.2"
32623279
resolved "https://registry.yarnpkg.com/regex-not/-/regex-not-1.0.2.tgz#1f4ece27e00b0b65e0247a6810e6a85d83a5752c"
@@ -3861,6 +3878,11 @@ tslib@^1.8.1:
38613878
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
38623879
integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==
38633880

3881+
tslib@^2.0.1:
3882+
version "2.1.0"
3883+
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.1.0.tgz#da60860f1c2ecaa5703ab7d39bc05b6bf988b97a"
3884+
integrity sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==
3885+
38643886
tsutils@^3.17.1:
38653887
version "3.17.1"
38663888
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.17.1.tgz#ed719917f11ca0dee586272b2ac49e015a2dd759"

0 commit comments

Comments
 (0)