]> git.openstreetmap.org Git - rails.git/blobdiff - config/eslint.js
Enable sort-keys for eslint.js
[rails.git] / config / eslint.js
index b2c527b7511fffbdb0086274b63ef927c14ec600..f51a1dc474b674a6282dd17ee787361d449892b4 100644 (file)
@@ -1,9 +1,11 @@
 const globals = require("globals");
 const js = require("@eslint/js");
+const erb = require("eslint-plugin-erb");
 const stylisticJs = require("@stylistic/eslint-plugin-js");
 
 module.exports = [
   js.configs.recommended,
+  erb.configs.recommended,
   {
     plugins: {
       "@stylistic": stylisticJs
@@ -19,12 +21,21 @@ module.exports = [
         L: "readonly",
         OSM: "writable",
         Matomo: "readonly",
-        Qs: "readonly",
         Turbo: "readonly",
         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: {
+      /* eslint sort-keys: ["warn"] */
       "@stylistic/array-bracket-newline": ["error", "consistent"],
       "@stylistic/array-bracket-spacing": "error",
       "@stylistic/block-spacing": "error",
@@ -37,18 +48,18 @@ module.exports = [
       "@stylistic/eol-last": "error",
       "@stylistic/func-call-spacing": "error",
       "@stylistic/indent": ["error", 2, {
-        SwitchCase: 1,
-        VariableDeclarator: "first",
+        CallExpression: { arguments: "first" },
         FunctionDeclaration: { parameters: "first" },
         FunctionExpression: { parameters: "first" },
-        CallExpression: { arguments: "first" }
+        SwitchCase: 1,
+        VariableDeclarator: "first"
       }],
       "@stylistic/key-spacing": "error",
       "@stylistic/keyword-spacing": "error",
       "@stylistic/no-floating-decimal": "error",
       "@stylistic/no-mixed-operators": "error",
-      "@stylistic/no-multiple-empty-lines": "error",
       "@stylistic/no-multi-spaces": "error",
+      "@stylistic/no-multiple-empty-lines": "error",
       "@stylistic/no-trailing-spaces": "error",
       "@stylistic/no-whitespace-before-property": "error",
       "@stylistic/object-curly-newline": ["error", { consistent: true }],
@@ -76,7 +87,7 @@ module.exports = [
       "curly": ["error", "multi-line", "consistent"],
       "dot-notation": "error",
       "eqeqeq": ["error", "smart"],
-      "no-alert": "warn",
+      "no-alert": "error",
       "no-array-constructor": "error",
       "no-caller": "error",
       "no-console": "warn",
@@ -87,12 +98,12 @@ module.exports = [
       "no-extra-bind": "error",
       "no-extra-label": "error",
       "no-implicit-coercion": "warn",
-      "no-implicit-globals": "warn",
+      "no-implicit-globals": "error",
       "no-implied-eval": "error",
       "no-invalid-this": "error",
       "no-iterator": "error",
-      "no-labels": "error",
       "no-label-var": "error",
+      "no-labels": "error",
       "no-lone-blocks": "error",
       "no-lonely-if": "error",
       "no-loop-func": "error",
@@ -101,11 +112,10 @@ module.exports = [
       "no-nested-ternary": "error",
       "no-new": "error",
       "no-new-func": "error",
-      "no-new-object": "error",
       "no-new-wrappers": "error",
+      "no-object-constructor": "error",
       "no-octal-escape": "error",
       "no-param-reassign": "error",
-      "no-process-env": "error",
       "no-proto": "error",
       "no-script-url": "error",
       "no-self-compare": "error",
@@ -117,10 +127,10 @@ module.exports = [
       "no-unneeded-ternary": "error",
       "no-unused-expressions": "off",
       "no-unused-vars": ["error", { caughtErrors: "none" }],
+      "no-use-before-define": ["error", { functions: false }],
       "no-useless-call": "error",
       "no-useless-concat": "error",
       "no-useless-return": "error",
-      "no-use-before-define": ["error", { functions: false }],
       "no-void": "error",
       "no-warning-comments": "warn",
       "radix": ["error", "always"],