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

Prettier 2.8 fails on "satisfies" keyword with 'SyntaxError: Missing semicolon' #13951

Closed
rikbrown opened this issue Dec 4, 2022 · 3 comments
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.

Comments

@rikbrown
Copy link

rikbrown commented Dec 4, 2022

Environments:

  • Prettier Version: 2.8.0
  • Running Prettier via: npx prettier --write test.ts
  • Runtime: Vite / Typescript 4.9.3
  • Operating System: Windows (WSL2 Ubuntu)
  • Prettier plugins (if any):
    "@trivago/prettier-plugin-sort-imports": "^3.4.0",
    "prettier-plugin-organize-imports": "^3.2.0",

package.json:

"devDependencies": {
    "@tailwindcss/forms": "^0.5.3",
    "@trivago/prettier-plugin-sort-imports": "^3.4.0",
    "@types/random-seed": "^0.3.3",
    "@types/react": "^18.0.25",
    "@types/react-dom": "^18.0.9",
    "@types/react-router": "^5.1.19",
    "@types/react-router-dom": "^5.3.3",
    "@typescript-eslint/eslint-plugin": "^5.45.0",
    "@typescript-eslint/parser": "^5.45.0",
    "@vitejs/plugin-react": "^2.2.0",
    "assert": "^2.0.0",
    "autoprefixer": "^10.4.13",
    "cssnano": "^5.1.14",
    "eslint": "^8.29.0",
    "eslint-config-prettier": "^8.5.0",
    "eslint-plugin-array-func": "^3.1.7",
    "eslint-plugin-lodash": "^7.4.0",
    "eslint-plugin-radar": "^0.2.1",
    "eslint-plugin-react": "^7.31.11",
    "eslint-plugin-react-hooks": "^4.6.0",
    "grpc-tools": "^1.11.3",
    "husky": "^8.0.2",
    "lint-staged": "^13.0.3",
    "postcss": "^8.4.19",
    "prettier": "^2.8.0",
    "prettier-plugin-organize-imports": "^3.2.0",
    "tailwindcss": "^3.2.4",
    "ts-proto": "^1.132.1",
    "typescript": "^4.9.3",
    "vite": "^3.2.4"
  },

.prettierrc.cjs:

module.exports = {
  semi: false,
  printWidth: 120,

  // Organize generated code and assets before the rest of our code.
  importOrder: ["/generated/", "/assets/", "^[./]"],
  importOrderSeparation: true,
  importOrderSortSpecifiers: true,

  trailingComma: "es5",
}

Steps to reproduce:

Create this Typescript file file.ts:

type MyType = { answer: number }

const question = { answer: 42 } satisfies MyType

Run npx prettier --write file.ts

Expected behavior:

Prettier does its magic.

Actual behavior:

$ npx prettier -v
2.8.0
$ npx prettier --write test.ts 
test.ts
[error] test.ts: SyntaxError: Missing semicolon. (3:31)
[error]   1 | type MyType = { answer: number }
[error]   2 |
[error]   3 | const question = { answer: 42 } satisfies MyType
[error]   4 |
@rikbrown
Copy link
Author

rikbrown commented Dec 4, 2022

Note that I expect this to work per #13516

@kachkaev
Copy link
Member

kachkaev commented Dec 4, 2022

Hi @rikbrown! Can you please share a reproducible example? I suspect that this error may be to do with one of your plugins which uses a wrong (or an outdated) parser. Playground results (without plugins):

If you want to sort imports, I suggest using ESLint instead. Common options include import/order and eslint-plugin-simple-import-sort. The rationale behind this is explained in docs under What Prettier is not concerned about.

@kachkaev kachkaev added the status:awaiting response Issues that require answers to questions from maintainers before action can be taken label Dec 4, 2022
@rikbrown
Copy link
Author

rikbrown commented Dec 5, 2022

You're right. I removed my plugins and it's working. I am very sorry for wasting your time there, I'll make sure to disable them next time before submitting an issue!

Thanks for the advice on import ordering - i will switch over to using eslint plugins for that instead.

Closing this. Appreciate your quick feedback!!

@rikbrown rikbrown closed this as completed Dec 5, 2022
@github-actions github-actions bot removed the status:awaiting response Issues that require answers to questions from maintainers before action can be taken label Dec 5, 2022
alextaing added a commit to yext/studio that referenced this issue Aug 7, 2023
Bump to tailwind 3.3.3 so that we can use .ts config files. Does not include breaking changes.

Some things of note:
[This change](tailwindlabs/tailwindcss#10765) seems to have caused some problems for users using Safari <14.1 and some mobile browsers.
More on tailwind changes can be found [here](https://tailwindcss.com/blog/tailwindcss-v3-3), and the commit changes can be found [here](tailwindlabs/tailwindcss@v3.2.7...v3.3.3).

Prettier was also bumped to 2.8.1 (only the test site was on an old version, 2.7.1).  This is because the auto-generated `tailwind.config.ts` file makes use of the new [`satisfies` keyword which is not supported until Prettier 2.8.1](prettier/prettier#13951). This broke our linking workflow.

J=SLAP-2820
@github-actions github-actions bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Nov 28, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.
Projects
None yet
Development

No branches or pull requests

2 participants