oxlint-comments
v1.0.0
Published
Oxlint plugin that requires // line comments instead of /* */ or JSDoc.
Maintainers
Readme
oxlint-comments
Oxlint plugin that requires // line comments.
// hello worldBlock comments and JSDoc are reported, and standalone comments can be rewritten automatically:
/* hello world */
/** Adds two numbers. */// hello world
// Adds two numbers.The rule is written with Oxlint's createOnce plugin API.
Install
pnpm add -D oxlint-commentsUsage
.oxlintrc.json:
{
"jsPlugins": ["oxlint-comments"],
"rules": {
"oxlint-comments/no-block-comments": "error"
}
}Or oxlint.config.ts:
import { defineConfig } from 'oxlint'
export default defineConfig({
jsPlugins: ['oxlint-comments'],
rules: {
'oxlint-comments/no-block-comments': 'error',
},
})Rule: no-block-comments
Reports every /* */ block comment and every JSDoc /** */ comment.
Allowed by default:
//line comments- shebangs (
#!/usr/bin/env node) - JSX empty-expression comments (
{/* ... */}), because//is not valid there - linter and coverage directives such as
/* oxlint-disable */and/* eslint-disable */ - compiler and bundler annotations such as
/* #__PURE__ */and/* webpackChunkName: "mod" */
Standalone block comments are autofixed to // lines. Inline comments such as fn(/* hint */ value) are reported without a fix, because rewriting them would break the surrounding code.
Options
{
"oxlint-comments/no-block-comments": [
"error",
{
"allowDirectives": true,
"allowAnnotations": true,
"ignorePattern": "^\\s*TODO\\b"
}
]
}| Option | Default | Meaning |
| ------------------ | ------- | ------------------------------------------------------------------------------- |
| allowDirectives | true | Allow Oxlint, ESLint, Prettier, Istanbul, c8, and similar directive comments. |
| allowAnnotations | true | Allow bundler and minifier annotations that have to stay block comments. |
| ignorePattern | unset | Skip block comments whose body matches this regular expression. |
Set allowDirectives or allowAnnotations to false if you want those comments converted to // as well.
Development
pnpm test
pnpm lint
pnpm fmtpnpm build bundles the plugin with tsdown. pnpm lint runs Oxlint and oxfmt --check.
License
MIT
