Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Long Type/Interface definitions that wrap cause linting errors #55

Open
opes opened this issue Jun 14, 2024 · 0 comments
Open

Long Type/Interface definitions that wrap cause linting errors #55

opes opened this issue Jun 14, 2024 · 0 comments

Comments

@opes
Copy link

opes commented Jun 14, 2024

Version: 3.1.2

Details

Using library-ts, when defining a long interface that goes beyond prettier's printWidth, npm run format wraps it onto new lines. This isn't a problem in *.ts files, but causes issues in *.marko files. Adding // prettier-ignore above the interface doesn't seem to prevent the line from being wrapped when running npm run format.

Expected Behavior

Preferably: Interface definitions that wrap multiple lines don't result in lint errors (ie. match the behavior of *.ts files)

Alternatively: npm run format respects // prettier-ignore in *.marko files

Actual Behavior

Interface/type definitions that wrap multiple lines result in linting errors, which blocks building/shipping code.

Possible Fix

I'm guessing this has something to do with how TypeScript is interpreted in *.marko files?

Additional Info

Your Environment

  • Environment name and version (e.g. Chrome 39, node.js 5.4): Mac Sonoma 14.5, node.js 20.12.2
  • Operating System and version (desktop or mobile): VSCode
  • Link to your project: https://github.corp.ebay.com/Sonata/ui

Steps to Reproduce

  1. Clone library-ts
  2. In any *.marko file, define an interface that has uses more characters than Prettier's printWidth setting, eg:
import type { BaseInput, Link, StarRatingInput } from "../../types/index.marko";
export interface Input extends Pick<StarRatingInput, "value" | "a11y-text">, Link, BaseInput {
  reviewCount: number;
}
  1. Run npm run format
  2. Notice how the interface definition gets wrapped before the extends keyword:
import type { BaseInput, Link, StarRatingInput } from "../../types/index.marko";
export interface Input
  extends Pick<StarRatingInput, "value" | "a11y-text">,
    Link,
    BaseInput {
  reviewCount: number;
}
  1. Notice the red linting errors that appear, then run npm run lint and see different errors in the console.

Stack Trace

Linting Errors in VSCode

Linting Errors

Error for imports line:
image

Error for extends line:
image

Error for npm run lint:

❯ npm run lint

> @ebay/[email protected] lint
> mtc && eslint --format unix . && stylelint --custom-formatter ./.stylelint-format.js '**/*.css' && prettier . --check --log-level=warn

src/components/su-star-rating/index.marko - error TS1005
'{' expected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant