godcrm/backend/__tests__/eslint-config.test.js
GOD CRM Release f89e074dd1
Some checks failed
CI / Lint / Typecheck / Test / Build (push) Has been cancelled
CI / PostgreSQL Integration Tests (push) Has been cancelled
GOD CRM — public scrubbed snapshot
Governed substrate for autonomous agents: scoped identity (passports),
audited actions, MCP workspace. Infra IPs and secrets redacted for public release.
2026-08-10 04:01:45 +03:00

54 lines
1.9 KiB
JavaScript

/**
* ESLint Backend Configuration Test
* ADR-037: Validates that no-console rule is configured
*/
import { describe, it, expect } from 'vitest';
import fs from 'fs';
import path from 'path';
describe('ESLint Backend Configuration', () => {
const configPath = path.resolve(__dirname, '../.eslintrc.cjs');
describe('Given backend ESLint config', () => {
it('When checking config file, then it should exist', () => {
expect(fs.existsSync(configPath)).toBe(true);
});
it('When loading config, then it should have no-console rule', () => {
// Clear require cache to get fresh config
delete require.cache[require.resolve(configPath)];
const config = require(configPath);
expect(config.rules).toBeDefined();
expect(config.rules['no-console']).toBeDefined();
});
it('When checking no-console rule, then it should be configured as warn', () => {
delete require.cache[require.resolve(configPath)];
const config = require(configPath);
const noConsoleRule = config.rules['no-console'];
// Rule can be ['warn', {...}] or 'warn'
const severity = Array.isArray(noConsoleRule) ? noConsoleRule[0] : noConsoleRule;
expect(severity).toBe('warn');
});
it('When checking no-console rule, then it should allow console.warn and console.error', () => {
delete require.cache[require.resolve(configPath)];
const config = require(configPath);
const noConsoleRule = config.rules['no-console'];
expect(Array.isArray(noConsoleRule)).toBe(true);
expect(noConsoleRule[1].allow).toContain('warn');
expect(noConsoleRule[1].allow).toContain('error');
});
it('When checking env, then it should be configured for Node.js', () => {
delete require.cache[require.resolve(configPath)];
const config = require(configPath);
expect(config.env.node).toBe(true);
});
});
});