Registry / testing / eslint-plugin-no-comments

eslint-plugin-no-comments

JSON →
library1.2.1jsnpmunverified

An ESLint plugin that disallows comment blocks in source code to prevent shipping notes, old code, or sensitive information to production. Current stable version is 1.2.1, released with support for ESLint 9 and 10 via flat config format. Requires Node.js >= 20.19.0. Key differentiator: automatically ignores comments starting with 'global' or 'eslint' to preserve ESLint directives, and allows a customizable allow list. Unlike general comment-stripping tools, it integrates directly with ESLint's rule system.

npm install eslint-plugin-no-comments
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-NO-C
E
eslint-plugin-no-comments
testingjavascriptv1.2.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

default
import noComments from 'eslint-plugin-no-comments'
const noComments = require('eslint-plugin-no-comments')
ESM-only since v1.2.0; require() will fail with ERR_REQUIRE_ESM. The default export is the plugin object.
noComments (as plugin)
import noComments from 'eslint-plugin-no-comments'
import { noComments } from 'eslint-plugin-no-comments'
The package has no named export; use default import. The correct plugin name in config is 'no-comments'.
rules (if accessing directly)
import noComments from 'eslint-plugin-no-comments'; const rules = noComments.rules;
import { rules } from 'eslint-plugin-no-comments'
Rules are only accessible via the default export's .rules property. Named export does not exist.
plugin for flat config
import noComments from 'eslint-plugin-no-comments'; export default [{ plugins: { 'no-comments': noComments }, rules: { 'no-comments/disallowComments': 'error' } }]
module.exports = { plugins: { 'no-comments': noComments }, rules: { ... } }
Flat config is the only supported format since v1.2.0; .eslintrc format is not supported. Use eslint.config.js.

Configures the plugin to error on all comments except those starting with 'global', 'eslint', 'TODO', or 'FIXME'. Uses the flat config format required since v1.2.0.

// Install: npm install eslint-plugin-no-comments --save-dev // eslint.config.js import noComments from 'eslint-plugin-no-comments'; export default [ { plugins: { 'no-comments': noComments }, rules: { 'no-comments/disallowComments': [ 'error', { allow: ['global', 'eslint', 'TODO', 'FIXME'] } ] } } ];
Debug
Known issues
breakingv1.2.0 drops support for .eslintrc (Legacy ESLint config format) and requires flat config (eslint.config.js).
fix
Migrate to eslint.config.js using the flat config pattern shown in the quickstart. See https://eslint.org/docs/latest/use/configure/configuration-files-new
affects: >=1.2.0
breakingv1.2.0 requires Node.js >= 20.19.0. Older Node versions cause crashes.
fix
Update Node.js to v20.19.0 or higher. Run: nvm install 20.19.0 (or use your version manager).
affects: >=1.2.0
deprecatedv1.1.x and earlier used .eslintrc configuration and CommonJS require(). They are deprecated and may break in future ESLint versions.
fix
Upgrade to v1.2.0+ and migrate to flat config. The old versions are no longer maintained.
affects: <1.2.0
gotchaIf you specify an `allow` array, it **replaces** the default allowed comments ('global' and 'eslint') entirely. Not including 'eslint' will cause directive comments like '// eslint-disable-next-line' to be flagged as errors.
fix
Always include 'eslint' and 'global' in the `allow` array if you want those comments to be allowed. See the README example with 'global', 'eslint', 'TODO', 'FIXME'.
affects: *
gotchaSingle-line comments (//) and block comments (/* */) are both disallowed unless they start with a string in the allow list. Comments without a leading word after the comment marker may also trigger errors.
fix
Ensure all allowed comments start with one of the strings in the `allow` array (or the defaults). For example, '// TODO' works but '//TODO' without space may not be recognized if the pattern is strict.
affects: *
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/node_modules/eslint-plugin-no-comments/index.js from /path/to/.eslintrc.js not supported.
Using CommonJS require() to load the plugin, but v1.2.0+ is an ESM-only package.
fix
Switch to import syntax and flat config: import noComments from 'eslint-plugin-no-comments'; in eslint.config.js.
ESLint couldn't find the plugin "eslint-plugin-no-comments". This is most likely an issue with the plugin resolution.
Incorrect plugin configuration in flat config (e.g., missing 'plugins' object or wrong key name).
fix
In eslint.config.js, export an array with an object containing plugins: { 'no-comments': noComments }.
Configuration for rule "no-comments/disallowComments" is invalid. Value "error" should be object or array.
Setting the rule to a string severity without specifying options when options are required.
fix
Use array syntax: 'no-comments/disallowComments': ['error', { allow: [...] }]
Upgrade
Version history
1.2.1latest on npm
Audit
Dependencies
eslintrequiredPeer dependency required to run as an ESLint plugin; must be version ^9.0.0 or ^10.0.0
Agent activity
2 hits · last 30 days
node
2
Resources