Giter Site home page Giter Site logo

Comments (9)

chentsulin avatar chentsulin commented on June 8, 2024 2

After upgraded to prettier 3.1.1, the error message is changed from SyntaxError: ';' expected. to SyntaxError: '{' expected.

from prettier-plugin-sort-imports.

chentsulin avatar chentsulin commented on June 8, 2024 2

Another requirement is to bump @babel/generator to >=7.22.0:

"@babel/generator": "7.17.7",

Ref: https://github.com/babel/babel/releases/tag/v7.22.0

from prettier-plugin-sort-imports.

MillerSvt avatar MillerSvt commented on June 8, 2024 2

You can use ["importAttributes", { deprecatedAssertSyntax: true }] to support both new and legacy syntax.

it is not working

from prettier-plugin-sort-imports.

fisker avatar fisker commented on June 8, 2024 1

You can use ["importAttributes", { deprecatedAssertSyntax: true }] to support both new and legacy syntax.

from prettier-plugin-sort-imports.

CHC383 avatar CHC383 commented on June 8, 2024 1

@ayusharma @byara Could someone please review #293 or #273?

from prettier-plugin-sort-imports.

chentsulin avatar chentsulin commented on June 8, 2024

We need to allow passing the importAttributesKeyword option to babel-generator:

const { code } = generate(newAST);

If the importAttributesKeyword option is undefined, babel unexpectedly transforms with { type: 'json' } to with type: 'json' (with-legacy): https://github.com/babel/babel/blob/8fa2a916e0bb601e728c3d368c1e271763880f40/packages/babel-generator/src/generators/modules.ts#L102-L106

Ref: https://babeljs.io/docs/babel-generator

from prettier-plugin-sort-imports.

JulianCataldo avatar JulianCataldo commented on June 8, 2024

I have the same problem. I tried to fiddle but the Babel parser importAttributes isn't working, while importAssertions does work. That is a blocker, so I had to disable the plugin altogether, so I can still continue to format the document as needed.

from prettier-plugin-sort-imports.

vincerubinetti avatar vincerubinetti commented on June 8, 2024

Is there any solution to this, even just a way to make a prettier lint check or in-IDE check not fail? I tried // prettier-ignore, // sort-imports-ignore, // @eslint-disable-next-line, using importAttributes vs importAssertions, with vs assert, nothing works.

I need to have this because I'm importing some JSON into a Playwright test and it can't handle it without the assert for some reason.

from prettier-plugin-sort-imports.

MillerSvt avatar MillerSvt commented on June 8, 2024

@CHC383 I think I'll post a fork if it's not reviewed this week.

from prettier-plugin-sort-imports.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.