debian-mirror-gitlab/danger/eslint/Dangerfile

32 lines
867 B
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# 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
2018-12-13 13:39:08 +05:30
eslint_candidates = get_eslint_files(helper.all_changed_files)
2018-12-05 23:21:45 +05:30
return if eslint_candidates.empty?
warn 'This merge request changed files with disabled eslint rules. Please consider fixing them.'
2019-12-04 20:38:33 +05:30
if GitlabDanger.new(helper.gitlab_helper).ci?
markdown(<<~MARKDOWN)
## Disabled eslint rules
2018-12-05 23:21:45 +05:30
2019-12-04 20:38:33 +05:30
The following files have disabled `eslint` rules. Please consider fixing them:
2018-12-05 23:21:45 +05:30
2019-12-04 20:38:33 +05:30
* #{eslint_candidates.map { |path| "`#{path}`" }.join("\n* ")}
2018-12-05 23:21:45 +05:30
2019-12-04 20:38:33 +05:30
Run the following command for more details
2018-12-05 23:21:45 +05:30
2019-12-04 20:38:33 +05:30
```
node_modules/.bin/eslint --report-unused-disable-directives --no-inline-config \\
#{eslint_candidates.map { |path| " '#{path}'" }.join(" \\\n")}
```
MARKDOWN
end