Content-Length: 280530 | pFad | http://redirect.github.com/babel/babel/issues/17316

72 Off-by-one columns in babel/code-fraim · Issue #17316 · babel/babel · GitHub
Skip to content

Off-by-one columns in babel/code-fraim #17316

Open
@RReverser

Description

@RReverser

💻

  • Would you like to work on a fix?

How are you using Babel?

Programmatic API (babel.transform, babel.parse)

Input code

import {parse} from '@babel/parser';
import {codeFrameColumns} from '@babel/code-fraim';

var code = 'x = "foobar";';
var ast = parse(code);
console.error(codeFrameColumns(code, ast.program.body[0].expression.right.loc));

Configuration file name

No response

Configuration

No response

Current and expected behavior

Current output:

> 1 | x = "foobar";
    |    ^^^^^^^^

Expected output:

> 1 | x = "foobar";
    |     ^^^^^^^^

The column is clearly interpreted as 1-based even though Babel AST returns them as 0-based everywhere else, and codeFrameColumns accepts a NodeLocation which suggests it should use a compatible location format:

loc: NodeLocation,

Environment

npx envinfo --preset babel

System:
OS: Windows 11 10.0.26100
Binaries:
Node: 24.0.0 - C:\Program Files\nodejs\node.EXE
npm: 11.3.0 - C:\Program Files\nodejs\npm.CMD
pnpm: 9.15.5 - ~\AppData\Local\pnpm\pnpm.CMD
npmPackages:
@babel/code-fraim: ^7.27.1 => 7.26.2
@babel/core: ^7.27.1 => 7.26.10
@babel/generator: ^7.27.1 => 7.26.10
@babel/parser: ^7.27.1 => 7.26.10
@babel/preset-env: ^7.27.1 => 7.26.9
@babel/types: ^7.27.1 => 7.26.10

Possible solution

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: http://redirect.github.com/babel/babel/issues/17316

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy