Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
Add rules for linting import order
Browse files Browse the repository at this point in the history
  • Loading branch information
sarayourfriend committed Feb 23, 2022
1 parent b417483 commit 195a096
Show file tree
Hide file tree
Showing 150 changed files with 409 additions and 142 deletions.
56 changes: 56 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,62 @@ module.exports = {
ignore: ['.svg'],
},
],
'import/newline-after-import': ['error'],
'import/order': [
'error',
{
'newlines-between': 'always-and-inside-groups',
groups: [
'builtin',
'external',
'internal',
'parent',
'sibling',
'index',
'object',
'type',
],
pathGroups: [
{
// Treate vue and composition-api as "builtin"
pattern: '(vue|@nuxtjs/composition-api)',
group: 'builtin',
position: 'before',
},
{
// Move assets to the very end of the imports list
pattern: 'assets/**',
patternOptions: { partial: true },
group: 'type',
position: 'after',
},
{
// Treat components as their own group and move to the end of the internal imports list
pattern: '~/components/**',
group: 'parent',
position: 'before',
},
/**
* These next two must come after any more specific matchers
* as the plugin uses the patterns in order and does not sort
* multiple-matches by specificity, it just takes the _first_
* pattern that matches and applies that group to the import.
*/
{
// Document webpack alias
pattern: '~/**',
group: 'internal',
position: 'before',
},
{
// Document webpack alias
pattern: '~~/**',
group: 'external',
position: 'after',
},
],
},
],
},
settings: {
'vue-i18n': {
Expand Down
2 changes: 2 additions & 0 deletions src/components/DownloadButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@
<script>
import filesize from 'filesize'
import axios from 'axios'
import local from '~/utils/local'
import DropdownButton from '~/components/DropdownButton.vue'
import VLink from '~/components/VLink.vue'
Expand Down
4 changes: 3 additions & 1 deletion src/components/DropdownButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@

<script>
import { defineComponent } from '@nuxtjs/composition-api'
import caretDown from '~/assets/icons/caret-down.svg'
import * as keycodes from '~/utils/key-codes'
import caretDown from '~/assets/icons/caret-down.svg'
const DropdownButton = defineComponent({
name: 'DropdownButton',
props: {
Expand Down
1 change: 1 addition & 0 deletions src/components/ImageDetails/ReuseSurvey.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
DETAIL_PAGE_EVENTS,
} from '~/constants/usage-data-analytics-types'
import { USAGE_DATA } from '~/constants/store-modules'
import VLink from '~/components/VLink.vue'
const reuseForm =
Expand Down
4 changes: 2 additions & 2 deletions src/components/License/VLicense.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
<script>
import { computed, useContext } from '@nuxtjs/composition-api'
import VIcon from '~/components/VIcon/VIcon.vue'
import {
ALL_LICENSES,
CC_LICENSES,
Expand All @@ -43,6 +41,8 @@ import nd from '~/assets/licenses/nd.svg'
import pdm from '~/assets/licenses/pdm.svg'
import sa from '~/assets/licenses/sa.svg'
import VIcon from '~/components/VIcon/VIcon.vue'
/**
* Displays the icons for the license along with a readable display name for the
* license.
Expand Down
4 changes: 2 additions & 2 deletions src/components/VAllResultsGrid/VAllResultsGrid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@
<script>
import { computed, defineComponent, useContext } from '@nuxtjs/composition-api'
import srand from '~/utils/srand'
import VImageCell from '~/components/VAllResultsGrid/VImageCell.vue'
import VAudioCell from '~/components/VAllResultsGrid/VAudioCell.vue'
import VLoadMore from '~/components/VLoadMore.vue'
import VContentLink from '~/components/VContentLink/VContentLink.vue'
import VGridSkeleton from '~/components/VSkeleton/VGridSkeleton.vue'
import srand from '~/utils/srand'
export default defineComponent({
name: 'VAllResultsGrid',
components: {
Expand Down
1 change: 1 addition & 0 deletions src/components/VAllResultsGrid/VAudioCell.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<script>
import { useContext, useRouter } from '@nuxtjs/composition-api'
import { defineComponent } from '@vue/composition-api'
import VAudioTrack from '~/components/VAudioTrack/VAudioTrack.vue'
export default defineComponent({
Expand Down
1 change: 1 addition & 0 deletions src/components/VAllResultsGrid/VImageCell.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

<script>
import VLicense from '~/components/License/VLicense.vue'
const errorImage = require('~/assets/image_not_available_placeholder.png')
const toAbsolutePath = (url, prefix = 'https://') => {
Expand Down
7 changes: 5 additions & 2 deletions src/components/VAudioDetails/VAudioDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,12 @@
</template>

<script>
import getProviderName from '~/utils/get-provider-name'
import { PROVIDER } from '~/constants/store-modules'
import { mapState } from 'vuex'
import { PROVIDER } from '~/constants/store-modules'
import getProviderName from '~/utils/get-provider-name'
import VLink from '~/components/VLink.vue'
import VAudioThumbnail from '~/components/VAudioThumbnail/VAudioThumbnail.vue'
import VMediaTag from '~/components/VMediaTag/VMediaTag.vue'
Expand Down
5 changes: 4 additions & 1 deletion src/components/VAudioDetails/VRelatedAudio.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@

<script>
import { computed, ref } from '@nuxtjs/composition-api'
import { AUDIO } from '~/constants/media'
import useRelated from '~/composables/use-related'
import { isMinScreen } from '~/composables/use-media-query'
import VAudioTrack from '~/components/VAudioTrack/VAudioTrack.vue'
import LoadingIcon from '~/components/LoadingIcon.vue'
import VAudioTrack from '~/components/VAudioTrack/VAudioTrack.vue'
export default {
name: 'VRelatedAudio',
components: { VAudioTrack, LoadingIcon },
Expand Down
13 changes: 7 additions & 6 deletions src/components/VAudioTrack/VAudioTrack.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ import {
import { useActiveAudio } from '~/composables/use-active-audio'
import { ACTIVE, MEDIA } from '~/constants/store-modules'
import {
PAUSE_ACTIVE_MEDIA_ITEM,
SET_ACTIVE_MEDIA_ITEM,
} from '~/constants/mutation-types'
import VPlayPause from '~/components/VAudioTrack/VPlayPause.vue'
import VWaveform from '~/components/VAudioTrack/VWaveform.vue'
Expand All @@ -58,12 +65,6 @@ import VRowLayout from '~/components/VAudioTrack/layouts/VRowLayout.vue'
import VBoxLayout from '~/components/VAudioTrack/layouts/VBoxLayout.vue'
import VGlobalLayout from '~/components/VAudioTrack/layouts/VGlobalLayout.vue'
import { ACTIVE, MEDIA } from '~/constants/store-modules'
import {
PAUSE_ACTIVE_MEDIA_ITEM,
SET_ACTIVE_MEDIA_ITEM,
} from '~/constants/mutation-types'
const propTypes = {
/**
* the information about the track, typically from a track's detail endpoint
Expand Down
4 changes: 2 additions & 2 deletions src/components/VAudioTrack/VPlayPause.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
<script>
import { defineComponent } from '@nuxtjs/composition-api'
import VIconButton from '~/components/VIconButton/VIconButton.vue'
import playIcon from '~/assets/icons/play.svg'
import pauseIcon from '~/assets/icons/pause.svg'
import replayIcon from '~/assets/icons/replay.svg'
import VIconButton from '~/components/VIconButton/VIconButton.vue'
/**
* Displays the control for switching between the playing and paused states of
* a media file.
Expand Down
1 change: 1 addition & 0 deletions src/components/VAudioTrack/VWaveform.vue
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ import {
onMounted,
ref,
} from '@nuxtjs/composition-api'
import { downsampleArray, upsampleArray } from '~/utils/resampling'
import * as keycodes from '~/utils/key-codes'
Expand Down
1 change: 1 addition & 0 deletions src/components/VAudioTrack/layouts/VRowLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@

<script>
import { computed, defineComponent, useContext } from '@nuxtjs/composition-api'
import { useBrowserIsBlink } from '~/composables/use-browser-detection'
import VAudioThumbnail from '~/components/VAudioThumbnail/VAudioThumbnail.vue'
Expand Down
1 change: 1 addition & 0 deletions src/components/VBackToSearchResultsLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

<script>
import { defineComponent } from '@vue/composition-api'
import Chevron from '~/assets/icons/chevron-left.svg?inline'
export default defineComponent({
Expand Down
4 changes: 3 additions & 1 deletion src/components/VButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ import {
toRefs,
computed,
} from '@nuxtjs/composition-api'
import VLink from '~/components/VLink.vue'
import { warn } from '~/utils/warn'
import VLink from '~/components/VLink.vue'
/**
* A button component that behaves just like a regular HTML `button` element
* aside from pre-applied styles based on the passed in variant.
Expand Down
3 changes: 2 additions & 1 deletion src/components/VCheckbox/VCheckbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
</template>

<script>
import Checkmark from '~/assets/icons/checkmark.svg?inline'
import { computed, defineComponent, ref, watch } from '@nuxtjs/composition-api'
import Checkmark from '~/assets/icons/checkmark.svg?inline'
const VCheckbox = defineComponent({
name: 'VCheckbox',
components: { Checkmark },
Expand Down
4 changes: 3 additions & 1 deletion src/components/VContentLink/VContentLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@

<script>
import { computed, defineComponent } from '@nuxtjs/composition-api'
import { useI18nResultsCount } from '~/composables/use-i18n-utilities'
import { AUDIO, IMAGE, supportedMediaTypes } from '~/constants/media'
import VIcon from '~/components/VIcon/VIcon.vue'
import audioIcon from '~/assets/icons/audio-wave.svg'
import imageIcon from '~/assets/icons/image.svg'
import VIcon from '~/components/VIcon/VIcon.vue'
const iconMapping = {
[AUDIO]: audioIcon,
[IMAGE]: imageIcon,
Expand Down
4 changes: 2 additions & 2 deletions src/components/VContentReport/VContentReportButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
<script>
import { defineComponent } from '@nuxtjs/composition-api'
import VIcon from '~/components/VIcon/VIcon.vue'
import flagIcon from '~/assets/icons/flag.svg'
import VIcon from '~/components/VIcon/VIcon.vue'
export default defineComponent({
name: 'VContentReportButton',
components: { VIcon },
Expand Down
12 changes: 6 additions & 6 deletions src/components/VContentReport/VContentReportForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,19 @@
<script>
import { computed, defineComponent, ref } from '@nuxtjs/composition-api'
import ReportService from '~/data/report-service'
import { reasons, statuses, DMCA_FORM_URL } from '~/constants/content-report'
import externalLinkIcon from '~/assets/icons/external-link.svg'
import VButton from '~/components/VButton.vue'
import VIcon from '~/components/VIcon/VIcon.vue'
import VRadio from '~/components/VRadio/VRadio.vue'
import VDmcaNotice from '~/components/VContentReport/VDmcaNotice.vue'
import VReportDescForm from '~/components/VContentReport/VReportDescForm.vue'
import VLink from '~/components/VLink.vue'
import ReportService from '~/data/report-service'
import { reasons, statuses, DMCA_FORM_URL } from '~/constants/content-report'
import externalLinkIcon from '~/assets/icons/external-link.svg'
export default defineComponent({
name: 'VContentReportForm',
components: {
Expand Down
7 changes: 4 additions & 3 deletions src/components/VContentReport/VContentReportPopover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@
<script>
import { computed, useStore, defineComponent } from '@nuxtjs/composition-api'
import VPopover from '~/components/VPopover/VPopover.vue'
import VContentReportButton from '~/components/VContentReport/VContentReportButton.vue'
import flagIcon from '~/assets/icons/flag.svg'
import closeSmallIcon from '~/assets/icons/close-small.svg'
import VPopover from '~/components/VPopover/VPopover.vue'
import VContentReportButton from '~/components/VContentReport/VContentReportButton.vue'
export default defineComponent({
name: 'VContentReportPopover',
components: { VPopover, VContentReportButton },
Expand Down
1 change: 1 addition & 0 deletions src/components/VContentReport/VDmcaNotice.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import { defineComponent } from '@nuxtjs/composition-api'
import { DMCA_FORM_URL } from '~/constants/content-report'
import VLink from '~/components/VLink.vue'
export default defineComponent({
Expand Down
1 change: 1 addition & 0 deletions src/components/VContentReport/VReportDescForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

<script>
import { computed, defineComponent } from '@nuxtjs/composition-api'
import { reasons } from '~/constants/content-report'
export default defineComponent({
Expand Down
7 changes: 5 additions & 2 deletions src/components/VContentSwitcher/VMobileMenuModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,13 @@ import {
ref,
watch,
} from '@nuxtjs/composition-api'
import { useBodyScrollLock } from '~/composables/use-body-scroll-lock'
import useSearchType from '~/composables/use-search-type'
import usePages from '~/composables/use-pages'
import useSearchType from '~/composables/use-search-type'
import { useBodyScrollLock } from '~/composables/use-body-scroll-lock'
import VMobileModalContent from '~/components/VModal/VMobileModalContent.vue'
import VSearchTypes from '~/components/VContentSwitcher/VSearchTypes.vue'
import VPageList from '~/components/VHeader/VPageMenu/VPageList.vue'
Expand Down
6 changes: 4 additions & 2 deletions src/components/VContentSwitcher/VSearchTypeButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,23 @@
</VButton>
</template>
<script>
import { ALL_MEDIA, supportedSearchTypes } from '~/constants/media'
import {
computed,
defineComponent,
inject,
useContext,
} from '@nuxtjs/composition-api'
import { ALL_MEDIA, supportedSearchTypes } from '~/constants/media'
import useSearchType from '~/composables/use-search-type'
import { isMinScreen } from '~/composables/use-media-query'
import caretDownIcon from '~/assets/icons/caret-down.svg'
import VButton from '~/components/VButton.vue'
import VIcon from '~/components/VIcon/VIcon.vue'
import VButton from '~/components/VButton.vue'
export default defineComponent({
name: 'VSearchTypeButton',
components: { VButton, VIcon },
Expand Down
Loading

0 comments on commit 195a096

Please sign in to comment.