]> git.openstreetmap.org Git - rails.git/blob - config/eslint.js
Bump @stylistic/eslint-plugin-js from 3.0.1 to 3.1.0
[rails.git] / config / eslint.js
1 const globals = require("globals");
2 const js = require("@eslint/js");
3 const erb = require("eslint-plugin-erb");
4 const stylisticJs = require("@stylistic/eslint-plugin-js");
5
6 module.exports = [
7   js.configs.recommended,
8   erb.configs.recommended,
9   {
10     ignores: [
11       "app/assets/javascripts/i18n/",
12       "coverage/assets/",
13       "public/assets/",
14       "vendor/"
15     ]
16   },
17   {
18     plugins: {
19       "@stylistic": stylisticJs
20     },
21     languageOptions: {
22       ecmaVersion: 2021,
23       sourceType: "script",
24       globals: {
25         ...globals.browser,
26         ...globals.jquery,
27         Cookies: "readonly",
28         I18n: "readonly",
29         L: "readonly",
30         OSM: "writable",
31         Matomo: "readonly",
32         Turbo: "readonly",
33         updateLinks: "readonly"
34       }
35     },
36     linterOptions: {
37       // The "unused disable directive" is set to "warn" by default.
38       // For the ERB plugin to work correctly, you must disable
39       // this directive to avoid issues described here
40       // https://github.com/eslint/eslint/discussions/18114
41       // If you're using the CLI, you might also use the following flag:
42       // --report-unused-disable-directives-severity=off
43       reportUnusedDisableDirectives: "off"
44     },
45     rules: {
46       /* eslint sort-keys: ["warn"] */
47       "@stylistic/array-bracket-newline": ["error", "consistent"],
48       "@stylistic/array-bracket-spacing": "error",
49       "@stylistic/block-spacing": "error",
50       "@stylistic/brace-style": ["error", "1tbs", { allowSingleLine: true }],
51       "@stylistic/comma-dangle": "error",
52       "@stylistic/comma-spacing": "error",
53       "@stylistic/comma-style": "error",
54       "@stylistic/computed-property-spacing": "error",
55       "@stylistic/dot-location": ["error", "property"],
56       "@stylistic/eol-last": "error",
57       "@stylistic/func-call-spacing": "error",
58       "@stylistic/indent": ["error", 2, {
59         CallExpression: { arguments: "first" },
60         FunctionDeclaration: { parameters: "first" },
61         FunctionExpression: { parameters: "first" },
62         SwitchCase: 1,
63         VariableDeclarator: "first"
64       }],
65       "@stylistic/key-spacing": "error",
66       "@stylistic/keyword-spacing": "error",
67       "@stylistic/max-statements-per-line": "error",
68       "@stylistic/no-floating-decimal": "error",
69       "@stylistic/no-mixed-operators": "error",
70       "@stylistic/no-multi-spaces": "error",
71       "@stylistic/no-multiple-empty-lines": "error",
72       "@stylistic/no-trailing-spaces": "error",
73       "@stylistic/no-whitespace-before-property": "error",
74       "@stylistic/object-curly-newline": ["error", { consistent: true }],
75       "@stylistic/object-curly-spacing": ["error", "always"],
76       "@stylistic/object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
77       "@stylistic/one-var-declaration-per-line": "error",
78       "@stylistic/operator-linebreak": ["error", "after"],
79       "@stylistic/padded-blocks": ["error", "never"],
80       "@stylistic/quote-props": ["error", "consistent-as-needed", { keywords: true, numbers: true }],
81       "@stylistic/quotes": ["error", "double"],
82       "@stylistic/semi": ["error", "always"],
83       "@stylistic/semi-spacing": "error",
84       "@stylistic/semi-style": "error",
85       "@stylistic/space-before-blocks": "error",
86       "@stylistic/space-before-function-paren": ["error", { named: "never" }],
87       "@stylistic/space-in-parens": "error",
88       "@stylistic/space-infix-ops": "error",
89       "@stylistic/space-unary-ops": "error",
90       "@stylistic/switch-colon-spacing": "error",
91       "@stylistic/wrap-iife": "error",
92       "@stylistic/wrap-regex": "error",
93
94       "accessor-pairs": "error",
95       "array-callback-return": "error",
96       "block-scoped-var": "error",
97       "curly": ["error", "multi-line", "consistent"],
98       "dot-notation": "error",
99       "eqeqeq": ["error", "smart"],
100       "no-alert": "error",
101       "no-array-constructor": "error",
102       "no-caller": "error",
103       "no-console": "warn",
104       "no-div-regex": "error",
105       "no-else-return": ["error", { allowElseIf: false }],
106       "no-eq-null": "error",
107       "no-eval": "error",
108       "no-extend-native": "error",
109       "no-extra-bind": "error",
110       "no-extra-label": "error",
111       "no-implicit-coercion": "warn",
112       "no-implicit-globals": "error",
113       "no-implied-eval": "error",
114       "no-invalid-this": "error",
115       "no-iterator": "error",
116       "no-label-var": "error",
117       "no-labels": "error",
118       "no-lone-blocks": "error",
119       "no-lonely-if": "error",
120       "no-loop-func": "error",
121       "no-multi-str": "error",
122       "no-negated-condition": "error",
123       "no-nested-ternary": "error",
124       "no-new": "error",
125       "no-new-func": "error",
126       "no-new-wrappers": "error",
127       "no-object-constructor": "error",
128       "no-octal-escape": "error",
129       "no-param-reassign": "error",
130       "no-proto": "error",
131       "no-script-url": "error",
132       "no-self-compare": "error",
133       "no-sequences": "error",
134       "no-throw-literal": "error",
135       "no-undef-init": "error",
136       "no-undefined": "error",
137       "no-unmodified-loop-condition": "error",
138       "no-unneeded-ternary": "error",
139       "no-unused-expressions": "off",
140       "no-unused-vars": ["error", { caughtErrors: "none" }],
141       "no-use-before-define": ["error", { functions: false }],
142       "no-useless-call": "error",
143       "no-useless-concat": "error",
144       "no-useless-return": "error",
145       "no-void": "error",
146       "no-warning-comments": "warn",
147       "operator-assignment": "error",
148       "prefer-object-spread": "error",
149       "radix": ["error", "always"],
150       "yoda": "error"
151     }
152   },
153   {
154     // Additional configuration for test files
155     files: ["test/**/*.js"],
156     languageOptions: {
157       globals: {
158         ...globals.mocha,
159         expect: "readonly",
160         assert: "readonly",
161         should: "readonly"
162       }
163     }
164   },
165   {
166     files: ["config/eslint.js"],
167     languageOptions: {
168       ecmaVersion: 2019,
169       sourceType: "commonjs",
170       globals: {
171         ...globals.commonjs
172       }
173     }
174   }
175 ];