Skip to content

Commit 39a2e92

Browse files
committed
fix(lint): add ESLint config and clear all errors
Ship .eslintrc.js (was missing — lint crashed like grok-faf-mcp), drop unused imports/params, replace require('os') with imports, createRequire for optional WASM kernel, and fix template/empty-catch hotspots. Errors only — warnings not in scope.
1 parent 1d5cd40 commit 39a2e92

19 files changed

Lines changed: 68 additions & 21 deletions

.eslintrc.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
module.exports = {
2+
root: true,
3+
parser: '@typescript-eslint/parser',
4+
parserOptions: {
5+
ecmaVersion: 2022,
6+
sourceType: 'module',
7+
project: './tsconfig.json',
8+
},
9+
plugins: ['@typescript-eslint'],
10+
extends: [
11+
'eslint:recommended',
12+
'plugin:@typescript-eslint/recommended',
13+
'plugin:@typescript-eslint/recommended-requiring-type-checking',
14+
],
15+
env: {
16+
node: true,
17+
es2022: true,
18+
},
19+
rules: {
20+
// Championship rules - strict but sensible
21+
// TODO: Upgrade these from 'warn' to 'error' after proper type safety refactor
22+
'@typescript-eslint/no-explicit-any': 'warn',
23+
'@typescript-eslint/no-unsafe-assignment': 'warn',
24+
'@typescript-eslint/no-unsafe-member-access': 'warn',
25+
'@typescript-eslint/no-unsafe-call': 'warn',
26+
'@typescript-eslint/no-unsafe-return': 'warn',
27+
'@typescript-eslint/no-unsafe-argument': 'warn',
28+
'@typescript-eslint/require-await': 'warn',
29+
'@typescript-eslint/explicit-function-return-type': 'off',
30+
'@typescript-eslint/no-unused-vars': ['error', {
31+
argsIgnorePattern: '^_',
32+
varsIgnorePattern: '^_'
33+
}],
34+
'@typescript-eslint/no-floating-promises': 'error',
35+
'@typescript-eslint/no-misused-promises': 'error',
36+
'no-console': 'off', // We use console for MCP logging
37+
},
38+
ignorePatterns: [
39+
'dist/**',
40+
'node_modules/**',
41+
'**/*.test.ts',
42+
'jest.config.js',
43+
],
44+
};

src/faf-core/commands/audit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export interface AuditResult {
2626
message: string;
2727
}
2828

29-
export async function auditFafFile(projectPath?: string, options: AuditOptions = {}): Promise<AuditResult> {
29+
export async function auditFafFile(projectPath?: string, _options: AuditOptions = {}): Promise<AuditResult> {
3030
try {
3131
const fafPath = projectPath ? `${projectPath}/project.faf` : await findFafFile();
3232

src/faf-core/commands/auto.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
import { findFafFile } from '../utils/file-utils.js';
8+
import * as os from 'os';
89
import { initFafFile, type InitResult } from './init.js';
910
import { scoreFafFile, type ScoreResult } from './score.js';
1011

@@ -35,7 +36,7 @@ export async function autoCommand(
3536

3637
try {
3738
const targetDir = directory || process.cwd();
38-
const homeDir = require('os').homedir();
39+
const homeDir = os.homedir();
3940

4041
// CRITICAL: Prevent running in home or root directory
4142
if (!directory && (targetDir === homeDir || targetDir === '/')) {

src/faf-core/commands/formats.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Lists all discovered formats in the project
44
*/
55

6-
import * as fs from 'fs';
76
import * as path from 'path';
87
import { fileExists } from '../utils/file-utils';
98

@@ -26,7 +25,7 @@ export interface FormatsResult {
2625
message: string;
2726
}
2827

29-
export async function formatsCommand(projectPath?: string, options: FormatsOptions = {}): Promise<FormatsResult> {
28+
export async function formatsCommand(projectPath?: string, _options: FormatsOptions = {}): Promise<FormatsResult> {
3029
try {
3130
const projectRoot = projectPath || process.cwd();
3231
const startTime = Date.now();

src/faf-core/commands/init.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
import { promises as fs } from 'fs';
7+
import * as os from 'os';
78
import * as path from 'path';
89
import { detectProjectType, fileExists } from '../utils/file-utils.js';
910
import { generateFafFromProject } from '../generators/faf-generator-championship.js';
@@ -41,7 +42,7 @@ export async function initFafFile(
4142

4243
try {
4344
const projectRoot = projectPath || process.cwd();
44-
const homeDir = require('os').homedir();
45+
const homeDir = os.homedir();
4546

4647
// CRITICAL: Prevent running in home or root directory
4748
if (!projectPath && (projectRoot === homeDir || projectRoot === '/')) {

src/faf-core/commands/sync.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import { promises as fs } from 'fs';
77
import * as path from 'path';
88
import { parse as parseYAML, stringify as stringifyYAML } from '../fix-once/yaml';
9-
import { findFafFile, findPackageJson, fileExists } from '../utils/file-utils';
9+
import { findFafFile, fileExists } from '../utils/file-utils';
1010

1111
export interface SyncOptions {
1212
auto?: boolean;

src/faf-core/commands/update.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export interface UpdateResult {
1616
message: string;
1717
}
1818

19-
export async function updateFafFile(projectPath?: string, options: UpdateOptions = {}): Promise<UpdateResult> {
19+
export async function updateFafFile(projectPath?: string, _options: UpdateOptions = {}): Promise<UpdateResult> {
2020
try {
2121
const fafPath = projectPath ? `${projectPath}/project.faf` : await findFafFile();
2222

src/faf-core/commands/validate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export interface ValidateResult {
2626
message: string;
2727
}
2828

29-
export async function validateFafFile(projectPath?: string, options: ValidateOptions = {}): Promise<ValidateResult> {
29+
export async function validateFafFile(projectPath?: string, _options: ValidateOptions = {}): Promise<ValidateResult> {
3030
try {
3131
const fafPath = projectPath ? `${projectPath}/project.faf` : await findFafFile();
3232

src/faf-core/compiler/faf-compiler.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@
88

99
import { parse as parseYAML } from '../fix-once/yaml';
1010
import * as crypto from 'crypto';
11+
import { createRequire } from 'node:module';
1112
import { ChromeExtensionDetector } from '../utils/chrome-extension-detector';
1213
import { FabFormatsProcessor } from '../engines/fab-formats-processor';
1314
import * as path from 'path';
1415

16+
const nodeRequire = createRequire(__filename);
17+
1518
// ============================================================================
1619
// TYPE_DEFINITIONS - Single Source of Truth for Project Types
1720
// Ported from faf-cli v3.2.5 for scoring parity
@@ -958,8 +961,8 @@ export class FafCompiler {
958961
let mk4Total: number | null = null;
959962

960963
try {
961-
const kernel = require('faf-scoring-kernel');
962-
const { stringify } = require('yaml');
964+
const kernel = nodeRequire('faf-scoring-kernel') as { score_faf: (yaml: string) => string };
965+
const { stringify } = nodeRequire('yaml') as { stringify: (data: unknown) => string };
963966

964967
const projectType = this.detectProjectTypeFromContext(ast);
965968
const applicableSlots = getSlotsForType(projectType);

src/faf-core/engines/dependency-tsa.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import * as fs from 'fs';
1212
import * as path from 'path';
1313
import { findSourceFiles } from '../utils/native-file-finder';
14-
import { execSync } from 'child_process';
1514

1615
export interface DependencyInspection {
1716
package: string;

0 commit comments

Comments
 (0)