mirror of
https://github.com/Egonex-AI/Understand-Anything.git
synced 2026-06-22 10:58:03 +08:00
Merge pull request #161 from okwn/contrib/understand-anything/eslint-tooling
chore: add ESLint tooling with TypeScript support
This commit is contained in:
@@ -20,6 +20,9 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
|
||||
- name: Lint
|
||||
run: pnpm lint
|
||||
|
||||
- name: Build core
|
||||
run: pnpm --filter @understand-anything/core build
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
import eslint from '@eslint/js';
|
||||
import tseslint from 'typescript-eslint';
|
||||
import globals from 'globals';
|
||||
|
||||
export default tseslint.config(
|
||||
{
|
||||
ignores: [
|
||||
'**/node_modules/**',
|
||||
'**/dist/**',
|
||||
'**/build/**',
|
||||
'**/public/**',
|
||||
'**/coverage/**',
|
||||
'**/.understand-anything/**',
|
||||
'**/.claude-plugin/**',
|
||||
'**/.cursor-plugin/**',
|
||||
'**/.copilot-plugin/**',
|
||||
'**/.astro/**',
|
||||
'.private/**',
|
||||
],
|
||||
},
|
||||
eslint.configs.recommended,
|
||||
...tseslint.configs.recommended,
|
||||
{
|
||||
languageOptions: {
|
||||
globals: {
|
||||
...globals.node,
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
'@typescript-eslint/no-unused-vars': [
|
||||
'error',
|
||||
{
|
||||
argsIgnorePattern: '^_',
|
||||
varsIgnorePattern: '^_',
|
||||
caughtErrorsIgnorePattern: '^_',
|
||||
destructuredArrayIgnorePattern: '^_',
|
||||
},
|
||||
],
|
||||
'no-irregular-whitespace': ['error', { skipComments: true }],
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['understand-anything-plugin/packages/dashboard/**/*.{ts,tsx,js,jsx}'],
|
||||
languageOptions: {
|
||||
globals: {
|
||||
...globals.browser,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['**/*.test.ts', '**/*.test.tsx', '**/*.test.mjs', '**/__tests__/**/*.{ts,tsx,mjs}'],
|
||||
rules: {
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
},
|
||||
},
|
||||
);
|
||||
@@ -12,7 +12,11 @@
|
||||
"lint": "eslint ."
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.0.0",
|
||||
"eslint": "^9.0.0",
|
||||
"globals": "^17.6.0",
|
||||
"typescript": "^5.7.0",
|
||||
"typescript-eslint": "^8.0.0",
|
||||
"vitest": "^3.1.0"
|
||||
},
|
||||
"pnpm": {
|
||||
|
||||
Generated
+748
-9
File diff suppressed because it is too large
Load Diff
@@ -199,7 +199,7 @@ function injectTier3Node(node) {
|
||||
}
|
||||
}
|
||||
|
||||
function injectTier3Edge(edge, validNodeIds) {
|
||||
function injectTier3Edge(edge, _validNodeIds) {
|
||||
const r = Math.random();
|
||||
if (r < 0.4) {
|
||||
edge.target = "nonexistent-node-999999";
|
||||
|
||||
@@ -3,7 +3,6 @@ import {
|
||||
parsePluginConfig,
|
||||
serializePluginConfig,
|
||||
type PluginConfig,
|
||||
type PluginEntry,
|
||||
DEFAULT_PLUGIN_CONFIG,
|
||||
} from "../plugins/discovery.js";
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import {
|
||||
validateGraph,
|
||||
normalizeGraph,
|
||||
sanitizeGraph,
|
||||
autoFixGraph,
|
||||
NODE_TYPE_ALIASES,
|
||||
|
||||
@@ -23,7 +23,7 @@ export function classifyUpdate(
|
||||
totalFilesInGraph: number,
|
||||
allKnownFiles: string[] = [],
|
||||
): UpdateDecision {
|
||||
const { newFiles, deletedFiles, structurallyChangedFiles, cosmeticOnlyFiles, unchangedFiles } = analysis;
|
||||
const { newFiles, deletedFiles, structurallyChangedFiles, cosmeticOnlyFiles } = analysis;
|
||||
const structuralCount = structurallyChangedFiles.length + newFiles.length + deletedFiles.length;
|
||||
|
||||
// No structural changes at all — skip
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { StructuralAnalysis, CallGraphEntry } from "../../types.js";
|
||||
import type { LanguageExtractor, TreeSitterNode } from "./types.js";
|
||||
import { findChild, findChildren } from "./base-extractor.js";
|
||||
import { findChild } from "./base-extractor.js";
|
||||
|
||||
/**
|
||||
* Set of method names that Ruby uses for imports.
|
||||
|
||||
@@ -24,7 +24,6 @@ export class GraphQLParser implements AnalyzerPlugin {
|
||||
|
||||
private extractDefinitions(content: string): DefinitionInfo[] {
|
||||
const definitions: DefinitionInfo[] = [];
|
||||
const lines = content.split("\n");
|
||||
|
||||
// Match type, input, enum, interface, union, scalar definitions
|
||||
const typeRegex = /^(type|input|enum|interface|union|scalar)\s+(\w+)/gm;
|
||||
|
||||
@@ -22,7 +22,6 @@ export class SQLParser implements AnalyzerPlugin {
|
||||
|
||||
private extractDefinitions(content: string): DefinitionInfo[] {
|
||||
const definitions: DefinitionInfo[] = [];
|
||||
const lines = content.split("\n");
|
||||
|
||||
// Match CREATE TABLE statements
|
||||
const tableRegex = /CREATE\s+TABLE\s+(?:IF\s+NOT\s+EXISTS\s+)?(?:`|")?(\w+)(?:`|")?/gi;
|
||||
|
||||
@@ -15,7 +15,6 @@ const require = createRequire(import.meta.url);
|
||||
|
||||
type TreeSitterParser = import("web-tree-sitter").Parser;
|
||||
type TreeSitterLanguage = import("web-tree-sitter").Language;
|
||||
type TreeSitterNode = import("web-tree-sitter").Node;
|
||||
|
||||
/**
|
||||
* Config-driven tree-sitter plugin.
|
||||
|
||||
@@ -466,7 +466,7 @@ export function normalizeGraph(data: unknown): unknown {
|
||||
const result = { ...d };
|
||||
|
||||
if (Array.isArray(d.nodes)) {
|
||||
result.nodes = (d.nodes as any[]).map((node) => {
|
||||
result.nodes = (d.nodes as Array<Record<string, unknown>>).map((node) => {
|
||||
if (
|
||||
typeof node === "object" &&
|
||||
node !== null &&
|
||||
@@ -480,7 +480,7 @@ export function normalizeGraph(data: unknown): unknown {
|
||||
}
|
||||
|
||||
if (Array.isArray(d.edges)) {
|
||||
result.edges = (d.edges as any[]).map((edge) => {
|
||||
result.edges = (d.edges as Array<Record<string, unknown>>).map((edge) => {
|
||||
if (
|
||||
typeof edge === "object" &&
|
||||
edge !== null &&
|
||||
|
||||
@@ -82,7 +82,7 @@ async function main() {
|
||||
let content;
|
||||
try {
|
||||
content = readFileSync(absolutePath, 'utf-8');
|
||||
} catch (err) {
|
||||
} catch {
|
||||
filesSkipped.push(file.path);
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user