From 47a85896e03b89222663986aba614efb0d5b6dc9 Mon Sep 17 00:00:00 2001 From: David Sheldrick Date: Mon, 11 Mar 2024 14:08:04 +0000 Subject: [PATCH] [dx] Allow vscode to search inside md files by default (#3105) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this PR all .md files were targeted by the `.ignore` file, which has bitten me on a number of occasions since .md files often contain valuable information (e.g. the vscode extensions docs). This PR unignores .md files while still ignoring _generated_ .md files like our changelogs, the api-report files, and the generated docs sections. Additionally, the `yarn format` and `yarn lint` commands were configured slightly differently, which was confusing, so I've unified those and simplified the lint.ts script at the same time. ### Change Type - [ ] `patch` — Bug fix - [ ] `minor` — New feature - [ ] `major` — Breaking change - [ ] `dependencies` — Changes to package dependencies[^1] - [ ] `documentation` — Changes to the documentation only[^2] - [ ] `tests` — Changes to any test code only[^2] - [x] `internal` — Any other changes that don't affect the published package[^2] - [ ] I don't know [^1]: publishes a `patch` release, for devDependencies use `internal` [^2]: will not publish a new version --- .eslintignore | 1 + .github/workflows/checks.yml | 2 +- .github/workflows/publish-new.yml | 4 +- .ignore | 6 +- .prettierignore | 6 +- .yarnrc.yml | 2 +- apps/docs/content/docs/user-interface.mdx | 1 - .../content/getting-started/quick-start.mdx | 22 +++--- apps/dotcom/README.md | 9 ++- apps/dotcom/index.html | 3 +- apps/examples/src/examples/basic/README.md | 2 - .../src/examples/infer-dark-mode/README.md | 2 - .../src/examples/peristence-key/README.md | 2 - .../examples/speech-bubble/customhandles.css | 3 +- apps/examples/src/index.html | 2 +- apps/health-worker/README.md | 2 +- package.json | 2 +- scripts/lint.ts | 74 ++++--------------- templates/nextjs/next.config.cjs | 10 +-- templates/vite/.eslintrc.cjs | 24 +++--- templates/vite/index.html | 22 +++--- 21 files changed, 78 insertions(+), 123 deletions(-) diff --git a/.eslintignore b/.eslintignore index f0d18f085..3fd48ab97 100644 --- a/.eslintignore +++ b/.eslintignore @@ -17,6 +17,7 @@ **/next.config.js **/setupTests.js **/setupJest.js +**/jestResolver.js apps/vscode/extension/editor apps/examples/www apps/docs/api-content.json diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 7d4b01256..780e08332 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -73,4 +73,4 @@ jobs: run: "yarn build | sed -E 's/^.*? ::/::/'" - name: Pack public packages - run: "yarn lazy pack-tarball | sed -E 's/^.*? ::/::/'" \ No newline at end of file + run: "yarn lazy pack-tarball | sed -E 's/^.*? ::/::/'" diff --git a/.github/workflows/publish-new.yml b/.github/workflows/publish-new.yml index 7b6c5d2c3..f218c053e 100644 --- a/.github/workflows/publish-new.yml +++ b/.github/workflows/publish-new.yml @@ -76,6 +76,4 @@ jobs: secrets: VITE_TEMPLATE_REPO_SSH_DEPLOY_KEY: ${{ secrets.VITE_TEMPLATE_REPO_SSH_DEPLOY_KEY }} NEXTJS_TEMPLATE_REPO_SSH_DEPLOY_KEY: ${{ secrets.NEXTJS_TEMPLATE_REPO_SSH_DEPLOY_KEY }} - needs: [ - deploy - ] + needs: [deploy] diff --git a/.ignore b/.ignore index dd142cc32..d6fe09214 100644 --- a/.ignore +++ b/.ignore @@ -2,9 +2,9 @@ dist .tsbuild-dev .tsbuild-pub .tsbuild -node\*modules +node_modules *.d.ts -*.md +**/api-report.md **/_archive **/*.tsbuildinfo yarn.lock @@ -25,4 +25,6 @@ packages/tldraw/tldraw.css **/*.js.map **/*.api.json apps/docs/utils/vector-db +apps/docs/content/releases/**/* +apps/docs/content/reference/**/* packages/**/api \ No newline at end of file diff --git a/.prettierignore b/.prettierignore index 2088ec33e..b8fb0abb0 100644 --- a/.prettierignore +++ b/.prettierignore @@ -8,7 +8,6 @@ !**/pages/api/* **/.tsbuild* **/.next/* -*.mdx **/_archive/* apps/docs/api-content.json apps/docs/content.json @@ -18,6 +17,11 @@ content.json apps/docs/utils/vector-db/index.json **/gen/**/*.md +**/api-report.md +**/CHANGELOG.md +apps/docs/content/releases/**/* +apps/docs/content/reference/**/* + **/.vercel/* **/.wrangler/* **/.out/* diff --git a/.yarnrc.yml b/.yarnrc.yml index af041da40..e61390b39 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -4,4 +4,4 @@ enableGlobalCache: false enableInlineBuilds: true -nodeLinker: node-modules \ No newline at end of file +nodeLinker: node-modules diff --git a/apps/docs/content/docs/user-interface.mdx b/apps/docs/content/docs/user-interface.mdx index 45509219f..5a56623f8 100644 --- a/apps/docs/content/docs/user-interface.mdx +++ b/apps/docs/content/docs/user-interface.mdx @@ -59,7 +59,6 @@ Note that `onUiEvent` is only called when interacting with the user interface. I See the [tldraw repository](https://github.com/tldraw/tldraw/tree/main/apps/examples) for an example of how to customize tldraw's user interface. - ## Overrides The content of tldraw's menus can be controlled via the `overrides` prop. This prop accepts a [TLUiOverrides](/reference/tldraw/TLUiOverrides) object, which has methods for each part of the user interface, such as the `toolbar` or `keyboardShortcutsMenu`. diff --git a/apps/docs/content/getting-started/quick-start.mdx b/apps/docs/content/getting-started/quick-start.mdx index a85c3a1a9..fbfa2e481 100644 --- a/apps/docs/content/getting-started/quick-start.mdx +++ b/apps/docs/content/getting-started/quick-start.mdx @@ -10,7 +10,7 @@ order: 0 You can use the tldraw SDK to craft infinite canvas experiences for the web. It's perfect for collaborative whiteboards but you can use it for lots of other things, too. -By the end of this guide you will have made something that looks like this: +By the end of this guide you will have made something that looks like this: @@ -50,26 +50,26 @@ To render the Tldraw component This will render a full screen canvas: ```javascript -import { Tldraw } from "tldraw"; -import "./index.css"; +import { Tldraw } from 'tldraw' +import './index.css' export default function App() { - return ( -
- -
- ); + return ( +
+ +
+ ) } ``` ## Next Steps -Now that you have your canvas working, you may be wondering: what next? +Now that you have your canvas working, you may be wondering: what next? -You can try: +You can try: - Giving the editor a makeover by [customizing the UI](/docs/user-interface) - Adding your own [shapes](/docs/shapes) and [tools](/docs/tools) -- Providing collaboration using [multiplayer](https://github.com/tldraw/tldraw-yjs-example) +- Providing collaboration using [multiplayer](https://github.com/tldraw/tldraw-yjs-example) We provide the above examples and more in our [examples section](/examples). Go build something creative and please do share it with us in our [#show-and-tell](https://discord.com/invite/SBBEVCA4PG) channel on Discord! diff --git a/apps/dotcom/README.md b/apps/dotcom/README.md index bc69357d2..13d84d40a 100644 --- a/apps/dotcom/README.md +++ b/apps/dotcom/README.md @@ -60,21 +60,24 @@ You need to have a psql client [installed](https://www.timescale.com/blog/how-to ## Sending emails -We are using [Resend](https://resend.com/) for sending emails. It allows us to write emails as React components. Emails live in a separate app `apps/tl-emails`. +We are using [Resend](https://resend.com/) for sending emails. It allows us to write emails as React components. Emails live in a separate app `apps/tl-emails`. Right now we are only using Resend via Supabase, but in the future we will probably also include Resend in our application and send emails directly. The development workflow is as follows: ### 1. Creating / updating an email template - To start the development server for email run `yarn dev-email` from the root folder of our repo. You can then open [http://localhost:3333](http://localhost:3333) to see the result. This allows for quick local development of email templates. + +To start the development server for email run `yarn dev-email` from the root folder of our repo. You can then open [http://localhost:3333](http://localhost:3333) to see the result. This allows for quick local development of email templates. Any images you want to use in the email should be uploaded to supabase to the `email` bucket. Supabase provides some custom params (like the magic link url) that we can insert into our email, [check their website](https://supabase.com/dashboard/project/faafybhoymfftncjttyq/auth/templates) for more info. ### 2. Generating the `html` version of the email -Once you are happy with the email template you can run `yarn build-email` from the root folder of our repo. This will generate the `html` version of the email and place it in `apps/tl-emails/out` folder. + +Once you are happy with the email template you can run `yarn build-email` from the root folder of our repo. This will generate the `html` version of the email and place it in `apps/tl-emails/out` folder. ### 3. Updating the template in Supabase + Once you have the `html` version of the email you can copy it into the Supabase template editor. You can find the templates [here](https://supabase.com/dashboard/project/faafybhoymfftncjttyq/auth/templates). diff --git a/apps/dotcom/index.html b/apps/dotcom/index.html index 9795dd999..9c5a8170d 100644 --- a/apps/dotcom/index.html +++ b/apps/dotcom/index.html @@ -1,4 +1,4 @@ - + @@ -46,5 +46,4 @@ - diff --git a/apps/examples/src/examples/basic/README.md b/apps/examples/src/examples/basic/README.md index 655bb045f..b88917d63 100644 --- a/apps/examples/src/examples/basic/README.md +++ b/apps/examples/src/examples/basic/README.md @@ -5,8 +5,6 @@ category: basic priority: 1 --- - - --- The `Tldraw` component provides the tldraw editor as a regular React component. You can put this component anywhere in your React project. In this example, we make the component take up the height and width of the container. diff --git a/apps/examples/src/examples/infer-dark-mode/README.md b/apps/examples/src/examples/infer-dark-mode/README.md index 51f469e24..1f0b4dd70 100644 --- a/apps/examples/src/examples/infer-dark-mode/README.md +++ b/apps/examples/src/examples/infer-dark-mode/README.md @@ -5,8 +5,6 @@ category: basic priority: 5 --- - - --- When the `Tldraw` component's `inferDarkMode` is true, the editor will infer its initial theme based on the user's system preferences, if available. You can toggle the dark mode by pressing `Command + /`. diff --git a/apps/examples/src/examples/peristence-key/README.md b/apps/examples/src/examples/peristence-key/README.md index 26124e366..0e7291bc2 100644 --- a/apps/examples/src/examples/peristence-key/README.md +++ b/apps/examples/src/examples/peristence-key/README.md @@ -5,8 +5,6 @@ category: basic priority: 2 --- - - --- If the `persistenceKey` prop is provided to the `` component, the editor will persist its data locally under that key. diff --git a/apps/examples/src/examples/speech-bubble/customhandles.css b/apps/examples/src/examples/speech-bubble/customhandles.css index a57e290ab..8dae68671 100644 --- a/apps/examples/src/examples/speech-bubble/customhandles.css +++ b/apps/examples/src/examples/speech-bubble/customhandles.css @@ -1,5 +1,4 @@ /* Resize handles are normally on top, but We're going to give shape handles priority */ .tl-user-handles { z-index: 101; - -} \ No newline at end of file +} diff --git a/apps/examples/src/index.html b/apps/examples/src/index.html index 5b3efcb37..c933b376c 100644 --- a/apps/examples/src/index.html +++ b/apps/examples/src/index.html @@ -1,4 +1,4 @@ - + diff --git a/apps/health-worker/README.md b/apps/health-worker/README.md index b292dc138..639b2098d 100644 --- a/apps/health-worker/README.md +++ b/apps/health-worker/README.md @@ -1,3 +1,3 @@ # Health Worker -Accepts webhooks from [Updown](https://updown.io/), sends them to our Discord. \ No newline at end of file +Accepts webhooks from [Updown](https://updown.io/), sends them to our Discord. diff --git a/package.json b/package.json index 4818aa2d5..be9ae6468 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "build-package": "lazy build-package", "preview-app": "VITE_PREVIEW=1 yarn dev-app", "lint": "lazy lint", - "format": "prettier --write --cache \"**/*.{ts,tsx,js,jsx,json}\"", + "format": "prettier --write --cache '**/*.{yml,yaml,json,md,mdx,html,css,js,jsx,ts,tsx,cjs,mjs}'", "typecheck": "yarn refresh-assets && tsx scripts/typecheck.ts", "check-scripts": "tsx scripts/check-scripts.ts", "check-tsconfigs": "tsx scripts/check-tsconfigs.ts", diff --git a/scripts/lint.ts b/scripts/lint.ts index 79fe74391..d11d1d06f 100755 --- a/scripts/lint.ts +++ b/scripts/lint.ts @@ -1,70 +1,26 @@ -import ignore from 'ignore' import * as path from 'path' import { exec } from './lib/exec' -import { REPO_ROOT, readFileIfExists } from './lib/file' - -const ESLINT_EXTENSIONS = ['js', 'jsx', 'ts', 'tsx'] -const PRETTIER_EXTENSIONS = ['js', 'jsx', 'ts', 'tsx', 'json'] +import { REPO_ROOT } from './lib/file' async function main() { const shouldFix = process.argv.includes('--fix') - - const lsFiles = await exec('git', ['ls-files', '.'], { - processStdoutLine: () => { - // don't print anything - }, - }) - - const filesByExtension = new Map() - for (const file of lsFiles.trim().split('\n')) { - const ext = file.split('.').pop() - if (!ext) continue - let files = filesByExtension.get(ext) - if (!files) { - files = [] - filesByExtension.set(ext.toLowerCase(), files) - } - files.push(file) - } - - let prettierFiles = PRETTIER_EXTENSIONS.flatMap((ext) => filesByExtension.get(ext) ?? []) - let eslintFiles = ESLINT_EXTENSIONS.flatMap((ext) => filesByExtension.get(ext) ?? []) - const relativeCwd = path.relative(REPO_ROOT, process.cwd()) - const prettierIgnoreFile = await readFileIfExists(path.join(REPO_ROOT, '.prettierignore')) - if (prettierIgnoreFile) { - prettierFiles = prettierFiles - .map((f) => path.join(relativeCwd, f)) - .filter(ignore().add(prettierIgnoreFile).createFilter()) - .map((f) => path.relative(relativeCwd, f)) - } - - const eslintIgnoreFile = await readFileIfExists(path.join(REPO_ROOT, '.eslintignore')) - if (eslintIgnoreFile) { - eslintFiles = eslintFiles - .map((f) => path.join(relativeCwd, f)) - .filter(ignore().add(eslintIgnoreFile).createFilter()) - .map((f) => path.relative(relativeCwd, f)) - } - try { - await exec('yarn', [ - 'run', - '-T', - 'prettier', - shouldFix ? '--write' : '--check', - '--cache', - ...prettierFiles, - ]) - await exec('yarn', [ - 'run', - '-T', - 'eslint', - '--report-unused-disable-directives', - shouldFix ? '--fix' : null, - ...eslintFiles, - ]) + await exec('yarn', ['prettier', shouldFix ? '--write' : '--check', '--cache', relativeCwd], { + pwd: REPO_ROOT, + }) + await exec( + 'yarn', + [ + 'eslint', + '--report-unused-disable-directives', + '--no-error-on-unmatched-pattern', + shouldFix ? '--fix' : null, + relativeCwd, + ], + { pwd: REPO_ROOT } + ) } catch (error) { process.exit(1) } diff --git a/templates/nextjs/next.config.cjs b/templates/nextjs/next.config.cjs index 55712b642..5cc51c3b1 100644 --- a/templates/nextjs/next.config.cjs +++ b/templates/nextjs/next.config.cjs @@ -1,8 +1,8 @@ /** @type {import('next').NextConfig} */ const nextConfig = { - experimental: { - serverComponentsExternalPackages: ["@tldraw/tldraw"], - }, -}; + experimental: { + serverComponentsExternalPackages: ['@tldraw/tldraw'], + }, +} -module.exports = nextConfig; +module.exports = nextConfig diff --git a/templates/vite/.eslintrc.cjs b/templates/vite/.eslintrc.cjs index 4020bcbf4..29bddcf1f 100644 --- a/templates/vite/.eslintrc.cjs +++ b/templates/vite/.eslintrc.cjs @@ -1,14 +1,14 @@ module.exports = { - env: { browser: true, es2020: true }, - extends: [ - 'eslint:recommended', - 'plugin:@typescript-eslint/recommended', - 'plugin:react-hooks/recommended', - ], - parser: '@typescript-eslint/parser', - parserOptions: { ecmaVersion: 'latest', sourceType: 'module' }, - plugins: ['react-refresh'], - rules: { - 'react-refresh/only-export-components': 'warn', - }, + env: { browser: true, es2020: true }, + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:react-hooks/recommended', + ], + parser: '@typescript-eslint/parser', + parserOptions: { ecmaVersion: 'latest', sourceType: 'module' }, + plugins: ['react-refresh'], + rules: { + 'react-refresh/only-export-components': 'warn', + }, } diff --git a/templates/vite/index.html b/templates/vite/index.html index c1c7871fb..4024e639b 100644 --- a/templates/vite/index.html +++ b/templates/vite/index.html @@ -1,13 +1,13 @@ - + - - - - - tldraw Vite template - - -
- - + + + + + tldraw Vite template + + +
+ +