Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
47efbe732c
commit
a5185ab986
|
@ -8,8 +8,9 @@ exclude:
|
||||||
- 'spec/**/*'
|
- 'spec/**/*'
|
||||||
- 'ee/spec/**/*'
|
- 'ee/spec/**/*'
|
||||||
require:
|
require:
|
||||||
- './haml_lint/linter/no_plain_nodes.rb'
|
|
||||||
- './haml_lint/linter/documentation_links.rb'
|
- './haml_lint/linter/documentation_links.rb'
|
||||||
|
- './haml_lint/linter/inline_javascript.rb'
|
||||||
|
- './haml_lint/linter/no_plain_nodes.rb'
|
||||||
|
|
||||||
linters:
|
linters:
|
||||||
AltText:
|
AltText:
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
unless Rails.env.production?
|
|
||||||
require 'haml_lint/haml_visitor'
|
|
||||||
require 'haml_lint/linter'
|
|
||||||
require 'haml_lint/linter_registry'
|
|
||||||
|
|
||||||
module HamlLint
|
|
||||||
class Linter::InlineJavaScript < Linter
|
|
||||||
include ::HamlLint::LinterRegistry
|
|
||||||
|
|
||||||
def visit_filter(node)
|
|
||||||
return unless node.filter_type == 'javascript'
|
|
||||||
|
|
||||||
record_lint(node, 'Inline JavaScript is discouraged (https://docs.gitlab.com/ee/development/gotchas.html#do-not-use-inline-javascript-in-views)')
|
|
||||||
end
|
|
||||||
|
|
||||||
def visit_tag(node)
|
|
||||||
return unless node.tag_name == 'script'
|
|
||||||
|
|
||||||
record_lint(node, 'Inline JavaScript is discouraged (https://docs.gitlab.com/ee/development/gotchas.html#do-not-use-inline-javascript-in-views)')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module HamlLint
|
||||||
|
class Linter
|
||||||
|
class InlineJavaScript < Linter
|
||||||
|
include ::HamlLint::LinterRegistry
|
||||||
|
|
||||||
|
MSG = 'Inline JavaScript is discouraged (https://docs.gitlab.com/ee/development/gotchas.html#do-not-use-inline-javascript-in-views)'
|
||||||
|
|
||||||
|
def visit_filter(node)
|
||||||
|
return unless node.filter_type == 'javascript'
|
||||||
|
|
||||||
|
record_lint(node, MSG)
|
||||||
|
end
|
||||||
|
|
||||||
|
def visit_tag(node)
|
||||||
|
return unless node.tag_name == 'script'
|
||||||
|
|
||||||
|
record_lint(node, MSG)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
unless Rails.env.production?
|
unless Rails.env.production?
|
||||||
require 'haml_lint/rake_task'
|
require 'haml_lint/rake_task'
|
||||||
require Rails.root.join('haml_lint/inline_javascript')
|
|
||||||
|
|
||||||
HamlLint::RakeTask.new
|
HamlLint::RakeTask.new
|
||||||
end
|
end
|
||||||
|
|
|
@ -133,6 +133,8 @@ RSpec.describe "Admin > Admin sees background migrations" do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'can change tabs and retain database param' do
|
it 'can change tabs and retain database param' do
|
||||||
|
skip_if_multiple_databases_not_setup
|
||||||
|
|
||||||
visit admin_background_migrations_path(database: 'ci')
|
visit admin_background_migrations_path(database: 'ci')
|
||||||
|
|
||||||
within '#content-body' do
|
within '#content-body' do
|
||||||
|
@ -157,6 +159,8 @@ RSpec.describe "Admin > Admin sees background migrations" do
|
||||||
describe 'selected database toggle', :js do
|
describe 'selected database toggle', :js do
|
||||||
context 'when multi database is not enabled' do
|
context 'when multi database is not enabled' do
|
||||||
before do
|
before do
|
||||||
|
skip_if_multiple_databases_are_setup
|
||||||
|
|
||||||
allow(Gitlab::Database).to receive(:db_config_names).and_return(['main'])
|
allow(Gitlab::Database).to receive(:db_config_names).and_return(['main'])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -169,6 +173,8 @@ RSpec.describe "Admin > Admin sees background migrations" do
|
||||||
|
|
||||||
context 'when multi database is enabled' do
|
context 'when multi database is enabled' do
|
||||||
before do
|
before do
|
||||||
|
skip_if_multiple_databases_not_setup
|
||||||
|
|
||||||
allow(Gitlab::Database).to receive(:db_config_names).and_return(%w[main ci])
|
allow(Gitlab::Database).to receive(:db_config_names).and_return(%w[main ci])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'spec_helper'
|
require 'fast_spec_helper'
|
||||||
require 'haml_lint'
|
require 'haml_lint'
|
||||||
require 'haml_lint/spec'
|
require 'haml_lint/spec'
|
||||||
require Rails.root.join('haml_lint/linter/documentation_links')
|
|
||||||
|
require_relative '../../../haml_lint/linter/documentation_links'
|
||||||
|
|
||||||
RSpec.describe HamlLint::Linter::DocumentationLinks do
|
RSpec.describe HamlLint::Linter::DocumentationLinks do
|
||||||
include_context 'linter'
|
include_context 'linter'
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'fast_spec_helper'
|
||||||
|
require 'haml_lint'
|
||||||
|
require 'haml_lint/spec'
|
||||||
|
require 'rspec-parameterized'
|
||||||
|
|
||||||
|
require_relative '../../../haml_lint/linter/inline_javascript'
|
||||||
|
|
||||||
|
RSpec.describe HamlLint::Linter::InlineJavaScript do # rubocop:disable RSpec/FilePath
|
||||||
|
using RSpec::Parameterized::TableSyntax
|
||||||
|
|
||||||
|
include_context 'linter'
|
||||||
|
|
||||||
|
let(:message) { described_class::MSG }
|
||||||
|
|
||||||
|
where(:haml, :should_report) do
|
||||||
|
'%script' | true
|
||||||
|
'%javascript' | false
|
||||||
|
':javascript' | true
|
||||||
|
':markdown' | false
|
||||||
|
end
|
||||||
|
|
||||||
|
with_them do
|
||||||
|
if params[:should_report]
|
||||||
|
it { is_expected.to report_lint message: message }
|
||||||
|
else
|
||||||
|
it { is_expected.not_to report_lint }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,9 +1,10 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'spec_helper'
|
require 'fast_spec_helper'
|
||||||
require 'haml_lint'
|
require 'haml_lint'
|
||||||
require 'haml_lint/spec'
|
require 'haml_lint/spec'
|
||||||
require Rails.root.join('haml_lint/linter/no_plain_nodes')
|
|
||||||
|
require_relative '../../../haml_lint/linter/no_plain_nodes'
|
||||||
|
|
||||||
RSpec.describe HamlLint::Linter::NoPlainNodes do
|
RSpec.describe HamlLint::Linter::NoPlainNodes do
|
||||||
include_context 'linter'
|
include_context 'linter'
|
||||||
|
|
Loading…
Reference in New Issue