next.js103 lines · main
| 1 | const { defineConfig } = require('eslint/config') |
| 2 | const js = require('@eslint/js') |
| 3 | const { FlatCompat } = require('@eslint/eslintrc') |
| 4 | const prettierConfig = require('eslint-config-prettier/flat') |
| 5 | const { default: turboConfig } = require('eslint-config-turbo/flat') |
| 6 | const tanstackQuery = require('@tanstack/eslint-plugin-query') |
| 7 | const tseslint = require('@typescript-eslint/eslint-plugin') |
| 8 | const tsparser = require('@typescript-eslint/parser') |
| 9 | |
| 10 | // Custom Briven rules |
| 11 | const noAwaitBeforeCopyToClipboard = require('./rules/no-await-before-copy-to-clipboard') |
| 12 | |
| 13 | const compat = new FlatCompat({ |
| 14 | baseDirectory: __dirname, |
| 15 | recommendedConfig: js.configs.recommended, |
| 16 | allConfig: js.configs.all, |
| 17 | }) |
| 18 | |
| 19 | // Custom Briven ESLint plugin |
| 20 | const brivenPlugin = { |
| 21 | rules: { |
| 22 | 'no-await-before-copy-to-clipboard': noAwaitBeforeCopyToClipboard, |
| 23 | }, |
| 24 | } |
| 25 | |
| 26 | // TypeScript ESLint config for TypeScript files |
| 27 | const typescriptConfig = { |
| 28 | name: 'typescript', |
| 29 | files: ['**/*.ts', '**/*.tsx'], |
| 30 | languageOptions: { |
| 31 | parser: tsparser, |
| 32 | parserOptions: { |
| 33 | ecmaVersion: 'latest', |
| 34 | sourceType: 'module', |
| 35 | }, |
| 36 | }, |
| 37 | plugins: { |
| 38 | '@typescript-eslint': tseslint, |
| 39 | briven: brivenPlugin, |
| 40 | }, |
| 41 | rules: { |
| 42 | '@typescript-eslint/no-explicit-any': 'warn', |
| 43 | 'briven/no-await-before-copy-to-clipboard': 'error', |
| 44 | }, |
| 45 | } |
| 46 | |
| 47 | module.exports = defineConfig([ |
| 48 | // Global ignore for the .next folder |
| 49 | { ignores: ['.next', 'public', '.contentlayer'] }, |
| 50 | turboConfig, |
| 51 | prettierConfig, |
| 52 | tanstackQuery.configs['flat/recommended'], |
| 53 | { |
| 54 | rules: { |
| 55 | '@tanstack/query/exhaustive-deps': 'warn', |
| 56 | }, |
| 57 | }, |
| 58 | typescriptConfig, |
| 59 | { |
| 60 | extends: compat.extends('next/core-web-vitals'), |
| 61 | linterOptions: { |
| 62 | reportUnusedDisableDirectives: 'warn', |
| 63 | }, |
| 64 | rules: { |
| 65 | '@next/next/no-html-link-for-pages': 'off', |
| 66 | 'react/jsx-key': 'off', |
| 67 | 'no-restricted-imports': [ |
| 68 | 'warn', |
| 69 | { |
| 70 | name: 'react-data-grid', |
| 71 | message: 'Please use @tanstack/react-table instead.', |
| 72 | }, |
| 73 | { |
| 74 | name: 'react-contexify', |
| 75 | message: 'Please use ContextMenu from the ui package instead.', |
| 76 | }, |
| 77 | ], |
| 78 | }, |
| 79 | }, |
| 80 | { |
| 81 | // check for default exports in all files except app and pages folders. |
| 82 | ignores: [ |
| 83 | 'pages/**/*.ts', |
| 84 | 'app/**/*.ts', |
| 85 | 'pages/**/*.tsx', |
| 86 | 'app/**/*.tsx', |
| 87 | 'components/interfaces/**/content/**/content.tsx', |
| 88 | 'vitest.config.ts', |
| 89 | 'postcss.config.js', |
| 90 | 'postcss.config.cjs', |
| 91 | ], |
| 92 | rules: { |
| 93 | 'no-restricted-exports': [ |
| 94 | 'warn', |
| 95 | { |
| 96 | restrictDefaultExports: { |
| 97 | direct: true, |
| 98 | }, |
| 99 | }, |
| 100 | ], |
| 101 | }, |
| 102 | }, |
| 103 | ]) |