Skip to content

Every analytics tool wants a subscription. And your data. I built Twiligent instead. YouTube stats. Instagram stats. One dashboard. Runs locally on your machine.

2.7 KB
Raw Blame
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'
import { defineConfig, globalIgnores } from 'eslint/config'

export default defineConfig([
  // .claude holds Claude Code's local worktrees: whole copies of the repository with their own node_modules
  globalIgnores(['**/dist', '**/.wrangler', '**/node_modules', '.claude']),
  {
    files: ['**/*.{ts,tsx}'],
    extends: [js.configs.recommended, tseslint.configs.recommended],
  },
  {
    files: ['frontend/**/*.{ts,tsx}'],
    extends: [
      reactHooks.configs.flat.recommended,
      reactRefresh.configs.vite,
    ],
    languageOptions: {
      globals: globals.browser,
    },
    rules: {
      '@typescript-eslint/no-unused-vars': ['error', { varsIgnorePattern: '^[A-Z_]' }],
      // shadcn files export their cva variants, Intent UI's chart its helpers, and contexts their hooks; editing those files reloads the page
      'react-refresh/only-export-components': ['error', {
        allowConstantExport: true,
        allowExportNames: ['badgeVariants', 'buttonVariants', 'tabsListVariants', 'toggleVariants', 'useSidebar', 'useAppContext', 'useAuth', 'useChart', 'valueToPercent', 'constructCategoryColors', 'getColorValue'],
      }],
    },
  },
  {
    files: ['site/**/*.{ts,tsx}'],
    extends: [
      reactHooks.configs.flat.recommended,
      reactRefresh.configs.vite,
    ],
    languageOptions: {
      globals: globals.browser,
    },
    rules: {
      // no exception for capitalised names: TypeScript sees JSX use, so an unused component is reported like any variable
      '@typescript-eslint/no-unused-vars': 'error',
      'react-refresh/only-export-components': ['error', { allowConstantExport: true }],
    },
  },
  {
    files: ['site/vite.config.ts', 'site/build/**/*.ts', 'site/tests/**/*.ts'],
    languageOptions: {
      globals: globals.node,
    },
  },
  {
    // the worker runs on the web platform, so it gets service worker globals, not node
    files: ['backend/**/*.ts'],
    languageOptions: {
      globals: globals.serviceworker,
    },
    rules: {
      '@typescript-eslint/no-unused-vars': ['error', { varsIgnorePattern: '^_', argsIgnorePattern: '^_', caughtErrors: 'none' }],
    },
  },
  {
    files: ['backend/tests/**/*.ts', 'frontend/tests/**/*.ts', 'frontend/vite.config.ts', 'scripts/**/*.ts'],
    languageOptions: {
      globals: globals.node,
    },
  },
  {
    files: ['*.js', '*.mjs'],
    extends: [js.configs.recommended],
    languageOptions: {
      ecmaVersion: 'latest',
      sourceType: 'module',
      globals: globals.node,
    },
  },
])