Registry / testing / eslint-plugin-annotation

eslint-plugin-annotation

JSON →
library1.1.6jsnpmunverified

ESLint plugin providing lint rules to validate and auto-correct code based on JSDoc-like annotations in comments. Current stable version 1.1.6, released 2023. Supports Node 12, 14, 16+. Differentiators: allows enforcing sort order, uniqueness, and date format via annotation comments, with autofix support for sort and unique rules. Lightweight, no external runtime dependencies beyond ESLint peer dependency.

npm install eslint-plugin-annotation
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-ANNO
E
eslint-plugin-annotation
testingjavascriptv1.1.6
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

plugin
✓ import annotation from 'eslint-plugin-annotation'
✗ const annotation = require('eslint-plugin-annotation')
ESLint plugins are typically loaded via plugins array in config; explicit import only needed for programmatic use.
rules
✓ import { rules } from 'eslint-plugin-annotation'
ESM-only; named export for rules object.
configs
✓ import { configs } from 'eslint-plugin-annotation'
✗ const configs = require('eslint-plugin-annotation').configs
ESM-only; configs export for presets.

Shows ESLint config to enable all four rules and optional programmatic usage import.

// .eslintrc.js module.exports = { plugins: ['annotation'], rules: { 'annotation/format-date': 'error', 'annotation/sort-keys': 'error', 'annotation/sort': 'error', 'annotation/unique': 'error', }, }; // For programmatic usage (ESM): // import annotation from 'eslint-plugin-annotation'; // const linter = new ESLint({ plugins: { annotation } });
Debug
Known issues
gotchaRules only work if annotation comments are present in the code (e.g., @sort, @unique). Without them, rules silently pass.
fix
Add the appropriate annotation comment above the target code block.
affects: >=1.0.0
gotchaAutofix for sort and sort-keys rules may change array or object order unexpectedly; review before committing.
fix
Use --fix-dry-run to preview changes.
affects: >=1.0.0
gotchaPlugin only supports Node ^12.22.0 || ^14.17.0 || >=16.0.0; older Node versions not supported.
fix
Upgrade Node to supported version.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Failed to load plugin 'annotation' declared in '.eslintrc.js': Cannot find module 'eslint-plugin-annotation'
Plugin not installed or not in node_modules.
fix
Run 'npm install eslint-plugin-annotation --save-dev'
Oops! Something went wrong! :(. ESLint: 7.x encountered an unexpected error.
ESLint version incompatible (may need ESLint >=8).
fix
Update ESLint to version 8 or later: 'npm install eslint@latest --save-dev'
Parsing error: The keyword '@sort' is not supported
Syntax error in annotation or using wrong format.
fix
Ensure annotation comment is on its own line above the target, e.g., '// @sort' or '/* @sort */'
Upgrade
Version history
1.1.6latest on npm
Audit
Dependencies
eslintrequiredPeer dependency required for plugin to function
Agent activity
4 hits · last 30 days
node
4
Resources
eslint-plugin-annotation — npm install eslint-plugin-annotation · libregistry