{"id":15198402,"url":"https://github.com/splines/eslint-plugin-erb","last_synced_at":"2026-02-24T02:08:12.092Z","repository":{"id":207996395,"uuid":"720417816","full_name":"Splines/eslint-plugin-erb","owner":"Splines","description":"Lint your JavaScript inside ERB (embedded Ruby) files","archived":false,"fork":false,"pushed_at":"2024-12-17T13:42:51.000Z","size":117,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-13T15:14:20.843Z","etag":null,"topics":["erb","eslint","eslint-plugin","javascript","linter"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/eslint-plugin-erb","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Splines.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-18T12:29:58.000Z","updated_at":"2024-12-15T18:31:57.000Z","dependencies_parsed_at":"2024-02-19T12:49:36.021Z","dependency_job_id":"5e361f06-2272-49dc-92dd-8577e455e345","html_url":"https://github.com/Splines/eslint-plugin-erb","commit_stats":{"total_commits":50,"total_committers":2,"mean_commits":25.0,"dds":0.12,"last_synced_commit":"baa20350239835528cd4a7d74f1a0f1432766e37"},"previous_names":["splines/eslint-plugin-erb"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Splines%2Feslint-plugin-erb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Splines%2Feslint-plugin-erb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Splines%2Feslint-plugin-erb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Splines%2Feslint-plugin-erb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Splines","download_url":"https://codeload.github.com/Splines/eslint-plugin-erb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233761321,"owners_count":18726116,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["erb","eslint","eslint-plugin","javascript","linter"],"created_at":"2024-09-28T01:05:16.373Z","updated_at":"2026-02-24T02:08:12.036Z","avatar_url":"https://github.com/Splines.png","language":"JavaScript","readme":"# eslint-plugin-erb\n\n**Lint your JavaScript code inside ERB files (`.js.erb`).**\nA zero-dependency plugin for [ESLint](https://eslint.org/).\n\u003cbr\u003eAlso lints your **HTML code** in `.html.erb` if you want to.\n\n![showcase-erb-lint-gif](https://github.com/Splines/eslint-plugin-erb/assets/37160523/623d6007-b4f5-41ce-be76-5bc0208ed636?raw=true)\n\n## Usage\n\n### Install\n\nInstall the plugin alongside [ESLint](https://eslint.org/docs/latest/use/getting-started):\n\n```sh\nnpm install --save-dev eslint eslint-plugin-erb\n```\n\n### Configure\n\nStarting of v9 ESLint provides a [new flat config format](https://eslint.org/docs/latest/use/configure/configuration-files-new) (`eslint.config.js`). Also see the [configuration migration guide](https://eslint.org/docs/latest/use/configure/migration-guide). Use it as follows and it will automatically lint all your **JavaScript code** in `.js.erb` files:\n\n```js\n// eslint.config.js\nimport erb from \"eslint-plugin-erb\";\n\nexport default [\n  erb.configs.recommended,\n  {\n    linterOptions: {\n      // The \"unused disable directive\" is set to \"warn\" by default.\n      // For the ERB plugin to work correctly, you must disable\n      // this directive to avoid issues described here\n      // https://github.com/eslint/eslint/discussions/18114\n      // If you're using the CLI, you might also use the following flag:\n      // --report-unused-disable-directives-severity=off\n      reportUnusedDisableDirectives: \"off\",\n    },\n    // your other configuration options\n  }\n];\n```\n\n\u003cdetails\u003e\n\u003csummary\u003eSee more complete example\u003c/summary\u003e\n\n```js\n// eslint.config.js\nimport js from \"@eslint/js\";\nimport stylistic from \"@stylistic/eslint-plugin\";\nimport globals from \"globals\";\nimport erb from \"eslint-plugin-erb\";\n\nconst customizedStylistic = stylistic.configs.customize({\n  \"indent\": 2,\n  \"jsx\": false,\n  \"quote-props\": \"always\",\n  \"semi\": \"always\",\n  \"brace-style\": \"1tbs\",\n});\n\nconst customGlobals = {\n  MyGlobalVariableOrFunctionOrClassOrWhatever: \"readable\",\n};\n\n// [1] https://eslint.org/docs/latest/use/configure/configuration-files-new#globally-ignoring-files-with-ignores\n\nexport default [\n  js.configs.recommended,\n  erb.configs.recommended,\n  // Globally ignoring the following files\n  // \"Note that only global ignores patterns can match directories.\n  // 'ignores' patterns that are specific to a configuration will\n  // only match file names.\" ~ see [1]\n  {\n    ignores: [\n      \"node_modules/\",\n      \"tests/fixtures/\",\n      \"tmp/\",\n    ],\n  },\n  {\n    plugins: {\n      \"@stylistic\": stylistic,\n    },\n    rules: {\n      ...customizedStylistic.rules,\n      \"no-unused-vars\": [\"warn\", { argsIgnorePattern: \"^_\" }],\n      \"@stylistic/quotes\": [\"error\", \"double\", { avoidEscape: true }],\n    },\n    languageOptions: {\n      ecmaVersion: 2022,\n      sourceType: \"module\",\n      globals: {\n        ...customGlobals,\n        ...globals.browser,\n        ...globals.node,\n      },\n    },\n    linterOptions: {\n      // The \"unused disable directive\" is set to \"warn\" by default.\n      // For the ERB plugin to work correctly, you must disable\n      // this directive to avoid issues described here\n      // https://github.com/eslint/eslint/discussions/18114\n      // If you're using the CLI, you might also use the following flag:\n      // --report-unused-disable-directives-severity=off\n      reportUnusedDisableDirectives: \"off\",\n    },\n  },\n];\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\n\u003csummary\u003eAlternative way to configure the processor\u003c/summary\u003e\n\nWith this variant you have a bit more control over what is going on, e.g. you could name your files `.js.special-erb` and still lint them (if they contain JS and ERB syntax).\n\n```js\n// eslint.config.js\nimport erb from \"eslint-plugin-erb\";\n\nexport default [\n  {\n    files: [\"**/*.js.erb\"],\n    processor: erb.processors.processorJs,\n  },\n  {\n    linterOptions: {\n      // The \"unused disable directive\" is set to \"warn\" by default.\n      // For the ERB plugin to work correctly, you must disable\n      // this directive to avoid issues described here\n      // https://github.com/eslint/eslint/discussions/18114\n      // If you're using the CLI, you might also use the following flag:\n      // --report-unused-disable-directives-severity=off\n      reportUnusedDisableDirectives: \"off\",\n    },\n    // your other configuration options\n  }\n];\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eLegacy: you can still use the old `.eslintrc.js` format\u003c/summary\u003e\n\nYou can extend the `plugin:erb/recommended-legacy` config that will enable the ERB processor on all `.js.erb` files.\n\n```js\n// .eslintrc.js\nmodule.exports = {\n    extends: \"plugin:erb/recommended-legacy\"\n};\n```\n\nOr you can configure the processor manually:\n\n```js\n// .eslintrc.js\nmodule.exports = {\n    plugins: [\"erb\"],\n    overrides: [\n        {\n            files: [\"**/*.js.erb\"],\n            processor: \"erb/processorJs\"\n        }\n    ]\n};\n```\n\n\u003c/details\u003e\n\n\u003cbr\u003e\n\nIf you also want to lint **HTML code** in `.html.erb` files, you can use our preprocessor in conjunction with the amazing [`html-eslint`](https://html-eslint.org/) plugin. Install `html-eslint`, then add the following to your ESLint config file (flat config format):\n\n```js\n// eslint.config.js\nimport erb from \"eslint-plugin-erb\";\n\nexport default [\n  // your other configurations...\n  {\n    processor: erb.processors[\"processorHtml\"],\n    ...html.configs[\"flat/recommended\"],\n    files: [\"**/*.html\", \"**/*.html.erb\"],\n    rules: {\n        ...html.configs[\"flat/recommended\"].rules,\n        \"@html-eslint/indent\": [\"error\", 2],\n        // other rules...\n    },\n  }\n];\n```\n\nAdditionally, you might want to add the following option to the other objects (`{}`) in `export default []` (at the same level like the `files` key above), since other rules might be incompatible with HTML files:\n\n```js\nignores: [\"**/*.html**\"],\n```\n\n## Editor Integrations\n\nThe [ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) for VSCode has built-in support for the ERB processor once you've configured it in your `.eslintrc.js` file as shown above.\n\nIf you're using VSCode, you may find this `settings.json` options useful:\n\n```jsonc\n{\n    \"editor.formatOnSave\": false, // it still autosaves with the options below\n    //////////////////////////////////////\n    // JS (ESLint)\n    //////////////////////////////////////\n    // https://eslint.style/guide/faq#how-to-auto-format-on-save\n    // https://github.com/microsoft/vscode-eslint#settings-options\n    \"eslint.format.enable\": true,\n    \"[javascript]\": {\n        \"editor.formatOnSave\": false, // to avoid formatting twice (ESLint + VSCode)\n        \"editor.defaultFormatter\": \"dbaeumer.vscode-eslint\" // use ESLint plugin\n    },\n    \"editor.codeActionsOnSave\": {\n        \"source.fixAll.eslint\": \"explicit\" // Auto-fix ESLint errors on save\n    },\n    // this disables VSCode built-int formatter (instead we want to use ESLint)\n    \"javascript.validate.enable\": false,\n    //////////////////////////////////////\n    // Files\n    //////////////////////////////////////\n    \"files.associations\": {\n        \"*.js.erb\": \"javascript\"\n    },\n}\n```\n\n## Limitations\n\n- Does not account for code indentation inside `if/else` ERB statements, e.g.\nthis snippet\n\n```js\n\u003c% if you_feel_lucky %\u003e\n    console.log(\"You are lucky 🍀\");\n\u003c% end %\u003e\n```\n\nwill be autofixed to\n\n```js\n\u003c% if you_feel_lucky %\u003e\nconsole.log(\"You are lucky 🍀\");\n\u003c% end %\u003e\n```\n\n- No support for ESLint _suggestions_ (but full support for _autofixes_ as shown in the GIF above)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsplines%2Feslint-plugin-erb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsplines%2Feslint-plugin-erb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsplines%2Feslint-plugin-erb/lists"}