forked from openwebwork/webwork2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add prettier formatting of JavaScript, style, and HTML files, and che…
…ck formatting in a workflow. Prettier is used to format JavaScript, style, and HTML files in htdocs. The configuration chosen is in .prettierrc and .editorconfig. Prettier doesn't really have many options as it is very opinionated. I am not entirely happy with everything prettier does, but it does give a more uniform code format to files. Furthermore, it is nice to be able to be able to just run prettier and not need to worry about formatting code. A workflow now checks formatting of JavaScript, style, and HTML files with prettier in addition checking formatting of perl files with perltidy. Note the "linter" workflow has been renamed to "check-formats", because that is what it does, and this really does not have anything to do with linting. Note that developers can (and should) run `npm run prettier-format` in the htdocs directory to format files. You can also run `npm run prettier-check` to check that formatting of these files is correct, and not actually change the files. This is what the workflow does.
- Loading branch information
Showing
6 changed files
with
95 additions
and
33 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,17 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
max_line_length = 120 | ||
trim_trailing_whitespace = true | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
[*.yml] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[*.pg] | ||
trim_trailing_whitespace = false |
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,44 @@ | ||
--- | ||
name: Check Formatting of Code Base | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
on: | ||
push: | ||
branches-ignore: [main, develop] | ||
pull_request: | ||
|
||
jobs: | ||
perltidy: | ||
name: Check Perl file formatting with perltidy | ||
runs-on: ubuntu-22.04 | ||
container: | ||
image: perl:5.34 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Install dependencies | ||
run: cpanm -n Perl::Tidy@20220613 | ||
- name: Run perltidy | ||
shell: bash | ||
run: | | ||
git config --global --add safe.directory "$GITHUB_WORKSPACE" | ||
shopt -s extglob globstar nullglob | ||
perltidy --pro=./.perltidyrc -b -bext='/' ./**/*.p[lm] ./**/*.t && git diff --exit-code | ||
prettier: | ||
name: Check JavaScript, style, and HTML file formatting with prettier | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Install Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' | ||
- name: Install Dependencies | ||
run: cd htdocs && npm ci --ignore-scripts | ||
- name: Check formatting with prettier | ||
run: cd htdocs && npm run prettier-check |
This file was deleted.
Oops, something went wrong.
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,8 @@ | ||
{ | ||
"arrowParens": "always", | ||
"bracketSpacing": true, | ||
"printWidth": 120, | ||
"semi": true, | ||
"singleQuote": true, | ||
"trailingComma": "none" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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