Skip to content

Sort JS imports in the EE specs

Vitaly Slobodin requested to merge vs-sort-js-importa-in-ee-specs into master

What does this MR do?

Sort all imports by their groups. This is the 4th MR from 4 to address the issue.

Example

Without path group this order considered as valid

import { GlIcon } from '@gitlab/ui';
import $ from 'jquery';
import '~/behaviors/markdown/render_gfm';
import { unescape } from 'lodash';
import MarkdownHeader from './header.vue'; // not okay
import MarkdownToolbar from './toolbar.vue'; // not okay
import { deprecatedCreateFlash as Flash } from '~/flash';
import GLForm from '~/gl_form';
import axios from '~/lib/utils/axios_utils';
import { stripHtml } from '~/lib/utils/text_utility';
import { __, sprintf } from '~/locale';
import GlMentions from '~/vue_shared/components/gl_mentions.vue';
import Suggestions from '~/vue_shared/components/markdown/suggestions.vue';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';

With path group this order will be transformed to

import { GlIcon } from '@gitlab/ui';
import $ from 'jquery';
import '~/behaviors/markdown/render_gfm';
import { unescape } from 'lodash';
import { deprecatedCreateFlash as Flash } from '~/flash';
import GLForm from '~/gl_form';
import axios from '~/lib/utils/axios_utils';
import { stripHtml } from '~/lib/utils/text_utility';
import { __, sprintf } from '~/locale';
import GlMentions from '~/vue_shared/components/gl_mentions.vue';
import Suggestions from '~/vue_shared/components/markdown/suggestions.vue';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import MarkdownHeader from './header.vue';
import MarkdownToolbar from './toolbar.vue';

ESLint configuration used:

{
  "rules": {
    "import/order": [
      "error",
      {
        "groups": ["builtin", "external", "internal", "parent", "sibling", "index"],
        "pathGroups": [
          {
            "pattern": "~/**",
            "group": "internal"
          },
          {
            "pattern": "ee_else_ce/**",
            "group": "internal"
          },
          {
            "pattern": "emojis/**",
            "group": "internal"
          },
          {
            "pattern": "empty_states/**",
            "group": "internal"
          },
          {
            "pattern": "icons/**",
            "group": "internal"
          },
          {
            "pattern": "images/**",
            "group": "internal"
          },
          {
            "pattern": "vendor/**",
            "group": "internal"
          },
          {
            "pattern": "shared_queries/**",
            "group": "internal"
          },
          {
            "pattern": "ee/**",
            "group": "internal"
          },
          {
            "pattern": "ee_component/**",
            "group": "internal"
          },
          {
            "pattern": "ee_empty_states/**",
            "group": "internal"
          },
          {
            "pattern": "ee_icons/**",
            "group": "internal"
          },
          {
            "pattern": "ee_images/**",
            "group": "internal"
          }
        ]
      }
    ]
  }
}

All aliases were pulled from our Webpack configuration.

Screenshots (strongly suggested)

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Vitaly Slobodin

Merge request reports