eslint-rules/src/presets/typescript.ts
2025-01-25 19:44:09 -05:00

66 lines
2.3 KiB
TypeScript

import type { ImportXRulesObject } from '@aet/eslint-define-config/src/rules/import-x';
import type { TypeScriptRulesObject } from '@aet/eslint-define-config/src/rules/typescript-eslint';
import { error, off, warn } from '../constants';
export const importRules: Partial<ImportXRulesObject> = {
'import-x/first': error,
'import-x/no-absolute-path': error,
'import-x/no-duplicates': warn,
'import-x/no-useless-path-segments': error,
'import-x/order': [
warn,
{
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index', 'object'],
'newlines-between': 'always',
alphabetize: { order: 'asc', caseInsensitive: true },
},
],
'import-x/unambiguous': error,
};
export const typescriptRules: Partial<TypeScriptRulesObject> = {
'@typescript-eslint/ban-ts-comment': [
error,
{
'ts-expect-error': 'allow-with-description',
'ts-check': false,
'ts-ignore': 'allow-with-description',
'ts-nocheck': 'allow-with-description',
},
],
'@typescript-eslint/consistent-type-imports': [
error,
{ disallowTypeAnnotations: false, fixStyle: 'inline-type-imports' },
],
'@typescript-eslint/explicit-member-accessibility': [
warn,
{ accessibility: 'no-public' },
],
'@typescript-eslint/no-empty-object-type': off,
'@typescript-eslint/no-empty-interface': [error, { allowSingleExtends: true }],
'@typescript-eslint/no-explicit-any': off,
'@typescript-eslint/no-floating-promises': [
'warn',
{
allowForKnownSafeCalls: [
{ from: 'package', name: ['it', 'describe', 'test'], package: 'node:test' },
],
},
],
'@typescript-eslint/no-misused-promises': [error, { checksVoidReturn: false }],
'@typescript-eslint/no-namespace': off,
'@typescript-eslint/no-unnecessary-type-assertion': error,
'@typescript-eslint/no-unsafe-argument': off,
'@typescript-eslint/no-unsafe-assignment': off,
'@typescript-eslint/no-unsafe-call': off,
'@typescript-eslint/no-unsafe-member-access': off,
'@typescript-eslint/no-unsafe-return': off,
'@typescript-eslint/no-unused-vars': off,
'@typescript-eslint/no-use-before-define': off,
'@typescript-eslint/no-var-requires': off,
'@typescript-eslint/restrict-template-expressions': off,
'@typescript-eslint/triple-slash-reference': off,
'@typescript-eslint/unbound-method': off,
};