Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 40 additions & 55 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,82 +1,67 @@
import js from '@eslint/js';
import typescript from '@typescript-eslint/eslint-plugin';
import typescriptParser from '@typescript-eslint/parser';
import tseslint from 'typescript-eslint';
import prettierConfig from 'eslint-config-prettier';
import prettierPlugin from 'eslint-plugin-prettier';

export default [
// 基础 JavaScript 推荐配置
export default tseslint.config(
// 基础推荐配置
js.configs.recommended,
...tseslint.configs.recommended,

// TypeScript 文件配置
// Prettier 集成
prettierConfig,

// 源代码配置
{
files: ['**/*.{ts,tsx}'],
files: ['src/**/*.{ts,tsx}'],
languageOptions: {
parser: typescriptParser,
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./tsconfig.json', './tsconfig.test.json'],
tsconfigRootDir: process.cwd(),
project: './tsconfig.json',
tsconfigRootDir: import.meta.dirname,
},
},
plugins: {
'@typescript-eslint': typescript,
prettier: prettierPlugin,
},
rules: {
// TypeScript 推荐规则
...typescript.configs['recommended'].rules,
...typescript.configs['recommended-requiring-type-checking'].rules,

// 自定义规则
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/prefer-const': 'error',
'@typescript-eslint/no-non-null-assertion': 'warn',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/await-thenable': 'error',
'@typescript-eslint/no-misused-promises': 'error',

// 代码质量规则
'no-console': 'warn',
'prefer-const': 'error',
'no-var': 'error',
'object-shorthand': 'error',
'prefer-template': 'error',

// Prettier 规则
'prettier/prettier': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_'
}
],
'no-console': 'off', // CLI 工具需要 console
},
},

// 测试文件特殊配置
// 测试文件配置
{
files: ['**/*.test.{ts,tsx}', '**/*.spec.{ts,tsx}'],
files: ['tests/**/*.{ts,tsx}', '**/*.test.{ts,tsx}', '**/*.spec.{ts,tsx}'],
languageOptions: {
parserOptions: {
project: './tsconfig.test.json',
tsconfigRootDir: import.meta.dirname,
},
},
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_'
}
],
'no-console': 'off',
},
},

// 忽略文件
// 忽略配置
{
ignores: [
'node_modules/',
'dist/',
'coverage/',
'node_modules/',
'*.js',
'*.mjs',
'*.cjs',
'bin/',
'scripts/',
'lib/',
'*.mjs',
'*.cjs'
],
},

// Prettier 配置(必须放在最后)
prettierConfig,
];
}
);
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"format": "prettier --write \"src/**/*.{ts,tsx,json,md}\" \"tests/**/*.{ts,tsx,json}\"",
"format:check": "prettier --check \"src/**/*.{ts,tsx,json,md}\" \"tests/**/*.{ts,tsx,json}\"",
"clean": "rimraf dist coverage",

"prepublishOnly": "pnpm run clean && pnpm run build && pnpm run test",
"prepare": "husky"
},
Expand All @@ -43,7 +42,14 @@
"pnpm": ">=9.0.0"
},
"packageManager": "pnpm@9.15.0",
"keywords": ["claude", "claude code", "cli", "wrapper", "anthropic", "typescript"],
"keywords": [
"claude",
"claude code",
"cli",
"wrapper",
"anthropic",
"typescript"
],
"author": "Milly Lee",
"license": "MIT",
"devDependencies": {
Expand All @@ -54,12 +60,12 @@
"@vitest/ui": "^3.2.4",
"eslint": "^9.18.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"husky": "^9.1.7",
"lint-staged": "^15.3.0",
"prettier": "^3.4.2",
"rimraf": "^6.0.1",
"typescript": "^5.7.2",
"typescript-eslint": "^8.38.0",
"vite": "^7.0.5",
"vitest": "^3.2.4"
}
Expand Down
74 changes: 21 additions & 53 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading