Skip to content
Snippets Groups Projects
Unverified Commit 600155b6 authored by markrian's avatar markrian
Browse files

Disable default export rules

This is part of the work to implement the consensus reached in the
[RFC][1] to prefer named exports over defalt exports.

Future iterations will migrate existing default exports to named
exports.

The bulk of the changes in this commit were performed with the following
script:

```bash
set -u

changed-files()
{
    local trunk="origin/master"
    local file=
    local committed_files=$(git diff "$trunk"... --numstat \
        | awk '/\.(js|vue)$/{ print $3 }')
    local changed_files=$(git diff --numstat \
        | awk '/\.(js|vue)$/{ print $3 }')
    for file in ${committed_files[@]} ${changed_files[@]}; do
        if [ -f "$file" ]; then
            echo "$file"
        fi
    done
}

git grep -lz "import/prefer-default-export" -- '**/*.js' \
    | xargs -0 perl -0pi -e \
    "s/[^\n]*eslint-disable[^\n]*"\
"import\/prefer-default-export[^\n]*\n//mgs"

git grep -lz "rfcs/-/issues/20" -- '**/*.js' \
    | xargs -0 perl -0pi -e \
    "s/[^\n]*rfcs\/-\/issues\/20[^\n]*\n//mgs"

yarn prettier --write $(changed-files)
```

The script is [idempotent][2], to help make it easier to keep
up-to-date.

[1]: https://gitlab.com/gitlab-org/frontend/rfcs/-/issues/20
[2]: https://en.wikipedia.org/wiki/Idempotence
parent 53814371
No related branches found
No related tags found
No related merge requests found
Showing
with 1 addition and 24 deletions
Loading
Loading
@@ -17,6 +17,7 @@ settings:
config: './config/webpack.config.js'
rules:
import/no-commonjs: error
import/no-default-export: off
no-underscore-dangle:
- error
- allow:
Loading
Loading
Loading
Loading
@@ -3,7 +3,6 @@
* and returns an array of the following form:
* [{ key: "forks", label: "Forks", value: 50 }]
*/
// eslint-disable-next-line import/prefer-default-export
export const getStatistics = state => labels =>
Object.keys(labels).map(key => {
const result = {
Loading
Loading
Loading
Loading
@@ -3,7 +3,6 @@ import { mapActions } from 'vuex';
import store from '~/mr_notes/stores';
import ReviewBar from './components/review_bar.vue';
 
// eslint-disable-next-line import/prefer-default-export
export const initReviewBar = () => {
const el = document.getElementById('js-review-bar');
 
Loading
Loading
import { __ } from '~/locale';
 
// eslint-disable import/prefer-default-export
export const ADD_CI_VARIABLE_MODAL_ID = 'add-ci-variable';
 
export const displayText = {
Loading
Loading
/* eslint-disable import/prefer-default-export */
// Disabling import/prefer-default-export can be
// removed once a second getter is added to this file
import { uniq } from 'lodash';
 
export const joinedEnvironments = state => {
Loading
Loading
Loading
Loading
@@ -3,7 +3,6 @@ import { __ } from '~/locale';
import service from '../services/contributors_service';
import * as types from './mutation_types';
 
// eslint-disable-next-line import/prefer-default-export
export const fetchChartData = ({ commit }, endpoint) => {
commit(types.SET_LOADING_STATE, true);
 
Loading
Loading
// eslint-disable-next-line import/prefer-default-export
export const KUBERNETES_VERSIONS = [{ name: '1.14', value: '1.14' }];
// eslint-disable-next-line import/prefer-default-export
export const subnetValid = ({ selectedSubnet }) =>
Array.isArray(selectedSubnet) && selectedSubnet.length >= 2;
Loading
Loading
@@ -5,7 +5,6 @@ const DESIGN_TRACKING_CONTEXT_SCHEMA = 'iglu:com.gitlab/design_management_contex
const DESIGN_TRACKING_PAGE_NAME = 'projects:issues:design';
const DESIGN_TRACKING_EVENT_NAME = 'view_design';
 
// eslint-disable-next-line import/prefer-default-export
export function trackDesignDetailView(
referer = '',
owner = '',
Loading
Loading
Loading
Loading
@@ -5,7 +5,6 @@ const DESIGN_TRACKING_CONTEXT_SCHEMA = 'iglu:com.gitlab/design_management_contex
const DESIGN_TRACKING_PAGE_NAME = 'projects:issues:design';
const DESIGN_TRACKING_EVENT_NAME = 'view_design';
 
// eslint-disable-next-line import/prefer-default-export
export function trackDesignDetailView(
referer = '',
owner = '',
Loading
Loading
Loading
Loading
@@ -18,7 +18,6 @@ function fileSymlinkInformation(file, fileList) {
);
}
 
/* eslint-disable-next-line import/prefer-default-export */
export function prepareRawDiffFile({ file, allFiles }) {
Object.assign(file, {
brokenSymlink: fileSymlinkInformation(file, allFiles),
Loading
Loading
Loading
Loading
@@ -11,9 +11,6 @@
* @typedef {String} UUIDv4
*/
 
// https://gitlab.com/gitlab-org/frontend/rfcs/-/issues/20
/* eslint-disable import/prefer-default-export */
import MersenneTwister from 'mersenne-twister';
import stringHash from 'string-hash';
import { isString } from 'lodash';
Loading
Loading
Loading
Loading
@@ -4,5 +4,4 @@
* @param {Object} environment
* @returns {Object}
*/
// eslint-disable-next-line import/prefer-default-export
export const setDeployBoard = (oldEnvironmentState, environment) => environment;
Loading
Loading
@@ -10,7 +10,6 @@ const stopPolling = poll => {
if (poll) poll.stop();
};
 
// eslint-disable-next-line import/prefer-default-export
export function startPollingStacktrace({ commit }, endpoint) {
stackTracePoll = new Poll({
resource: service,
Loading
Loading
// eslint-disable-next-line import/prefer-default-export
export const stacktrace = state =>
state.stacktraceData.stack_trace_entries
? state.stacktraceData.stack_trace_entries.reverse()
Loading
Loading
// eslint-disable-next-line import/prefer-default-export
export const hasSearchQuery = state => state.searchQuery !== '';
Loading
Loading
@@ -33,7 +33,6 @@ const EmptyRouterComponent = {
},
};
 
// eslint-disable-next-line import/prefer-default-export
export const createRouter = store => {
const router = new IdeRouter({
mode: 'history',
Loading
Loading
import { diffLines } from 'diff';
import { defaultDiffOptions } from '../editor_options';
 
// See: https://gitlab.com/gitlab-org/frontend/rfcs/-/issues/20
// eslint-disable-next-line import/prefer-default-export
export const computeDiff = (originalContent, newContent) => {
// prevent EOL changes from highlighting the entire file
const changes = diffLines(
Loading
Loading
Loading
Loading
@@ -42,7 +42,6 @@ function getRulesWithConfigs(filePath, configFiles = [], rules = {}) {
return isRoot ? result : getRulesWithConfigs(filePath, nextConfigs, result);
}
 
// eslint-disable-next-line import/prefer-default-export
export function getRulesWithTraversal(filePath, getFileContent) {
const editorconfigPaths = [
...getPathParents(filePath).map(x => `${x}/.editorconfig`),
Loading
Loading
Loading
Loading
@@ -17,5 +17,4 @@ const getClient = memoize(() =>
),
);
 
// eslint-disable-next-line import/prefer-default-export
export const query = (...args) => getClient().query(...args);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment