next.js 2.6 KB

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