forked from openlawteam/openlaw-client
-
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.
integrate scalafmt code formatting scaffolding (openlawteam#175)
* integrate code formatting scaffolding Since OSS contributors to this repo are more likely to be touching the JS portion, I left out the "recommend extensions" for Scala for the default vscode conf, so we dont bug everyone who wants to contribute to install it. * apply scalafmt auto fix * apply lint-style-fix globally catches a Markdown formatting thing in README via Prettier.
- Loading branch information
Showing
9 changed files
with
713 additions
and
258 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 |
---|---|---|
|
@@ -19,3 +19,12 @@ jobs: | |
- uses: actions/checkout@v1 | ||
- name: Shellcheck Lint | ||
uses: azohra/[email protected] | ||
|
||
lint-scala: | ||
name: Run scalafmt | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
with: | ||
fetch-depth: 1 | ||
- uses: openlawteam/scalafmt-ci@v2 |
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,25 @@ | ||
# Scalafmt configuration | ||
# | ||
# Reference: https://scalameta.org/scalafmt/docs/configuration.html | ||
|
||
# We would like to define an "edition" to freeze the rules without requiring a | ||
# specific version. | ||
# | ||
# In effect, this then enforces a minimum version of scalafmt but allows some | ||
# users to have more recent versions installed on their machine, and lets us | ||
# upgrade the default ruleset all at once for the project if desired. | ||
# | ||
# Unfortunately, IntelliJ parses the conf file on its own prior to passing to | ||
# scalafmt, and it does not yet support the `edition` tag and bombs. | ||
# | ||
# https://intellij-support.jetbrains.com/hc/en-us/requests/2449753 | ||
|
||
# edition = 2019-12 | ||
version = "2.3.2" | ||
|
||
|
||
project.excludeFilters = ["target/"] | ||
|
||
# NOTE: To adhere to OSS community standards, and to have as minimum a gap as | ||
# possible between "default" projects, we do not override any of the style | ||
# defaults. |
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,9 @@ | ||
{ | ||
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. | ||
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp | ||
|
||
// List of extensions which should be recommended for users of this workspace. | ||
"recommendations": ["esbenp.prettier-vscode"], | ||
// List of extensions recommended by VS Code that should not be recommended for users of this workspace. | ||
"unwantedRecommendations": [] | ||
} |
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 @@ | ||
{ | ||
"editor.formatOnSave": true, | ||
"[javascript]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
} | ||
} |
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,58 @@ | ||
############################################################################### | ||
# Linters (not normally run manually via command line, but here for backup.) | ||
############################################################################### | ||
.PHONY: lint lint-style lint-style-fix lint-code | ||
lint: lint-style lint-code | ||
lint-code: lint-code-js | ||
lint-style: lint-style-js lint-style-scala ## Lint all files for code style | ||
lint-style-fix: lint-style-js-fix lint-style-scala-fix # Automatically fix all files for code style | ||
|
||
lint-style-js: | ||
npm run style | ||
|
||
lint-style-js-fix: | ||
npm run style:fix | ||
|
||
lint-code-js: | ||
npm run lint | ||
|
||
lint-code-js-fix: | ||
npm run lint:fix | ||
|
||
SCALAFMT_IMAGE = mrothy/scalafmt-native:2.3.2 | ||
SCALAFMT_TARGETS = src project build.sbt | ||
SCALAFMT_EXCLUSIONS = target/ | ||
|
||
lint-style-scala: # Lint scala files for code style | ||
docker run \ | ||
-v $$(PWD):/src \ | ||
--rm -it \ | ||
--workdir /src \ | ||
$(SCALAFMT_IMAGE) \ | ||
--exclude $(SCALAFMT_EXCLUSIONS) \ | ||
--list \ | ||
$(SCALAFMT_TARGETS) | ||
|
||
lint-style-scala-fix: # Automatically fix scala files for code style | ||
docker run \ | ||
-v $$(PWD):/src \ | ||
--rm -it \ | ||
--workdir /src \ | ||
$(SCALAFMT_IMAGE) \ | ||
--exclude $(SCALAFMT_EXCLUSIONS) \ | ||
$(SCALAFMT_TARGETS) | ||
|
||
############################################################################### | ||
# Modified version of self-documenting help script from: | ||
# https://suva.sh/posts/well-documented-makefiles/ | ||
# | ||
# This creates a default `help` goal that will document all tasks that are | ||
# annotated with a double comment "#" marker. | ||
############################################################################### | ||
.DEFAULT_GOAL:=help | ||
help: ## Display this help message | ||
@awk 'BEGIN { \ | ||
FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n" \ | ||
} /^[a-zA-Z0-9_-]+:.*?##/ { \ | ||
printf " \033[36m%-12s\033[0m %s\n", $$1, $$2 \ | ||
}' $(MAKEFILE_LIST) |
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
Oops, something went wrong.