canvas-lms/script/eslint

37 lines
954 B
Ruby
Executable File

#!/usr/bin/env ruby
require_relative './linter'
linter_options = {
linter_name: "eslint",
# ignore packages subdirectory
file_regex: /^(?!(?:packages\/)).*\.js$/,
format: "eslint",
command: "node_modules/.bin/eslint",
campsite_mode: false,
append_files_to_command: true,
comment_post_processing: proc do |comments|
# This section should be removed when we start -2ing patchsets
comments.each do |comment|
comment[:severity] = 'warn'
end
end
}
eslint = Linter.new(linter_options)
eslint.run
puts "Linting sub-packages"
linter_options[:command] = "yarn lint"
linter_options[:base_dir] = "../../"
package_dirs = `ls -1 packages/*/package.json 2> /dev/null`.split(/\n/).map { |d| d.sub("/package.json", "")}
cwd = Dir.pwd
package_dirs.each do |d|
puts "working sub-package dir #{d}"
Dir.chdir d
linter_options[:file_regex] = /#{d}\/.*\.js$/
eslint = Linter.new(linter_options)
eslint.run
Dir.chdir cwd
end