Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
319 changes: 256 additions & 63 deletions .oxlintrc.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -12,82 +12,275 @@
"browser": true,
"node": true,
},
"categories": {
"correctness": "error",
"suspicious": "error",
"options": {
"typeAware": true,
"typeCheck": true,
},
"plugins": [
"oxc",
"eslint",
"unicorn",
"typescript",
"import",
"jsx-a11y",
"oxc",
"promise",
"react",
"jsx-a11y",
"react-perf",
"import",
"typescript",
"unicorn",
],
"rules": {
// Correctness
"react/no-children-prop": ["off"],
// Eslint
"array-callback-return": "error",
"constructor-super": "error",
"for-direction": "error",
"func-names": ["warn", "as-needed", { "generators": "as-needed" }],
"func-style": ["warn", "declaration"],
"max-params": ["warn", { "max": 3 }],
"no-async-promise-executor": "error",
"no-caller": "error",
"no-class-assign": "error",
"no-compare-neg-zero": "error",
"no-cond-assign": "error",
"no-console": ["warn", { "allow": ["error", "error", "info"] }],
"no-const-assign": "error",
"no-constant-binary-expression": "error",
"no-constant-condition": "error",
"no-constructor-return": "warn",
"no-control-regex": "error",
"no-debugger": "error",
"no-delete-var": "error",
"no-dupe-class-members": "error",
"no-dupe-else-if": "error",
"no-dupe-keys": "error",
"no-duplicate-case": "error",
"no-duplicate-imports": "warn",
"no-empty-character-class": "error",
"no-empty-pattern": "error",
"no-empty-static-block": "error",
"no-eval": "error",
"no-ex-assign": "error",
"no-extra-boolean-cast": "error",
"no-func-assign": "error",
"no-global-assign": "error",
"no-import-assign": "error",
"no-invalid-regexp": "error",
"no-irregular-whitespace": "error",
"no-iterator": "error",
"no-loss-of-precision": "error",
"no-misleading-character-class": "error",
"no-new": "warn",
"no-new-native-nonconstructor": "error",
"no-new-wrappers": "warn",
"no-nonoctal-decimal-escape": "error",
"no-obj-calls": "error",
"no-self-assign": "error",
"no-setter-return": "error",
"no-shadow-restricted-names": "error",
"no-sparse-arrays": "error",
"no-this-before-super": "error",
"no-unassigned-vars": "error",
"no-unexpected-multiline": "error",
"no-unsafe-finally": "error",
"no-unsafe-negation": "error",
"no-unsafe-optional-chaining": "error",
"no-unused-expressions": "error",
"no-unused-labels": "error",
"no-unused-private-class-members": "error",
"no-unused-vars": "error",
"no-useless-backreference": "error",
"no-useless-catch": "error",
"no-useless-constructor": "warn",
"no-useless-escape": "error",
"no-useless-rename": "error",
"no-var": "warn",
"no-with": "error",
"prefer-const": "warn",
"prefer-object-has-own": "warn",
"radix": "warn",
"prefer-numeric-literals": "warn",
"require-yield": "error",
"use-isnan": "error",
"valid-typeof": "error",
"yoda": "warn",

// Perf
"no-await-in-loop": "error",
"no-useless-call": "error",
"oxc/no-accumulating-spread": "error",
"oxc/no-map-spread": "error",
"unicorn/prefer-array-find": "error",
"unicorn/prefer-array-flat-map": "error",
"unicorn/prefer-set-has": "error",

// Restriction
"default-case": ["error", { "commentPattern": "^skip\\sdefault" }],
"no-console": ["warn", { "allow": ["error", "warn", "info"] }],
"no-empty": "error",
"no-param-reassign": "error",
"no-restricted-globals": "error",
"typescript/no-import-type-side-effects": "error",
"typescript/no-explicit-any": "error",
"typescript/no-non-null-asserted-nullish-coalescing": "error",
"typescript/no-non-null-assertion": "error",
"typescript/promise-function-async": "error",
"typescript/use-unknown-in-catch-callback-variable": "error",
"unicorn/prefer-node-protocol": "error",
"react/no-unknown-property": "error",
"react/button-has-type": "error",
// Import
"import/no-cycle": ["error", { "maxDepth": 3 }],
"import/no-empty-named-blocks": "warn",
"import/no-named-as-default": "warn",
"import/no-named-as-default-member": "warn",
"import/no-self-import": "error",
"import/unambiguous": "warn",

// Suspicious
"eslint/no-unneeded-ternary": "off",
"eslint/no-shadow": "off",
"react/react-in-jsx-scope": "off",
"import/no-unassigned-import": "off",
// JSX Accessibility
"jsx-a11y/alt-text": "error",
"jsx-a11y/anchor-has-content": "error",
"jsx-a11y/anchor-is-valid": "error",
"jsx-a11y/aria-activedescendant-has-tabindex": "error",
"jsx-a11y/aria-props": "error",
"jsx-a11y/aria-proptypes": "error",
"jsx-a11y/aria-role": "error",
"jsx-a11y/aria-unsupported-elements": "error",
"jsx-a11y/autocomplete-valid": "error",
"jsx-a11y/heading-has-content": "error",
"jsx-a11y/html-has-lang": "error",
"jsx-a11y/iframe-has-title": "error",
"jsx-a11y/img-redundant-alt": "error",
"jsx-a11y/label-has-associated-control": "error",
"jsx-a11y/media-has-caption": "error",
"jsx-a11y/mouse-events-have-key-events": "error",
"jsx-a11y/no-access-key": "warn",
"jsx-a11y/no-aria-hidden-on-focusable": "error",
"jsx-a11y/no-autofocus": "warn",
"jsx-a11y/no-distracting-elements": "error",
"jsx-a11y/no-redundant-roles": "error",
"jsx-a11y/no-static-element-interactions": "error",
"jsx-a11y/tabindex-no-positive": "warn",
"jsx-a11y/prefer-tag-over-role": "error",
"jsx-a11y/role-has-required-aria-props": "error",
"jsx-a11y/role-supports-aria-props": "error",
"jsx-a11y/scope": "error",

// Pedantic
"eqeqeq": ["error", "smart"],
"radix": "error",
"require-await": "error",
"typescript/no-unsafe-argument": "error",
"typescript/return-await": "error",
"react/jsx-no-target-blank": "error",
"react/jsx-no-useless-fragment": "error",
"react/rules-of-hooks": "error",
// Oxc
"oxc/approx-constant": "warn",
"oxc/bad-array-method-on-arguments": "error",
"oxc/bad-char-at-comparison": "error",
"oxc/bad-comparison-sequence": "error",
"oxc/bad-min-max-func": "error",
"oxc/bad-object-literal-comparison": "error",
"oxc/bad-replace-all-arg": "error",
"oxc/const-comparisons": "error",
"oxc/double-comparisons": "error",
"oxc/erasing-op": "error",
"oxc/misrefactored-assign-op": "warn",
"oxc/missing-throw": "error",
"oxc/no-accumulating-spread": "warn",
"oxc/no-barrel-file": ["warn", { "threshold": 10 }],
"oxc/number-arg-out-of-range": "error",
"oxc/only-used-in-recursion": "error",
"oxc/uninvoked-array-callback": "error",

// Style
"capitalized-comments": "off",
"default-case-last": "error",
"default-param-last": "error",
"func-names": ["error", "as-needed", { "generators": "as-needed" }],
"max-params": ["error", { "max": 3 }],
"no-duplicate-imports": "error",
"no-implicit-coercion": "error",
"no-template-curly-in-string": "error",
"yoda": "error",
"typescript/consistent-type-definitions": ["error", "interface"],
"unicorn/filename-case": ["error", { "case": "kebabCase" }],
// Promise
"promise/always-return": "warn",
"promise/catch-or-return": "error",
"promise/no-callback-in-promise": "error",
"promise/no-multiple-resolved": "error",
"promise/no-new-statics": "error",
"promise/no-promise-in-callback": "error",
"promise/param-names": "warn",
"promise/valid-params": "error",

// React
"react/button-has-type": "error",
"react/checked-requires-onchange-or-readonly": "error",
"react/exhaustive-deps": "error",
"react/forbid-dom-props": ["error", { "forbid": [] }],
"react/forbid-elements": ["error", { "forbid": [] }],
"react/iframe-missing-sandbox": "error",
"react/jsx-boolean-value": ["warn", "never"],
"react/jsx-filename-extension": ["warn", { "extensions": ["jsx", "tsx"] }],
"react/jsx-fragments": ["warn", "element"],
"react/jsx-handler-names": "warn",
"react/jsx-key": "error",
"react/jsx-no-comment-textnodes": "warn",
"react/jsx-no-script-url": "error",
"react/jsx-no-target-blank": "warn",
"react/jsx-no-constructed-context-values": "error",
"react/jsx-no-duplicate-props": "error",
"react/jsx-no-undef": "error",
"react/jsx-no-useless-fragment": "warn",
"react/jsx-pascal-case": "warn",
"react/jsx-props-no-spread-multi": "error",
"react/no-children-prop": "error",
"react/no-danger-with-children": "error",
"react/no-direct-mutation-state": "error",
"react/no-find-dom-node": "error",
"react/no-string-refs": "error",
"react/no-this-in-sfc": "error",
"react/no-unsafe": "error",
"react/style-prop-object": "error",
"react/prefer-function-component": "warn",
"react/rules-of-hooks": "error",
"react/self-closing-comp": "warn",
"import/no-duplicates": "error",
"eslint/func-style": ["error", "declaration"],
"react/void-dom-elements-no-children": "error",

// TypeScript
"typescript/adjacent-overload-signatures": "warn",
"typescript/array-type": ["warn", { "default": "array" }],
"typescript/await-thenable": "error",
"typescript/consistent-type-imports": [
"warn",
{
"prefer": "type-imports",
"fixStyle": "inline-type-imports",
"disallowTypeAnnotations": false,
},
],
"typescript/consistent-type-assertions": [
"warn",
{ "assertionStyle": "as" },
],
"typescript/consistent-type-definitions": ["warn", "interface"],
"typescript/no-array-delete": "error",
"typescript/no-base-to-string": "error",
"typescript/no-duplicate-enum-values": "error",
"typescript/no-duplicate-type-constituents": "error",
"typescript/no-extra-non-null-assertion": "error",
"typescript/no-floating-promises": "error",
"typescript/no-for-in-array": "error",
"typescript/no-implied-eval": "error",
"typescript/no-meaningless-void-operator": "error",
"typescript/no-misused-new": "error",
"typescript/no-confusing-non-null-assertion": "warn",
"typescript/no-explicit-any": "warn",
"typescript/no-misused-spread": "error",
"typescript/no-non-null-asserted-optional-chain": "error",
"typescript/no-redundant-type-constituents": "error",
"typescript/no-unnecessary-boolean-literal-compare": "warn",
"typescript/no-unnecessary-template-expression": "warn",
"typescript/no-unnecessary-type-assertion": "warn",
"typescript/no-unnecessary-type-constraint": "warn",
"typescript/no-this-alias": "error",
"typescript/no-unnecessary-condition": "error",
"typescript/no-unnecessary-parameter-property-assignment": "error",
"typescript/no-unsafe-declaration-merging": "error",
"typescript/no-unsafe-unary-minus": "error",
"typescript/no-useless-empty-export": "error",
"typescript/no-wrapper-object-types": "error",
"typescript/prefer-as-const": "error",
"typescript/prefer-function-type": "warn",
"typescript/prefer-namespace-keyword": "error",
"typescript/prefer-string-starts-ends-with": "warn",
"typescript/require-array-sort-compare": "error",
"typescript/restrict-template-expressions": "error",
"typescript/require-await": "warn",
"typescript/switch-exhaustiveness-check": "warn",
"typescript/triple-slash-reference": "error",
"typescript/unbound-method": "error",

// Unicorn
"unicorn/error-message": "warn",
"unicorn/filename-case": ["warn", { "case": "kebabCase" }],
"unicorn/no-accessor-recursion": "error",
"unicorn/no-array-reverse": "warn",
"unicorn/no-array-sort": "warn",
"unicorn/no-await-in-promise-methods": "error",
"unicorn/no-instanceof-builtins": "warn",
"unicorn/no-empty-file": "error",
"unicorn/no-invalid-fetch-options": "error",
"unicorn/no-invalid-remove-event-listener": "error",
"unicorn/no-new-array": "error",
"unicorn/no-single-promise-in-promise-methods": "error",
"unicorn/no-thenable": "error",
"unicorn/no-unnecessary-await": "error",
"unicorn/no-useless-fallback-in-spread": "error",
"unicorn/no-useless-length-check": "error",
"unicorn/no-useless-promise-resolve-reject": "warn",
"unicorn/no-useless-spread": "error",
"unicorn/prefer-array-flat-map": "warn",
"unicorn/prefer-array-some": "warn",
"unicorn/prefer-node-protocol": "warn",
"unicorn/prefer-optional-catch-binding": "warn",
"unicorn/prefer-set-size": "error",
"unicorn/throw-new-error": "warn",
"unicorn/prefer-string-starts-ends-with": "error",
},
"overrides": [
{
Expand Down
8 changes: 8 additions & 0 deletions @types/react.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import 'react';

declare module 'react' {
interface CSSProperties {
// Allow any CSS variable starting with '--'
[key: `--${string}`]: string | number;
}
}
12 changes: 2 additions & 10 deletions drizzle.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dotenv/config';
import { defineConfig } from 'drizzle-kit';

import { getLocalCloudflareD1Path } from './src/lib/database/utils';
import { drizzleEnv } from './src/lib/env/drizzle';

const DBEnvironments = ['local', 'remote'] as const;
type DBEnvironment = (typeof DBEnvironments)[number];
Expand All @@ -11,7 +12,6 @@ interface DBConfig {
config: ReturnType<typeof defineConfig>;
}

const DB_ENV = process.env.DB_ENV as DBEnvironment;
const OUT_DIR = './src/lib/database/migrations';
const SCHEMA_DIR = './src/lib/database/schema';

Expand Down Expand Up @@ -59,14 +59,6 @@ const ENVIRONMENTS: Record<DBEnvironment, DBConfig> = {
},
};

const activeConfig = ENVIRONMENTS[DB_ENV];

if (!activeConfig) {
throw new Error(
`Invalid DB_ENV value. Expected one of ${DBEnvironments.join(', ')}. Please set the DB_ENV environment variable accordingly.`,
);
}

const activeConfig = ENVIRONMENTS[drizzleEnv.DB_ENV];
console.info(`Running Drizzle config in ${activeConfig.name} mode`);

export default activeConfig.config;
Loading