Skip to content

Type for CssLocation is incorrect #94

@bartveneman

Description

@bartveneman

Hi, long time csstree user looking to move over to @eslint/css-tree :)

Minimal reproduction using "@eslint/css-tree": "^3.6.6"

While porting over one of my Project Wallace packages I noticed that the type for CssLocation is off:

// actual
// https://github.com/eslint/csstree/blob/10f6ab4f10af41467c02ad6c63cf8f08b94e3802/lib/index.d.ts#L41-L56
export interface CssLocation {
    /**
     * The 0-indexed character offset from the beginning of the source.
     */
    offset: number;

    /**
     * The 1-indexed line number.
     */
    line: number;

    /**
     * The 1-indexed column number.
     */
    column: number;
}

// expected
export interface CssLocation {
	start: {
		/**
		 * The 0-indexed character offset from the beginning of the source.
		 */
		offset: number;

		/**
		 * The 1-indexed line number.
		 */
		line: number;

		/**
		 * The 1-indexed column number.
		 */
		column: number;
	},
	end: {
		/**
		 * The 0-indexed character offset from the beginning of the source.
		 */
		offset: number;

		/**
		 * The 1-indexed line number.
		 */
		line: number;

		/**
		 * The 1-indexed column number.
		 */
		column: number;
	}
}

CSSTree source: https://github.com/csstree/csstree/blob/56afb6dd761149099cd3cdfb0a38e15e8cc0a71a/lib/tokenizer/OffsetToLocation.js#L43-L86

I'm not sure if this specific type is wrong or that the function signature for parsing is incorrect. With a little guidance I'm happy to raise a PR. I use parse('css{}', { positions: true }) a ton to re-generate authored CSS back from the AST.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Complete

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions