summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitlab-ci.yml1
-rw-r--r--Dangerfile1
-rw-r--r--danger/eslint/Dangerfile29
3 files changed, 31 insertions, 0 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 5028aa98a85..cccbaeb3af1 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -461,6 +461,7 @@ danger-review:
- $CI_COMMIT_REF_NAME =~ /.*-stable(-ee)?-prepare-.*/
script:
- git version
+ - node --version
- yarn install --frozen-lockfile --cache-folder .yarn-cache
- danger --fail-on-errors=true
diff --git a/Dangerfile b/Dangerfile
index fe1e3d16ba5..10caacff4c4 100644
--- a/Dangerfile
+++ b/Dangerfile
@@ -8,3 +8,4 @@ danger.import_dangerfile(path: 'danger/documentation')
danger.import_dangerfile(path: 'danger/frozen_string')
danger.import_dangerfile(path: 'danger/commit_messages')
danger.import_dangerfile(path: 'danger/prettier')
+danger.import_dangerfile(path: 'danger/eslint')
diff --git a/danger/eslint/Dangerfile b/danger/eslint/Dangerfile
new file mode 100644
index 00000000000..f78488cfd0a
--- /dev/null
+++ b/danger/eslint/Dangerfile
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+def get_eslint_files(files)
+ files.select do |file|
+ file.end_with?('.js', '.vue') &&
+ File.read(file).include?('/* eslint-disable')
+ end
+end
+
+eslint_candidates = get_eslint_files(git.added_files + git.modified_files)
+
+return if eslint_candidates.empty?
+
+warn 'This merge request changed files with disabled eslint rules. Please consider fixing them.'
+
+markdown(<<~MARKDOWN)
+ ## Disabled eslint rules
+
+ The following files have disabled `eslint` rules. Please consider fixing them:
+
+ * #{eslint_candidates.map { |path| "`#{path}`" }.join("\n* ")}
+
+ Run the following command for more details
+
+ ```
+ node_modules/.bin/eslint --report-unused-disable-directives --no-inline-config \\
+ #{eslint_candidates.map { |path| " '#{path}'" }.join(" \\\n")}
+ ```
+MARKDOWN