Giter Club home page Giter Club logo

prettier-plugin-prisma's People

Contributors

avocadowastaken avatar dependabot[bot] avatar jolg42 avatar nirtamir2 avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

prettier-plugin-prisma's Issues

Auto formatting is working but auto completion(like relation) is not working

Describe the bug
Auto formatting is working but auto completion(like relation) is not working

Expected behavior

Tools (please provide the output of the following commands):
macOS, vscode, prettier-plugin-prisma v3.10, prisma v3.10

  • Node version: v14.17.6
  • OS name: macOS,
  • Installed prettier versions: v8.1.0
  • Installed plugin versions: v3.10

스크린샷 2022-03-01 오후 1 15 32

Feat: Flat Formatting

How it currently works

When working on a group project, adding another field to your Prisma schema, which is longer than all the other fields, will cause a significant merge conflict on the Prisma schema and make it hard to see exactly which fields have been changed and how to merge it properly.

Example:

model User {
  id    String  @id @default(uuid()) @db.Uuid
  email String? @db.Citext
  name  String? @db.Text
}

Following a new field 'address'

model User {
  id      String  @id @default(uuid()) @db.Uuid
  email   String? @db.Citext
  name    String? @db.Text
  address String? @db.Text
}

You can see that all of the field types have been shifted to the right, making the file resolve a significant merge conflict.

Proposed Solution

By enabling a flag in the config, perhaps a flatFormat flag in the config, we can format it to a single space between field options.

Example:

Before format

model User {
  id String  @id @default(uuid()) @db.Uuid
  email        String? @db.Citext
  name String?             @db.Text
}

After format

model User {
  id String @id @default(uuid()) @db.Uuid
  email String? @db.Citext
  name String? @db.Text
}

This helps with commits and changes to large models. This could also work in injunction with tabWidth to use the specified spacing but still not align them along the y-axis.

useTabs seems to not be respected

With the following .prettierrc.json configuration, I get proper tabs on all ts files, but not prisma, where I get 4 spaces instead.

{
	"useTabs": true,
	"tabWidth": 4,
	"semi": true,
	"singleQuote": true,
	"trailingComma": "all",
	"printWidth": 120
}

Am I missing something?

Steps to reproduce the behavior:

  1. Using this config, make a prisma file with fucked up indent
  2. Use prettier ./file.prisma

Expected behavior

Formatting would end up as tabs

Tools (please provide the output of the following commands):

  • Node version: v17.9.0
  • OS name: Arch-linux
  • Installed prettier versions: 2.6.2
  • Installed plugin versions: 3.13.0

Prettier is trapping when evaluating a prisma file

When running npx prisma format schema.prisma everything works great but running npx prettier schema.prisma traps with the following messages, some referring to the wasm engine. I'm running this code in a MacBook Pro M1 with Big Sur 11.2.1.

#
# Fatal error in , line 0
# Check failed: allocator->SetPermissions(reinterpret_cast<void*>(region.begin()), region.size(), PageAllocator::kNoAccess).
#
#
#
#FailureMessage Object: 0x16f752918
 1: 0x1007a5104 node::NodePlatform::GetStackTracePrinter()::$_3::__invoke() [/opt/homebrew/bin/node]
 2: 0x101130054 V8_Fatal(char const*, ...) [/opt/homebrew/bin/node]
 3: 0x100d19358 v8::internal::wasm::WasmCodeAllocator::GetNumCodeSpaces() const [/opt/homebrew/bin/node]
 4: 0x100d191f8 v8::internal::wasm::WasmCodeAllocator::FreeCode(v8::internal::Vector<v8::internal::wasm::WasmCode* const>) [/opt/homebrew/bin/node]
 5: 0x100d1c048 v8::internal::wasm::NativeModule::FreeCode(v8::internal::Vector<v8::internal::wasm::WasmCode* const>) [/opt/homebrew/bin/node]
 6: 0x100d29bcc v8::internal::wasm::WasmEngine::FreeDeadCodeLocked(std::__1::unordered_map<v8::internal::wasm::NativeModule*, std::__1::vector<v8::internal::wasm::WasmCode*, std::__1::allocator<v8::internal::wasm::WasmCode*> >, std::__1::hash<v8::internal::wasm::NativeModule*>, std::__1::equal_to<v8::internal::wasm::NativeModule*>, std::__1::allocator<std::__1::pair<v8::internal::wasm::NativeModule* const, std::__1::vector<v8::internal::wasm::WasmCode*, std::__1::allocator<v8::internal::wasm::WasmCode*> > > > > const&) [/opt/homebrew/bin/node]
 7: 0x100d27bec v8::internal::wasm::WasmEngine::PotentiallyFinishCurrentGC() [/opt/homebrew/bin/node]
 8: 0x100d28e28 v8::internal::wasm::WasmEngine::ReportLiveCodeForGC(v8::internal::Isolate*, v8::internal::Vector<v8::internal::wasm::WasmCode*>) [/opt/homebrew/bin/node]
 9: 0x100d2b548 v8::internal::wasm::(anonymous namespace)::WasmGCForegroundTask::RunInternal() [/opt/homebrew/bin/node]
10: 0x1007a3bc0 node::PerIsolatePlatformData::RunForegroundTask(std::__1::unique_ptr<v8::Task, std::__1::default_delete<v8::Task> >) [/opt/homebrew/bin/node]
11: 0x1007a2cb4 node::PerIsolatePlatformData::FlushForegroundTasksInternal() [/opt/homebrew/bin/node]
12: 0x1007a3d7c node::NodePlatform::DrainTasks(v8::Isolate*) [/opt/homebrew/bin/node]
13: 0x1006b0aa4 node::SpinEventLoop(node::Environment*) [/opt/homebrew/bin/node]
14: 0x100781224 node::NodeMainInstance::Run(node::EnvSerializeInfo const*) [/opt/homebrew/bin/node]
15: 0x100724ce4 node::Start(int, char**) [/opt/homebrew/bin/node]
16: 0x198afdf34 start [/usr/lib/system/libdyld.dylib]
[1]    2979 trace trap  npx prettier schema.prisma

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update dependency prettier-plugin-packagejson to v2.4.13
  • chore(deps): update dependency vscode-languageserver-protocol to v3.17.5
  • chore(deps): update jest monorepo (@types/jest, jest)
  • chore(deps): update dependency lint-staged to v13.3.0
  • chore(deps): update dependency typescript to v5.4.3
  • chore(deps): update dependency husky to v9
  • chore(deps): update dependency lint-staged to v15
  • chore(deps): update dependency npm to v10
  • chore(deps): update node.js to v20
  • 🔐 Create all rate-limited PRs at once 🔐

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/main.yml
  • umidbekk/actions v2
  • umidbekk/actions v2
npm
package.json
  • @prisma/prisma-schema-wasm 4.17.0-26.6b0aef69b7cdfc787f822ecd7cdc76d5f1991584
  • @types/jest 29.5.3
  • @umidbekk/configs 0.3.0
  • cross-env 7.0.3
  • husky 8.0.3
  • jest 29.6.1
  • lint-staged 13.2.3
  • prettier 3.0.0
  • prettier-plugin-packagejson 2.4.5
  • typescript 5.1.6
  • vscode-languageserver-protocol 3.17.3
  • prettier >=2 || >=3
  • node >=14
  • npm >=8
  • node 14.21.3
  • npm 8.19.4

  • Check this box to trigger a request for Renovate to run again on this repository

Prettier 3.0 support

Describe the bug
Prettier 3.0 has been released: https://prettier.io/blog/2023/07/05/3.0.0.html. It looks like that this plugin is no longer working with the new 3.0 version:

Checking formatting...
prisma/schema.prisma
[error] No parser could be inferred for file "/prisma/schema.prisma".

To Reproduce
Steps to reproduce the behavior:

  1. Upgrade to Prettier 3.0
  2. Install plugin
  3. Perform check

Expected behavior
No error and schema is formatted

Should not modify schema to add new relationships

Describe the bug

This prettier plugin modifies our schema to add new reverse relationships.

To Reproduce

Table A adds a relationship on table B.

Expected behavior

Nothing.

Experienced behavior

Table B gets a relationship added back to Table A.

Additional context

I get that this is useful in some cases, but a prettier plugin shouldn't be making those decisions for us. Furthermore, the reverse relationship that gets added isn't consistent in terms of casing/style with our other ones.

In our case, we don't want that reverse relationship adding because we don't have indexes on it so it would be an inefficient query.

Auto format on file save doesn't work

When I save the file in my editor (Vim & VS Code) prettier doesn't auto-format .prisma files. It does auto-format .js and .json files though.

When I run npx prettier --write ./ manually - it formats .prisma files correctly.

Can prettier-plugin-prisma auto-format on save?

$ node --version
v16.13.2

$ npx os-name-cli
macOS Big Sur

$ npx npm-why prettier

  Who required prettier:

  serverless-functions > eslint-plugin-prettier > [email protected]
  serverless-functions > [email protected]
  serverless-functions > prettier-plugin-prisma > [email protected]

$ npx npm-why prettier-plugin-prisma

  Who required prettier-plugin-prisma:

  serverless-functions > [email protected]

not working when trying to use with prettier.format function ?

I have schema code built by other tools i build and in this use case i want to have a function where i can provide generated code and get nice formatted schema to write to schema file.

I tried @umidbekk plugin but it failed to do the job with error which seem like prettier is looking like prettier thinks it's javascript, while it's not. And i don't see any way to tell prettier that it's prisma schema. Any hints?

  const prettier = require("prettier");
  let result = prettier.format(code, {
      parser: "babel", plugins: ["prettier-plugin-prisma"]
    });

image

also posted at prisma repo prisma/prisma#1761

[improvement] Support @map and @@map

Thank you for this plugin.

Is there a chance that you could support the @map and @@map instructions, as defined here in the Prisma documentation? Where my Prisma file contains @map, the plugin reformats the file like this:

model users {
  id                        Int                         @id @default(autoincrement()) @map("ID")
  username                  String                      @unique(map: "username") @db.VarChar(25)
  password                  String                      @db.VarChar(40)
  allowSharing              Boolean                     @default(true) @map("AccepterPartage")
}

where I would expect something like:

model users {
  id                        Int                         @id @default(autoincrement())             @map("ID")
  username                  String                      @unique(map: "username") @db.VarChar(25)
  password                  String                      @db.VarChar(40)
  allowSharing              Boolean                     @default(true)                            @map("AccepterPartage")
}

Doesn't seem to work when using pnpm

Describe the bug
When using pnpm as the package manager, this message is shown:

npx prettier prisma\schema.prisma 
Checking formatting...
prisma\schema.prisma[error] No parser could be inferred for file: prisma\schema.prisma
All matched files use Prettier code style!

Is this a problem with any prettier plugin with pnpm or is it specific to this plugin?

To Reproduce
use pnpm to add prettier and prettier-plugin-prisma to dependencies and run prettier on a prisma file

pnpm add -D prettier prettier-plugin-prisma
pnpx prettier -c prisma\schema.prisma

Expected behavior
Prettier should be able to automatically find this plugin and format a .prisma file

Tools (please provide the output of the following commands):

  • Node version: 16.2.0
  • OS name: Windows 10
  • Installed prettier versions: 2.4.1
  • Installed plugin versions: 3.4.1

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: Cannot find preset's package (:assignees(umidbekk)). Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

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.