Skip to content

Instantly share code, notes, and snippets.

@Avi-E-Koenig
Created May 28, 2025 09:16
Show Gist options
  • Select an option

  • Save Avi-E-Koenig/2cc12b9be49dd67c7fd61992262d667c to your computer and use it in GitHub Desktop.

Select an option

Save Avi-E-Koenig/2cc12b9be49dd67c7fd61992262d667c to your computer and use it in GitHub Desktop.
import { dirname } from 'path'
import { fileURLToPath } from 'url'
import { FlatCompat } from '@eslint/eslintrc'
import prettier from 'eslint-plugin-prettier'
import jsxA11y from 'eslint-plugin-jsx-a11y'
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
const compat = new FlatCompat({ baseDirectory: __dirname })
const eslintConfig = [
...compat.extends(
'next/core-web-vitals',
'next/typescript',
'plugin:react/recommended',
'plugin:@next/next/recommended',
'plugin:prettier/recommended',
'plugin:jsx-a11y/recommended',
),
{
plugins: {
prettier,
'jsx-a11y': jsxA11y,
},
rules: {
'react/jsx-max-props-per-line': [1, { maximum: 1, when: 'multiline' }],
'object-curly-newline': 'off',
'react/react-in-jsx-scope': 'off',
'prettier/prettier': ['error', {}, { usePrettierrc: true }],
'jsx-a11y/alt-text': 'warn',
},
settings: {
react: { version: 'detect' },
},
},
]
export default eslintConfig
@AssafFogelman
Copy link

import eslint from '@eslint/js';
import tseslint from '@typescript-eslint/eslint-plugin';
import tseslintParser from '@typescript-eslint/parser';
import reactPlugin from 'eslint-plugin-react';
import reactNativePlugin from 'eslint-plugin-react-native';
import reactHooks from 'eslint-plugin-react-hooks';
import reactRefresh from 'eslint-plugin-react-refresh';
import importPlugin from 'eslint-plugin-import';
import prettier from 'eslint-config-prettier';

export default [
// Base config for all files
{
ignores: [
'/dist/',
'/node_modules/',
'/__MACOSX/',
'/cal-ai-clone/',
'/.expo/',
'/*.d.ts',
'
/packages/mobile/android/',
'
/packages/mobile/ios/**',
'packages/mobile/index.js',
],
},
eslint.configs.recommended,

{
files: ['/*.ts', '/.tsx'],
languageOptions: {
parser: tseslintParser,
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./tsconfig.json', './packages/
/tsconfig.json'],
module: 'esnext',
},
},
plugins: {
'@typescript-eslint': tseslint,
import: importPlugin,
},
rules: {
...tseslint.configs.recommended.rules,
// Import rules
'import/extensions': 'off',
'@typescript-eslint/no-require-imports': 'off',

  // TypeScript rules
  '@typescript-eslint/no-unused-vars': [
    'warn',
    {
      argsIgnorePattern: '^_',
      varsIgnorePattern: '^_',
    },
  ],
  '@typescript-eslint/no-explicit-any': 'warn',
  'no-undef': 'off', // TypeScript handles this
},

},

// React Native files config
{
files: ['**/*.tsx', 'packages/mobile/index.js'],
plugins: {
react: reactPlugin,
'react-native': reactNativePlugin,
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
},
languageOptions: {
parser: tseslintParser,
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./tsconfig.json'],
module: 'esnext',
},
globals: {
...reactPlugin.configs['jsx-runtime'].globals,
...reactNativePlugin.environments['react-native'].globals,
},
},
settings: {
react: {
version: 'detect',
},
},
rules: {
'react/react-in-jsx-scope': 'off',
'react/prop-types': 'off',

  'react-hooks/rules-of-hooks': 'error',
  'react-hooks/exhaustive-deps': 'warn',
  'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
},

},

// Node.js files config
{
files: ['packages/server/**/*.ts'],
languageOptions: {
parser: tseslintParser,
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./packages/server/tsconfig.json'],
module: 'esnext',
},
globals: {
node: true,
},
},
rules: {
'max-len': [
'warn',
{
code: 120,
ignoreUrls: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
ignoreRegExpLiterals: true,
},
],
'no-case-declarations': 'off',
},
},
prettier,
];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment