Add support for pnpm
mcmxcdev opened this issue · 4 comments
Not sure if this error pops up due to wrong usage on my end or if it simply doesn't work yet.
This is the stack trace that I encounter:
$ pnpm dlx prisma-lint apps/backend/prisma/schema.prisma
.../share/pnpm/store/v3/tmp/dlx-653806 | +72 +++++++
.../share/pnpm/store/v3/tmp/dlx-653806 | Progress: resolved 72, reused 72, downloaded 0, added 72, done
Unable to find configuration file for prisma-lint ✖
ERROR Command failed with exit code 1: prisma-lint apps/backend/prisma/schema.prisma
pnpm: Command failed with exit code 1: prisma-lint apps/backend/prisma/schema.prisma
at makeError (/home/user/.volta/tools/image/pnpm/8.2.0/dist/pnpm.cjs:24230:17)
at handlePromise (/home/user/.volta/tools/image/pnpm/8.2.0/dist/pnpm.cjs:24801:33)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.handler [as dlx] (/home/user/.volta/tools/image/pnpm/8.2.0/dist/pnpm.cjs:206486:7)
at async /home/user/.volta/tools/image/pnpm/8.2.0/dist/pnpm.cjs:215818:21
at async main (/home/user/.volta/tools/image/pnpm/8.2.0/dist/pnpm.cjs:215785:34)
at async runPnpm (/home/user/.volta/tools/image/pnpm/8.2.0/dist/pnpm.cjs:216040:5)
at async /home/user/.volta/tools/image/pnpm/8.2.0/dist/pnpm.cjs:216032:7
If pnpm is officially not supported yet, it would be great to make a small note in the README for it.
Good call out; I haven't tried with pnpm. I'll take a look shortly -- thanks for the feedback.
I manually tested, and pnpm seems to work fine. I think you're just missing a config file. #58 should improve the error message.
Try creating a .prismalintrc.json
file in your project root with this content and let me know if it works (with plural
instead of singular
if you prefer):
{
"rules": {
"model-name-grammatical-number": [
"error",
{
"style": "singular"
}
]
}
% pnpm init
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
% pnpm install prisma-lint
Packages: +72
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
dependencies:
+ prisma-lint 0.0.17
Done in 3.5s
~/tmp/test
% cp ~/prisma-lint/example/valid.prisma prisma/schema.prisma
~/tmp/test
% cp ~/prisma-lint/example/.prismalintrc.json .
~/tmp/test
% mv valid.prisma prisma/schema.prisma
~/tmp/test
% pnpm prisma-lint
prisma/schema.prisma ✔
You are correct, it works once I add .prismalintrc.json
There's often tools that use default settings when no config is provided, and it wasn't clear to me through the README that the config file would be a hard requirement.
Thanks for pointing me to a solution; I will be playing around with prisma-lint now ;)
Makes sense. I considered a default configuration, but my feeling was that most of the rules are a matter of taste. Perhaps we could add an "init" script that runs when no configuration is found, asking the user in a series of CLI prompts how they'd like to configure the linter.