diff --git a/.github/workflows/prettier.yml b/.github/workflows/prettier.yml new file mode 100644 index 0000000..82692e0 --- /dev/null +++ b/.github/workflows/prettier.yml @@ -0,0 +1,23 @@ +# From https://til.simonwillison.net/github-actions/prettier-github-actions +name: Check JavaScript for conformance with Prettier + +on: + push: + pull_request: + +jobs: + prettier: + runs-on: ubuntu-latest + steps: + - name: Check out repo + uses: actions/checkout@v3 + - uses: actions/cache@v3 + name: Configure npm caching + with: + path: ~/.npm + key: ${{ runner.os }}-npm-${{ hashFiles('**/workflows/prettier.yml') }} + restore-keys: | + ${{ runner.os }}-npm- + - name: Run prettier + run: |- + npx prettier --check . diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..c36c824 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,5 @@ +dist +coverage + +# semantic-release +CHANGELOG.md diff --git a/.prettierrc.toml b/.prettierrc.toml new file mode 100644 index 0000000..437054d --- /dev/null +++ b/.prettierrc.toml @@ -0,0 +1,3 @@ +trailingComma = "all" +semi = true +useTabs = true \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 3f6b932..da95ef4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -39,6 +39,7 @@ "jest": "^29.4.2", "mock-socket": "^9.1.5", "parcel": "^2.8.2", + "prettier": "^2.8.4", "semantic-release": "^20.0.0", "typescript": "^4.1.2" }, @@ -12098,6 +12099,21 @@ "node": ">= 0.8.0" } }, + "node_modules/prettier": { + "version": "2.8.4", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.4.tgz", + "integrity": "sha512-vIS4Rlc2FNh0BySk3Wkd6xmwxB0FpOndW5fisM5H8hsZSxU2VWVB5CWIkIjWvrHjIhxk2g3bfMKM87zNTrZddw==", + "dev": true, + "bin": { + "prettier": "bin-prettier.js" + }, + "engines": { + "node": ">=10.13.0" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, "node_modules/pretty-format": { "version": "29.4.2", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.4.2.tgz", @@ -22948,6 +22964,12 @@ "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", "dev": true }, + "prettier": { + "version": "2.8.4", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.4.tgz", + "integrity": "sha512-vIS4Rlc2FNh0BySk3Wkd6xmwxB0FpOndW5fisM5H8hsZSxU2VWVB5CWIkIjWvrHjIhxk2g3bfMKM87zNTrZddw==", + "dev": true + }, "pretty-format": { "version": "29.4.2", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.4.2.tgz", diff --git a/package.json b/package.json index 87443c0..e7d5af3 100644 --- a/package.json +++ b/package.json @@ -61,6 +61,7 @@ "module": {} }, "scripts": { + "format": "prettier --write .", "build": "parcel build", "lint": "eslint --ext .js,.ts . && npm run check", "check": "tsc --noEmit", @@ -98,6 +99,7 @@ "jest": "^29.4.2", "mock-socket": "^9.1.5", "parcel": "^2.8.2", + "prettier": "^2.8.4", "semantic-release": "^20.0.0", "typescript": "^4.1.2" }