Skip to content

Commit

Permalink
fix(prettier-config): fix crash when running npx git-validator
Browse files Browse the repository at this point in the history
  • Loading branch information
zanminkian committed Sep 24, 2023
1 parent b1ffc74 commit 317fd54
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/weak-plants-sell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@git-validator/prettier-config": patch
---

fix(prettier-config): fix crash when running `npx git-validator`
9 changes: 6 additions & 3 deletions packages/prettier-config/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
// @ts-check
import fs from "node:fs/promises";
import { createRequire } from "node:module";
import path from "node:path";
import process from "node:process";

const requireResolve = createRequire(import.meta.url).resolve;

const configFilePaths = ["js", "ts", "json"].map((i) =>
path.resolve(process.cwd(), `tailwind.config.${i}`),
);
Expand All @@ -20,9 +23,9 @@ const tailwindConfig = configFilePaths[index];

export default {
plugins: [
"prettier-plugin-curly",
"prettier-plugin-packagejson",
...(tailwindConfig ? ["prettier-plugin-tailwindcss"] : []),
requireResolve("prettier-plugin-curly"),
requireResolve("prettier-plugin-packagejson"),
...(tailwindConfig ? [requireResolve("prettier-plugin-tailwindcss")] : []),
],
...(tailwindConfig ? { tailwindConfig } : {}),
printWidth: 100, // 120 may be too long
Expand Down

0 comments on commit 317fd54

Please sign in to comment.