Commit 3a991363 authored by Mike Greiling's avatar Mike Greiling

Merge branch '63560-add-vue-i18n-eslint' into 'master'

Add ESLint vue rules to detect vue i18n offences

Closes #63560

See merge request gitlab-org/gitlab-ce!31124
parents 83f68719 834f1f97
......@@ -10,12 +10,15 @@ plugins:
- import
- html
- "@gitlab/i18n"
- "@gitlab/vue-i18n"
settings:
import/resolver:
webpack:
config: './config/webpack.config.js'
rules:
"@gitlab/i18n/no-non-i18n-strings": error
"@gitlab/vue-i18n/no-bare-strings": error
"@gitlab/vue-i18n/no-bare-attribute-strings": error
import/no-commonjs: error
no-underscore-dangle:
- error
......@@ -36,9 +39,6 @@ rules:
vue/use-v-on-exact: off
overrides:
files:
# Vue is temporarily being disabled until the autofix errors are resolved
# Follow up issue https://gitlab.com/gitlab-org/gitlab-ce/issues/57969
- '*.vue'
- '**/spec/**/*'
rules:
"@gitlab/i18n/no-non-i18n-strings": off
......@@ -3,6 +3,8 @@ import Icon from '~/vue_shared/components/icon.vue';
import { GlLoadingIcon, GlTooltipDirective } from '@gitlab/ui';
export default {
// name: 'Badge' is a false positive: https://gitlab.com/gitlab-org/frontend/eslint-plugin-i18n/issues/25
// eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings
name: 'Badge',
components: {
Icon,
......
<script>
/* eslint-disable @gitlab/vue-i18n/no-bare-strings */
import Sortable from 'sortablejs';
import { GlLoadingIcon } from '@gitlab/ui';
import boardNewIssue from './board_new_issue.vue';
......
<script>
/* eslint-disable @gitlab/vue-i18n/no-bare-strings */
import { __ } from '~/locale';
import ModalFilters from './filters';
import ModalTabs from './tabs.vue';
......
<script>
/* eslint-disable @gitlab/vue-i18n/no-bare-strings */
import ModalStore from '../../stores/modal_store';
import modalMixin from '../../mixins/modal_mixins';
......
<script>
/* eslint-disable vue/require-default-prop */
/* eslint-disable @gitlab/vue-i18n/no-bare-strings */
import { GlLink, GlModalDirective } from '@gitlab/ui';
import TimeagoTooltip from '../../vue_shared/components/time_ago_tooltip.vue';
import { s__, __, sprintf } from '~/locale';
......
......@@ -49,8 +49,8 @@ export default {
return this.author.id ? this.author.id : '';
},
authorUrl() {
// TODO: when the vue i18n rules are merged need to disable @gitlab/i18n/no-non-i18n-strings
// name: 'mailto:' is a false positive: https://gitlab.com/gitlab-org/frontend/eslint-plugin-i18n/issues/26#possible-false-positives
// eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings
return this.author.web_url || `mailto:${this.commit.author_email}`;
},
authorAvatar() {
......
<script>
/* eslint-disable @gitlab/vue-i18n/no-bare-strings */
import { mapActions, mapGetters, mapState } from 'vuex';
import { GlTooltipDirective, GlLink, GlButton } from '@gitlab/ui';
import { __ } from '~/locale';
......
<script>
/* eslint-disable @gitlab/vue-i18n/no-bare-strings */
export default {
props: {
total: {
......
<script>
/* eslint-disable @gitlab/vue-i18n/no-bare-strings */
import { __, sprintf } from '~/locale';
import Timeago from 'timeago.js';
import _ from 'underscore';
......@@ -286,9 +287,9 @@ export default {
* @returns {Boolean|Undefined}
*/
isLastDeployment() {
// TODO: when the vue i18n rules are merged need to disable @gitlab/i18n/no-non-i18n-strings
// name: 'last?' is a false positive: https://gitlab.com/gitlab-org/frontend/eslint-plugin-i18n/issues/26#possible-false-positives
// Vue i18n ESLint rules issue: https://gitlab.com/gitlab-org/gitlab-ce/issues/63560
// eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings
return this.model && this.model.last_deployment && this.model.last_deployment['last?'];
},
......
<script>
/* eslint-disable @gitlab/vue-i18n/no-bare-strings */
import { GlTooltipDirective } from '@gitlab/ui';
import GlModal from '~/vue_shared/components/gl_modal.vue';
import { s__, sprintf } from '~/locale';
......
......@@ -36,12 +36,14 @@ export default {
<label class="label-bold" for="error-tracking-api-host">{{ __('Sentry API URL') }}</label>
<div class="row">
<div class="col-8 col-md-9 gl-pr-0">
<!-- eslint-disable @gitlab/vue-i18n/no-bare-attribute-strings -->
<gl-form-input
id="error-tracking-api-host"
:value="apiHost"
placeholder="https://mysentryserver.com"
@input="$emit('update-api-host', $event)"
/>
<!-- eslint-enable @gitlab/vue-i18n/no-bare-attribute-strings -->
</div>
</div>
<p class="form-text text-muted">
......
<script>
/* eslint-disable @gitlab/vue-i18n/no-bare-strings */
import Icon from '~/vue_shared/components/icon.vue';
import Timeago from '~/vue_shared/components/time_ago_tooltip.vue';
import router from '../../ide_router';
......
......@@ -45,6 +45,8 @@ export default {
},
computed: {
iconName() {
// name: '-solid' is a false positive: https://gitlab.com/gitlab-org/frontend/eslint-plugin-i18n/issues/26#possible-false-positives
// eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings
const suffix = this.stagedList ? '-solid' : '';
return `${getCommitIconMap(this.file).icon}${suffix}`;
......
<script>
/* eslint-disable @gitlab/vue-i18n/no-bare-strings */
import { mapActions, mapState, mapGetters } from 'vuex';
import IdeStatusList from 'ee_else_ce/ide/components/ide_status_list.vue';
import icon from '~/vue_shared/components/icon.vue';
......
<script>
/* eslint-disable @gitlab/vue-i18n/no-bare-strings */
import _ from 'underscore';
import { GlLink, GlTooltip, GlTooltipDirective } from '@gitlab/ui';
import { __ } from '~/locale';
......
<script>
/* eslint-disable @gitlab/vue-i18n/no-bare-strings */
import { __, sprintf } from '~/locale';
import updateMixin from '../mixins/update';
import eventHub from '../event_hub';
......
<script>
/* eslint-disable @gitlab/vue-i18n/no-bare-strings */
import timeAgoTooltip from '../../vue_shared/components/time_ago_tooltip.vue';
export default {
......
<script>
/* eslint-disable @gitlab/vue-i18n/no-bare-strings */
import $ from 'jquery';
import IssuableTemplateSelectors from '../../../templates/issuable_template_selectors';
......
<script>
/* eslint-disable @gitlab/vue-i18n/no-bare-strings */
import { GlLink } from '@gitlab/ui';
import ClipboardButton from '~/vue_shared/components/clipboard_button.vue';
......
<script>
/* eslint-disable @gitlab/vue-i18n/no-bare-strings */
import { GlPopover, GlSkeletonLoading } from '@gitlab/ui';
import Icon from '../../vue_shared/components/icon.vue';
import CiIcon from '../../vue_shared/components/ci_icon.vue';
......@@ -7,7 +8,8 @@ import query from '../queries/merge_request.query.graphql';
import { mrStates, humanMRStates } from '../constants';
export default {
name: 'MRPopover',
// name: 'MRPopover' is a false positive: https://gitlab.com/gitlab-org/frontend/eslint-plugin-i18n/issues/25
name: 'MRPopover', // eslint-disable-line @gitlab/i18n/no-non-i18n-strings
components: {
GlPopover,
GlSkeletonLoading,
......@@ -102,9 +104,11 @@ export default {
<ci-icon v-if="detailedStatus" :status="detailedStatus" />
</div>
<h5 class="my-2">{{ mergeRequestTitle }}</h5>
<!-- eslint-disable @gitlab/vue-i18n/no-bare-strings -->
<div class="text-secondary">
{{ `${projectPath}!${mergeRequestIID}` }}
</div>
<!-- eslint-enable @gitlab/vue-i18n/no-bare-strings -->
</div>
</gl-popover>
</template>
......@@ -43,7 +43,7 @@ renderer.paragraph = t => {
if (typeof katex !== 'undefined') {
const katexString = text
.replace(/&amp;/g, '&')
.replace(/&=&/g, '\\space=\\space')
.replace(/&=&/g, '\\space=\\space') // eslint-disable-line @gitlab/i18n/no-non-i18n-strings
.replace(/<(\/?)em>/g, '_');
const regex = new RegExp(katexRegexString, 'gi');
const matchLocation = katexString.search(regex);
......
......@@ -25,7 +25,7 @@ export default {
},
computed: {
imgSrc() {
return `data:${this.outputType};base64,${this.rawCode}`;
return `data:${this.outputType};base64,${this.rawCode}`; // eslint-disable-line @gitlab/i18n/no-non-i18n-strings
},
showOutput() {
return this.index === 0;
......
......@@ -39,7 +39,7 @@ export default {
},
methods: {
cellType(type) {
return `${type}-cell`;
return `${type}-cell`; // eslint-disable-line @gitlab/i18n/no-non-i18n-strings
},
},
};
......
<script>
/* eslint-disable @gitlab/vue-i18n/no-bare-strings */
import { mapState, mapActions } from 'vuex';
import DiffFileHeader from '~/diffs/components/diff_file_header.vue';
import DiffViewer from '~/vue_shared/components/diff_viewer/diff_viewer.vue';
......
<script>
/* eslint-disable @gitlab/vue-i18n/no-bare-strings */
import timeAgoTooltip from '../../vue_shared/components/time_ago_tooltip.vue';
export default {
......
......@@ -53,12 +53,15 @@ export default {
label-for="full-dashboard-url"
:description="s__('ExternalMetrics|Enter the URL of the dashboard you want to link to')"
>
<!-- placeholder with a url is a false positive -->
<!-- eslint-disable @gitlab/vue-i18n/no-bare-attribute-strings -->
<gl-form-input
id="full-dashboard-url"
v-model="userDashboardUrl"
placeholder="https://my-org.gitlab.io/my-dashboards"
@keydown.enter.native.prevent="updateExternalDashboardUrl"
/>
<!-- eslint-enable @gitlab/vue-i18n/no-bare-attribute-strings -->
</gl-form-group>
<gl-button variant="success" @click="updateExternalDashboardUrl">
{{ __('Save Changes') }}
......
<script>
/* eslint-disable @gitlab/vue-i18n/no-bare-strings */
import settingsMixin from 'ee_else_ce/pages/projects/shared/permissions/mixins/settings_pannel_mixin';
import { __ } from '~/locale';
import projectFeatureSetting from './project_feature_setting.vue';
......
......@@ -66,7 +66,7 @@ export default {
<template v-if="detailsList.length">
<tr v-for="(item, index) in detailsList" :key="index">
<td>
<span>{{ item.duration }}ms</span>
<span>{{ sprintf(__('%{duration}ms'), { duration: item.duration }) }}</span>
</td>
<td>
<div class="js-toggle-container">
......
......@@ -76,7 +76,6 @@ export default {
if (this.hasHost && this.currentRequest.details.host.canary) {
return glEmojiTag('baby_chick');
}
return '';
},
},
......
<script>
/* eslint-disable @gitlab/vue-i18n/no-bare-strings */
import { GlLink, GlTooltipDirective } from '@gitlab/ui';
import Icon from '~/vue_shared/components/icon.vue';
......
......@@ -81,9 +81,11 @@ export default {
);
},
dockerBuildCommand() {
// eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings
return `docker build -t ${this.repositoryUrl} .`;
},
dockerPushCommand() {
// eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings
return `docker push ${this.repositoryUrl}`;
},
},
......
<script>
/* eslint-disable @gitlab/vue-i18n/no-bare-strings */
import _ from 'underscore';
import { GlTooltipDirective, GlLink, GlBadge } from '@gitlab/ui';
import Icon from '~/vue_shared/components/icon.vue';
......
<script>
// import { sprintf, __ } from '~/locale';
import Modal from '~/vue_shared/components/gl_modal.vue';
import LoadingButton from '~/vue_shared/components/loading_button.vue';
import CodeBlock from '~/vue_shared/components/code_block.vue';
......@@ -47,9 +48,9 @@ export default {
</a>
</template>
<template v-else-if="field.type === $options.fieldTypes.miliseconds">
{{ field.value }} ms
</template>
<template v-else-if="field.type === $options.fieldTypes.miliseconds">{{
sprintf(__('%{value} ms'), { value: field.value })
}}</template>
<template v-else-if="field.type === $options.fieldTypes.text">
{{ field.value }}
......
<script>
/* eslint-disable @gitlab/vue-i18n/no-bare-strings */
export default {
name: 'ReportIssueLink',
props: {
......
<script>
/* eslint-disable @gitlab/vue-i18n/no-bare-strings */
import { GlTooltipDirective, GlLink, GlButton, GlLoadingIcon } from '@gitlab/ui';
import { sprintf, s__ } from '~/locale';
import Icon from '../../vue_shared/components/icon.vue';
......
......@@ -115,6 +115,7 @@ export default {
<component :is="linkComponent" :to="routerLinkTo" :href="url" class="str-truncated">
{{ fullPath }}
</component>
<!-- eslint-disable-next-line @gitlab/vue-i18n/no-bare-strings -->
<gl-badge v-if="lfsOid" variant="default" class="label-lfs ml-1">LFS</gl-badge>
<template v-if="isSubmodule">
@ <gl-link :href="submoduleTreeUrl" class="commit-sha">{{ shortSha }}</gl-link>
......
......@@ -3,6 +3,8 @@ import { __, sprintf } from '~/locale';
import tooltip from '~/vue_shared/directives/tooltip';
export default {
// name: 'Assignees' is a false positive: https://gitlab.com/gitlab-org/frontend/eslint-plugin-i18n/issues/26#possible-false-positives
// eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings
name: 'Assignees',
directives: {
tooltip,
......
......@@ -14,6 +14,8 @@ import ReviewAppLink from './review_app_link.vue';
import MRWidgetService from '../services/mr_widget_service';
export default {
// name: 'Deployment' is a false positive: https://gitlab.com/gitlab-org/frontend/eslint-plugin-i18n/issues/26#possible-false-positives
// eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings
name: 'Deployment',
components: {
LoadingButton,
......
<script>
/* eslint-disable @gitlab/vue-i18n/no-bare-strings */
import Flash from '~/flash';
import tooltip from '~/vue_shared/directives/tooltip';
import { s__, __ } from '~/locale';
......@@ -84,6 +85,8 @@ export default {
.removeSourceBranch()
.then(res => res.data)
.then(data => {
// False positive i18n lint: https://gitlab.com/gitlab-org/frontend/eslint-plugin-i18n/issues/26
// eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings
if (data.message === 'Branch was deleted') {
eventHub.$emit('MRWidgetUpdateRequested', () => {
this.isMakingRequest = false;
......
......@@ -40,6 +40,8 @@ import { setFaviconOverlay } from '../lib/utils/common_utils';
export default {
el: '#js-vue-mr-widget',
// False positive i18n lint: https://gitlab.com/gitlab-org/frontend/eslint-plugin-i18n/issues/25
// eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings
name: 'MRWidget',
components: {
'mr-widget-header': WidgetHeader,
......
......@@ -44,6 +44,8 @@ export default {
},
computed: {
changedIcon() {
// False positive i18n lint: https://gitlab.com/gitlab-org/frontend/eslint-plugin-i18n/issues/26
// eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings
const suffix = !this.file.changed && this.file.staged && !this.showStagedIcon ? '-solid' : '';
if (this.forceModifiedIcon) return `file-modified${suffix}`;
......
......@@ -38,10 +38,11 @@ export default {
computed: {
mdTable() {
return [
'| header | header |',
// False positive i18n lint: https://gitlab.com/gitlab-org/frontend/eslint-plugin-i18n/issues/26
'| header | header |', // eslint-disable-line @gitlab/i18n/no-non-i18n-strings
'| ------ | ------ |',
'| cell | cell |',
'| cell | cell |',
'| cell | cell |', // eslint-disable-line @gitlab/i18n/no-non-i18n-strings
'| cell | cell |', // eslint-disable-line @gitlab/i18n/no-non-i18n-strings
].join('\n');
},
mdSuggestion() {
......
<script>
/* eslint-disable @gitlab/vue-i18n/no-bare-strings */
import { GlLink } from '@gitlab/ui';
export default {
......
......@@ -3,6 +3,8 @@ import $ from 'jquery';
import 'select2';
export default {
// False positive i18n lint: https://gitlab.com/gitlab-org/frontend/eslint-plugin-i18n/issues/26
// eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings
name: 'Select2Select',
props: {
options: {
......
......@@ -78,6 +78,8 @@ export default {
return percent;
},
barStyle(percent) {
// False positive i18n lint: https://gitlab.com/gitlab-org/frontend/eslint-plugin-i18n/issues/26
// eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings
return `width: ${percent}%;`;
},
getTooltip(label, count) {
......
......@@ -145,6 +145,9 @@ msgid_plural "%{count} participants"
msgstr[0] ""
msgstr[1] ""
msgid "%{duration}ms"
msgstr ""
msgid "%{edit_in_new_fork_notice} Try to cherry-pick this commit again."
msgstr ""
......@@ -285,6 +288,9 @@ msgstr ""
msgid "%{username}'s avatar"
msgstr ""
msgid "%{value} ms"
msgstr ""
msgid "%{verb} %{time_spent_value} spent time."
msgstr ""
......
......@@ -991,6 +991,13 @@
dependencies:
requireindex "~1.1.0"
"@gitlab/eslint-plugin-vue-i18n@^1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@gitlab/eslint-plugin-vue-i18n/-/eslint-plugin-vue-i18n-1.2.0.tgz#6dcd8bf6bdd7a31c1c4c2c4114762508af435836"
integrity sha512-lROk643/C3tBORIJeXNQlPutjAdSkjA43rpNHVxugU5OcpIOfc7oVXDZ23GwiHMZp8bE3QpP/91PEvEY9ywAVQ==
dependencies:
vue-eslint-parser "^6.0.4"
"@gitlab/svgs@^1.67.0":
version "1.67.0"
resolved "https://registry.yarnpkg.com/@gitlab/svgs/-/svgs-1.67.0.tgz#c7b94eca13b99fd3aaa737fb6dcc0abc41d3c579"
......@@ -4745,6 +4752,15 @@ espree@^4.0.0, espree@^4.1.0:
acorn-jsx "^5.0.0"
eslint-visitor-keys "^1.0.0"
espree@^5.0.0:
version "5.0.1"
resolved "https://registry.yarnpkg.com/espree/-/espree-5.0.1.tgz#5d6526fa4fc7f0788a5cf75b15f30323e2f81f7a"
integrity sha512-qWAZcWh4XE/RwzLJejfcofscgMc9CamR6Tn1+XRXNzrvUSSbiAjGOI/fggztjIi7y9VLPqnICMIPiGyr8JaZ0A==
dependencies:
acorn "^6.0.7"
acorn-jsx "^5.0.0"
eslint-visitor-keys "^1.0.0"
esprima@^3.1.3:
version "3.1.3"
resolved "https://registry.yarnpkg.com/esprima/-/esprima-3.1.3.tgz#fdca51cee6133895e3c88d535ce49dbff62a4633"
......@@ -12646,6 +12662,18 @@ vue-eslint-parser@^4.0.2:
esquery "^1.0.1"
lodash "^4.17.11"
vue-eslint-parser@^6.0.4:
version "6.0.4"
resolved "https://registry.yarnpkg.com/vue-eslint-parser/-/vue-eslint-parser-6.0.4.tgz#56ff47e2c2644bff39951d5a284982c7ecd6f7fa"
integrity sha512-GYsDsDWwKaGtnkW4nGUxr01wqIO2FB9/QHQTW1Gl5SUr5OyQvpnR90/D+Gq2cIxURX7aJ7+VyD+37Yx9eFwTgw==
dependencies:
debug "^4.1.1"
eslint-scope "^4.0.0"
eslint-visitor-keys "^1.0.0"
espree "^5.0.0"
esquery "^1.0.1"
lodash "^4.17.11"
vue-functional-data-merge@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/vue-functional-data-merge/-/vue-functional-data-merge-3.1.0.tgz#08a7797583b7f35680587f8a1d51d729aa1dc657"
......
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