]> git.openstreetmap.org Git - rails.git/blobdiff - config/eslint.js
Merge remote-tracking branch 'upstream/pull/5657'
[rails.git] / config / eslint.js
index 8307b15d6cc1a63dc49721560a0e3739587b2320..895ab380c16c275d0ff3c984fc212a728078a9c4 100644 (file)
@@ -6,6 +6,14 @@ const stylisticJs = require("@stylistic/eslint-plugin-js");
 module.exports = [
   js.configs.recommended,
   erb.configs.recommended,
+  {
+    ignores: [
+      "app/assets/javascripts/i18n/",
+      "coverage/assets/",
+      "public/assets/",
+      "vendor/"
+    ]
+  },
   {
     plugins: {
       "@stylistic": stylisticJs
@@ -19,8 +27,8 @@ module.exports = [
         Cookies: "readonly",
         I18n: "readonly",
         L: "readonly",
-        OSM: "writable",
         Matomo: "readonly",
+        OSM: "writable",
         Turbo: "readonly",
         updateLinks: "readonly"
       }
@@ -47,23 +55,25 @@ 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/max-statements-per-line": "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 }],
       "@stylistic/object-curly-spacing": ["error", "always"],
       "@stylistic/object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
+      "@stylistic/one-var-declaration-per-line": "error",
       "@stylistic/operator-linebreak": ["error", "after"],
       "@stylistic/padded-blocks": ["error", "never"],
       "@stylistic/quote-props": ["error", "consistent-as-needed", { keywords: true, numbers: true }],
@@ -86,11 +96,12 @@ 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",
       "no-div-regex": "error",
+      "no-else-return": ["error", { allowElseIf: false }],
       "no-eq-null": "error",
       "no-eval": "error",
       "no-extend-native": "error",
@@ -101,8 +112,8 @@ module.exports = [
       "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",
@@ -126,12 +137,14 @@ 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",
+      "operator-assignment": "error",
+      "prefer-object-spread": "error",
       "radix": ["error", "always"],
       "yoda": "error"
     }
@@ -156,6 +169,9 @@ module.exports = [
       globals: {
         ...globals.commonjs
       }
+    },
+    rules: {
+      "sort-keys": ["error", "asc", { minKeys: 5 }]
     }
   }
 ];