79815885

Date: 2025-11-10 16:49:40
Score: 0.5
Natty:
Report link

How to import a local config file (like lint-staged.config.js) in all Nx apps

If you want to use the same config file (for example lint-staged.config.js) in different apps inside your Nx workspace, you can create a TypeScript path alias.

  1. Open your tsconfig.base.json (or tsconfig.base.ts if using TypeScript config).

  2. Inside compilerOptions, add a new alias under "paths":

{
  "compilerOptions": {
    "paths": {
      "@project-name/lint-config": ["lint-staged.config.js"]
      // other existing paths...
    }
  }
}
  1. Now you can import this file from anywhere in your Nx workspace:
import rootConfig from '@project-name/lint-config';

Nx and TypeScript will automatically resolve the alias to your config file. If it doesn’t work right away, restart your TypeScript server or rebuild the project.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Starts with a question (0.5): How to
  • Low reputation (1):
Posted by: Smirnov Evgeny