mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: tracks self pattern in Dangerfile (#7102)
This commit is contained in:
parent
801a9cf637
commit
7078d39f96
17
Dangerfile
17
Dangerfile
@ -22,21 +22,23 @@ files = (git.added_files + git.modified_files)
|
|||||||
.select { |path| !path.start_with?("plugins/") }
|
.select { |path| !path.start_with?("plugins/") }
|
||||||
.select { |path| path.end_with?("es6") || path.end_with?("rb") }
|
.select { |path| path.end_with?("es6") || path.end_with?("rb") }
|
||||||
|
|
||||||
js_test_files = files.select { |path| path.end_with?("-test.js.es6") }
|
js_files = files.select { |path| path.end_with?(".js.es6") }
|
||||||
|
js_test_files = js_files.select { |path| path.end_with?("-test.js.es6") }
|
||||||
|
|
||||||
super_offenses = []
|
super_offenses = []
|
||||||
jquery_find_offenses = []
|
self_offenses = []
|
||||||
|
js_files.each do |path|
|
||||||
files.each do |path|
|
|
||||||
diff = git.diff_for_file(path)
|
diff = git.diff_for_file(path)
|
||||||
|
|
||||||
next if !diff
|
next if !diff
|
||||||
|
|
||||||
diff.patch.lines.grep(/^\+\s\s/).each do |added_line|
|
diff.patch.lines.grep(/^\+\s\s/).each do |added_line|
|
||||||
super_offenses << path if added_line['this._super()']
|
super_offenses << path if added_line['this._super()']
|
||||||
|
self_offenses << path if added_line['self']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
jquery_find_offenses = []
|
||||||
js_test_files.each do |path|
|
js_test_files.each do |path|
|
||||||
diff = git.diff_for_file(path)
|
diff = git.diff_for_file(path)
|
||||||
|
|
||||||
@ -47,6 +49,13 @@ js_test_files.each do |path|
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if !self_offenses.empty?
|
||||||
|
warn(%{
|
||||||
|
Use fat arrow instead of self pattern.`\n
|
||||||
|
#{self_offenses.uniq.map { |o| github.html_link(o) }.join("\n")}
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
if !super_offenses.empty?
|
if !super_offenses.empty?
|
||||||
warn(%{
|
warn(%{
|
||||||
When possible use `this._super(...arguments)` instead of `this._super()`\n
|
When possible use `this._super(...arguments)` instead of `this._super()`\n
|
||||||
|
Loading…
Reference in New Issue
Block a user