summaryrefslogtreecommitdiff
path: root/lib/tasks/lint.rake
blob: e7812ff35689a946229f8b3fcb1f0c7d3e023f1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
unless Rails.env.production?
  namespace :lint do
    task :static_verification_env do
      ENV['STATIC_VERIFICATION'] = 'true'
    end

    desc "GitLab | lint | Static verification"
    task static_verification: %w[
      lint:static_verification_env
      dev:load
    ] do
      Gitlab::Utils::Override.verify!
    end

    desc "GitLab | lint | Lint JavaScript files using ESLint"
    task :javascript do
      Rake::Task['eslint'].invoke
    end

    desc "GitLab | lint | Run several lint checks"
    task :all do
      status = 0
      original_stdout = $stdout

      %w[
        config_lint
        haml_lint
        scss_lint
        flay
        gettext:lint
        lint:static_verification
      ].each do |task|
        begin
          $stdout = StringIO.new
          Rake::Task[task].invoke
        rescue RuntimeError, SystemExit => ex
          raise ex if ex.is_a?(RuntimeError) && task != 'haml_lint'
          original_stdout << $stdout.string
          status = 1
        ensure
          $stdout = original_stdout
        end
      end

      exit status
    end
  end
end