-
Notifications
You must be signed in to change notification settings - Fork 346
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2543 from cloudflare/npaun/add-js-formatting
Add TS/JS/JSON formatting to the project
- Loading branch information
Showing
198 changed files
with
26,402 additions
and
22,930 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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.