2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-03-03 22:05:52 +08:00
discourse/bin/rubocop
Sam bb8ed7d6f9
DEV: fix linter and linting config (#36815)
This amends lefthook to use the more reliable doublestar globber:
https://github.com/evilmartians/lefthook/blob/master/docs/mdbook/configuration/glob_matcher.md
it also cleans up the config so we can properly run and filter.

Notably ember linter explodes if you pass it files your are not meant to
lint.

The current fix has bin/lint read the config from lefthook and filter
out the files that need no linting. `--file` overrides the glob so we
can not pass in files unfiltered.

This also simplifies some of the linters internals for easier
maintenance
2025-12-22 07:23:19 +11:00

30 lines
807 B
Ruby
Executable file

#!/usr/bin/env ruby
# frozen_string_literal: true
#
# This file was generated by Bundler.
#
# The application 'rubocop' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require "pathname"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", Pathname.new(__FILE__).realpath)
bundle_binstub = File.expand_path("../bundle", __FILE__)
if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
load(bundle_binstub)
else
abort(
"Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.",
)
end
end
require "rubygems"
require "bundler/setup"
load Gem.bin_path("rubocop", "rubocop")