Disable default export rules
What does this MR do?
Disable default export rules
This is part of the work to implement the consensus reached in the RFC to prefer named exports over defalt exports.
Future iterations will migrate existing default exports to named exports.
Note that a previous version of this MR added eslint-disable import/no-default-export
directives, and explicitly disabled that rule. That approach was abandoned for this more iterative approach, since it meant there were over 1,000 changed files!
This bumps to @gitlab/eslint-plugin@4.0.0
to explicitly prefer named exports to default exports (see gitlab-org/frontend/eslint-plugin!22 (merged)).
The bulk of the changes in this MR were performed with the following script:
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, to help make it easier to keep this MR up-to-date.
Does this MR meet the acceptance criteria?
Conformity
- [-] Changelog entry
- [-] Documentation (if required)
-
Code review guidelines - [-] Merge request performance guidelines
-
Style guides - [-] Database guides
- [-] Separation of EE specific content
Availability and Testing
- [-] Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process.
- [-] Tested in all supported browsers
- [-] Informed Infrastructure department of a default or new setting change, if applicable per definition of done