Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 104 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import eslint from '@eslint/js';
import vitest from '@vitest/eslint-plugin';
import eslintComments from 'eslint-plugin-eslint-comments';
import importPlugin from 'eslint-plugin-import';
import noBarrelFiles from 'eslint-plugin-no-barrel-files';
import unusedImports from 'eslint-plugin-unused-imports';
import tseslint from 'typescript-eslint';

Expand All @@ -11,6 +14,8 @@ export default tseslint.config(
plugins: {
'unused-imports': unusedImports,
import: importPlugin,
'no-barrel-files': noBarrelFiles,
'eslint-comments': eslintComments,
},
languageOptions: {
parserOptions: {
Expand All @@ -36,7 +41,43 @@ export default tseslint.config(
],
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/no-empty-object-type': 'error',
'@typescript-eslint/no-require-imports': 'error',
'no-barrel-files/no-barrel-files': 'error',
'import/no-default-export': 'error',
'import/named': 'error',
'import/no-extraneous-dependencies': ['error', { devDependencies: true }],
'eslint-comments/no-unused-disable': 'error',
'no-void': ['error', { allowAsStatement: true }],
'default-case': 'error',
'no-constant-condition': ['error', { checkLoops: false }],
'no-param-reassign': ['error', { props: false }],
'no-promise-executor-return': 'error',
'prefer-promise-reject-errors': 'error',
'prefer-arrow-callback': ['error', { allowNamedFunctions: true }],
'no-restricted-syntax': [
'error',
{
selector: 'ForInStatement',
message:
'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
},
{
selector: 'LabeledStatement',
message:
'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
},
{
selector: 'WithStatement',
message:
'`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
},
{
selector: 'ExportAllDeclaration',
message:
"Export all doesn't work well if imported in ESM due to how they are transpiled, and they can also lead to unexpected exposure of internal methods.",
},
],
'unused-imports/no-unused-imports': 'error',
'import/order': [
'error',
Expand All @@ -61,15 +102,24 @@ export default tseslint.config(
},
],
'import/no-cycle': 'error',
'import/extensions': ['error', 'ignorePackages', { js: 'always', ts: 'never' }],
'no-console': 'error',
},
},
{
files: ['tests/**/*.ts'],
plugins: {
vitest,
},
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/consistent-type-assertions': 'off',
'no-console': 'off',
'vitest/expect-expect': [
'error',
{ assertFunctionNames: ['expect', 'expect*', 'assert*'] },
],
'vitest/valid-expect': ['error', { maxArgs: 2 }],
},
},
{
Expand All @@ -79,6 +129,59 @@ export default tseslint.config(
'no-console': 'off',
},
},
{
// Dedicated barrels and protocol-parity shims: their sole purpose is
// re-exporting the package/protocol surface, so the no-barrel-files rule
// does not apply. The protocol barrels mirror the upstream
// factory-mono-alpha source-of-truth layout and rely on `export *`, so the
// ExportAllDeclaration ban is lifted for them too. `daemon/automations-enums.ts`
// is a thin parity shim that re-exposes the hoisted canonical enums under
// the daemon import path the protocol contract (and tests) require.
files: [
'src/index.ts',
'src/schemas/index.ts',
'src/daemon/index.ts',
'src/protocol/index.ts',
'src/protocol/daemon/index.ts',
'src/protocol/daemon/automations-enums.ts',
// Modules with intentional convenience re-exports of a small, curated
// slice of another module's surface (not full barrels).
'src/constants.ts',
'src/session.ts',
'src/hooks.ts',
],
rules: {
'no-barrel-files/no-barrel-files': 'off',
'no-restricted-syntax': [
'error',
{
selector: 'ForInStatement',
message:
'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.',
},
{
selector: 'LabeledStatement',
message:
'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.',
},
{
selector: 'WithStatement',
message:
'`with` is disallowed in strict mode because it makes code impossible to predict and optimize.',
},
],
},
},
{
// Zod's deeply-recursive request/notification schemas exceed TypeScript's
// inference depth (TS7056), so these modules assert the schema's public
// `z.ZodType<...>` shape over the inferred internal type. The assertion is
// a localized type-system workaround, not an unsafe runtime cast.
files: ['src/schemas/client.ts', 'src/schemas/server.ts'],
rules: {
'@typescript-eslint/consistent-type-assertions': 'off',
},
},
{
ignores: ['dist/', 'node_modules/', '*.config.*'],
}
Expand Down
3 changes: 3 additions & 0 deletions examples/hook-execution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ async function main(): Promise<void> {
case DroidMessageType.Result:
console.log('\n\n--- Turn complete ---');
break;

default:
break;
}
}
} finally {
Expand Down
3 changes: 3 additions & 0 deletions examples/session-stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ async function main(): Promise<void> {
);
}
break;

default:
break;
}
}
} finally {
Expand Down
Loading
Loading