2023-04-25 11:01:25 +00:00
|
|
|
module.exports = {
|
|
|
|
extends: [
|
|
|
|
'prettier',
|
|
|
|
'eslint:recommended',
|
|
|
|
'plugin:@typescript-eslint/recommended',
|
|
|
|
'plugin:@next/next/core-web-vitals',
|
|
|
|
],
|
2023-05-30 14:28:56 +00:00
|
|
|
ignorePatterns: [],
|
2023-11-16 15:34:56 +00:00
|
|
|
plugins: [
|
|
|
|
'@typescript-eslint',
|
|
|
|
'no-only-tests',
|
|
|
|
'import',
|
|
|
|
'local',
|
|
|
|
'@next/next',
|
|
|
|
'react-hooks',
|
|
|
|
'deprecation',
|
|
|
|
],
|
2023-04-25 11:01:25 +00:00
|
|
|
settings: {
|
|
|
|
next: {
|
|
|
|
rootDir: ['apps/*/', 'packages/*/'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
rules: {
|
2023-11-16 15:34:56 +00:00
|
|
|
'deprecation/deprecation': 'error',
|
2023-04-25 11:01:25 +00:00
|
|
|
'@next/next/no-html-link-for-pages': 'off',
|
|
|
|
'react/jsx-key': 'off',
|
|
|
|
'no-non-null-assertion': 'off',
|
|
|
|
'no-fallthrough': 'off',
|
|
|
|
'@typescript-eslint/no-fallthrough': 'off',
|
|
|
|
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
|
|
'@typescript-eslint/no-explicit-any': 'off',
|
|
|
|
'@typescript-eslint/ban-ts-comment': 'off',
|
|
|
|
'react/display-name': 'off',
|
|
|
|
'@next/next/no-img-element': 'off',
|
|
|
|
'@typescript-eslint/no-extra-semi': 'off',
|
|
|
|
'no-mixed-spaces-and-tabs': 'off',
|
|
|
|
'@typescript-eslint/no-unused-vars': [
|
|
|
|
'error',
|
|
|
|
{
|
|
|
|
argsIgnorePattern: '^_',
|
|
|
|
varsIgnorePattern: '^_',
|
|
|
|
caughtErrorsIgnorePattern: '^_',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
'no-throw-literal': 'error',
|
|
|
|
'react-hooks/rules-of-hooks': 'error',
|
|
|
|
'react-hooks/exhaustive-deps': 'error',
|
|
|
|
'import/no-extraneous-dependencies': 'error',
|
2024-02-29 16:06:19 +00:00
|
|
|
'import/no-internal-modules': ['error', { forbid: ['@tldraw/*/**', 'tldraw/**'] }],
|
2023-04-25 11:01:25 +00:00
|
|
|
'@typescript-eslint/consistent-type-exports': [
|
|
|
|
'error',
|
|
|
|
{ fixMixedExportsWithInlineTypeSpecifier: true },
|
|
|
|
],
|
|
|
|
'local/no-export-star': 'error',
|
2023-05-12 13:19:39 +00:00
|
|
|
'no-only-tests/no-only-tests': 'error',
|
2023-11-16 12:07:33 +00:00
|
|
|
'no-restricted-syntax': [
|
|
|
|
'error',
|
|
|
|
{ selector: "MethodDefinition[kind='set']", message: 'Property setters are not allowed' },
|
|
|
|
{ selector: "MethodDefinition[kind='get']", message: 'Property getters are not allowed' },
|
2024-03-04 16:15:20 +00:00
|
|
|
{
|
|
|
|
selector: 'Identifier[name=localStorage]',
|
|
|
|
message: 'Use the getFromLocalStorage/setInLocalStorage helpers instead',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
selector: 'Identifier[name=sessionStorage]',
|
|
|
|
message: 'Use the getFromSessionStorage/setInSessionStorage helpers instead',
|
|
|
|
},
|
2023-11-16 12:07:33 +00:00
|
|
|
],
|
use native structuredClone on node, cloudflare workers, and in tests (#3166)
Currently, we only use native `structuredClone` in the browser, falling
back to `JSON.parse(JSON.stringify(...))` elsewhere, despite Node
supporting `structuredClone` [since
v17](https://developer.mozilla.org/en-US/docs/Web/API/structuredClone)
and Cloudflare Workers supporting it [since
2022](https://blog.cloudflare.com/standards-compliant-workers-api/).
This PR adjusts our shim to use the native `structuredClone` on all
platforms, if available.
Additionally, `jsdom` doesn't implement `structuredClone`, a bug [open
since 2022](https://github.com/jsdom/jsdom/issues/3363). This PR patches
`jsdom` environment in all packages/apps that use it for tests.
Also includes a driveby removal of `deepCopy`, a function that is
strictly inferior to `structuredClone`.
### Change Type
<!-- ❗ Please select a 'Scope' label ❗️ -->
- [x] `sdk` — Changes the tldraw SDK
- [x] `dotcom` — Changes the tldraw.com web app
- [ ] `docs` — Changes to the documentation, examples, or templates.
- [ ] `vs code` — Changes to the vscode plugin
- [ ] `internal` — Does not affect user-facing stuff
<!-- ❗ Please select a 'Type' label ❗️ -->
- [ ] `bugfix` — Bug fix
- [ ] `feature` — New feature
- [x] `improvement` — Improving existing features
- [x] `chore` — Updating dependencies, other boring stuff
- [ ] `galaxy brain` — Architectural changes
- [ ] `tests` — Changes to any test code
- [ ] `tools` — Changes to infrastructure, CI, internal scripts,
debugging tools, etc.
- [ ] `dunno` — I don't know
### Test Plan
1. A smoke test would be enough
- [ ] Unit Tests
- [x] End to end tests
2024-03-18 17:16:09 +00:00
|
|
|
'no-restricted-globals': [
|
|
|
|
'error',
|
|
|
|
{ name: 'structuredClone', message: 'Use structuredClone from @tldraw/util instead' },
|
|
|
|
],
|
2023-04-25 11:01:25 +00:00
|
|
|
},
|
|
|
|
parser: '@typescript-eslint/parser',
|
|
|
|
parserOptions: {
|
|
|
|
project: true,
|
|
|
|
},
|
|
|
|
overrides: [
|
|
|
|
{
|
|
|
|
// enable the rule specifically for TypeScript files
|
|
|
|
files: ['*.ts', '*.tsx'],
|
|
|
|
rules: {
|
|
|
|
'@typescript-eslint/explicit-module-boundary-types': [0],
|
|
|
|
'no-console': ['error', { allow: ['warn', 'error'] }],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
files: ['e2e/**/*'],
|
|
|
|
rules: {
|
|
|
|
'@typescript-eslint/no-empty-function': 'off',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
files: 'scripts/**/*',
|
|
|
|
rules: {
|
|
|
|
'import/no-extraneous-dependencies': 'off',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
files: ['apps/examples/**/*'],
|
|
|
|
rules: {
|
|
|
|
'import/no-internal-modules': 'off',
|
2024-03-04 16:15:20 +00:00
|
|
|
'no-restricted-syntax': 'off',
|
2023-04-25 11:01:25 +00:00
|
|
|
},
|
|
|
|
},
|
2024-01-16 14:38:05 +00:00
|
|
|
{
|
|
|
|
files: ['apps/huppy/**/*', 'scripts/**/*'],
|
|
|
|
rules: {
|
|
|
|
'no-console': 'off',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
files: ['apps/dotcom/**/*'],
|
|
|
|
rules: {
|
|
|
|
'no-restricted-properties': [
|
|
|
|
2,
|
|
|
|
{
|
|
|
|
object: 'crypto',
|
|
|
|
property: 'randomUUID',
|
|
|
|
message: 'Please use the makeUUID util instead.',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
2023-04-25 11:01:25 +00:00
|
|
|
],
|
|
|
|
}
|