Package information and metadata utilities for integrating with build tools and development workflows.
The meta export provides access to package information:
interface Meta {
name: string;
version: string;
}
const meta: Meta;The package name as defined in package.json.
const name: "eslint-plugin-regexp";The current package version as defined in package.json.
const version: string; // e.g., "2.10.0"import { meta } from "eslint-plugin-regexp";
console.log(`Using ${meta.name} version ${meta.version}`);
// Output: "Using eslint-plugin-regexp version 2.10.0"// webpack.config.js
const { meta } = require("eslint-plugin-regexp");
module.exports = {
plugins: [
new webpack.DefinePlugin({
ESLINT_PLUGIN_REGEXP_VERSION: JSON.stringify(meta.version)
})
]
};import { meta } from "eslint-plugin-regexp";
import semver from "semver";
// Check if plugin version meets minimum requirements
if (semver.gte(meta.version, "2.0.0")) {
console.log("Plugin supports modern features");
} else {
console.warn("Please upgrade to a newer version");
}// Custom ESLint plugin registry
const pluginRegistry = {
[meta.name]: {
version: meta.version,
rules: Object.keys(rules).length,
configs: Object.keys(configs)
}
};// scripts/check-plugin-version.js
import { meta } from "eslint-plugin-regexp";
const expectedVersion = process.env.EXPECTED_VERSION;
if (meta.version !== expectedVersion) {
console.error(`Version mismatch: expected ${expectedVersion}, got ${meta.version}`);
process.exit(1);
}The meta object is exported as a constant with inferred types:
// Import types
import type { Meta } from "eslint-plugin-regexp";
// The meta export matches this interface
interface Meta {
readonly name: "eslint-plugin-regexp";
readonly version: string;
}The metadata is sourced directly from the package.json file at runtime, ensuring it always reflects the installed version. The implementation uses require() instead of import to prevent TypeScript from copying package.json to the dist folder during compilation.
// Internal implementation (for reference only)
const { name, version } = require("../package.json");
export { name, version };