Socket
Book a DemoInstallSign in
Socket

eslint-plugin-lockfile

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-lockfile

An eslint plugin to lint your npm ecosystem lockfiles.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

eslint-plugin-lockfile Version Badge

github actions coverage License Downloads

npm badge

An ESLint plugin to lint your npm ecosystem lockfiles for security and consistency issues.

This plugin supports lockfiles from npm, yarn, pnpm, bun, and vlt package managers.

Installation

npm install eslint-plugin-lockfile --save-dev

Configuration

Flat Config (ESLint 9+)

// eslint.config.js
import lockfile from 'eslint-plugin-lockfile';

export default [
	lockfile.configs.recommended,
];

Legacy Config (ESLint 8)

{
	"extends": ["plugin:lockfile/recommended-legacy"]
}

Manual Configuration

// eslint.config.js
import lockfile from 'eslint-plugin-lockfile';

export default [
	{
		files: ['**/package-lock.json', '**/yarn.lock', '**/pnpm-lock.yaml', '**/bun.lock', '**/bun.lockb', '**/vlt-lock.json'],
		plugins: { lockfile },
		rules: {
			'lockfile/flavor': ['error', 'npm'],
			'lockfile/version': 'error',
			'lockfile/integrity': 'error',
			'lockfile/registry': 'error',
			'lockfile/non-registry-specifiers': 'error',
			'lockfile/binary-conflicts': 'error',
		},
	},
];

Supported Package Managers

Package ManagerLockfile(s)
npmpackage-lock.json, npm-shrinkwrap.json
yarnyarn.lock
pnpmpnpm-lock.yaml
bunbun.lock, bun.lockb
vltvlt-lock.json

Rules

NameDescription
binary-conflictsDetect binary name conflicts between packages
flavorEnforce allowed lockfile formats
integrityEnforce integrity values in lockfiles
non-registry-specifiersWarn on dependencies from non-registry sources
registryEnforce allowed registries in lockfiles
versionEnforce lockfile version

lockfile/flavor

Enforces which lockfile formats are allowed in your project. This helps ensure your team uses a consistent package manager.

// Allow only npm lockfiles
'lockfile/flavor': ['error', 'npm']

// Allow npm or yarn
'lockfile/flavor': ['error', ['npm', 'yarn']]

// Allow specific lockfile variants
'lockfile/flavor': ['error', [{ name: 'npm', files: ['package-lock.json'] }]]

lockfile/version

Enforces lockfile versions to ensure consistency across environments.

// Default: latest versions for each package manager
'lockfile/version': 'error'

// Specific versions
'lockfile/version': ['error', { npm: 3, yarn: 2, pnpm: '9.0' }]

Valid versions:

  • npm: 1, 2, 3
  • yarn: 1, 2
  • pnpm: '5.3', '5.4', '6.0', '6.1', '7.0', '9.0'
  • bun: 0, 1
  • vlt: 0

lockfile/integrity

Ensures all packages have integrity hashes and verifies they match the actual package tarballs. This protects against supply chain attacks.

// Default: allow all standard algorithms
'lockfile/integrity': 'error'

// Require specific algorithms
'lockfile/integrity': ['error', ['sha512', 'sha384']]

lockfile/registry

Enforces that all packages come from allowed registries. Useful for security policies and private registry enforcement.

// Default: uses npm config registry
'lockfile/registry': 'error'

// Single registry
'lockfile/registry': ['error', 'https://registry.npmjs.org']

// Multiple registries
'lockfile/registry': ['error', ['https://registry.npmjs.org', 'https://npm.pkg.github.com']]

// Per-package registry mapping
'lockfile/registry': ['error', {
	'https://registry.npmjs.org': true,  // Default for all packages
	'https://npm.pkg.github.com': ['@myorg/*'],  // Specific packages
}]

lockfile/non-registry-specifiers

Warns when packages are installed from non-registry sources like GitHub URLs, git URLs, or local file paths. These can bypass integrity checks.

// Warn on all non-registry specifiers
'lockfile/non-registry-specifiers': 'error'

// Ignore specific specifiers with explanation
'lockfile/non-registry-specifiers': ['error', {
	ignore: [
		{
			specifier: 'github:user/repo#commit',
			explanation: 'Required for unreleased bug fix',
		},
	],
}]

lockfile/binary-conflicts

Detects when multiple packages provide command-line binaries with the same name, which can cause non-deterministic behavior.

'lockfile/binary-conflicts': 'error'

CLI

For a standalone CLI that doesn't require ESLint configuration, see lintlock.

Tests

Clone the repo, npm install, and run npm test.

License

MIT

Keywords

eslint

FAQs

Package last updated on 22 Dec 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts