Comments (3)
Cheers, thanks for taking the time to explain the reasoning.
from nextjs-monorepo-example.
Hey @bryce-larson nice that you point this out.
In my experience what makes eslint and prettier fast is actually starting from a warm (or as warm as possible) cache.
But you're right, separating prettier and eslint rather than using the eslint-plugin-prettier and cleanup incompatible rules with eslint-prettier-config will be globally faster.
In that case we'll have to run 2 separate steps (one for prettier, one for eslint) and handle proper caching for 2 tools instead of one... and that's a bit painful
As a "contrived" example:
{
"scripts": {
"prettier-check": "run --top-level prettier --check --cache --cache-location=\"../../.cache/prettier/exception.prettiercache\" --config ../../.prettierrc.js --ignore-path ../../.prettierignore \"./**/*.{js,jsx,cjs,mjs,ts,tsx,mts,md,mdx,json,css,scss,less}\"",
"prettier-fix": "run --top-level prettier --write --cache --cache-location=\"../../.cache/prettier/exception.prettiercache\" --config ../../.prettierrc.js --ignore-path ../../.prettierignore \"./**/*.{js,jsx,cjs,mjs,ts,tsx,mts,md,mdx,json,css,scss,less}\"",
"lint": "eslint . --ext .ts,.tsx,.js,.jsx,.mjs,.cjs,.mts,.cts --cache --cache-location ../../.cache/eslint/exception.eslintcache",
"lint-timing": "cross-env TIMING=1 run lint",
}
}
Some ci steps:
## Here an action cache to save the global .cache folder (will need an invalidation key based on date to
## avoid growing over time
- name: 🔬 Prettier checks
run: yarn workspaces foreach -tv --from '@httpx/*' --no-private run prettier-check
- name: 🔬 ESLint checks
run: yarn workspaces foreach -tv --from '@httpx/*' --no-private run lint
PS: same to add for lint-staged / husky, vscode fix on save, webstorm etc...
That said I use both approaches in multiple repos... and globally I'd say no significant difference in global speed (when cache is in place).
The key is that when using the slower eslint-plugin-prettier approach, the setup part is easier (only one tool).
As this repo is an example, I would keep it simple for now...
If you like, you can have a look to my day to day eslint configs... In that one, you can choose which mode you prefer:
There's also a lot to say regarding caches:
- many tools tried to store their caches in node_modules and reverting back due to monorepo issues (prettier, ...)
- nextjs stores them in .next folder (inluding eslint caches...)... helps also with vercel.
- jest will use the cache from config...
I'm still waiting a bit to see if it's worth to create some tooling to align those difference (ie: eslint flat configs, stylint) and if some idea reduce the setup, I'd gladly isolate prettier and eslint for every project. That would also help covers other file formats (yaml...)
from nextjs-monorepo-example.
Glad to hear
worth to mention: https://antfu.me/posts/why-not-prettier. The author has good points imho. I'm also following the upcoming typescript-eslint v6: https://typescript-eslint.io/blog/announcing-typescript-eslint-v6-beta/. It might help clarify stylistic vs typechecks.
from nextjs-monorepo-example.
Related Issues (20)
- Automated releases HOT 1
- Early cache invalidation in multistage Docker build HOT 4
- Problem with prisma in monorepo
- How debug server side for next.js `nextjs-app` using vscode? HOT 3
- Adding commitzen command HOT 2
- Action Required: Fix Renovate Configuration
- Does it support NodeNext .mjs, .mts ? HOT 8
- RFC: Move to pnpm HOT 1
- Example with standalone build HOT 3
- changeset publish does not replace workspace: ranges with current version in workspace HOT 4
- Best practice for add a backend server HOT 1
- nextjs-app compilation error and warning HOT 2
- Semantic error TS6059 File 'packages/ts-utils/src/index.ts' is not under 'rootDir' HOT 3
- Error: No mesh config file found HOT 1
- Make repo size lower
- Debug Nexjs app in monorepo with "NODE_OPTIONS='inspect'" HOT 10
- Deprecated package @types/prettier HOT 1
- storybook recognizing tailwind config from outside HOT 3
- Upgrade eslint to V9 and typescript-eslint v7 HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nextjs-monorepo-example.