Commit 40d309cc authored by Mike Greiling's avatar Mike Greiling

Merge branch '59733-autofix-i18n-offences-in-js-files-using-eslint' into 'master'

"Add ESLint  i18n plugin"

Closes #62359

See merge request gitlab-org/gitlab-ce!26789
parents ea9fcebf 3d8163dc
...@@ -8,11 +8,13 @@ globals: ...@@ -8,11 +8,13 @@ globals:
plugins: plugins:
- import - import
- html - html
- "@gitlab/i18n"
settings: settings:
import/resolver: import/resolver:
webpack: webpack:
config: './config/webpack.config.js' config: './config/webpack.config.js'
rules: rules:
"@gitlab/i18n/no-non-i18n-strings": error
import/no-commonjs: error import/no-commonjs: error
no-underscore-dangle: no-underscore-dangle:
- error - error
...@@ -31,3 +33,11 @@ rules: ...@@ -31,3 +33,11 @@ rules:
vue/no-use-v-if-with-v-for: off vue/no-use-v-if-with-v-for: off
vue/no-v-html: off vue/no-v-html: off
vue/use-v-on-exact: off 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
/* eslint-disable class-methods-use-this */ /* eslint-disable class-methods-use-this, @gitlab/i18n/no-non-i18n-strings */
import $ from 'jquery'; import $ from 'jquery';
import _ from 'underscore'; import _ from 'underscore';
......
const notImplemented = () => { const notImplemented = () => {
/* eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings */
throw new Error('Not implemented!'); throw new Error('Not implemented!');
}; };
......
import * as mutationTypes from './mutation_types'; import * as mutationTypes from './mutation_types';
const notImplemented = () => { const notImplemented = () => {
/* eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings */
throw new Error('Not implemented!'); throw new Error('Not implemented!');
}; };
......
...@@ -29,4 +29,5 @@ export const updateDraft = (autosaveKey, text) => { ...@@ -29,4 +29,5 @@ export const updateDraft = (autosaveKey, text) => {
}; };
export const getDiscussionReplyKey = (noteableType, discussionId) => export const getDiscussionReplyKey = (noteableType, discussionId) =>
/* eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings */
['Note', capitalizeFirstCharacter(noteableType), discussionId, 'Reply'].join('/'); ['Note', capitalizeFirstCharacter(noteableType), discussionId, 'Reply'].join('/');
...@@ -12,6 +12,7 @@ function notificationGranted(message, opts, onclick) { ...@@ -12,6 +12,7 @@ function notificationGranted(message, opts, onclick) {
} }
function notifyPermissions() { function notifyPermissions() {
/* eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings */
if ('Notification' in window) { if ('Notification' in window) {
return Notification.requestPermission(); return Notification.requestPermission();
} }
...@@ -24,6 +25,7 @@ function notifyMe(message, body, icon, onclick) { ...@@ -24,6 +25,7 @@ function notifyMe(message, body, icon, onclick) {
icon: icon, icon: icon,
}; };
// Let's check if the browser supports notifications // Let's check if the browser supports notifications
/* eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings */
if (!('Notification' in window)) { if (!('Notification' in window)) {
// do nothing // do nothing
} else if (Notification.permission === 'granted') { } else if (Notification.permission === 'granted') {
......
/* eslint-disable func-names, no-var, one-var, consistent-return, no-return-assign, prefer-arrow-callback, prefer-template, no-shadow, no-else-return */ /* eslint-disable func-names, no-var, one-var, consistent-return, no-return-assign, prefer-arrow-callback, prefer-template, no-shadow, no-else-return, @gitlab/i18n/no-non-i18n-strings */
import $ from 'jquery'; import $ from 'jquery';
import RefSelectDropdown from './ref_select_dropdown'; import RefSelectDropdown from './ref_select_dropdown';
......
...@@ -124,11 +124,14 @@ export const ContributorsGraph = (function() { ...@@ -124,11 +124,14 @@ export const ContributorsGraph = (function() {
}; };
ContributorsGraph.prototype.draw_x_axis = function() { ContributorsGraph.prototype.draw_x_axis = function() {
return this.svg return (
.append('g') this.svg
.attr('class', 'x axis') .append('g')
.attr('transform', 'translate(0, ' + this.height + ')') .attr('class', 'x axis')
.call(this.x_axis); /* eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings */
.attr('transform', 'translate(0, ' + this.height + ')')
.call(this.x_axis)
);
}; };
ContributorsGraph.prototype.draw_y_axis = function() { ContributorsGraph.prototype.draw_y_axis = function() {
...@@ -205,6 +208,7 @@ export const ContributorsMasterGraph = (function(superClass) { ...@@ -205,6 +208,7 @@ export const ContributorsMasterGraph = (function(superClass) {
.attr('height', this.height + this.MARGIN.top + this.MARGIN.bottom) .attr('height', this.height + this.MARGIN.top + this.MARGIN.bottom)
.attr('class', 'tint-box') .attr('class', 'tint-box')
.append('g') .append('g')
/* eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings */
.attr('transform', 'translate(' + this.MARGIN.left + ',' + this.MARGIN.top + ')'); .attr('transform', 'translate(' + this.MARGIN.left + ',' + this.MARGIN.top + ')');
return this.svg; return this.svg;
}; };
...@@ -354,6 +358,7 @@ export const ContributorsAuthorGraph = (function(superClass) { ...@@ -354,6 +358,7 @@ export const ContributorsAuthorGraph = (function(superClass) {
.attr('height', this.height + this.MARGIN.top + this.MARGIN.bottom) .attr('height', this.height + this.MARGIN.top + this.MARGIN.bottom)
.attr('class', 'spark') .attr('class', 'spark')
.append('g') .append('g')
/* eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings */
.attr('transform', 'translate(' + this.MARGIN.left + ',' + this.MARGIN.top + ')'); .attr('transform', 'translate(' + this.MARGIN.left + ',' + this.MARGIN.top + ')');
return this.svg; return this.svg;
}; };
......
...@@ -18,6 +18,7 @@ const defaultClient = createDefaultClient( ...@@ -18,6 +18,7 @@ const defaultClient = createDefaultClient(
cacheConfig: { cacheConfig: {
fragmentMatcher, fragmentMatcher,
dataIdFromObject: obj => { dataIdFromObject: obj => {
/* eslint-disable @gitlab/i18n/no-non-i18n-strings */
// eslint-disable-next-line no-underscore-dangle // eslint-disable-next-line no-underscore-dangle
switch (obj.__typename) { switch (obj.__typename) {
// We need to create a dynamic ID for each entry // We need to create a dynamic ID for each entry
...@@ -33,6 +34,7 @@ const defaultClient = createDefaultClient( ...@@ -33,6 +34,7 @@ const defaultClient = createDefaultClient(
// eslint-disable-next-line no-underscore-dangle // eslint-disable-next-line no-underscore-dangle
return obj.id || obj._id; return obj.id || obj._id;
} }
/* eslint-enable @gitlab/i18n/no-non-i18n-strings */
}, },
}, },
}, },
......
...@@ -5,5 +5,6 @@ export const setTitle = (pathMatch, ref, project) => { ...@@ -5,5 +5,6 @@ export const setTitle = (pathMatch, ref, project) => {
const path = pathMatch.replace(/^\//, ''); const path = pathMatch.replace(/^\//, '');
const isEmpty = path === ''; const isEmpty = path === '';
/* eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings */
document.title = `${isEmpty ? 'Files' : path} · ${ref} · ${project}`; document.title = `${isEmpty ? 'Files' : path} · ${ref} · ${project}`;
}; };
...@@ -447,9 +447,11 @@ export class SearchAutocomplete { ...@@ -447,9 +447,11 @@ export class SearchAutocomplete {
onClick(item, $el, e) { onClick(item, $el, e) {
if (window.location.pathname.indexOf(item.url) !== -1) { if (window.location.pathname.indexOf(item.url) !== -1) {
if (!e.metaKey) e.preventDefault(); if (!e.metaKey) e.preventDefault();
/* eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings */
if (item.category === 'Projects') { if (item.category === 'Projects') {
this.projectInputEl.val(item.id); this.projectInputEl.val(item.id);
} }
/* eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings */
if (item.category === 'Groups') { if (item.category === 'Groups') {
this.groupInputEl.val(item.id); this.groupInputEl.val(item.id);
} }
......
...@@ -427,6 +427,7 @@ function UsersSelect(currentUser, els, options = {}) { ...@@ -427,6 +427,7 @@ function UsersSelect(currentUser, els, options = {}) {
const isActive = $el.hasClass('is-active'); const isActive = $el.hasClass('is-active');
const previouslySelected = $dropdown const previouslySelected = $dropdown
.closest('.selectbox') .closest('.selectbox')
/* eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings */
.find("input[name='" + $dropdown.data('fieldName') + "'][value!=0]"); .find("input[name='" + $dropdown.data('fieldName') + "'][value!=0]");
// Enables support for limiting the number of users selected // Enables support for limiting the number of users selected
......
...@@ -693,6 +693,13 @@ ...@@ -693,6 +693,13 @@
eslint-plugin-promise "^4.1.1" eslint-plugin-promise "^4.1.1"
eslint-plugin-vue "^5.0.0" eslint-plugin-vue "^5.0.0"
"@gitlab/eslint-plugin-i18n@^1.0.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@gitlab/eslint-plugin-i18n/-/eslint-plugin-i18n-1.1.0.tgz#e494d599e644ce3a094ea85f87dbbda41a924c5e"
integrity sha512-Cwm7sLtQnUDqvxE9Ez8UMslyosPCpMVLxBnFb+2n6QcBZmXRao4aNSVRkmlsDZYgYegWhOGn3Qq3MLy4BSqauQ==
dependencies:
requireindex "~1.1.0"
"@gitlab/svgs@^1.63.0": "@gitlab/svgs@^1.63.0":
version "1.63.0" version "1.63.0"
resolved "https://registry.yarnpkg.com/@gitlab/svgs/-/svgs-1.63.0.tgz#9dd544026d203e4ce6efed72b05db68f710c4d49" resolved "https://registry.yarnpkg.com/@gitlab/svgs/-/svgs-1.63.0.tgz#9dd544026d203e4ce6efed72b05db68f710c4d49"
...@@ -9439,6 +9446,11 @@ require-uncached@^1.0.3: ...@@ -9439,6 +9446,11 @@ require-uncached@^1.0.3:
caller-path "^0.1.0" caller-path "^0.1.0"
resolve-from "^1.0.0" resolve-from "^1.0.0"
requireindex@~1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/requireindex/-/requireindex-1.1.0.tgz#e5404b81557ef75db6e49c5a72004893fe03e162"
integrity sha1-5UBLgVV+91225JxacgBIk/4D4WI=
requires-port@1.x.x, requires-port@^1.0.0: requires-port@1.x.x, requires-port@^1.0.0:
version "1.0.0" version "1.0.0"
resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff"
......
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