-
Notifications
You must be signed in to change notification settings - Fork 1.9k
dev: Add a script to auto fix all lint violations #19560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
2010YOUY01
wants to merge
5
commits into
apache:main
Choose a base branch
from
2010YOUY01:auto-fix
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1e5b557
auto fix for all non-functional tests in dev/rust_lint.sh
2010YOUY01 8c99417
Introduce all possible lint violations
2010YOUY01 dbfc318
fix license_header.sh bug
2010YOUY01 f499533
auto-fix violations
2010YOUY01 ae7fc70
review
2010YOUY01 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,41 +17,68 @@ | |
| # specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| SCRIPT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BASH_SOURCE[0]}")" | ||
|
|
||
| MODE="--check" | ||
| ACTION="Checking" | ||
| if [ $# -gt 0 ]; then | ||
| if [ "$1" = "--write" ]; then | ||
| MODE="--write" | ||
| ACTION="Formatting" | ||
| else | ||
| echo "Usage: $0 [--write]" >&2 | ||
| exit 1 | ||
| fi | ||
| set -euo pipefail | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| SCRIPT_NAME="$(basename "${BASH_SOURCE[0]}")" | ||
| PRETTIER_VERSION="2.7.1" | ||
| PRETTIER_TARGETS=( | ||
| '{datafusion,datafusion-cli,datafusion-examples,dev,docs}/**/*.md' | ||
| '!datafusion/CHANGELOG.md' | ||
| README.md | ||
| CONTRIBUTING.md | ||
| ) | ||
|
|
||
| source "${SCRIPT_DIR}/utils/git.sh" | ||
|
|
||
| MODE="check" | ||
| ALLOW_DIRTY=0 | ||
|
|
||
| usage() { | ||
| cat >&2 <<EOF | ||
| Usage: $SCRIPT_NAME [--write] [--allow-dirty] | ||
| Runs prettier@${PRETTIER_VERSION} over markdown docs. | ||
| --write Run with \`--write\` to format files (requires a clean git worktree, no uncommitted changes). | ||
| --allow-dirty Allow \`--write\` to run even when the git worktree has uncommitted changes. | ||
| EOF | ||
| exit 1 | ||
| } | ||
|
|
||
| while [[ $# -gt 0 ]]; do | ||
| case "$1" in | ||
| --write) | ||
| MODE="write" | ||
| ;; | ||
| --allow-dirty) | ||
| ALLOW_DIRTY=1 | ||
| ;; | ||
| -h|--help) | ||
| usage | ||
| ;; | ||
| *) | ||
| usage | ||
| ;; | ||
| esac | ||
| shift | ||
| done | ||
|
|
||
| if [[ "$MODE" == "write" && $ALLOW_DIRTY -eq 0 ]]; then | ||
| require_clean_work_tree "$SCRIPT_NAME" || exit 1 | ||
| fi | ||
|
|
||
| echo "$SCRIPT_PATH: $ACTION documents with prettier" | ||
| echo "[${SCRIPT_NAME}] prettier@${PRETTIER_VERSION} ${MODE}" | ||
|
|
||
| # Ensure `npx` is available | ||
| if ! command -v npx >/dev/null 2>&1; then | ||
| echo "npx is required to run the prettier check. Install Node.js (e.g., brew install node) and re-run." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Ignore subproject CHANGELOG.md because it is machine generated | ||
| npx [email protected] $MODE \ | ||
| '{datafusion,datafusion-cli,datafusion-examples,dev,docs}/**/*.md' \ | ||
| '!datafusion/CHANGELOG.md' \ | ||
| README.md \ | ||
| CONTRIBUTING.md | ||
| status=$? | ||
|
|
||
| if [ $status -ne 0 ]; then | ||
| if [ "$MODE" = "--check" ]; then | ||
| echo "Prettier check failed. Re-run with --write (e.g., ./ci/scripts/doc_prettier_check.sh --write) to format files, commit the changes, and re-run the check." >&2 | ||
| else | ||
| echo "Prettier format failed. Files may have been modified; commit any changes and re-run." >&2 | ||
| fi | ||
| exit $status | ||
|
|
||
| PRETTIER_MODE=(--check) | ||
| if [[ "$MODE" == "write" ]]; then | ||
| PRETTIER_MODE=(--write) | ||
| fi | ||
|
|
||
| # Ignore subproject CHANGELOG.md because it is machine generated | ||
| npx "prettier@${PRETTIER_VERSION}" "${PRETTIER_MODE[@]}" "${PRETTIER_TARGETS[@]}" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to keep using this old version ?
Latest is https://www.npmjs.com/package/prettier/v/3.7.4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I think it's supposed to get updated manually.
We can do so separately since it might have a large code diff.