Skip to content

Commit

Permalink
Add the eslint-erb-plugin to provide linting of our .js.erb files
Browse files Browse the repository at this point in the history
  • Loading branch information
gravitystorm committed Jan 24, 2025
1 parent 6dc5578 commit a632b84
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
11 changes: 11 additions & 0 deletions config/eslint.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
const globals = require("globals");
const js = require("@eslint/js");
const erb = require("eslint-plugin-erb");

module.exports = [
js.configs.recommended,
erb.configs.recommended,
{
languageOptions: {
ecmaVersion: 2021,
Expand All @@ -20,6 +22,15 @@ module.exports = [
updateLinks: "readonly"
}
},
linterOptions: {
// The "unused disable directive" is set to "warn" by default.
// For the ERB plugin to work correctly, you must disable
// this directive to avoid issues described here
// https://github.com/eslint/eslint/discussions/18114
// If you're using the CLI, you might also use the following flag:
// --report-unused-disable-directives-severity=off
reportUnusedDisableDirectives: "off"
},
rules: {
"accessor-pairs": "error",
"array-bracket-newline": ["error", "consistent"],
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/eslint.rake
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ end

def js_files
Rails.application.assets.each_file.select do |file|
file.ends_with?(".js") && !file.match?(%r{/(gems|vendor|i18n|node_modules)/})
(file.ends_with?(".js") || file.ends_with?(".js.erb")) && !file.match?(%r{/(gems|vendor|i18n|node_modules)/})
end
end

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "openstreetmap",
"private": true,
"dependencies": {
"eslint-plugin-erb": "^2.1.0",
"jquery-simulate": "^1.0.2",
"js-cookie": "^3.0.0",
"leaflet": "^1.8.0",
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,11 @@ eslint-formatter-compact@^8.40.0:
resolved "https://registry.yarnpkg.com/eslint-formatter-compact/-/eslint-formatter-compact-8.40.0.tgz#d7455b2d75fd70e8c0e7a98a5e189f168e9dfe2d"
integrity sha512-cwGUs113TgmTQXecx5kfRjB7m0y2wkDLSadPTE2pK6M/wO4N8PjmUaoWOFNCP9MHgsiZwgqd5bZFnDCnszC56Q==

eslint-plugin-erb@^2.1.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-erb/-/eslint-plugin-erb-2.1.1.tgz#8a0a6c2bcaf3a8573c381b595969145aff93cfc6"
integrity sha512-AhznaVwRpQqR8NADjN4SZnKNbaIdAbGxTjCg6cj3UhwGyQOUJ6kXwhYrl1LYrGDNx7Ouyd8xuEG7wepFZyPgFw==

eslint-scope@^8.2.0:
version "8.2.0"
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-8.2.0.tgz#377aa6f1cb5dc7592cfd0b7f892fd0cf352ce442"
Expand Down

0 comments on commit a632b84

Please sign in to comment.