diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..43abf1a --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,16 @@ +# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.222.0/containers/javascript-node/.devcontainer/base.Dockerfile + +# [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 16, 14, 12, 16-bullseye, 14-bullseye, 12-bullseye, 16-buster, 14-buster, 12-buster +ARG VARIANT="16" +FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT} + +# [Optional] Uncomment this section to install additional OS packages. +# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ +# && apt-get -y install --no-install-recommends + +# [Optional] Uncomment if you want to install an additional version of node using nvm +# ARG EXTRA_NODE_VERSION=10 +# RUN su node -c "source/usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}" + +# [Optional] Uncomment if you want to install more global node modules +# RUN su node -c "npm install -g " diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..bf736f9 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,32 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.222.0/containers/javascript-node +{ + "name": "Node.js", + "build": { + "dockerfile": "Dockerfile", + // Update 'VARIANT' to pick a Node version: 16, 14, 12. + // Append -bullseye or -buster to pin to an OS version. + // Use -bullseye variants on local arm64/Apple Silicon. + "args": { "VARIANT": "16" } + }, + + // Set *default* container specific settings.json values on container create. + "settings": {}, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "dbaeumer.vscode-eslint" + ], + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "yarn install", + + // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "node", + "features": { + "git": "latest" + } +} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..d5a3d25 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,45 @@ +name: Publish + +on: + release: + types: [created] + +jobs: + publish-npm: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 14 + registry-url: https://registry.npmjs.org/ + cache: npm + - run: npm ci + - run: npm test + - run: npm version ${TAG_NAME} --git-tag-version=false + env: + TAG_NAME: ${{ github.event.release.tag_name }} + - run: npm whoami; npm --ignore-scripts publish + env: + NODE_AUTH_TOKEN: ${{secrets.npm_token}} + + publish-github: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 14 + registry-url: https://npm.pkg.github.com + cache: npm + - run: npm ci + - run: npm test + - run: npm version ${TAG_NAME} --git-tag-version=false + env: + TAG_NAME: ${{ github.event.release.tag_name }} + - run: npm whoami; npm --ignore-scripts publish + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..f5dc344 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,18 @@ +name: Node CI + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Use Node.js 18.x + uses: actions/setup-node@v1 + with: + node-version: 18.x + - name: npm install, build, and test + run: | + npm it + env: + CI: true diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000..e6bf555 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1 @@ +* @github/web-systems-reviewers diff --git a/examples/one.ts b/examples/one.ts new file mode 100644 index 0000000..6ebaa43 --- /dev/null +++ b/examples/one.ts @@ -0,0 +1,23 @@ +const obj = { + one: 1, + two: 2, + three: 3, +} + +;('this config avoids semicolons at the end of statements and uses single quotes for strings') + +async function heresAFunctionWhichSpansMulitpleLinesAnd( + that, + includes, + many, + args, + to, + demonstrait, + trailing, + func, + commas, +) { + return obj +} + +const arrowFunctions = avoidParens => 1 diff --git a/index.js b/index.js index f4e6e08..c92394c 100644 --- a/index.js +++ b/index.js @@ -3,5 +3,6 @@ module.exports = { semi: false, singleQuote: true, bracketSpacing: false, - trailingComma: 'none' + trailingComma: 'all', + arrowParens: 'avoid' } diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..bc4be5c --- /dev/null +++ b/package-lock.json @@ -0,0 +1,39 @@ +{ + "name": "@github/prettier-config", + "version": "0.0.4", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "@github/prettier-config", + "version": "0.0.4", + "license": "MIT", + "devDependencies": { + "prettier": "^2.8.0" + } + }, + "node_modules/prettier": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.0.tgz", + "integrity": "sha512-9Lmg8hTFZKG0Asr/kW9Bp8tJjRVluO8EJQVfY2T7FMw9T5jy4I/Uvx0Rca/XWf50QQ1/SS48+6IJWnrb+2yemA==", + "dev": true, + "bin": { + "prettier": "bin-prettier.js" + }, + "engines": { + "node": ">=10.13.0" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + } + }, + "dependencies": { + "prettier": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.0.tgz", + "integrity": "sha512-9Lmg8hTFZKG0Asr/kW9Bp8tJjRVluO8EJQVfY2T7FMw9T5jy4I/Uvx0Rca/XWf50QQ1/SS48+6IJWnrb+2yemA==", + "dev": true + } + } +} diff --git a/package.json b/package.json index d10f3f5..b71ecaa 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,22 @@ { "name": "@github/prettier-config", - "version": "0.0.2", + "version": "0.0.0-development", "description": "Prettier config used at GitHub", "repository": "github/prettier-config", "keywords": [ "prettier" ], + "files": [ + "index.js" + ], "license": "MIT", "author": "GitHub Inc.", "main": "index.js", - "publishConfig": { - "registry": "https://npm.pkg.github.com/" + "scripts": { + "test:update": "prettier --config ./index.js --write examples/", + "test": "prettier --config ./index.js --check examples/" + }, + "devDependencies": { + "prettier": "^2.8.0" } }