Improve JSDoc types and add eslint-plugin-jsdoc

Standardized JSDoc type annotations across the codebase, replacing 'Object' with 'object' and refining function signatures for better type safety. Added and configured eslint-plugin-jsdoc for enhanced documentation linting, and updated ESLint settings to include adapters and new JSDoc rules. Updated dependencies to include eslint-plugin-jsdoc and related packages.
This commit is contained in:
xixu-me committed 2025-12-11 13:27:26 +08:00
1 parent bfec1d2d9e
commit 07f5f35972
18 files changed
+295 -102

No files matched your search

+39 -1
View File
@@ -1,10 +1,12 @@
import js from '@eslint/js';
import prettierConfig from 'eslint-config-prettier';
import jsdoc from 'eslint-plugin-jsdoc';
export default [
js.configs.recommended,
jsdoc.configs['flat/recommended'],
{
files: ['src/**/*.js', 'test/**/*.js'],
files: ['src/**/*.js', 'test/**/*.js', 'adapters/**/*.js'],
languageOptions: {
ecmaVersion: 2022,
sourceType: 'module',
@@ -33,6 +35,7 @@ export default [
TextDecoder: 'readonly',
performance: 'readonly',
globalThis: 'readonly',
process: 'readonly',
// Vitest globals
describe: 'readonly',
@@ -45,7 +48,42 @@ export default [
vi: 'readonly'
}
},
settings: {
jsdoc: {
mode: 'typescript',
tagNamePreference: {
returns: 'returns'
}
}
},
rules: {
// JSDoc rules overrides
'jsdoc/require-description': 'warn',
'jsdoc/require-returns': 'off', // Often redundant if return type is void or obvious
'jsdoc/require-param-description': 'off', // Names are often self-explanatory
'jsdoc/no-undefined-types': [
'warn',
{
definedTypes: [
'ExecutionContext',
'Cache',
'RequestInit',
'Request',
'Response',
'Headers',
'URL',
'URLSearchParams',
'AbortController',
'AbortSignal',
'ReadableStream',
'WritableStream',
'TransformStream',
'TextEncoder',
'TextDecoder'
]
}
],
// Code quality rules
'no-unused-vars': [
'error',