{"id":25507,"library":"eslint-plugin-erb","title":"eslint-plugin-erb","description":"ESLint plugin to lint JavaScript inside ERB files (.js.erb) and optionally HTML inside .html.erb using html-eslint. Version 2.1.1 is current, actively maintained with monthly releases. Key differentiator: zero-dependency, supports ESLint flat config (v9+), handles ERB tags (<% %>, <%= %>) inside JS code, and provides recommended configs. Unlike generic processors, it also fixes autofix interactions with stylistic rules (e.g., quotes). The plugin requires explicitly disabling `reportUnusedDisableDirectives` to avoid false positives.","status":"active","version":"2.1.1","language":"javascript","source_language":"en","source_url":"https://github.com/Splines/eslint-plugin-erb","tags":["javascript","eslint","eslintplugin","eslint-processor","erb","ruby","embedded ruby","lint"],"install":[{"cmd":"npm install eslint-plugin-erb","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-erb","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-erb","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only since v2 (supports ESLint flat config). CJS require() will fail.","wrong":"const erb = require('eslint-plugin-erb')","symbol":"default import","correct":"import erb from 'eslint-plugin-erb'"},{"note":"processorJs is not a named export; access via erb.processors.processorJs.","wrong":"import { processorJs } from 'eslint-plugin-erb'","symbol":"erb.processors.processorJs","correct":"import { processors } from 'eslint-plugin-erb';\nconst processorJs = erb.processors.processorJs;"},{"note":"Default export is the plugin object; use erb.configs.recommended, not { erb }.","wrong":"import { erb } from 'eslint-plugin-erb'","symbol":"erb.configs.recommended","correct":"import erb from 'eslint-plugin-erb';\nexport default [ erb.configs.recommended, ... ]"},{"note":"For .eslintrc.js files (legacy format), use 'recommended-legacy' config. v2.0.0+ drops legacy support; this config is a backward-compatible alias.","wrong":"require('eslint-plugin-erb').configs['recommended-legacy']","symbol":"erb.configs['recommended-legacy']","correct":"import erb from 'eslint-plugin-erb';  module.exports = [ erb.configs['recommended-legacy'] ];"}],"quickstart":{"code":"// 1. Install: npm install --save-dev eslint eslint-plugin-erb\n// 2. Create eslint.config.js:\nimport erb from 'eslint-plugin-erb';\nexport default [\n  erb.configs.recommended,\n  {\n    linterOptions: {\n      reportUnusedDisableDirectives: 'off'\n    }\n  }\n];\n// 3. Lint your .js.erb file\n// sample.js.erb:\nconst x = <%= some_ruby %>;\nconsole.log(x);\n// Run: npx eslint sample.js.erb\n// This will lint the JS parts, ignoring ERB tags.\n// The plugin will process the file and report any JS errors.","lang":"javascript","description":"Set up ESLint with eslint-plugin-erb using flat config and lint a .js.erb file, showing how ERB tags are ignored."},"warnings":[{"fix":"Use erb.configs.recommended in flat config, or switch to erb.configs['recommended-legacy'] for .eslintrc.*.","message":"v2.0.0 drops support for ESLint flat config migration: requires ESLint v9+ and eslint.config.js format.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Migrate to flat config (eslint.config.js) and use erb.configs.recommended.","message":"Legacy .eslintrc.* config format is deprecated in v2.0.0; recommended-legacy config is provided but will be removed in a future major version.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Add `linterOptions: { reportUnusedDisableDirectives: 'off' }` to your ESLint config.","message":"Must set reportUnusedDisableDirectives to 'off' in linterOptions, otherwise ESLint will incorrectly warn about unused disable directives due to ERB tag transformation.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Either use eslint.config.js with erb.configs.recommended or downgrade to v1.x.","message":"If using ESLint v9+, the flat config is required; .eslintrc.* files are not supported unless you use the legacy config via erb.configs['recommended-legacy'].","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Wrap linterOptions inside a configuration object: `{ linterOptions: { reportUnusedDisableDirectives: 'off' } }`.","cause":"reportUnusedDisableDirectives is placed outside the object where it belongs.","error":"Error: ESLint configuration in eslint.config.js is invalid: - Unexpected top-level property \"linterOptions\""},{"fix":"Install with `npm install --save-dev eslint-plugin-erb` and ensure ESLint is v9+.","cause":"Package not installed or mismatched ESLint version (v2+ requires ESLint v9+).","error":"Error: Cannot find module 'eslint-plugin-erb'"},{"fix":"Add `processor: erb.processors.processorJs` to your config or use `erb.configs.recommended`.","cause":"ESLint is trying to parse the entire .js.erb file as JavaScript without the processor, failing on ERB tags like <%%=.","error":"SyntaxError: Unexpected token '<'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}