• Mark Florian's avatar
    Disable default export rules · 600155b6
    Mark Florian authored
    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
    600155b6
index.js 317 Bytes