Commit e1a37112 authored by Mark Florian's avatar Mark Florian

Work around vue/one-component-per-file violations

We don't currently violate this rule at all, but the rule does find some
false positives due to a loose heuristic. This is tracked upstream as
https://github.com/vuejs/eslint-plugin-vue/issues/1411.

Addresses https://gitlab.com/gitlab-org/gitlab/-/issues/297217.
parent c66d7b5d
...@@ -51,7 +51,6 @@ rules: ...@@ -51,7 +51,6 @@ rules:
# new ones, to ease migration to v7, so violations of each can be fixed # new ones, to ease migration to v7, so violations of each can be fixed
# separately. # separately.
vue/no-mutating-props: off vue/no-mutating-props: off
vue/one-component-per-file: off
vue/no-lone-template: off vue/no-lone-template: off
vue/component-definition-name-casing: off vue/component-definition-name-casing: off
# END eslint-plugin-vue@7 overrides # END eslint-plugin-vue@7 overrides
......
<script> <script>
// Work around for https://github.com/vuejs/eslint-plugin-vue/issues/1411
/* eslint-disable vue/one-component-per-file */
import { GlDropdown } from '@gitlab/ui'; import { GlDropdown } from '@gitlab/ui';
import Tracking from '~/tracking'; import Tracking from '~/tracking';
import CodeInstruction from '~/vue_shared/components/registry/code_instruction.vue'; import CodeInstruction from '~/vue_shared/components/registry/code_instruction.vue';
......
<script> <script>
// Work around for https://github.com/vuejs/eslint-plugin-vue/issues/1411
/* eslint-disable vue/one-component-per-file */
import { GlIcon, GlTooltipDirective } from '@gitlab/ui'; import { GlIcon, GlTooltipDirective } from '@gitlab/ui';
import { __ } from '~/locale'; import { __ } from '~/locale';
import Tracking from '~/tracking'; import Tracking from '~/tracking';
......
<script> <script>
// Work around for https://github.com/vuejs/eslint-plugin-vue/issues/1411
/* eslint-disable vue/one-component-per-file */
import $ from 'jquery'; import $ from 'jquery';
import { GlLoadingIcon, GlIcon, GlTooltipDirective } from '@gitlab/ui'; import { GlLoadingIcon, GlIcon, GlTooltipDirective } from '@gitlab/ui';
import { __, s__ } from '~/locale'; import { __, s__ } from '~/locale';
......
...@@ -16,7 +16,7 @@ describe('Applications', () => { ...@@ -16,7 +16,7 @@ describe('Applications', () => {
gon.features = gon.features || {}; gon.features = gon.features || {};
}); });
const createApp = ({ applications, type, propsData } = {}, isShallow) => { const createComponent = ({ applications, type, propsData } = {}, isShallow) => {
const mountMethod = isShallow ? shallowMount : mount; const mountMethod = isShallow ? shallowMount : mount;
wrapper = mountMethod(Applications, { wrapper = mountMethod(Applications, {
...@@ -29,7 +29,7 @@ describe('Applications', () => { ...@@ -29,7 +29,7 @@ describe('Applications', () => {
}); });
}; };
const createShallowApp = (options) => createApp(options, true); const createShallowComponent = (options) => createComponent(options, true);
const findByTestId = (id) => wrapper.find(`[data-testid="${id}"]`); const findByTestId = (id) => wrapper.find(`[data-testid="${id}"]`);
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
...@@ -37,7 +37,7 @@ describe('Applications', () => { ...@@ -37,7 +37,7 @@ describe('Applications', () => {
describe('Project cluster applications', () => { describe('Project cluster applications', () => {
beforeEach(() => { beforeEach(() => {
createApp({ type: CLUSTER_TYPE.PROJECT }); createComponent({ type: CLUSTER_TYPE.PROJECT });
}); });
it('renders a row for Ingress', () => { it('renders a row for Ingress', () => {
...@@ -82,7 +82,7 @@ describe('Applications', () => { ...@@ -82,7 +82,7 @@ describe('Applications', () => {
describe('Group cluster applications', () => { describe('Group cluster applications', () => {
beforeEach(() => { beforeEach(() => {
createApp({ type: CLUSTER_TYPE.GROUP }); createComponent({ type: CLUSTER_TYPE.GROUP });
}); });
it('renders a row for Ingress', () => { it('renders a row for Ingress', () => {
...@@ -128,7 +128,7 @@ describe('Applications', () => { ...@@ -128,7 +128,7 @@ describe('Applications', () => {
describe('Instance cluster applications', () => { describe('Instance cluster applications', () => {
beforeEach(() => { beforeEach(() => {
createApp({ type: CLUSTER_TYPE.INSTANCE }); createComponent({ type: CLUSTER_TYPE.INSTANCE });
}); });
it('renders a row for Ingress', () => { it('renders a row for Ingress', () => {
...@@ -174,14 +174,14 @@ describe('Applications', () => { ...@@ -174,14 +174,14 @@ describe('Applications', () => {
describe('Helm application', () => { describe('Helm application', () => {
it('does not render a row for Helm Tiller', () => { it('does not render a row for Helm Tiller', () => {
createApp(); createComponent();
expect(wrapper.find('.js-cluster-application-row-helm').exists()).toBe(false); expect(wrapper.find('.js-cluster-application-row-helm').exists()).toBe(false);
}); });
}); });
describe('Ingress application', () => { describe('Ingress application', () => {
it('shows the correct warning message', () => { it('shows the correct warning message', () => {
createApp(); createComponent();
expect(findByTestId('ingressCostWarning').element).toMatchSnapshot(); expect(findByTestId('ingressCostWarning').element).toMatchSnapshot();
}); });
...@@ -195,7 +195,7 @@ describe('Applications', () => { ...@@ -195,7 +195,7 @@ describe('Applications', () => {
}, },
}; };
beforeEach(() => createShallowApp(propsData)); beforeEach(() => createShallowComponent(propsData));
it('renders IngressModsecuritySettings', () => { it('renders IngressModsecuritySettings', () => {
const modsecuritySettings = wrapper.find(IngressModsecuritySettings); const modsecuritySettings = wrapper.find(IngressModsecuritySettings);
...@@ -206,7 +206,7 @@ describe('Applications', () => { ...@@ -206,7 +206,7 @@ describe('Applications', () => {
describe('when installed', () => { describe('when installed', () => {
describe('with ip address', () => { describe('with ip address', () => {
it('renders ip address with a clipboard button', () => { it('renders ip address with a clipboard button', () => {
createApp({ createComponent({
applications: { applications: {
ingress: { ingress: {
title: 'Ingress', title: 'Ingress',
...@@ -225,7 +225,7 @@ describe('Applications', () => { ...@@ -225,7 +225,7 @@ describe('Applications', () => {
describe('with hostname', () => { describe('with hostname', () => {
it('renders hostname with a clipboard button', () => { it('renders hostname with a clipboard button', () => {
createApp({ createComponent({
applications: { applications: {
ingress: { ingress: {
title: 'Ingress', title: 'Ingress',
...@@ -255,7 +255,7 @@ describe('Applications', () => { ...@@ -255,7 +255,7 @@ describe('Applications', () => {
describe('without ip address', () => { describe('without ip address', () => {
it('renders an input text with a loading icon and an alert text', () => { it('renders an input text with a loading icon and an alert text', () => {
createApp({ createComponent({
applications: { applications: {
ingress: { ingress: {
title: 'Ingress', title: 'Ingress',
...@@ -272,7 +272,7 @@ describe('Applications', () => { ...@@ -272,7 +272,7 @@ describe('Applications', () => {
describe('before installing', () => { describe('before installing', () => {
it('does not render the IP address', () => { it('does not render the IP address', () => {
createApp(); createComponent();
expect(wrapper.text()).not.toContain('Ingress IP Address'); expect(wrapper.text()).not.toContain('Ingress IP Address');
expect(wrapper.find('.js-endpoint').exists()).toBe(false); expect(wrapper.find('.js-endpoint').exists()).toBe(false);
...@@ -282,13 +282,13 @@ describe('Applications', () => { ...@@ -282,13 +282,13 @@ describe('Applications', () => {
describe('Cert-Manager application', () => { describe('Cert-Manager application', () => {
it('shows the correct description', () => { it('shows the correct description', () => {
createApp(); createComponent();
expect(findByTestId('certManagerDescription').element).toMatchSnapshot(); expect(findByTestId('certManagerDescription').element).toMatchSnapshot();
}); });
describe('when not installed', () => { describe('when not installed', () => {
it('renders email & allows editing', () => { it('renders email & allows editing', () => {
createApp({ createComponent({
applications: { applications: {
cert_manager: { cert_manager: {
title: 'Cert-Manager', title: 'Cert-Manager',
...@@ -305,7 +305,7 @@ describe('Applications', () => { ...@@ -305,7 +305,7 @@ describe('Applications', () => {
describe('when installed', () => { describe('when installed', () => {
it('renders email in readonly', () => { it('renders email in readonly', () => {
createApp({ createComponent({
applications: { applications: {
cert_manager: { cert_manager: {
title: 'Cert-Manager', title: 'Cert-Manager',
...@@ -324,7 +324,7 @@ describe('Applications', () => { ...@@ -324,7 +324,7 @@ describe('Applications', () => {
describe('Jupyter application', () => { describe('Jupyter application', () => {
describe('with ingress installed with ip & jupyter installable', () => { describe('with ingress installed with ip & jupyter installable', () => {
it('renders hostname active input', () => { it('renders hostname active input', () => {
createApp({ createComponent({
applications: { applications: {
ingress: { ingress: {
title: 'Ingress', title: 'Ingress',
...@@ -342,7 +342,7 @@ describe('Applications', () => { ...@@ -342,7 +342,7 @@ describe('Applications', () => {
describe('with ingress installed without external ip', () => { describe('with ingress installed without external ip', () => {
it('does not render hostname input', () => { it('does not render hostname input', () => {
createApp({ createComponent({
applications: { applications: {
ingress: { title: 'Ingress', status: 'installed' }, ingress: { title: 'Ingress', status: 'installed' },
}, },
...@@ -356,7 +356,7 @@ describe('Applications', () => { ...@@ -356,7 +356,7 @@ describe('Applications', () => {
describe('with ingress & jupyter installed', () => { describe('with ingress & jupyter installed', () => {
it('renders readonly input', () => { it('renders readonly input', () => {
createApp({ createComponent({
applications: { applications: {
ingress: { ingress: {
title: 'Ingress', title: 'Ingress',
...@@ -375,7 +375,7 @@ describe('Applications', () => { ...@@ -375,7 +375,7 @@ describe('Applications', () => {
describe('without ingress installed', () => { describe('without ingress installed', () => {
beforeEach(() => { beforeEach(() => {
createApp(); createComponent();
}); });
it('does not render input', () => { it('does not render input', () => {
...@@ -388,7 +388,7 @@ describe('Applications', () => { ...@@ -388,7 +388,7 @@ describe('Applications', () => {
describe('Prometheus application', () => { describe('Prometheus application', () => {
it('shows the correct description', () => { it('shows the correct description', () => {
createApp(); createComponent();
expect(findByTestId('prometheusDescription').element).toMatchSnapshot(); expect(findByTestId('prometheusDescription').element).toMatchSnapshot();
}); });
}); });
...@@ -414,14 +414,14 @@ describe('Applications', () => { ...@@ -414,14 +414,14 @@ describe('Applications', () => {
let knativeDomainEditor; let knativeDomainEditor;
beforeEach(() => { beforeEach(() => {
createShallowApp(propsData); createShallowComponent(propsData);
jest.spyOn(eventHub, '$emit'); jest.spyOn(eventHub, '$emit');
knativeDomainEditor = wrapper.find(KnativeDomainEditor); knativeDomainEditor = wrapper.find(KnativeDomainEditor);
}); });
it('shows the correct description', async () => { it('shows the correct description', async () => {
createApp(); createComponent();
wrapper.setProps({ wrapper.setProps({
providerType: PROVIDER_TYPE.GCP, providerType: PROVIDER_TYPE.GCP,
preInstalledKnative: true, preInstalledKnative: true,
...@@ -487,7 +487,7 @@ describe('Applications', () => { ...@@ -487,7 +487,7 @@ describe('Applications', () => {
}, },
}; };
beforeEach(() => createShallowApp(propsData)); beforeEach(() => createShallowComponent(propsData));
it('renders the correct Component', () => { it('renders the correct Component', () => {
const crossplane = wrapper.find(CrossplaneProviderStack); const crossplane = wrapper.find(CrossplaneProviderStack);
...@@ -495,7 +495,7 @@ describe('Applications', () => { ...@@ -495,7 +495,7 @@ describe('Applications', () => {
}); });
it('shows the correct description', () => { it('shows the correct description', () => {
createApp(); createComponent();
expect(findByTestId('crossplaneDescription').element).toMatchSnapshot(); expect(findByTestId('crossplaneDescription').element).toMatchSnapshot();
}); });
}); });
...@@ -503,7 +503,7 @@ describe('Applications', () => { ...@@ -503,7 +503,7 @@ describe('Applications', () => {
describe('Elastic Stack application', () => { describe('Elastic Stack application', () => {
describe('with elastic stack installable', () => { describe('with elastic stack installable', () => {
it('renders the install button enabled', () => { it('renders the install button enabled', () => {
createApp(); createComponent();
expect( expect(
wrapper wrapper
...@@ -517,7 +517,7 @@ describe('Applications', () => { ...@@ -517,7 +517,7 @@ describe('Applications', () => {
describe('elastic stack installed', () => { describe('elastic stack installed', () => {
it('renders uninstall button', () => { it('renders uninstall button', () => {
createApp({ createComponent({
applications: { applications: {
elastic_stack: { title: 'Elastic Stack', status: 'installed' }, elastic_stack: { title: 'Elastic Stack', status: 'installed' },
}, },
...@@ -535,7 +535,7 @@ describe('Applications', () => { ...@@ -535,7 +535,7 @@ describe('Applications', () => {
}); });
describe('Fluentd application', () => { describe('Fluentd application', () => {
beforeEach(() => createShallowApp()); beforeEach(() => createShallowComponent());
it('renders the correct Component', () => { it('renders the correct Component', () => {
expect(wrapper.find(FluentdOutputSettings).exists()).toBe(true); expect(wrapper.find(FluentdOutputSettings).exists()).toBe(true);
...@@ -544,7 +544,7 @@ describe('Applications', () => { ...@@ -544,7 +544,7 @@ describe('Applications', () => {
describe('Cilium application', () => { describe('Cilium application', () => {
it('shows the correct description', () => { it('shows the correct description', () => {
createApp({ propsData: { ciliumHelpPath: 'cilium-help-path' } }); createComponent({ propsData: { ciliumHelpPath: 'cilium-help-path' } });
expect(findByTestId('ciliumDescription').element).toMatchSnapshot(); expect(findByTestId('ciliumDescription').element).toMatchSnapshot();
}); });
}); });
......
// Work around for https://github.com/vuejs/eslint-plugin-vue/issues/1411
/* eslint-disable vue/one-component-per-file */
import { setHTMLFixture } from 'helpers/fixtures'; import { setHTMLFixture } from 'helpers/fixtures';
import Tracking, { initUserTracking, initDefaultTrackers } from '~/tracking'; import Tracking, { initUserTracking, initDefaultTrackers } from '~/tracking';
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment