Skip to content

Commit

Permalink
Run prettier in individual workspaces (#3925)
Browse files Browse the repository at this point in the history
This adds a `lint:prettier` task in each workspace so that we can get
the benefits of a granular cache and when running prettier, we don't
have to run it across the entire monorepo (notably the `benchmark/`
workspace which is very slow to run prettier on, and rarely changes --
an ideal candidate for a cache hit)
  • Loading branch information
mehulkar committed Jun 2, 2023
1 parent 56b5c62 commit 9ce240a
Show file tree
Hide file tree
Showing 22 changed files with 208 additions and 28 deletions.
3 changes: 2 additions & 1 deletion .github/actions/cargo-sweep/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"build:main": "ncc build src/main.js -o dist/main --source-map",
"build:post": "ncc build src/post.js -o dist/post --source-map",
"prepare": "pnpm run build:main && pnpm run build:post",
"lint": "eslint . --ext js,jsx,ts,tsx"
"lint": "eslint . --ext js,jsx,ts,tsx",
"lint:prettier": "prettier -c . --cache --ignore-path=../../../.prettierignore"
},
"dependencies": {
"@actions/core": "^1.10.0",
Expand Down
3 changes: 2 additions & 1 deletion .github/actions/next-integration-stat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"private": true,
"main": "src/index.js",
"scripts": {
"pack": "ncc -t -o . build src/index.ts"
"pack": "ncc -t -o . build src/index.ts",
"lint:prettier": "prettier -c . --cache --ignore-path=../../../.prettierignore"
},
"devDependencies": {
"@types/node": "^18.11.18",
Expand Down
3 changes: 2 additions & 1 deletion .github/actions/turbopack-bump/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"version": "1.0.0",
"scripts": {
"build": "ncc build src/index.ts -o dist --source-map --minify",
"prepare": "pnpm run build"
"prepare": "pnpm run build",
"lint:prettier": "prettier -c . --cache --ignore-path=../../../.prettierignore"
},
"dependencies": {
"@actions/core": "^1.10.0",
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1221,9 +1221,11 @@ jobs:

- name: Format check
# This is the syntax for running the `//#lint` task specifically in turbo.json
# It runs the taplo check on taplo.toml, and prettier check across the whole repo.
# TODO: run prettier in individual workspaces instead of globally.
run: turbo run lint --filter=//
# It runs the taplo check on taplo.toml, and lint:prettier per workspace.
# Skip `cli` workspace for now. It has the lint task, but in Github CI
# we need to setup golangci-lint to make it work. Go linting is run in the "Go linting"
# job in this workflow. We can move that in here in the next step.
run: turbo run lint --filter=!cli

final:
name: Ok
Expand Down
4 changes: 3 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.next/
build/
dist/
dist

node_modules/
target/
coverage/
Expand All @@ -9,6 +10,7 @@ generated/
pnpm-lock.yaml

__generated__/
/cli/dist-cross*
/docs/public/schema.json
/packages/eslint-plugin-turbo/__tests__/fixtures/
/packages/turbo-codemod/templates/
Expand Down
3 changes: 2 additions & 1 deletion benchmark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"ndjson": "^2.0.0"
},
"scripts": {
"benchmark": "node -r esbuild-register src/index.ts"
"benchmark": "node -r esbuild-register src/index.ts",
"lint:prettier": "prettier -c . --cache --ignore-path=../.prettierignore"
},
"devDependencies": {
"@types/node": "^16.11.49"
Expand Down
3 changes: 2 additions & 1 deletion cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"build": "make",
"test": "make test-go",
"format": "make fmt-go",
"lint": "make lint-go"
"lint": "make lint-go",
"lint:prettier": "prettier -c . --cache --ignore-path=../.prettierignore"
},
"devDependencies": {
"copy-template-dir": "^1.4.0",
Expand Down
3 changes: 2 additions & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"build": "next build ",
"lint": "next lint",
"rss": "node scripts/generate-rss.js",
"schema": "turbo-types-generate ./public/schema.json"
"schema": "turbo-types-generate ./public/schema.json",
"lint:prettier": "prettier -c . --cache --ignore-path=../.prettierignore"
},
"author": "Jared Palmer",
"license": "MPL-2.0",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"build": "pnpm -- turbo run build --filter=docs",
"build:turbo": "pnpm run --filter=cli build",
"build:ts": "tsc -b tsconfig.project.json",
"check:prettier": "prettier -c .",
"lint:prettier": "turbo run lint:prettier",
"check:toml": "taplo format --check",
"format": "run-p format:prettier format:rs format:toml",
"format:prettier": "prettier -w .",
Expand Down
3 changes: 2 additions & 1 deletion packages/create-turbo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"build": "tsup",
"test": "jest",
"lint": "eslint src/**/*.ts",
"check-types": "tsc --noEmit"
"check-types": "tsc --noEmit",
"lint:prettier": "prettier -c . --cache --ignore-path=../../.prettierignore"
},
"dependencies": {
"chalk": "2.4.2",
Expand Down
3 changes: 3 additions & 0 deletions packages/eslint-config-turbo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
"bugs": {
"url": "https://github.com/vercel/turbo/issues"
},
"scripts": {
"lint:prettier": "prettier -c . --cache --ignore-path=../../.prettierignore"
},
"keywords": [
"turbo",
"eslint",
Expand Down
3 changes: 2 additions & 1 deletion packages/eslint-plugin-turbo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"test": "jest",
"build": "tsup",
"check-types": "tsc --noEmit",
"lint": "eslint lib/**/*.ts"
"lint": "eslint lib/**/*.ts",
"lint:prettier": "prettier -c . --cache --ignore-path=../../.prettierignore"
},
"devDependencies": {
"@types/eslint": "^8.4.5",
Expand Down
3 changes: 2 additions & 1 deletion packages/turbo-codemod/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"test": "jest",
"lint": "eslint src/**/*.ts",
"check-types": "tsc --noEmit",
"add-transformer": "plop"
"add-transformer": "plop",
"lint:prettier": "prettier -c . --cache --ignore-path=../../.prettierignore"
},
"dependencies": {
"axios": "0.27.2",
Expand Down
3 changes: 2 additions & 1 deletion packages/turbo-ignore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"build": "tsup",
"test": "jest",
"lint": "eslint src/**/*.ts",
"check-types": "tsc --noEmit"
"check-types": "tsc --noEmit",
"lint:prettier": "prettier -c . --cache --ignore-path=../../.prettierignore"
},
"devDependencies": {
"@types/jest": "^27.4.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/turbo-test-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
},
"scripts": {
"lint": "eslint src/**/*.ts",
"check-types": "tsc --noEmit"
"check-types": "tsc --noEmit",
"lint:prettier": "prettier -c . --cache --ignore-path=../../.prettier-ignore"
},
"devDependencies": {
"@types/fs-extra": "^9.0.13",
Expand Down
3 changes: 2 additions & 1 deletion packages/turbo-tracing-next-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"next": "^13.0.6"
},
"scripts": {
"lint": "eslint src/**/*.ts"
"lint": "eslint src/**/*.ts",
"lint:prettier": "prettier -c . --cache --ignore-path=../../.prettierignore"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"scripts": {
"dev": "next dev",
"build": "cross-env MONGODB_URI=localhost:27017 next build",
"start": "next start"
"start": "next start",
"lint:prettier": "prettier -c . --cache --ignore-path=../../../../.prettier-ignore"
},
"dependencies": {
"mongoose": "^6.4.5",
Expand Down
3 changes: 2 additions & 1 deletion packages/turbo-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"turbo-types-generate": "./src/scripts/codegen.js"
},
"scripts": {
"lint": "eslint src/**/*.ts"
"lint": "eslint src/**/*.ts",
"lint:prettier": "prettier -c . --cache"
},
"dependencies": {
"ts-json-schema-generator": "1.1.2"
Expand Down
3 changes: 2 additions & 1 deletion packages/turbo-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"build": "tsup",
"test": "jest",
"lint": "eslint src/**/*.ts",
"check-types": "tsc --noEmit"
"check-types": "tsc --noEmit",
"lint:prettier": "prettier -c . --cache --ignore-path=../../.prettierignore"
},
"devDependencies": {
"@manypkg/find-root": "^1.1.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/turbo-workspaces/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"dev": "tsup --watch",
"test": "jest",
"lint": "eslint src/**/*.ts",
"check-types": "tsc --noEmit"
"check-types": "tsc --noEmit",
"lint:prettier": "prettier -c . --cache --ignore-path=../../.prettierignore"
},
"dependencies": {
"chalk": "2.4.2",
Expand Down
3 changes: 2 additions & 1 deletion packages/webpack-nmt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"webpack": "^5.75.0"
},
"scripts": {
"lint": "eslint src/**/*.ts"
"lint": "eslint src/**/*.ts",
"lint:prettier": "prettier -c . --cache --ignore-path=../../.prettierignore"
}
}
168 changes: 162 additions & 6 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,170 @@
"dependsOn": ["^build"]
},

// lint tasks
"lint": {},
// root lint task runs toml check and prettier
// TODO: run prettier in individual workspaces instead of globally.
// run prettier check before eslint
"lint": {
"dependsOn": ["lint:prettier"]
},

// root lint task runs toml check
"//#lint": {
"dependsOn": ["//#check:toml", "//#check:prettier"]
"dependsOn": ["//#check:toml"]
},
"//#check:prettier": {},

// run lint:prettier in all workspaces
"lint:prettier": {
"inputs": [
"**/*.4DForm",
"**/*.4DProject",
"**/*.JSON-tmLanguage",
"**/*._js",
"**/*.avsc",
"**/*.bones",
"**/*.cjs",
"**/*.code-snippets",
"**/*.component.html",
"**/*.css",
"**/*.cts",
"**/*.es",
"**/*.es6",
"**/*.frag",
"**/*.geojson",
"**/*.gltf",
"**/*.gql",
"**/*.graphql",
"**/*.graphqls",
"**/*.gs",
"**/*.handlebars",
"**/*.har",
"**/*.hbs",
"**/*.hta",
"**/*.htm",
"**/*.html",
"**/*.html.hl",
"**/*.ice",
"**/*.importmap",
"**/*.inc",
"**/*.jake",
"**/*.javascript",
"**/*.js",
"**/*.js.flow",
"**/*.jsb",
"**/*.jscad",
"**/*.jsfl",
"**/*.jslib",
"**/*.jsm",
"**/*.json",
"**/*.json5",
"**/*.jsonc",
"**/*.jspre",
"**/*.jss",
"**/*.jsx",
"**/*.less",
"**/*.livemd",
"**/*.markdown",
"**/*.mcmeta",
"**/*.md",
"**/*.mdown",
"**/*.mdwn",
"**/*.mdx",
"**/*.mir",
"**/*.mjml",
"**/*.mjs",
"**/*.mkd",
"**/*.mkdn",
"**/*.mkdown",
"**/*.mts",
"**/*.njs",
"**/*.pac",
"**/*.pcss",
"**/*.postcss",
"**/*.reek",
"**/*.ronn",
"**/*.rviz",
"**/*.scd",
"**/*.scss",
"**/*.sjs",
"**/*.ssjs",
"**/*.sublime-build",
"**/*.sublime-commands",
"**/*.sublime-completions",
"**/*.sublime-keymap",
"**/*.sublime-macro",
"**/*.sublime-menu",
"**/*.sublime-mousemap",
"**/*.sublime-project",
"**/*.sublime-settings",
"**/*.sublime-syntax",
"**/*.sublime-theme",
"**/*.sublime-workspace",
"**/*.sublime_metrics",
"**/*.sublime_session",
"**/*.syntax",
"**/*.tfstate",
"**/*.tfstate.backup",
"**/*.topojson",
"**/*.ts",
"**/*.tsx",
"**/*.vue",
"**/*.webapp",
"**/*.webmanifest",
"**/*.workbook",
"**/*.wxs",
"**/*.wxss",
"**/*.xht",
"**/*.xhtml",
"**/*.xsjs",
"**/*.xsjslib",
"**/*.yaml",
"**/*.yaml-tmlanguage",
"**/*.yaml.sed",
"**/*.yml",
"**/*.yml.mysql",
"**/*.yy",
"**/*.yyp",
"**/*.arcconfig",
"**/*.auto-changelog",
"**/*.babelrc",
"**/*.c8rc",
"**/*.clang-format",
"**/*.clang-tidy",
"**/*.devcontainer.json",
"**/*.eslintrc",
"**/*.eslintrc.json",
"**/*.gemrc",
"**/*.htmlhintrc",
"**/*.imgbotconfig",
"**/*.jscsrc",
"**/*.jshintrc",
"**/*.jslintrc",
"**/*.lintstagedrc",
"**/*.nycrc",
"**/*.prettierrc",
"**/*.stylelintrc",
"**/*.swcrc",
"**/*.tern-config",
"**/*.tern-project",
"**/*.watchmanconfig",
"**/*CITATION.cff",
"**/*Jakefile",
"**/*Pipfile.lock",
"**/*README",
"**/*api-extractor.json",
"**/*composer.json",
"**/*composer.lock",
"**/*contents.lr",
"**/*devcontainer.json",
"**/*glide.lock",
"**/*jsconfig.json",
"**/*language-configuration.json",
"**/*mcmod.info",
"**/*package-lock.json",
"**/*package.json",
"**/*tsconfig.json",
"**/*tslint.json"
]
},

"//#check:toml": {},
"check-types": {
"dependsOn": ["^build"]
Expand Down

1 comment on commit 9ce240a

@vercel
Copy link

@vercel vercel bot commented on 9ce240a Jun 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.