-
Notifications
You must be signed in to change notification settings - Fork 402
Add TS/JS/JSON formatting to the project #2543
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4bed3a6
Add a basic prettierrc config
npaun ab15158
Extend tools/cross/format.py to handle JS too
npaun 0523bf8
Bulk reformat JS, TS, JSON files
npaun d150b43
Add to git-blame-ignore-revs
npaun d5b2e51
Add githooks
npaun 1463f77
Correct placement of ts-ignore / eslint-ignore
npaun 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Apply prettier to the project | ||
0523bf8b36a937348f1bb79eceda2463a5c220b5 |
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Lint | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-24.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
show-progress: false | ||
- name: Setup Linux | ||
run: | | ||
export DEBIAN_FRONTEND=noninteractive | ||
wget https://apt.llvm.org/llvm.sh | ||
sed -i '/apt-get install/d' llvm.sh | ||
chmod +x llvm.sh | ||
sudo ./llvm.sh 18 | ||
sudo apt-get install -y --no-install-recommends clang-format-18 | ||
- name: Install pnpm | ||
uses: pnpm/action-setup@v4 | ||
# The pnpm version will be determined by the `packageManager` field in `.npmrc` | ||
- name: Install project deps with pnpm | ||
run: | | ||
pnpm i | ||
- name: Lint | ||
run: | | ||
python3 ./tools/cross/format.py --check | ||
env: | ||
CLANG_FORMAT: clang-format-18 |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
samples/nodejs-compat-streams-split2/split2.js |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"printWidth": 80, | ||
"tabWidth": 2, | ||
"singleQuote": true, | ||
"trailingComma": "es5" | ||
} |
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
|
||
source "$(dirname -- $BASH_SOURCE)/../tools/unix/find-python3.sh" | ||
PYTHON_PATH=$(get_python3) | ||
if [[ -z "$PYTHON_PATH" ]]; then | ||
echo | ||
echo "python3 is required for formatting and was not found" | ||
echo | ||
echo "ERROR: you must either install python3 and try pushing again or run `git push` with `--no-verify`" | ||
exit 1 | ||
fi | ||
|
||
while read LOCAL_REF LOCAL_SHA REMOTE_REF REMOTE_SHA | ||
do | ||
git fetch origin master &>/dev/null | ||
# Check all local changes, not present in origin/master, for lint. | ||
set +e | ||
$PYTHON_PATH "$(dirname -- $BASH_SOURCE)/../tools/cross/format.py" --check git --source $LOCAL_SHA --target origin/master | ||
EXIT_CODE=$? | ||
set -e | ||
case $EXIT_CODE in | ||
0) | ||
# No lint. | ||
;; | ||
1) | ||
echo | ||
echo "ERROR: changes in $LOCAL_REF have lint which may fail CI." | ||
echo | ||
echo "To fix lint:" | ||
echo " python3 ./tools/cross/format.py" | ||
echo | ||
exit 1 | ||
;; | ||
2) | ||
echo | ||
echo "ERROR: failed to run format.py, Pass '--no-verify' or '-n' to skip." | ||
echo | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,41 @@ | ||
{ | ||
"env": { | ||
"es2022": true, | ||
"worker": true | ||
"es2022": true, | ||
"worker": true | ||
}, | ||
"extends": [ | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:@typescript-eslint/recommended-requiring-type-checking", | ||
"plugin:@typescript-eslint/strict" | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:@typescript-eslint/recommended-requiring-type-checking", | ||
"plugin:@typescript-eslint/strict" | ||
], | ||
"overrides": [], | ||
"parserOptions": { | ||
"ecmaVersion": "latest", | ||
"sourceType": "module", | ||
"project": "src/cloudflare/tsconfig.json" | ||
}, | ||
"ecmaVersion": "latest", | ||
"sourceType": "module", | ||
"project": "src/cloudflare/tsconfig.json" | ||
}, | ||
"rules": { | ||
"@typescript-eslint/explicit-function-return-type": "error", | ||
"@typescript-eslint/explicit-member-accessibility": "error", | ||
"@typescript-eslint/explicit-module-boundary-types": "error", | ||
"@typescript-eslint/no-require-imports": "error", | ||
"@typescript-eslint/prefer-enum-initializers": "error", | ||
"@typescript-eslint/type-annotation-spacing": "error", | ||
"@typescript-eslint/restrict-template-expressions": "warn", | ||
"@typescript-eslint/no-non-null-assertion": "warn", | ||
"@typescript-eslint/no-extraneous-class": "off", | ||
"@typescript-eslint/unified-signatures": "off", | ||
"@typescript-eslint/no-unused-vars": [ | ||
"error", | ||
{ | ||
"args": "all", | ||
"argsIgnorePattern": "^_", | ||
"caughtErrors": "all", | ||
"caughtErrorsIgnorePattern": "^_", | ||
"destructuredArrayIgnorePattern": "^_", | ||
"varsIgnorePattern": "^_", | ||
"ignoreRestSiblings": true | ||
} | ||
] | ||
"@typescript-eslint/explicit-function-return-type": "error", | ||
"@typescript-eslint/explicit-member-accessibility": "error", | ||
"@typescript-eslint/explicit-module-boundary-types": "error", | ||
"@typescript-eslint/no-require-imports": "error", | ||
"@typescript-eslint/prefer-enum-initializers": "error", | ||
"@typescript-eslint/type-annotation-spacing": "error", | ||
"@typescript-eslint/restrict-template-expressions": "warn", | ||
"@typescript-eslint/no-non-null-assertion": "warn", | ||
"@typescript-eslint/no-extraneous-class": "off", | ||
"@typescript-eslint/unified-signatures": "off", | ||
"@typescript-eslint/no-unused-vars": [ | ||
"error", | ||
{ | ||
"args": "all", | ||
"argsIgnorePattern": "^_", | ||
"caughtErrors": "all", | ||
"caughtErrorsIgnorePattern": "^_", | ||
"destructuredArrayIgnorePattern": "^_", | ||
"varsIgnorePattern": "^_", | ||
"ignoreRestSiblings": true | ||
} | ||
] | ||
} | ||
} |
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.
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.
Uh oh!
There was an error while loading. Please reload this page.