| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- // https://docs.expo.dev/guides/using-eslint/
- const { defineConfig } = require('eslint/config');
- const expoConfig = require('eslint-config-expo/flat');
- module.exports = defineConfig([
- expoConfig,
- {
- files: ['**/*.{ts,tsx,js,jsx}'],
- rules: {
- // type-only 导入与值导入分开,autofix 自动加 `type` 关键字
- '@typescript-eslint/consistent-type-imports': [
- 'error',
- { prefer: 'type-imports', fixStyle: 'separate-type-imports' },
- ],
- // 当一条 import 同时包含 type 和 value,强制拆成两条 `import type` / `import`
- 'import/consistent-type-specifier-style': ['error', 'prefer-top-level'],
- // import 自动排序与分组
- 'import/order': [
- 'error',
- {
- groups: [
- ['builtin', 'external'],
- 'internal',
- ['parent', 'sibling', 'index'],
- 'object',
- 'type',
- ],
- pathGroups: [
- { pattern: '@/**', group: 'internal', position: 'before' },
- ],
- pathGroupsExcludedImportTypes: ['builtin', 'type'],
- 'newlines-between': 'never',
- alphabetize: { order: 'asc', caseInsensitive: true },
- },
- ],
- 'import/no-duplicates': ['error', { 'prefer-inline': false }],
- },
- },
- {
- ignores: ['dist/*'],
- },
- ]);
|