{"id":19849,"library":"eslint-plugin-no-comments","title":"eslint-plugin-no-comments","description":"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.","status":"active","version":"1.2.1","language":"javascript","source_language":"en","source_url":"https://github.com/wisniewski94/eslint-plugin-no-comments","tags":["javascript","eslint","eslintplugin","comments","disallow","no-comments","disallow-comments","eslint-plugin"],"install":[{"cmd":"npm install eslint-plugin-no-comments","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-no-comments","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-no-comments","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required to run as an ESLint plugin; must be version ^9.0.0 or ^10.0.0","package":"eslint","optional":false}],"imports":[{"note":"ESM-only since v1.2.0; require() will fail with ERR_REQUIRE_ESM. The default export is the plugin object.","wrong":"const noComments = require('eslint-plugin-no-comments')","symbol":"default","correct":"import noComments from 'eslint-plugin-no-comments'"},{"note":"The package has no named export; use default import. The correct plugin name in config is 'no-comments'.","wrong":"import { noComments } from 'eslint-plugin-no-comments'","symbol":"noComments (as plugin)","correct":"import noComments from 'eslint-plugin-no-comments'"},{"note":"Rules are only accessible via the default export's .rules property. Named export does not exist.","wrong":"import { rules } from 'eslint-plugin-no-comments'","symbol":"rules (if accessing directly)","correct":"import noComments from 'eslint-plugin-no-comments'; const rules = noComments.rules;"},{"note":"Flat config is the only supported format since v1.2.0; .eslintrc format is not supported. Use eslint.config.js.","wrong":"module.exports = { plugins: { 'no-comments': noComments }, rules: { ... } }","symbol":"plugin for flat config","correct":"import noComments from 'eslint-plugin-no-comments'; export default [{ plugins: { 'no-comments': noComments }, rules: { 'no-comments/disallowComments': 'error' } }]"}],"quickstart":{"code":"// Install: npm install eslint-plugin-no-comments --save-dev\n\n// eslint.config.js\nimport noComments from 'eslint-plugin-no-comments';\n\nexport default [\n  {\n    plugins: {\n      'no-comments': noComments\n    },\n    rules: {\n      'no-comments/disallowComments': [\n        'error',\n        {\n          allow: ['global', 'eslint', 'TODO', 'FIXME']\n        }\n      ]\n    }\n  }\n];","lang":"javascript","description":"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."},"warnings":[{"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","message":"v1.2.0 drops support for .eslintrc (Legacy ESLint config format) and requires flat config (eslint.config.js).","severity":"breaking","affected_versions":">=1.2.0"},{"fix":"Update Node.js to v20.19.0 or higher. Run: nvm install 20.19.0 (or use your version manager).","message":"v1.2.0 requires Node.js >= 20.19.0. Older Node versions cause crashes.","severity":"breaking","affected_versions":">=1.2.0"},{"fix":"Upgrade to v1.2.0+ and migrate to flat config. The old versions are no longer maintained.","message":"v1.1.x and earlier used .eslintrc configuration and CommonJS require(). They are deprecated and may break in future ESLint versions.","severity":"deprecated","affected_versions":"<1.2.0"},{"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'.","message":"If 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.","severity":"gotcha","affected_versions":"*"},{"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.","message":"Single-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.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Switch to import syntax and flat config: import noComments from 'eslint-plugin-no-comments'; in eslint.config.js.","cause":"Using CommonJS require() to load the plugin, but v1.2.0+ is an ESM-only package.","error":"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."},{"fix":"In eslint.config.js, export an array with an object containing plugins: { 'no-comments': noComments }.","cause":"Incorrect plugin configuration in flat config (e.g., missing 'plugins' object or wrong key name).","error":"ESLint couldn't find the plugin \"eslint-plugin-no-comments\". This is most likely an issue with the plugin resolution."},{"fix":"Use array syntax: 'no-comments/disallowComments': ['error', { allow: [...] }]","cause":"Setting the rule to a string severity without specifying options when options are required.","error":"Configuration for rule \"no-comments/disallowComments\" is invalid. Value \"error\" should be object or array."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}