86 lines
2.9 KiB
JavaScript
86 lines
2.9 KiB
JavaScript
// Shared flat ESLint config — the mechanical enforcement of the project's
|
|
// non-negotiable code-quality standards. Each package's eslint.config.mjs
|
|
// imports `base` from here and appends its own architecture-boundary rules.
|
|
//
|
|
// Enforced here (build fails on violation):
|
|
// - no `any` (@typescript-eslint/no-explicit-any + no-unsafe-*)
|
|
// - no type assertions (consistent-type-assertions: never → bans `x as T`)
|
|
// - no non-null `!` (no-non-null-assertion)
|
|
// - no dead optional `?.`(no-unnecessary-condition)
|
|
// - functional iteration (prefer-const, no-param-reassign, no-var)
|
|
// - no suppressions (ban-ts-comment)
|
|
// - safe promises (no-floating-promises, await-thenable)
|
|
|
|
import js from '@eslint/js';
|
|
import tseslint from 'typescript-eslint';
|
|
import prettier from 'eslint-config-prettier';
|
|
import globals from 'globals';
|
|
|
|
export const base = tseslint.config(
|
|
{
|
|
ignores: ['**/dist/**', '**/build/**', '**/.expo/**', '**/coverage/**', '**/*.d.ts'],
|
|
},
|
|
js.configs.recommended,
|
|
...tseslint.configs.strictTypeChecked,
|
|
...tseslint.configs.stylisticTypeChecked,
|
|
{
|
|
languageOptions: {
|
|
parserOptions: {
|
|
projectService: true,
|
|
tsconfigRootDir: import.meta.dirname,
|
|
},
|
|
globals: {
|
|
...globals.node,
|
|
},
|
|
},
|
|
rules: {
|
|
// --- no any ---
|
|
'@typescript-eslint/no-explicit-any': 'error',
|
|
'@typescript-eslint/no-unsafe-assignment': 'error',
|
|
'@typescript-eslint/no-unsafe-call': 'error',
|
|
'@typescript-eslint/no-unsafe-member-access': 'error',
|
|
'@typescript-eslint/no-unsafe-return': 'error',
|
|
'@typescript-eslint/no-unsafe-argument': 'error',
|
|
|
|
// --- no type assertions (bans `x as T`; `as const` still allowed) ---
|
|
'@typescript-eslint/consistent-type-assertions': [
|
|
'error',
|
|
{ assertionStyle: 'never' },
|
|
],
|
|
|
|
// --- no non-null assertions ---
|
|
'@typescript-eslint/no-non-null-assertion': 'error',
|
|
|
|
// --- no error-silencing optional chaining / dead conditions ---
|
|
'@typescript-eslint/no-unnecessary-condition': 'error',
|
|
|
|
// --- functional / immutable iteration; no spaghetti ---
|
|
'prefer-const': 'error',
|
|
'no-param-reassign': 'error',
|
|
'no-var': 'error',
|
|
'object-shorthand': 'error',
|
|
|
|
// --- no suppressions ---
|
|
'@typescript-eslint/ban-ts-comment': 'error',
|
|
|
|
// --- safe async ---
|
|
'@typescript-eslint/no-floating-promises': 'error',
|
|
'@typescript-eslint/await-thenable': 'error',
|
|
|
|
// --- hygiene ---
|
|
'@typescript-eslint/no-unused-vars': [
|
|
'error',
|
|
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
|
|
],
|
|
'@typescript-eslint/consistent-type-imports': 'error',
|
|
},
|
|
},
|
|
{
|
|
// Config files themselves run outside the typed project graph.
|
|
files: ['**/*.config.{js,mjs,cjs,ts}', '**/*.setup.{js,mjs,cjs,ts}'],
|
|
...tseslint.configs.disableTypeChecked,
|
|
},
|
|
prettier,
|
|
);
|
|
|
|
export default base;
|