Skip to content

Let's use AI to Earn!

2.7 KB
Raw Blame
import antfu from '@antfu/eslint-config'
import * as nx from '@nx/eslint-plugin'
import importPlugin from 'eslint-plugin-import'

export default antfu(
  {
    formatters: true,
    ignores: [
      '**/dist',
      '**/*.md',
      '**/migrations',
      '**/*.generated.d.ts',
      '**/*.types.d.ts',
      '**/*.schema.json',
    ],
    plugins: {
      imports: importPlugin,
    },
    rules: {
      'no-restricted-syntax': [
        'error',
        {
          selector: 'CallExpression[callee.type=\'MemberExpression\'][callee.object.name=\'Logger\']',
          message: '禁止直接使用 Logger 的静态方法,请创建实例后使用(例如 this.logger.log())。',
        },
      ],
      'e18e/prefer-array-fill': ['off'],
      'e18e/prefer-array-at': ['off'],
      'e18e/prefer-static-regex': ['off'],
      'no-void': ['off'],
      'dot-notation': ['off'],
      'new-cap': ['off'],
      'ts/no-unused-vars': ['warn', { ignoreRestSiblings: true, argsIgnorePattern: '^_' }],
      'ts/consistent-type-imports': ['off'],
      'ts/no-inferrable-types': ['error', { ignoreProperties: true }],
      'ts/no-explicit-any': ['warn'],
      'jsdoc/require-returns-description': ['off'],
      'node/prefer-global/buffer': ['off'],
      'node/prefer-global/process': ['off'],
      'imports/no-absolute-path': ['error'],
    },
  },
  ...nx.configs['flat/base'],
  {
    files: [
      '**/*.ts',
      '**/*.tsx',
      '**/*.js',
      '**/*.jsx',
    ],
    rules: {
      '@nx/enforce-module-boundaries': [
        'error',
        {
          enforceBuildableLibDependency: true,
          allow: [
            '^.*/eslint(\\.base)?\\.config\\.[cm]?[jt]s$',
          ],
          depConstraints: [
            {
              sourceTag: '*',
              onlyDependOnLibsWithTags: [
                '*',
              ],
            },
          ],
        },
      ],
    },
  },
  {
    files: [
      '**/*.ts',
      '**/*.tsx',
      '**/*.cts',
      '**/*.mts',
    ],
    rules: {
      'no-console': ['error', { allow: [''] }],
    },
  },
  {
    files: [
      'e2e/**/*.ts',
    ],
    rules: {
      'no-console': 'off',
    },
  },
  {
    files: [
      '**/*.service.ts',
    ],
    rules: {
      'no-restricted-imports': ['error', {
        paths: [{
          name: '@nestjs/mongoose',
          importNames: ['InjectModel', 'InjectConnection'],
          message: '禁止在 Service 中直接注入 Model 或 Connection,请通过 Repository 访问数据。',
        }],
      }],
    },
  },
  {
    files: [
      '**/*.ts',
      '**/*.tsx',
      '**/*.cts',
      '**/*.mts',
      '**/*.js',
      '**/*.jsx',
      '**/*.cjs',
      '**/*.mjs',
    ],
    rules: {
    },
  },
)