Skip to content

Fix lint-staged pre-commit hook validation error #9

@AliiiBenn

Description

@AliiiBenn

Description

The lint-staged pre-commit hook is failing with a validation error.

Error

✖ Validation Error:

  Invalid value for 'linters': {
  '*.{js,json,ts}': [ 'prettier --write', 'git add' ],
  '*.md': [ 'markdown-toc -i', 'prettier --write', 'git add' ]
}

  Function task should contain 'title' and 'task' fields, where 'title' should be a string and 'task' should be a function.

Steps to Reproduce

  1. Try to commit with git commit
  2. The pre-commit hook runs pnpm lint-staged
  3. Fails with validation error

Expected Behavior

lint-staged should run successfully on staged files.

Possible Causes

  • Conflict with a lint-staged config somewhere in node_modules
  • Version incompatibility
  • Incorrect lint-staged.config.js format

Environment

  • Node.js v22.22.0
  • pnpm 9.15.0
  • lint-staged 16.2.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions