stock-bot/eslint.config.js

146 lines
3.6 KiB
JavaScript

import js from '@eslint/js';
import tseslint from '@typescript-eslint/eslint-plugin';
import tsparser from '@typescript-eslint/parser';
export default [
// Global ignores first
{
ignores: [
'dist/**',
'build/**',
'node_modules/**',
'**/dist/**',
'**/build/**',
'**/node_modules/**',
'**/.turbo/**',
'**/coverage/**',
'**/*.js',
'**/*.mjs',
'**/*.d.ts',
'.turbo/**',
'coverage/**',
'scripts/**',
'monitoring/**',
'database/**',
'**/.angular/**',
'**/src/polyfills.ts',
],
},
// Base JavaScript configuration
js.configs.recommended,
{
files: ['**/*.cjs'],
languageOptions: {
globals: { __dirname: 'readonly', require: 'readonly', module: 'readonly' },
},
},
// TypeScript configuration
{
files: ['**/*.{ts,tsx}'],
languageOptions: {
parser: tsparser,
parserOptions: {
ecmaVersion: 2022,
sourceType: 'module',
},
},
plugins: {
'@typescript-eslint': tseslint,
},
rules: {
// Disable base rules that are covered by TypeScript equivalents
'no-unused-vars': 'off',
'no-undef': 'off',
// TypeScript specific rules
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
destructuredArrayIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-non-null-assertion': 'warn',
// General rules
'no-console': 'warn',
'no-debugger': 'error',
'no-var': 'error',
'prefer-const': 'error',
eqeqeq: ['error', 'always'],
curly: ['error', 'all'],
},
},
// Pure calculation modules may not obtain hidden input or perform global I/O.
{
files: ['libs/calculations/src/**/*.ts'],
rules: {
'no-restricted-globals': [
'error',
'fetch',
'Bun',
'process',
'console',
'WebSocket',
'Worker',
'setTimeout',
'setInterval',
],
'no-restricted-properties': [
'error',
{ object: 'Math', property: 'random', message: 'Pass deterministic input explicitly.' },
{ object: 'Date', property: 'now', message: 'Pass observation time explicitly.' },
],
'no-restricted-syntax': [
'error',
{
selector: "NewExpression[callee.name='Date'][arguments.length=0]",
message: 'Pass observation time explicitly; wall-clock input is not pure math.',
},
],
},
},
// Handler files configuration
{
files: ['**/*.handler.ts'],
rules: {
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_|Handler$', // Ignore classes ending with Handler
destructuredArrayIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
},
},
// Test files configuration
{
files: ['**/*.test.ts', '**/*.spec.ts', '**/test/**/*', '**/tests/**/*'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'no-console': 'off',
},
},
// Console output is the interface of CLIs, examples, and the browser log sink.
{
files: [
'**/examples/**',
'**/scripts/**',
'tools/coverage-cli/**',
'**/web-app/src/utils/browserLog.ts',
],
rules: { 'no-console': 'off' },
},
];