style: 完成所有文件的lint

This commit is contained in:
claude-code-best
2026-05-01 21:39:30 +08:00
parent d136872cc9
commit 6182015005
1333 changed files with 68255 additions and 77882 deletions

View File

@@ -1,145 +1,141 @@
import { describe, expect, test } from "bun:test";
import { describe, expect, test } from 'bun:test'
import {
parseArguments,
parseArgumentNames,
generateProgressiveArgumentHint,
substituteArguments,
} from "../argumentSubstitution";
} from '../argumentSubstitution'
// ─── parseArguments ─────────────────────────────────────────────────────
describe("parseArguments", () => {
test("splits simple arguments", () => {
expect(parseArguments("foo bar baz")).toEqual(["foo", "bar", "baz"]);
});
describe('parseArguments', () => {
test('splits simple arguments', () => {
expect(parseArguments('foo bar baz')).toEqual(['foo', 'bar', 'baz'])
})
test("handles quoted strings", () => {
test('handles quoted strings', () => {
expect(parseArguments('foo "hello world" baz')).toEqual([
"foo",
"hello world",
"baz",
]);
});
'foo',
'hello world',
'baz',
])
})
test("handles single-quoted strings", () => {
test('handles single-quoted strings', () => {
expect(parseArguments("foo 'hello world' baz")).toEqual([
"foo",
"hello world",
"baz",
]);
});
'foo',
'hello world',
'baz',
])
})
test("handles escaped quotes inside quoted strings", () => {
test('handles escaped quotes inside quoted strings', () => {
expect(parseArguments('foo "hello \\"world\\"" baz')).toEqual([
"foo",
'foo',
'hello "world"',
"baz",
]);
});
'baz',
])
})
test("returns empty for empty string", () => {
expect(parseArguments("")).toEqual([]);
});
test('returns empty for empty string', () => {
expect(parseArguments('')).toEqual([])
})
test("returns empty for whitespace only", () => {
expect(parseArguments(" ")).toEqual([]);
});
});
test('returns empty for whitespace only', () => {
expect(parseArguments(' ')).toEqual([])
})
})
// ─── parseArgumentNames ─────────────────────────────────────────────────
describe("parseArgumentNames", () => {
test("parses space-separated string", () => {
expect(parseArgumentNames("foo bar baz")).toEqual(["foo", "bar", "baz"]);
});
describe('parseArgumentNames', () => {
test('parses space-separated string', () => {
expect(parseArgumentNames('foo bar baz')).toEqual(['foo', 'bar', 'baz'])
})
test("accepts array input", () => {
expect(parseArgumentNames(["foo", "bar"])).toEqual(["foo", "bar"]);
});
test('accepts array input', () => {
expect(parseArgumentNames(['foo', 'bar'])).toEqual(['foo', 'bar'])
})
test("filters out numeric-only names", () => {
expect(parseArgumentNames("foo 123 bar")).toEqual(["foo", "bar"]);
});
test('filters out numeric-only names', () => {
expect(parseArgumentNames('foo 123 bar')).toEqual(['foo', 'bar'])
})
test("filters out empty strings", () => {
expect(parseArgumentNames(["foo", "", "bar"])).toEqual(["foo", "bar"]);
});
test('filters out empty strings', () => {
expect(parseArgumentNames(['foo', '', 'bar'])).toEqual(['foo', 'bar'])
})
test("returns empty for undefined", () => {
expect(parseArgumentNames(undefined)).toEqual([]);
});
});
test('returns empty for undefined', () => {
expect(parseArgumentNames(undefined)).toEqual([])
})
})
// ─── generateProgressiveArgumentHint ────────────────────────────────────
describe("generateProgressiveArgumentHint", () => {
test("shows remaining arguments", () => {
expect(generateProgressiveArgumentHint(["a", "b", "c"], ["x"])).toBe(
"[b] [c]"
);
});
describe('generateProgressiveArgumentHint', () => {
test('shows remaining arguments', () => {
expect(generateProgressiveArgumentHint(['a', 'b', 'c'], ['x'])).toBe(
'[b] [c]',
)
})
test("returns undefined when all filled", () => {
expect(
generateProgressiveArgumentHint(["a"], ["x"])
).toBeUndefined();
});
test('returns undefined when all filled', () => {
expect(generateProgressiveArgumentHint(['a'], ['x'])).toBeUndefined()
})
test("shows all when none typed", () => {
expect(generateProgressiveArgumentHint(["a", "b"], [])).toBe("[a] [b]");
});
});
test('shows all when none typed', () => {
expect(generateProgressiveArgumentHint(['a', 'b'], [])).toBe('[a] [b]')
})
})
// ─── substituteArguments ────────────────────────────────────────────────
describe("substituteArguments", () => {
test("replaces $ARGUMENTS with full args", () => {
expect(substituteArguments("run $ARGUMENTS", "foo bar")).toBe(
"run foo bar"
);
});
describe('substituteArguments', () => {
test('replaces $ARGUMENTS with full args', () => {
expect(substituteArguments('run $ARGUMENTS', 'foo bar')).toBe('run foo bar')
})
test("replaces indexed $ARGUMENTS[0]", () => {
expect(substituteArguments("run $ARGUMENTS[0]", "foo bar")).toBe("run foo");
});
test('replaces indexed $ARGUMENTS[0]', () => {
expect(substituteArguments('run $ARGUMENTS[0]', 'foo bar')).toBe('run foo')
})
test("replaces shorthand $0, $1", () => {
expect(substituteArguments("$0 and $1", "hello world")).toBe(
"hello and world"
);
});
test('replaces shorthand $0, $1', () => {
expect(substituteArguments('$0 and $1', 'hello world')).toBe(
'hello and world',
)
})
test("replaces out-of-range index with empty string", () => {
expect(substituteArguments("$5", "hello world")).toBe("");
});
test('replaces out-of-range index with empty string', () => {
expect(substituteArguments('$5', 'hello world')).toBe('')
})
test("reuses same placeholder multiple times", () => {
expect(substituteArguments("cmd $0 $1 $0", "alpha beta")).toBe(
"cmd alpha beta alpha"
);
});
test('reuses same placeholder multiple times', () => {
expect(substituteArguments('cmd $0 $1 $0', 'alpha beta')).toBe(
'cmd alpha beta alpha',
)
})
test("replaces named arguments", () => {
expect(
substituteArguments("file: $name", "test.txt", true, ["name"])
).toBe("file: test.txt");
});
test('replaces named arguments', () => {
expect(substituteArguments('file: $name', 'test.txt', true, ['name'])).toBe(
'file: test.txt',
)
})
test("returns content unchanged for undefined args", () => {
expect(substituteArguments("hello", undefined)).toBe("hello");
});
test('returns content unchanged for undefined args', () => {
expect(substituteArguments('hello', undefined)).toBe('hello')
})
test("appends ARGUMENTS when no placeholder found", () => {
expect(substituteArguments("run this", "extra")).toBe(
"run this\n\nARGUMENTS: extra"
);
});
test('appends ARGUMENTS when no placeholder found', () => {
expect(substituteArguments('run this', 'extra')).toBe(
'run this\n\nARGUMENTS: extra',
)
})
test("does not append when appendIfNoPlaceholder is false", () => {
expect(substituteArguments("run this", "extra", false)).toBe("run this");
});
test('does not append when appendIfNoPlaceholder is false', () => {
expect(substituteArguments('run this', 'extra', false)).toBe('run this')
})
test("does not append for empty args string", () => {
expect(substituteArguments("run this", "")).toBe("run this");
});
});
test('does not append for empty args string', () => {
expect(substituteArguments('run this', '')).toBe('run this')
})
})