From 3d8163dcf6070a9e73fa1e8e31a65375ff5770d2 Mon Sep 17 00:00:00 2001 From: Brandon Labuschagne <blabuschagne@gitlab.com> Date: Thu, 13 Jun 2019 19:15:25 +0000 Subject: [PATCH] Disable unnecessary ESLint i18n offences Unnecessary offences include false positives as well as flagged errors which have follow up issues in order to be addressed. Not all issues have been addressed before this being submitted in the spirit of results and iteration. --- .eslintrc.yml | 10 ++++++++++ app/assets/javascripts/awards_handler.js | 2 +- app/assets/javascripts/boards/stores/actions.js | 1 + app/assets/javascripts/boards/stores/mutations.js | 1 + app/assets/javascripts/lib/utils/autosave.js | 1 + app/assets/javascripts/lib/utils/notify.js | 2 ++ app/assets/javascripts/new_branch_form.js | 2 +- .../graphs/show/stat_graph_contributors_graph.js | 15 ++++++++++----- app/assets/javascripts/repository/graphql.js | 2 ++ app/assets/javascripts/repository/utils/title.js | 1 + app/assets/javascripts/search_autocomplete.js | 2 ++ app/assets/javascripts/users_select.js | 1 + package.json | 1 + yarn.lock | 12 ++++++++++++ 14 files changed, 46 insertions(+), 7 deletions(-) diff --git a/.eslintrc.yml b/.eslintrc.yml index 98a497aa12a1b..2b881d5f201c3 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -8,11 +8,13 @@ globals: plugins: - import - html + - "@gitlab/i18n" settings: import/resolver: webpack: config: './config/webpack.config.js' rules: + "@gitlab/i18n/no-non-i18n-strings": error import/no-commonjs: error no-underscore-dangle: - error @@ -31,3 +33,11 @@ rules: vue/no-use-v-if-with-v-for: off vue/no-v-html: 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 diff --git a/app/assets/javascripts/awards_handler.js b/app/assets/javascripts/awards_handler.js index 743f11625bcfb..aaab217964c49 100644 --- a/app/assets/javascripts/awards_handler.js +++ b/app/assets/javascripts/awards_handler.js @@ -1,4 +1,4 @@ -/* eslint-disable class-methods-use-this */ +/* eslint-disable class-methods-use-this, @gitlab/i18n/no-non-i18n-strings */ import $ from 'jquery'; import _ from 'underscore'; diff --git a/app/assets/javascripts/boards/stores/actions.js b/app/assets/javascripts/boards/stores/actions.js index da82b52330a29..d4f4df3ad75e7 100644 --- a/app/assets/javascripts/boards/stores/actions.js +++ b/app/assets/javascripts/boards/stores/actions.js @@ -1,4 +1,5 @@ const notImplemented = () => { + /* eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings */ throw new Error('Not implemented!'); }; diff --git a/app/assets/javascripts/boards/stores/mutations.js b/app/assets/javascripts/boards/stores/mutations.js index 77ba68be07eec..09eb8bb9b98ba 100644 --- a/app/assets/javascripts/boards/stores/mutations.js +++ b/app/assets/javascripts/boards/stores/mutations.js @@ -1,6 +1,7 @@ import * as mutationTypes from './mutation_types'; const notImplemented = () => { + /* eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings */ throw new Error('Not implemented!'); }; diff --git a/app/assets/javascripts/lib/utils/autosave.js b/app/assets/javascripts/lib/utils/autosave.js index 023c336db02f4..37896626053dc 100644 --- a/app/assets/javascripts/lib/utils/autosave.js +++ b/app/assets/javascripts/lib/utils/autosave.js @@ -29,4 +29,5 @@ export const updateDraft = (autosaveKey, text) => { }; export const getDiscussionReplyKey = (noteableType, discussionId) => + /* eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings */ ['Note', capitalizeFirstCharacter(noteableType), discussionId, 'Reply'].join('/'); diff --git a/app/assets/javascripts/lib/utils/notify.js b/app/assets/javascripts/lib/utils/notify.js index d93873e0214ca..e7f6255e5f14c 100644 --- a/app/assets/javascripts/lib/utils/notify.js +++ b/app/assets/javascripts/lib/utils/notify.js @@ -12,6 +12,7 @@ function notificationGranted(message, opts, onclick) { } function notifyPermissions() { + /* eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings */ if ('Notification' in window) { return Notification.requestPermission(); } @@ -24,6 +25,7 @@ function notifyMe(message, body, icon, onclick) { icon: icon, }; // Let's check if the browser supports notifications + /* eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings */ if (!('Notification' in window)) { // do nothing } else if (Notification.permission === 'granted') { diff --git a/app/assets/javascripts/new_branch_form.js b/app/assets/javascripts/new_branch_form.js index f338dbbb0a6ff..98522c67696e0 100644 --- a/app/assets/javascripts/new_branch_form.js +++ b/app/assets/javascripts/new_branch_form.js @@ -1,4 +1,4 @@ -/* 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 RefSelectDropdown from './ref_select_dropdown'; diff --git a/app/assets/javascripts/pages/projects/graphs/show/stat_graph_contributors_graph.js b/app/assets/javascripts/pages/projects/graphs/show/stat_graph_contributors_graph.js index 377dce6c746fa..506e6075d1636 100644 --- a/app/assets/javascripts/pages/projects/graphs/show/stat_graph_contributors_graph.js +++ b/app/assets/javascripts/pages/projects/graphs/show/stat_graph_contributors_graph.js @@ -124,11 +124,14 @@ export const ContributorsGraph = (function() { }; ContributorsGraph.prototype.draw_x_axis = function() { - return this.svg - .append('g') - .attr('class', 'x axis') - .attr('transform', 'translate(0, ' + this.height + ')') - .call(this.x_axis); + return ( + this.svg + .append('g') + .attr('class', '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() { @@ -205,6 +208,7 @@ export const ContributorsMasterGraph = (function(superClass) { .attr('height', this.height + this.MARGIN.top + this.MARGIN.bottom) .attr('class', 'tint-box') .append('g') + /* eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings */ .attr('transform', 'translate(' + this.MARGIN.left + ',' + this.MARGIN.top + ')'); return this.svg; }; @@ -354,6 +358,7 @@ export const ContributorsAuthorGraph = (function(superClass) { .attr('height', this.height + this.MARGIN.top + this.MARGIN.bottom) .attr('class', 'spark') .append('g') + /* eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings */ .attr('transform', 'translate(' + this.MARGIN.left + ',' + this.MARGIN.top + ')'); return this.svg; }; diff --git a/app/assets/javascripts/repository/graphql.js b/app/assets/javascripts/repository/graphql.js index c64d16ef02a6b..ef147ec15cbe0 100644 --- a/app/assets/javascripts/repository/graphql.js +++ b/app/assets/javascripts/repository/graphql.js @@ -18,6 +18,7 @@ const defaultClient = createDefaultClient( cacheConfig: { fragmentMatcher, dataIdFromObject: obj => { + /* eslint-disable @gitlab/i18n/no-non-i18n-strings */ // eslint-disable-next-line no-underscore-dangle switch (obj.__typename) { // We need to create a dynamic ID for each entry @@ -33,6 +34,7 @@ const defaultClient = createDefaultClient( // eslint-disable-next-line no-underscore-dangle return obj.id || obj._id; } + /* eslint-enable @gitlab/i18n/no-non-i18n-strings */ }, }, }, diff --git a/app/assets/javascripts/repository/utils/title.js b/app/assets/javascripts/repository/utils/title.js index 4e194640e9231..87d54c012002b 100644 --- a/app/assets/javascripts/repository/utils/title.js +++ b/app/assets/javascripts/repository/utils/title.js @@ -5,5 +5,6 @@ export const setTitle = (pathMatch, ref, project) => { const path = pathMatch.replace(/^\//, ''); const isEmpty = path === ''; + /* eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings */ document.title = `${isEmpty ? 'Files' : path} · ${ref} · ${project}`; }; diff --git a/app/assets/javascripts/search_autocomplete.js b/app/assets/javascripts/search_autocomplete.js index 6aca4067ba77e..842fb5e5b4f7e 100644 --- a/app/assets/javascripts/search_autocomplete.js +++ b/app/assets/javascripts/search_autocomplete.js @@ -447,9 +447,11 @@ export class SearchAutocomplete { onClick(item, $el, e) { if (window.location.pathname.indexOf(item.url) !== -1) { if (!e.metaKey) e.preventDefault(); + /* eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings */ if (item.category === 'Projects') { this.projectInputEl.val(item.id); } + /* eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings */ if (item.category === 'Groups') { this.groupInputEl.val(item.id); } diff --git a/app/assets/javascripts/users_select.js b/app/assets/javascripts/users_select.js index 7e6f02b10af8d..33cedf78331fe 100644 --- a/app/assets/javascripts/users_select.js +++ b/app/assets/javascripts/users_select.js @@ -427,6 +427,7 @@ function UsersSelect(currentUser, els, options = {}) { const isActive = $el.hasClass('is-active'); const previouslySelected = $dropdown .closest('.selectbox') + /* eslint-disable-next-line @gitlab/i18n/no-non-i18n-strings */ .find("input[name='" + $dropdown.data('fieldName') + "'][value!=0]"); // Enables support for limiting the number of users selected diff --git a/package.json b/package.json index ab7268642ecd4..0758c27c75bd3 100644 --- a/package.json +++ b/package.json @@ -147,6 +147,7 @@ "devDependencies": { "@babel/plugin-transform-modules-commonjs": "^7.2.0", "@gitlab/eslint-config": "^1.6.0", + "@gitlab/eslint-plugin-i18n": "^1.0.0", "@vue/test-utils": "^1.0.0-beta.25", "axios-mock-adapter": "^1.15.0", "babel-jest": "^24.1.0", diff --git a/yarn.lock b/yarn.lock index b6d31ea08e600..dddf01414b22b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -693,6 +693,13 @@ eslint-plugin-promise "^4.1.1" 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": version "1.63.0" resolved "https://registry.yarnpkg.com/@gitlab/svgs/-/svgs-1.63.0.tgz#9dd544026d203e4ce6efed72b05db68f710c4d49" @@ -9439,6 +9446,11 @@ require-uncached@^1.0.3: caller-path "^0.1.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: version "1.0.0" resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" -- GitLab