tldraw/.eslintrc.js
Steve Ruiz 2f28d7c6f8
Protect local storage calls (#3043)
This PR provides some safe wrappers for local storage calls. Local
storage is not available in all environments (for example, a React
Native web view). The PR also adds an eslint rule preventing direct
calls to local / session storage.

### Change Type

- [x] `patch` — Bug fix

### Release Notes

- Fixes a bug that could cause crashes in React Native webviews.
2024-03-04 13:37:09 +00:00

115 lines
2.7 KiB
JavaScript

module.exports = {
extends: [
'prettier',
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@next/next/core-web-vitals',
],
ignorePatterns: [],
plugins: [
'@typescript-eslint',
'no-only-tests',
'import',
'local',
'@next/next',
'react-hooks',
'deprecation',
'no-storage',
],
settings: {
next: {
rootDir: ['apps/*/', 'packages/*/'],
},
},
rules: {
'no-storage/no-browser-storage': 2,
'deprecation/deprecation': 'error',
'@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',
'import/no-internal-modules': ['error', { forbid: ['@tldraw/*/**', 'tldraw/**'] }],
'@typescript-eslint/consistent-type-exports': [
'error',
{ fixMixedExportsWithInlineTypeSpecifier: true },
],
'local/no-export-star': 'error',
'no-only-tests/no-only-tests': 'error',
'no-restricted-syntax': [
'error',
{ selector: "MethodDefinition[kind='set']", message: 'Property setters are not allowed' },
{ selector: "MethodDefinition[kind='get']", message: 'Property getters are not allowed' },
],
},
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',
},
},
{
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.',
},
],
},
},
],
}