question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not formatting monorepo

See original GitHub issue

The formatter seems not to be working with monorepo!

I have three mono repo in a project (i.e. landing, servers, and studio), the landing dir is a Next.js app, while the servers dir contains multiple servers which are Nest.js apps, and finally, the studio dir is a Svelte (SvelteKit) app. If the working directory is the root/project folder prettier works perfectly on the landing and servers dir, and other files in the studio dir except for the .svelte files but the formatter works with .svelte files if the working directory is studio itself.

And my PC lag if I have multiple vscode instances running with other heavy applications (i.e. Docker, Firefox, Postman, etc)

What am I doing wrong!?

System info:

  • OS: Ubuntu 22.04
  • CPUs: Intel® Core™ i5-6300U CPU @ 2.40GHz (4 x 2500)
  • GPU Status: 2d_canvas: unavailable_software canvas_oop_rasterization: disabled_off direct_rendering_display_compositor: disabled_off_ok gpu_compositing: disabled_software multiple_raster_threads: enabled_on opengl: disabled_off rasterization: disabled_software raw_draw: disabled_off_ok skia_renderer: enabled_on video_decode: disabled_software video_encode: disabled_software vulkan: disabled_off webgl: unavailable_software webgl2: unavailable_software webgpu: disabled_off
  • Load (avg): 1, 0, 0
  • Memory (System): 7.65GB (2.55GB free)
  • Process Argv: --no-sandbox . --crash-reporter-id 93055eb6-6fd7-4a64-90ee-21296107114f
  • Screen Reader: no
  • VM: 0%

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:2
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
toqueteoscommented, Nov 18, 2022

@phcoliveira solution didn’t work for me but I found a working alternative.

  1. Rename .prettierrc to prettier.config.cjs
  2. Set plugins: [require('prettier-plugin-svelte')]
  3. It works!

Here’s the default .prettierrc (as generated from npm create svelte@next) translated into JS:

/**
 * @type {import('prettier').Options}
 */
module.exports = {
	useTabs: true,
	singleQuote: true,
	trailingComma: 'none',
	printWidth: 100,
	plugins: [require('prettier-plugin-svelte')],
	pluginSearchDirs: ["."],
	overrides: [{ 'files': '*.svelte', 'options': { 'parser': 'svelte' } }]
};
1reaction
phcoliveiracommented, Nov 18, 2022

@jsxclan, @jerebtw, @ItzaMi and @toqueteos, I had some problems in configuring prettier in my monorepo setup. But I fixed them with this setting pluginSearchDirs. Take a look at my prettier config, which is at the root of the package: apps/client, hence the value of ../../, because NPM installed the plugin at the root of the monorepo.

I hope it helps.

/**
 * @type {import('prettier').Options}
 */
module.exports = {
  plugins: [require('prettier-plugin-tailwindcss')],
  pluginSearchDirs: ['.'],
  overrides: [{files: '*.svelte', options: {parser: 'svelte'}}],
  tailwindConfig: './tailwind.config.cjs',
  arrowParens: 'always',
  bracketSpacing: false,
  endOfLine: 'lf',
  plugins: [],
  pluginSearchDirs: ['../../'],
  printWidth: 80,
  semi: true,
  singleQuote: true,
  tabWidth: 2,
  trailingComma: 'es5',
  useTabs: false,
  svelteSortOrder: 'options-styles-scripts-markup',
  svelteStrictMode: true,
  svelteBracketNewLine: false,
  svelteAllowShorthand: false,
  svelteIndentScriptAndStyle: true,
};
Read more comments on GitHub >

github_iconTop Results From Across the Web

prettierignore not working correctly in mono repo project #95
Hi, I have an issue that is similar to #14 My project folder structure is: root/ .git webapp/ package.json .prettierignore index.js foo/ ...
Read more >
What is monorepo? (and should you use it?) - Semaphore CI
A monorepo is a version-controlled code repository that holds many projects. While these projects may be related, they are often logically ...
Read more >
How to move your git repository into a monorepo without ...
Lets go over the script line by line. First we export all commits as a single patch file using git format-patch. The option...
Read more >
Improve Git monorepo performance with a file system monitor
Git's new builtin file system monitor makes it easy to speed up monorepo performance.
Read more >
The Ultimate Guide to TypeScript Monorepos
By declaring these in one central folder, dependencies do not need ... Prettier is a great tool for maintaining consistent formatting in a ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found