Skip to content

Commit c4a15df

Browse files
authored
fix(eslint): upgrade deps and add JSDoc comments (#313)
## Summary This PR includes dependency upgrades for `typescript-eslint` and `lint-staged` after a security audit, along with comprehensive JSDoc documentation for all config files. ## Changes - Upgraded `@typescript-eslint/eslint-plugin` and `@typescript-eslint/parser` to address audit findings - Updated `lint-staged` to the latest version - Added detailed JSDoc comments to all CLI functions and stages - Documented all config file functions (astro, command, comments, disables, ignores, imports, javascript, jsdoc, jsonc, jsx, markdown, nextjs, node, perfectionist, prettier, react, regexp, sort, svelte, test, toml, typescript, unicorn, vue, yaml) - Improved type documentation in factory and types files - Added empty changeset for tracking ## Motivation 1. **Security**: Address security findings from audit by upgrading typescript-eslint packages 2. **Maintainability**: Improve code documentation for better developer experience 3. **Consistency**: Ensure all public APIs have proper JSDoc documentation following best practices ## Summary by CodeRabbit * **New Features** * Added JSDoc plugin support for ESLint configuration. * **Bug Fixes** * Fixed issues after package upgrade. * Repositioned React rules to core plugin for consistency. * **Chores** * Updated configuration packages (@mheob/commitlint-config, @mheob/eslint-config) to patch versions. * Updated TypeScript ESLint and lint-staged dependencies. * **Documentation** * Enhanced comprehensive documentation for ESLint configuration functions.
1 parent 5f2578d commit c4a15df

35 files changed

+424
-108
lines changed

.changeset/breezy-aliens-clap.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@mheob/commitlint-config': patch
3+
'@mheob/eslint-config': patch
4+
---
5+
6+
fix issues after upgrade

.changeset/funny-sloths-live.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

packages/eslint-config/src/cli/run.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,24 @@ export interface CliRunOptions {
2525
}
2626

2727
/**
28+
* Executes the CLI migration/setup wizard for eslint configuration.
2829
*
29-
* @param options
30+
* This function guides the user through the setup or migration of ESLint config files,
31+
* supporting various frameworks. It checks whether an `eslint.config.js` or `eslint.config.mjs`
32+
* already exists in the current working directory and aborts if so. Optionally, it can skip prompts
33+
* if `options.yes` or the `SKIP_PROMPT` environment variable is set.
34+
*
35+
* The flow offers the following stages:
36+
* 1. Warn the user and abort if ESLint config already exists.
37+
* 2. Prompt (or programmatically resolve, if `yes` is set) for:
38+
* - Whether to continue if there are uncommitted git changes.
39+
* - Which frameworks to include in the setup.
40+
* - Whether to update VSCode settings for recommended integration.
41+
* 3. Applies updates by calling helper update stages for `package.json`, ESLint files, and VSCode settings.
42+
* 4. Displays a success message describing next steps.
43+
*
44+
* @param options - CLI run options to control wizard behavior.
45+
* @returns Promise that resolves once setup is complete.
3046
*/
3147
export async function run(options: CliRunOptions = {}): Promise<void> {
3248
const argumentSkipPrompt = Boolean(process.env.SKIP_PROMPT) || options.yes;

packages/eslint-config/src/cli/stages/update-eslint-files.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,14 @@ import type { PromptResult } from '../types';
1212
import { getEslintConfigContent } from '../utils';
1313

1414
/**
15+
* Updates the ESLint configuration files based on the user's choices.
1516
*
16-
* @param result
17+
* This function reads the existing .eslintignore file (if it exists),
18+
* processes it to extract ignored patterns, and generates a new ESLint
19+
* configuration file based on the selected frameworks.
20+
*
21+
* @param result - The user's choices from the CLI prompt.
22+
* @returns Promise that resolves once the configuration files are updated.
1723
*/
1824
export async function updateEslintFiles(result: PromptResult): Promise<void> {
1925
const cwd = process.cwd();

packages/eslint-config/src/cli/stages/update-package-json.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,13 @@ import type { PromptResult } from '../types';
1111
import { versionsMap } from '../versions-map.generated';
1212

1313
/**
14+
* Updates the package.json file to include the required dependencies for the selected frameworks.
1415
*
15-
* @param result
16+
* This function reads the existing package.json file, updates the @mheob/eslint-config
17+
* dependency version, and adds any additional dependencies required by the selected frameworks.
18+
*
19+
* @param result - The user's choices from the CLI prompt.
20+
* @returns Promise that resolves once the package.json file is updated.
1621
*/
1722
export async function updatePackageJson(result: PromptResult): Promise<void> {
1823
const cwd = process.cwd();

packages/eslint-config/src/cli/stages/update-vscode-settings.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@ import { vscodeSettingsString } from '../constants';
1010
import type { PromptResult } from '../types';
1111

1212
/**
13+
* Updates the VSCode settings file to include the recommended ESLint configuration.
1314
*
14-
* @param result
15+
* This function creates or updates the .vscode/settings.json file with the recommended
16+
* ESLint configuration based on the user's choices.
17+
*
18+
* @param result - The user's choices from the CLI prompt.
19+
* @returns Promise that resolves once the settings file is updated.
1520
*/
1621
export async function updateVscodeSettings(result: PromptResult): Promise<void> {
1722
const cwd = process.cwd();

packages/eslint-config/src/configs/astro.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,14 @@ import type { OptionsFiles, OptionsOverrides, TypedFlatConfigItem } from '../typ
33
import { ensurePackages, interopDefault } from '../utils';
44

55
/**
6+
* Configures the ESLint rules for Astro projects.
67
*
7-
* @param options
8+
* This function sets up the necessary ESLint plugins and parsers for Astro projects,
9+
* including the `eslint-plugin-astro` and `astro-eslint-parser`. It also configures
10+
* the language options for the Astro files, including the globals, parser, and parser options.
11+
*
12+
* @param options - The options for configuring the Astro ESLint rules.
13+
* @returns Promise that resolves once the Astro ESLint rules are configured.
814
*/
915
export async function astro(
1016
options: OptionsFiles & OptionsOverrides = {},

packages/eslint-config/src/configs/command.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ import createCommand from 'eslint-plugin-command/config';
33
import type { TypedFlatConfigItem } from '../types';
44

55
/**
6+
* Configures the ESLint rules for command line interface (CLI) projects.
67
*
8+
* This function sets up the necessary ESLint plugin for command line interface projects,
9+
* including the `eslint-plugin-command`. It also configures the language options for the
10+
* command line interface files, including the parser, parser options, and source type.
11+
*
12+
* @returns Promise that resolves once the command line interface ESLint rules are configured.
713
*/
814
export async function command(): Promise<TypedFlatConfigItem[]> {
915
return [

packages/eslint-config/src/configs/comments.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@ import { pluginComments } from '../plugins';
22
import type { TypedFlatConfigItem } from '../types';
33

44
/**
5+
* Configures the ESLint rules for comments.
56
*
7+
* This function sets up the necessary ESLint plugin for comments,
8+
* including the `eslint-plugin-eslint-comments`. It also configures
9+
* the rules for comments, including the no-aggregating-enable,
10+
* no-duplicate-disable, no-unlimited-disable, and no-unused-enable rules.
11+
*
12+
* @returns Promise that resolves once the comments ESLint rules are configured.
613
*/
714
export async function comments(): Promise<TypedFlatConfigItem[]> {
815
return [

packages/eslint-config/src/configs/disables.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@ import { GLOB_SRC, GLOB_SRC_EXT, GLOB_TSX } from '../globs';
22
import type { TypedFlatConfigItem } from '../types';
33

44
/**
5+
* Configures the ESLint rules for disables.
56
*
7+
* This function sets up the necessary ESLint rules for disables,
8+
* including the rules for disables, including the no-import-dist,
9+
* no-import-node-modules-by-path, no-top-level-await, no-console,
10+
* unicorn/no-process-exit, no-require-imports, antfu/no-top-level-await,
11+
* no-console, ts/explicit-function-return-type, sort-imports,
12+
* eslint-comments/no-unlimited-disable, no-restricted-syntax,
13+
* unused-imports/no-unused-vars.
14+
*
15+
* @returns Promise that resolves once the disables ESLint rules are configured.
616
*/
717
export async function disables(): Promise<TypedFlatConfigItem[]> {
818
return [

0 commit comments

Comments
 (0)