Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate lint-staged configuration to TypeScript #3696

Open
mfranzke opened this issue Jan 20, 2025 · 0 comments
Open

Migrate lint-staged configuration to TypeScript #3696

mfranzke opened this issue Jan 20, 2025 · 0 comments
Labels
🍄🆙improvement New feature or request

Comments

@mfranzke
Copy link
Member

Lint-staged now provides TypeScript types for the configuration and main Node.js API. You can use the JSDoc syntax in your JS configuration files:

/**
 * @filename: lint-staged.config.js
 * @type {import('lint-staged').Configuration}
 */
export default {
  '*': 'prettier --write',
}

It's also possible to use the .ts file extension for the configuration if your Node.js version supports it. The --experimental-strip-types flag was introduced in Node.js v22.6.0 and unflagged in v23.6.0, enabling Node.js to execute TypeScript files without additional configuration.

export NODE_OPTIONS="--experimental-strip-types"
npx lint-staged --config lint-staged.config.ts
@mfranzke mfranzke added the 🍄🆙improvement New feature or request label Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍄🆙improvement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant