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 4 additions and 21 deletions
/* eslint-disable import/prefer-default-export */
/*
@module
 
Loading
Loading
/* eslint-disable import/prefer-default-export */
export const setLanguage = languageCode => {
const htmlElement = document.querySelector('html');
 
Loading
Loading
// eslint-disable-next-line import/prefer-default-export
export const mockIntegrationProps = {
id: 25,
activeToggleProps: {
Loading
Loading
// eslint-disable-next-line import/prefer-default-export
export const keyboardDownEvent = (code, metaKey = false, ctrlKey = false) => {
const e = new CustomEvent('keydown');
 
Loading
Loading
import state from '~/jobs/store/state';
 
// eslint-disable-next-line import/prefer-default-export
export const resetStore = store => {
store.replaceState(state());
};
Loading
Loading
@@ -29,7 +29,6 @@ const getMockFiles = root => readdir.sync(root, { deep: MAX_DEPTH, filter: mockF
const defaultSetMock = (srcPath, mockPath) =>
jest.mock(srcPath, () => jest.requireActual(mockPath));
 
// eslint-disable-next-line import/prefer-default-export
export const setupManualMocks = function setupManualMocks(setMock = defaultSetMock) {
prefixMap.forEach(({ mocksRoot, requirePrefix }) => {
const mocksRootAbsolute = path.join(__dirname, mocksRoot);
Loading
Loading
// eslint-disable-next-line import/prefer-default-export
export const resetStore = store => {
store.replaceState({
notes: [],
Loading
Loading
// eslint-disable-next-line import/prefer-default-export
export const $toast = {
show: jest.fn(),
};
import state from '~/releases/stores/modules/list/state';
 
// eslint-disable-next-line import/prefer-default-export
export const resetStore = store => {
store.replaceState(state());
};
// eslint-disable-next-line import/prefer-default-export
export const mockReport = {
status: 'failed',
summary: {
Loading
Loading
// eslint-disable-next-line import/prefer-default-export
export const adjustMetricQuery = data => {
const updatedMetric = data.metrics;
 
Loading
Loading
// eslint-disable-next-line import/prefer-default-export
export const artifactsList = [
{
text: 'result.txt',
Loading
Loading
Loading
Loading
@@ -2,7 +2,6 @@ import { withValues } from '../utils/obj';
import { getCommit } from '../fixtures';
import { createCommitId } from './commit_id';
 
// eslint-disable-next-line import/prefer-default-export
export const createNewCommit = ({ id = createCommitId(), message }, orig = getCommit()) => {
return withValues(orig, {
id,
Loading
Loading
Loading
Loading
@@ -16,6 +16,5 @@ const graphqlResolvers = {
},
};
 
// eslint-disable-next-line import/prefer-default-export
export const graphqlQuery = (query, variables, schema) =>
graphql(graphqlSchema, query, graphqlResolvers, schema, variables);
Loading
Loading
@@ -31,7 +31,6 @@
*
* @param {Number} boost
*/
// eslint-disable-next-line import/prefer-default-export
export const useOverclockTimers = (boost = 50) => {
if (boost <= 0) {
throw new Error(`[overclock_timers] boost (${boost}) cannot be <= 0`);
Loading
Loading
Loading
Loading
@@ -827,10 +827,10 @@
resolved "https://registry.yarnpkg.com/@gitlab/at.js/-/at.js-1.5.5.tgz#5f6bfe6baaef360daa9b038fa78798d7a6a916b4"
integrity sha512-282Dn3SPVsUHVDhMsXgfnv+Rzog0uxecjttxGRQvxh25es1+xvkGQFsvJfkSKJ3X1kHVkSjKf+Tt5Rra+Jhp9g==
 
"@gitlab/eslint-plugin@3.2.0":
version "3.2.0"
resolved "https://registry.yarnpkg.com/@gitlab/eslint-plugin/-/eslint-plugin-3.2.0.tgz#e1780c2cab4c206e4900f2a1a4cf636f788182ea"
integrity sha512-3s28sQoGMgmwKtmVij7TjBDdW6fHiP4k6k6FWZdU6XZBJFwwA0JlU8PzYZRRTyY+pYed2u1jF06LHzv5YWNS2g==
"@gitlab/eslint-plugin@4.0.0":
version "4.0.0"
resolved "https://registry.yarnpkg.com/@gitlab/eslint-plugin/-/eslint-plugin-4.0.0.tgz#7beba53dea74f458d92040a8b2652e4fd60a6cc7"
integrity sha512-Gba9HXwWOLAN+O2H8WmGNPZFQ410wiGFmhgDQ5Sx4ic/N1ymtwNen2pnsaWcw8KK/1vAB/rHNUhH4Xu/l/mfMg==
dependencies:
babel-eslint "^10.0.3"
eslint-config-airbnb-base "^14.0.0"
Loading
Loading
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