remark-lint-directive-shortcut-attribute
raw JSON → 1.0.1 verified Fri May 01 auth: no javascript
A remark-lint rule that warns when verbose attribute names (e.g., class="value", id="value") are used in directives instead of shortcut syntax (e.g., .value, #value). Version 1.0.1 is the current stable release, part of the unified ecosystem. ESM-only, requires Node 16+. It is a complementary rule to other directive linting rules and is not included in any preset. Active development with frequent releases across the remark-lint monorepo.
Common errors
error Cannot find module 'remark-lint-directive-shortcut-attribute' ↓
cause Package not installed or ESM-only in a CommonJS project
fix
npm install remark-lint-directive-shortcut-attribute && ensure package.json has "type": "module" or use .mjs extension.
error Could not load plugin "remark-lint-directive-shortcut-attribute" from ... ↓
cause CLI misconfiguration or missing import when using unified programmatically
fix
Add the plugin to your remark configuration array: plugins: ['remark-lint', 'remark-lint-directive-shortcut-attribute']
Warnings
breaking ESM-only: package cannot be required via require() in Node.js ↓
fix Use import syntax or dynamic import(); upgrade to Node 16+.
gotcha Rule requires remark-lint and unified to be installed as peer dependencies; missing them causes runtime errors ↓
fix npm install remark-lint unified
gotcha The rule only works if remark-directive or another directive parser is used; otherwise it may not detect directives ↓
fix Ensure you have a directive plugin (like remark-directive) added to your unified pipeline before the lint rules.
Install
npm install remark-lint-directive-shortcut-attribute yarn add remark-lint-directive-shortcut-attribute pnpm add remark-lint-directive-shortcut-attribute Imports
- remarkLintDirectiveShortcutAttribute wrong
const remarkLintDirectiveShortcutAttribute = require('remark-lint-directive-shortcut-attribute')correctimport remarkLintDirectiveShortcutAttribute from 'remark-lint-directive-shortcut-attribute' - default export wrong
import { remarkLintDirectiveShortcutAttribute } from 'remark-lint-directive-shortcut-attribute'correctimport remarkLintDirectiveShortcutAttribute from 'remark-lint-directive-shortcut-attribute' - TypeScript types
import remarkLintDirectiveShortcutAttribute from 'remark-lint-directive-shortcut-attribute'
Quickstart
import { unified } from 'unified'
import remarkParse from 'remark-parse'
import remarkStringify from 'remark-stringify'
import remarkLint from 'remark-lint'
import remarkLintDirectiveShortcutAttribute from 'remark-lint-directive-shortcut-attribute'
import { reporter } from 'vfile-reporter'
const file = await unified()
.use(remarkParse)
.use(remarkLint)
.use(remarkLintDirectiveShortcutAttribute)
.use(remarkStringify)
.process(':planet[Jupiter]{class="fifth largest" id="jupiter"}')
console.error(reporter(file))
// Output:
// 1:18-1:23 warning Unexpected verbose attribute name `class`, expected shortcut attribute with `.` directive-shortcut-attribute remark-lint
// 1:40-1:42 warning Unexpected verbose attribute name `id`, expected shortcut attribute with `#` directive-shortcut-attribute remark-lint