[dx] Allow vscode to search inside md files by default (#3105)

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
This commit is contained in:
David Sheldrick 2024-03-11 14:08:04 +00:00 committed by GitHub
parent e527d7d0d7
commit 47a85896e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 78 additions and 123 deletions

View file

@ -17,6 +17,7 @@
**/next.config.js **/next.config.js
**/setupTests.js **/setupTests.js
**/setupJest.js **/setupJest.js
**/jestResolver.js
apps/vscode/extension/editor apps/vscode/extension/editor
apps/examples/www apps/examples/www
apps/docs/api-content.json apps/docs/api-content.json

View file

@ -76,6 +76,4 @@ jobs:
secrets: secrets:
VITE_TEMPLATE_REPO_SSH_DEPLOY_KEY: ${{ secrets.VITE_TEMPLATE_REPO_SSH_DEPLOY_KEY }} 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 }} NEXTJS_TEMPLATE_REPO_SSH_DEPLOY_KEY: ${{ secrets.NEXTJS_TEMPLATE_REPO_SSH_DEPLOY_KEY }}
needs: [ needs: [deploy]
deploy
]

View file

@ -2,9 +2,9 @@ dist
.tsbuild-dev .tsbuild-dev
.tsbuild-pub .tsbuild-pub
.tsbuild .tsbuild
node\*modules node_modules
*.d.ts *.d.ts
*.md **/api-report.md
**/_archive **/_archive
**/*.tsbuildinfo **/*.tsbuildinfo
yarn.lock yarn.lock
@ -25,4 +25,6 @@ packages/tldraw/tldraw.css
**/*.js.map **/*.js.map
**/*.api.json **/*.api.json
apps/docs/utils/vector-db apps/docs/utils/vector-db
apps/docs/content/releases/**/*
apps/docs/content/reference/**/*
packages/**/api packages/**/api

View file

@ -8,7 +8,6 @@
!**/pages/api/* !**/pages/api/*
**/.tsbuild* **/.tsbuild*
**/.next/* **/.next/*
*.mdx
**/_archive/* **/_archive/*
apps/docs/api-content.json apps/docs/api-content.json
apps/docs/content.json apps/docs/content.json
@ -18,6 +17,11 @@ content.json
apps/docs/utils/vector-db/index.json apps/docs/utils/vector-db/index.json
**/gen/**/*.md **/gen/**/*.md
**/api-report.md
**/CHANGELOG.md
apps/docs/content/releases/**/*
apps/docs/content/reference/**/*
**/.vercel/* **/.vercel/*
**/.wrangler/* **/.wrangler/*
**/.out/* **/.out/*

View file

@ -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. 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 ## 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`. 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`.

View file

@ -50,15 +50,15 @@ To render the Tldraw component
This will render a full screen canvas: This will render a full screen canvas:
```javascript ```javascript
import { Tldraw } from "tldraw"; import { Tldraw } from 'tldraw'
import "./index.css"; import './index.css'
export default function App() { export default function App() {
return ( return (
<div style={{ position: 'fixed', inset: 0 }}> <div style={{ position: 'fixed', inset: 0 }}>
<Tldraw /> <Tldraw />
</div> </div>
); )
} }
``` ```

View file

@ -67,14 +67,17 @@ Right now we are only using Resend via Supabase, but in the future we will proba
The development workflow is as follows: The development workflow is as follows:
### 1. Creating / updating an email template ### 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. 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. 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 ### 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 ### 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). 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).

View file

@ -1,4 +1,4 @@
<!DOCTYPE html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
@ -46,5 +46,4 @@
<script type="module" src="./src/main.tsx"></script> <script type="module" src="./src/main.tsx"></script>
<noscript>You need to enable JavaScript to run tldraw. ✌️</noscript> <noscript>You need to enable JavaScript to run tldraw. ✌️</noscript>
</body> </body>
</html> </html>

View file

@ -5,8 +5,6 @@ category: basic
priority: 1 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. 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.

View file

@ -5,8 +5,6 @@ category: basic
priority: 5 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 + /`. 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 + /`.

View file

@ -5,8 +5,6 @@ category: basic
priority: 2 priority: 2
--- ---
--- ---
If the `persistenceKey` prop is provided to the `<Tldraw/>` component, the editor will persist its data locally under that key. If the `persistenceKey` prop is provided to the `<Tldraw/>` component, the editor will persist its data locally under that key.

View file

@ -1,5 +1,4 @@
/* Resize handles are normally on top, but We're going to give shape handles priority */ /* Resize handles are normally on top, but We're going to give shape handles priority */
.tl-user-handles { .tl-user-handles {
z-index: 101; z-index: 101;
} }

View file

@ -1,4 +1,4 @@
<!DOCTYPE html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />

View file

@ -50,7 +50,7 @@
"build-package": "lazy build-package", "build-package": "lazy build-package",
"preview-app": "VITE_PREVIEW=1 yarn dev-app", "preview-app": "VITE_PREVIEW=1 yarn dev-app",
"lint": "lazy lint", "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", "typecheck": "yarn refresh-assets && tsx scripts/typecheck.ts",
"check-scripts": "tsx scripts/check-scripts.ts", "check-scripts": "tsx scripts/check-scripts.ts",
"check-tsconfigs": "tsx scripts/check-tsconfigs.ts", "check-tsconfigs": "tsx scripts/check-tsconfigs.ts",

View file

@ -1,70 +1,26 @@
import ignore from 'ignore'
import * as path from 'path' import * as path from 'path'
import { exec } from './lib/exec' import { exec } from './lib/exec'
import { REPO_ROOT, readFileIfExists } from './lib/file' import { REPO_ROOT } from './lib/file'
const ESLINT_EXTENSIONS = ['js', 'jsx', 'ts', 'tsx']
const PRETTIER_EXTENSIONS = ['js', 'jsx', 'ts', 'tsx', 'json']
async function main() { async function main() {
const shouldFix = process.argv.includes('--fix') const shouldFix = process.argv.includes('--fix')
const lsFiles = await exec('git', ['ls-files', '.'], {
processStdoutLine: () => {
// don't print anything
},
})
const filesByExtension = new Map<string, string[]>()
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 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 { try {
await exec('yarn', [ await exec('yarn', ['prettier', shouldFix ? '--write' : '--check', '--cache', relativeCwd], {
'run', pwd: REPO_ROOT,
'-T', })
'prettier', await exec(
shouldFix ? '--write' : '--check', 'yarn',
'--cache', [
...prettierFiles, 'eslint',
]) '--report-unused-disable-directives',
await exec('yarn', [ '--no-error-on-unmatched-pattern',
'run', shouldFix ? '--fix' : null,
'-T', relativeCwd,
'eslint', ],
'--report-unused-disable-directives', { pwd: REPO_ROOT }
shouldFix ? '--fix' : null, )
...eslintFiles,
])
} catch (error) { } catch (error) {
process.exit(1) process.exit(1)
} }

View file

@ -1,8 +1,8 @@
/** @type {import('next').NextConfig} */ /** @type {import('next').NextConfig} */
const nextConfig = { const nextConfig = {
experimental: { experimental: {
serverComponentsExternalPackages: ["@tldraw/tldraw"], serverComponentsExternalPackages: ['@tldraw/tldraw'],
}, },
}; }
module.exports = nextConfig; module.exports = nextConfig

View file

@ -1,14 +1,14 @@
module.exports = { module.exports = {
env: { browser: true, es2020: true }, env: { browser: true, es2020: true },
extends: [ extends: [
'eslint:recommended', 'eslint:recommended',
'plugin:@typescript-eslint/recommended', 'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended', 'plugin:react-hooks/recommended',
], ],
parser: '@typescript-eslint/parser', parser: '@typescript-eslint/parser',
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' }, parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
plugins: ['react-refresh'], plugins: ['react-refresh'],
rules: { rules: {
'react-refresh/only-export-components': 'warn', 'react-refresh/only-export-components': 'warn',
}, },
} }

View file

@ -1,13 +1,13 @@
<!DOCTYPE html> <!doctype html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" /> <link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>tldraw Vite template</title> <title>tldraw Vite template</title>
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>
<script type="module" src="/src/main.tsx"></script> <script type="module" src="/src/main.tsx"></script>
</body> </body>
</html> </html>