postman-eslint
raw JSON → 1.0.3 verified Fri May 01 auth: no javascript
A CLI tool for linting JavaScript scripts (pre-request and test scripts) in Postman collections using ESLint. Version 1.0.3, stable release. It fetches a Postman collection via API, extracts scripts from collection/folder/request levels, and runs ESLint with your local flat config. Differentiator: specifically targets Postman script linting with built-in globals like `pm`, uses Postman Collection SDK for parsing. Requires Node.js >=14.0.0.
Common errors
error Error: No ESLint config found. Please ensure eslint.config.js exists in the current directory. ↓
cause Missing eslint.config.js file in the project root.
fix
Create an eslint.config.js file (flat config) in the directory where you run postman-eslint.
error Error: API key is required. Provide via --api-key or POSTMAN_API_KEY environment variable. ↓
cause Neither command-line option nor environment variable set.
fix
Set POSTMAN_API_KEY environment variable or pass --api-key argument.
error Error: Failed to fetch collection. Check collection ID and API key. ↓
cause Invalid collection ID or API key, or network issue.
fix
Verify collection ID and API key; ensure internet connectivity.
error Error: Cannot find module 'eslint' ↓
cause ESLint is not installed in the project.
fix
npm install --save-dev eslint
Warnings
gotcha Requires ESLint flat config format (eslint.config.js). If you use .eslintrc, it will not work. ↓
fix Create or convert to eslint.config.js using flat config format. See https://eslint.org/docs/latest/use/configure/configuration-files-new
gotcha Must have an eslint.config.js in the current working directory; does not search parent directories. ↓
fix Ensure eslint.config.js exists where you run the command.
gotcha API key is required; will fail if not provided via --api-key or POSTMAN_API_KEY environment variable. ↓
fix Provide API key via command line option or environment variable.
deprecated Package version 1.0.3 uses older postman-collection SDK; consider updating if available. ↓
fix Check for newer versions of postman-eslint and postman-collection.
Install
npm install postman-eslint yarn add postman-eslint pnpm add postman-eslint Imports
- postman-eslint (CLI) wrong
node postman-eslint.jscorrectnpx postman-eslint --collection <id> --api-key <key> - ESLint config sample wrong
require('postman-eslint/eslint.config.js')correctcp node_modules/postman-eslint/eslint.config.js ./ - Environment variable for API key wrong
postman-eslint --api-key $POSTMAN_API_KEYcorrectexport POSTMAN_API_KEY=your_key
Quickstart
npm install -g postman-eslint
export POSTMAN_API_KEY='your-api-key'
postman-eslint --collection 'your-collection-id'