ng-lint-staged

raw JSON →
12.0.4 verified Fri May 01 auth: no javascript

ng-lint-staged is a shim that transforms the file list from lint-staged into the appropriate CLI option for Angular's lint builder. Version 12.0.4 supports the @angular-eslint/builder:lint with --lint-file-patterns flag. It handles the argument transformation needed because lint-staged provides a flat list of files while Angular expects a specific format. Regularly updated to support newer Angular versions. Key differentiator: eliminates the need for manual file mapping scripts when using lint-staged with Angular projects.

error Error: Cannot find module 'ng-lint-staged'
cause ng-lint-staged is not installed globally or locally.
fix
Run 'npm install --save-dev ng-lint-staged' in your project.
error Unknown option: --files
cause Using older ng-lint-staged version with eslint builder.
fix
Upgrade ng-lint-staged to >=12.0.0, or use --lint-file-patterns instead of --files.
error ng-lint-staged: lint-staged file list must be appended after '--'
cause Missing '--' separator in the command.
fix
Ensure the command ends with '--' like: 'ng-lint-staged lint --fix --'
breaking Version 12.0.0+ changed the CLI flag from --files to --lint-file-patterns (for eslint builder).
fix Update your lint-staged command: use 'ng-lint-staged lint --fix --' (no explicit flag needed).
breaking Version 7.0.0+ dropped support for tslint builder (now only eslint).
fix If using tslint, stick with ng-lint-staged <7.0.0.
gotcha Missing trailing '--' in the command will cause the files argument to be interpreted as part of the command.
fix Always append '--' at the end of the ng-lint-staged command.
gotcha The command assumes an npm script named 'lint' exists. If your script is named differently, the command will fail.
fix Ensure package.json has a 'lint' script that runs 'ng lint <project>'. Or specify a different script name after 'ng-lint-staged'.
deprecated Version 12.0.4 may be deprecated; check latest version.
fix Run 'npm outdated ng-lint-staged' to check for newer versions.
npm install ng-lint-staged
yarn add ng-lint-staged
pnpm add ng-lint-staged

Configure lint-staged to use ng-lint-staged for linting staged .ts files with Angular CLI.

// In package.json, add lint-staged configuration:
// "lint-staged": {
//   "src/**/*.ts": ["ng-lint-staged lint --fix --"]
// }
// Then run: npx lint-staged