mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-19 06:45:50 +00:00
style: 完成所有文件的lint
This commit is contained in:
@@ -1,75 +1,75 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { describe, expect, test } from 'bun:test'
|
||||
import {
|
||||
partiallySanitizeUnicode,
|
||||
recursivelySanitizeUnicode,
|
||||
} from "../sanitization";
|
||||
} from '../sanitization'
|
||||
|
||||
// ─── partiallySanitizeUnicode ───────────────────────────────────────────
|
||||
|
||||
describe("partiallySanitizeUnicode", () => {
|
||||
test("preserves normal ASCII text", () => {
|
||||
expect(partiallySanitizeUnicode("hello world")).toBe("hello world");
|
||||
});
|
||||
describe('partiallySanitizeUnicode', () => {
|
||||
test('preserves normal ASCII text', () => {
|
||||
expect(partiallySanitizeUnicode('hello world')).toBe('hello world')
|
||||
})
|
||||
|
||||
test("preserves CJK characters", () => {
|
||||
expect(partiallySanitizeUnicode("你好世界")).toBe("你好世界");
|
||||
});
|
||||
test('preserves CJK characters', () => {
|
||||
expect(partiallySanitizeUnicode('你好世界')).toBe('你好世界')
|
||||
})
|
||||
|
||||
test("removes zero-width spaces", () => {
|
||||
expect(partiallySanitizeUnicode("hello\u200Bworld")).toBe("helloworld");
|
||||
});
|
||||
test('removes zero-width spaces', () => {
|
||||
expect(partiallySanitizeUnicode('hello\u200Bworld')).toBe('helloworld')
|
||||
})
|
||||
|
||||
test("removes BOM", () => {
|
||||
expect(partiallySanitizeUnicode("\uFEFFhello")).toBe("hello");
|
||||
});
|
||||
test('removes BOM', () => {
|
||||
expect(partiallySanitizeUnicode('\uFEFFhello')).toBe('hello')
|
||||
})
|
||||
|
||||
test("removes directional formatting", () => {
|
||||
expect(partiallySanitizeUnicode("hello\u202Aworld")).toBe("helloworld");
|
||||
});
|
||||
test('removes directional formatting', () => {
|
||||
expect(partiallySanitizeUnicode('hello\u202Aworld')).toBe('helloworld')
|
||||
})
|
||||
|
||||
test("removes private use area characters", () => {
|
||||
expect(partiallySanitizeUnicode("hello\uE000world")).toBe("helloworld");
|
||||
});
|
||||
test('removes private use area characters', () => {
|
||||
expect(partiallySanitizeUnicode('hello\uE000world')).toBe('helloworld')
|
||||
})
|
||||
|
||||
test("handles empty string", () => {
|
||||
expect(partiallySanitizeUnicode("")).toBe("");
|
||||
});
|
||||
test('handles empty string', () => {
|
||||
expect(partiallySanitizeUnicode('')).toBe('')
|
||||
})
|
||||
|
||||
test("handles string with only dangerous characters", () => {
|
||||
const result = partiallySanitizeUnicode("\u200B\u200C\u200D\uFEFF");
|
||||
expect(result.length).toBeLessThanOrEqual(1); // ZWJ may survive NFKC
|
||||
});
|
||||
});
|
||||
test('handles string with only dangerous characters', () => {
|
||||
const result = partiallySanitizeUnicode('\u200B\u200C\u200D\uFEFF')
|
||||
expect(result.length).toBeLessThanOrEqual(1) // ZWJ may survive NFKC
|
||||
})
|
||||
})
|
||||
|
||||
// ─── recursivelySanitizeUnicode ─────────────────────────────────────────
|
||||
|
||||
describe("recursivelySanitizeUnicode", () => {
|
||||
test("sanitizes string values", () => {
|
||||
expect(recursivelySanitizeUnicode("hello\u200Bworld")).toBe("helloworld");
|
||||
});
|
||||
describe('recursivelySanitizeUnicode', () => {
|
||||
test('sanitizes string values', () => {
|
||||
expect(recursivelySanitizeUnicode('hello\u200Bworld')).toBe('helloworld')
|
||||
})
|
||||
|
||||
test("sanitizes array elements", () => {
|
||||
const result = recursivelySanitizeUnicode(["a\u200Bb", "c\uFEFFd"]);
|
||||
expect(result).toEqual(["ab", "cd"]);
|
||||
});
|
||||
test('sanitizes array elements', () => {
|
||||
const result = recursivelySanitizeUnicode(['a\u200Bb', 'c\uFEFFd'])
|
||||
expect(result).toEqual(['ab', 'cd'])
|
||||
})
|
||||
|
||||
test("sanitizes object values recursively", () => {
|
||||
test('sanitizes object values recursively', () => {
|
||||
const result = recursivelySanitizeUnicode({
|
||||
key: "val\u200Bue",
|
||||
nested: { inner: "te\uFEFFst" },
|
||||
});
|
||||
expect(result).toEqual({ key: "value", nested: { inner: "test" } });
|
||||
});
|
||||
key: 'val\u200Bue',
|
||||
nested: { inner: 'te\uFEFFst' },
|
||||
})
|
||||
expect(result).toEqual({ key: 'value', nested: { inner: 'test' } })
|
||||
})
|
||||
|
||||
test("preserves numbers", () => {
|
||||
expect(recursivelySanitizeUnicode(42)).toBe(42);
|
||||
});
|
||||
test('preserves numbers', () => {
|
||||
expect(recursivelySanitizeUnicode(42)).toBe(42)
|
||||
})
|
||||
|
||||
test("preserves booleans", () => {
|
||||
expect(recursivelySanitizeUnicode(true)).toBe(true);
|
||||
});
|
||||
test('preserves booleans', () => {
|
||||
expect(recursivelySanitizeUnicode(true)).toBe(true)
|
||||
})
|
||||
|
||||
test("preserves null", () => {
|
||||
expect(recursivelySanitizeUnicode(null)).toBeNull();
|
||||
});
|
||||
});
|
||||
test('preserves null', () => {
|
||||
expect(recursivelySanitizeUnicode(null)).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user