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 0 additions and 26 deletions
/* eslint-disable import/prefer-default-export */
export const FILTERED_SEARCH = {
MERGE_REQUESTS: 'merge_requests',
ISSUES: 'issues',
Loading
Loading
/* eslint-disable import/prefer-default-export */
export const ISSUABLE_INDEX = {
MERGE_REQUEST: 'merge_request_',
ISSUE: 'issue_',
Loading
Loading
import { pickBy } from 'lodash';
import { SUPPORTED_FILTER_PARAMETERS } from './constants';
 
// eslint-disable-next-line import/prefer-default-export
export const validateParams = params => {
return pickBy(params, (val, key) => SUPPORTED_FILTER_PARAMETERS.includes(key) && val);
};
Loading
Loading
@@ -7,7 +7,6 @@ import state from './state';
 
Vue.use(Vuex);
 
// eslint-disable-next-line import/prefer-default-export
export const createStore = () =>
new Vuex.Store({
state,
Loading
Loading
// eslint-disable-next-line import/prefer-default-export
export const decodeAndParse = param => JSON.parse(window.atob(param));
import { LOADING, ERROR, SUCCESS, STATUS_FAILED } from '../constants';
 
// eslint-disable-next-line import/prefer-default-export
export const summaryStatus = state => {
if (state.isLoading) {
return LOADING;
Loading
Loading
// eslint-disable-next-line import/prefer-default-export
export function normalizeData(data, path, extra = () => {}) {
return data.map(d => ({
sha: d.commit.id,
Loading
Loading
Loading
Loading
@@ -88,7 +88,6 @@ const fileTypeIcons = [
},
];
 
// eslint-disable-next-line import/prefer-default-export
export const getIconName = (type, path) => {
if (entryTypeIcons[type]) return entryTypeIcons[type];
 
Loading
Loading
Loading
Loading
@@ -28,5 +28,4 @@ const isPlainReadme = file => {
return re.test(file.name);
};
 
// eslint-disable-next-line import/prefer-default-export
export const readmeFile = blobs => blobs.find(isRichReadme) || blobs.find(isPlainReadme);
Loading
Loading
@@ -2,7 +2,6 @@ import GetSnippetQuery from '../queries/snippet.query.graphql';
 
const blobsDefault = [];
 
// eslint-disable-next-line import/prefer-default-export
export const getSnippetMixin = {
apollo: {
snippet: {
Loading
Loading
// eslint-disable-next-line import/prefer-default-export
export const getBinary = file => {
return new Promise((resolve, reject) => {
const reader = new FileReader();
Loading
Loading
import { s__, n__ } from '~/locale';
 
// eslint-disable-next-line import/prefer-default-export
export const title = state => {
if (state.isLoading) {
return s__('BuildArtifacts|Loading artifacts');
Loading
Loading
// eslint-disable-next-line import/prefer-default-export
export const stripQuotes = value => {
return value.includes(' ') ? value.slice(1, -1) : value;
};
/* eslint-disable import/prefer-default-export */
function trimFirstCharOfLineContent(text) {
if (!text) {
return text;
Loading
Loading
Loading
Loading
@@ -9,7 +9,6 @@
* @param {string} root - the key of the state where to search fo they keys described in list
* @returns {Object} a dictionary with all the computed properties generated
*/
// eslint-disable-next-line import/prefer-default-export
export const mapComputed = (list, defaultUpdateFn, root) => {
const result = {};
list.forEach(item => {
Loading
Loading
Loading
Loading
@@ -55,10 +55,6 @@ export const createStore = () =>
});
```
 
_Note:_ Until this
[RFC](https://gitlab.com/gitlab-org/frontend/rfcs/-/issues/20) is implemented,
the above will need to disable the `import/prefer-default-export` ESLint rule.
### `state.js`
 
The first thing you should do before writing any code is to design the state.
Loading
Loading
// eslint-disable-next-line import/prefer-default-export
export const customStageFormActive = ({ isCreatingCustomStage, isEditingCustomStage }) =>
Boolean(isCreatingCustomStage || isEditingCustomStage);
Loading
Loading
@@ -18,7 +18,6 @@ import { dateFormats } from '../shared/constants';
*
* @return {Array} the computed month data
*/
// eslint-disable-next-line import/prefer-default-export
export const computeMonthRangeData = (startDate, endDate, format = dateFormats.isoDate) => {
const monthData = [];
const monthNames = getMonthNames(true);
Loading
Loading
import SET_ENDPOINT from './mutation_types';
 
// eslint-disable-next-line import/prefer-default-export
export const setEndpoint = ({ commit }, endpoint) => commit(SET_ENDPOINT, endpoint);
// eslint-disable-next-line import/prefer-default-export
export const getMetricTypes = state => chartKey =>
state.metricTypes.filter(m => m.charts.indexOf(chartKey) !== -1);
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