Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: benjamn/recast
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.23.1
Choose a base ref
...
head repository: benjamn/recast
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.23.2
Choose a head ref

Commits on Dec 27, 2022

  1. Bump @typescript-eslint/parser from 4.14.2 to 5.47.1

    Bumps [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/parser) from 4.14.2 to 5.47.1.
    - [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
    - [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/CHANGELOG.md)
    - [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v5.47.1/packages/parser)
    
    ---
    updated-dependencies:
    - dependency-name: "@typescript-eslint/parser"
      dependency-type: direct:development
      update-type: version-update:semver-major
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Dec 27, 2022
    Copy the full SHA
    a0dde6f View commit details
  2. Merge pull request #1263 from benjamn/dependabot/npm_and_yarn/typescr…

    …ipt-eslint/parser-5.47.1
    dependabot[bot] authored Dec 27, 2022
    Copy the full SHA
    4d389c4 View commit details
  3. Bump glob and @types/glob

    Bumps [glob](https://github.com/isaacs/node-glob) and [@types/glob](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/glob). These dependencies needed to be updated together.
    
    Updates `glob` from 7.2.0 to 8.0.3
    - [Release notes](https://github.com/isaacs/node-glob/releases)
    - [Changelog](https://github.com/isaacs/node-glob/blob/main/changelog.md)
    - [Commits](isaacs/node-glob@v7.2.0...v8.0.3)
    
    Updates `@types/glob` from 7.2.0 to 8.0.0
    - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
    - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/glob)
    
    ---
    updated-dependencies:
    - dependency-name: glob
      dependency-type: direct:development
      update-type: version-update:semver-major
    - dependency-name: "@types/glob"
      dependency-type: direct:development
      update-type: version-update:semver-major
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Dec 27, 2022
    Copy the full SHA
    78bf044 View commit details

Commits on Jan 9, 2023

  1. Bump json5 from 2.2.1 to 2.2.3

    Bumps [json5](https://github.com/json5/json5) from 2.2.1 to 2.2.3.
    - [Release notes](https://github.com/json5/json5/releases)
    - [Changelog](https://github.com/json5/json5/blob/main/CHANGELOG.md)
    - [Commits](json5/json5@v2.2.1...v2.2.3)
    
    ---
    updated-dependencies:
    - dependency-name: json5
      dependency-type: indirect
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Jan 9, 2023
    Copy the full SHA
    ad82c87 View commit details

Commits on Jan 27, 2023

  1. Bump tslib from 2.3.0 to 2.5.0

    Bumps [tslib](https://github.com/Microsoft/tslib) from 2.3.0 to 2.5.0.
    - [Release notes](https://github.com/Microsoft/tslib/releases)
    - [Commits](microsoft/tslib@2.3.0...2.5.0)
    
    ---
    updated-dependencies:
    - dependency-name: tslib
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Jan 27, 2023
    Copy the full SHA
    e3f36ff View commit details

Commits on Feb 1, 2023

  1. docs: readme: add ")"

    coderaiser authored Feb 1, 2023
    Copy the full SHA
    3745c6c View commit details
  2. Copy the full SHA
    130d7ac View commit details

Commits on Feb 12, 2023

  1. Copy the full SHA
    691aa1c View commit details
  2. Copy the full SHA
    65a102d View commit details

Commits on Feb 16, 2023

  1. Copy the full SHA
    e800995 View commit details
  2. Copy the full SHA
    5e6442d View commit details

Commits on May 12, 2023

  1. Merge pull request #1266 from benjamn/dependabot/npm_and_yarn/json5-2…

    ….2.3
    
    Bump json5 from 2.2.1 to 2.2.3
    eventualbuddha authored May 12, 2023
    Copy the full SHA
    5ca8112 View commit details
  2. ci: update node versions

    10.x was EOL over two years ago, so I think it's okay to no longer test against it. Also adds 18.x, 19.x, and 20.x since they're the current releases per the NodeJS release schedule: https://github.com/nodejs/release#release-schedule.
    eventualbuddha committed May 12, 2023
    Copy the full SHA
    6fa727c View commit details
  3. Merge pull request #1286 from benjamn/ci/update-node-versions

    ci: update node versions
    eventualbuddha authored May 12, 2023
    Copy the full SHA
    e18deeb View commit details
  4. Bump eslint from 7.31.0 to 8.40.0

    Bumps [eslint](https://github.com/eslint/eslint) from 7.31.0 to 8.40.0.
    - [Release notes](https://github.com/eslint/eslint/releases)
    - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
    - [Commits](eslint/eslint@v7.31.0...v8.40.0)
    
    ---
    updated-dependencies:
    - dependency-name: eslint
      dependency-type: direct:development
      update-type: version-update:semver-major
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored May 12, 2023
    Copy the full SHA
    365b925 View commit details
  5. Copy the full SHA
    8be4600 View commit details
  6. Copy the full SHA
    298c24c View commit details
  7. Copy the full SHA
    b7520d5 View commit details
  8. Bump mocha and @types/mocha

    Bumps [mocha](https://github.com/mochajs/mocha) and [@types/mocha](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/mocha). These dependencies needed to be updated together.
    
    Updates `mocha` from 9.2.2 to 10.2.0
    - [Release notes](https://github.com/mochajs/mocha/releases)
    - [Changelog](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md)
    - [Commits](mochajs/mocha@v9.2.2...v10.2.0)
    
    Updates `@types/mocha` from 8.2.0 to 10.0.1
    - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
    - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/mocha)
    
    ---
    updated-dependencies:
    - dependency-name: mocha
      dependency-type: direct:development
      update-type: version-update:semver-major
    - dependency-name: "@types/mocha"
      dependency-type: direct:development
      update-type: version-update:semver-major
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored May 12, 2023
    Copy the full SHA
    dea1dae View commit details
  9. Merge pull request #1256 from benjamn/dependabot/npm_and_yarn/mocha-a…

    …nd-types/mocha-10.2.0
    
    Bump mocha and @types/mocha
    eventualbuddha authored May 12, 2023
    Copy the full SHA
    fdaebba View commit details
  10. Bump lint-staged from 12.4.1 to 13.2.2

    Bumps [lint-staged](https://github.com/okonet/lint-staged) from 12.4.1 to 13.2.2.
    - [Release notes](https://github.com/okonet/lint-staged/releases)
    - [Commits](lint-staged/lint-staged@v12.4.1...v13.2.2)
    
    ---
    updated-dependencies:
    - dependency-name: lint-staged
      dependency-type: direct:development
      update-type: version-update:semver-major
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored May 12, 2023
    Copy the full SHA
    2bdf178 View commit details
  11. Copy the full SHA
    fd44c62 View commit details
  12. Copy the full SHA
    1413bdf View commit details
  13. Merge pull request #1273 from coderaiser/fix/comments-move-in-call-ex…

    …pression-after-recast-print
    
    feature: improve support of comments inside CallExpression (benjamn/r…
    eventualbuddha authored May 12, 2023
    Copy the full SHA
    a35e6c3 View commit details
  14. 0.23.2

    eventualbuddha committed May 12, 2023
    Copy the full SHA
    34a6b3d View commit details
Showing with 1,068 additions and 1,326 deletions.
  1. +1 −1 .github/workflows/main.yml
  2. +2 −2 README.md
  3. +8 −0 lib/comments.ts
  4. +1,019 −1,315 package-lock.json
  5. +8 −8 package.json
  6. +30 −0 test/comments.ts
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node_version: ['10.x', '12.x', '14.x', '15.x', '16.x']
node_version: ['12.x', '14.x', '16.x', '18.x', '19.x', '20.x']
os: [ubuntu-latest]

steps:
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -64,7 +64,7 @@ const ast = recast.parse(code);

Now do _whatever_ you want to `ast`. Really, anything at all!

See [ast-types](https://github.com/benjamn/ast-types) (especially the [def/core.ts](https://github.com/benjamn/ast-types/blob/master/def/core.ts)) module for a thorough overview of the `ast` API.
See [ast-types](https://github.com/benjamn/ast-types) (especially the [def/core.ts](https://github.com/benjamn/ast-types/blob/master/src/def/core.ts)) module for a thorough overview of the `ast` API.

```js
// Grab a reference to the function declaration we just parsed.
@@ -170,7 +170,7 @@ const tsAst = recast.parse(source, {

**Note:** Some of these parsers import npm packages that Recast does not directly depend upon, so please be aware you may have to run `npm install @babel/parser` to use the `typescript`, `flow`, or `babel` parsers, or `npm install acorn` to use the `acorn` parser. Only Esprima is installed by default when Recast is installed.

After calling `recast.parse`, if you're going to transform the AST, make sure that the `.original` property is preserved. With Babel, for instance, if you call `transformFromAST`, you must pass `cloneInputAst: false` in its options. ([More detail](https://github.com/babel/babel/issues/12882).
After calling `recast.parse`, if you're going to transform the AST, make sure that the `.original` property is preserved. With Babel, for instance, if you call `transformFromAST`, you must pass `cloneInputAst: false` in its options. ([More detail](https://github.com/babel/babel/issues/12882)).

## Source maps

8 changes: 8 additions & 0 deletions lib/comments.ts
Original file line number Diff line number Diff line change
@@ -229,6 +229,14 @@ function breakTies(tiesToBreak: any[], lines: any) {
++indexOfFirstLeadingComment;
}

if (indexOfFirstLeadingComment) {
const { enclosingNode } = tiesToBreak[indexOfFirstLeadingComment - 1];

if (enclosingNode?.type === "CallExpression") {
--indexOfFirstLeadingComment;
}
}

tiesToBreak.forEach(function (comment, i) {
if (i < indexOfFirstLeadingComment) {
addTrailingComment(pn, comment);
Loading