diff options
author | Lukas Eipert <leipert@gitlab.com> | 2018-09-21 18:26:48 +0200 |
---|---|---|
committer | Lukas Eipert <leipert@gitlab.com> | 2018-09-29 08:22:12 +0200 |
commit | 685d579472018c968e785d7d49ec7f84f7438e97 (patch) | |
tree | b8a2133b31f4fcf931b86ef155c73ffccdddd390 /danger | |
parent | 4df24e5f046f94a04b379fcd1d6d57ef49cfd6dc (diff) | |
download | gitlab-ce-685d579472018c968e785d7d49ec7f84f7438e97.tar.gz |
Danger check for ignored eslint rulesleipert-frontend-danger
We disabled a lot of eslint rules on a per-file basis. This checks
touched files for those and reminds you to re-enable the rules and fix
them.
Diffstat (limited to 'danger')
-rw-r--r-- | danger/eslint/Dangerfile | 29 |
1 files changed, 29 insertions, 0 deletions
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 |