Skip to content

Commit

Permalink
chore: add formatting with prettier (#1946)
Browse files Browse the repository at this point in the history
* chore: remove eslintConfig from plugin packages

* chore: switch to eslint flat config

* chore: add prettier

* chore: convert eslint config to cjs

* chore: temporarily disable tag-lines rule in ts

* chore: update prettier ignore

* chore: manually fix lint errors

* chore: remove blockly-scripts lint

* chore: do not lint from webpack

* chore: un-remove blockly-scripts lint

This partially reverts commit cc9914e.

* deprecate: add warning to blockly-scripts lint

* chore: update copyright date

* fix: no autofix missing jsdoc

* chore: update package lock after merge conflicts

* fix: update lint fix command

* fix: autofix lint problems

* chore: format everything

* fix: ignore sample app files in dev-create

* chore: package lock shenanigans
  • Loading branch information
maribethb authored Oct 26, 2023
1 parent d3ea99a commit 82f1c35
Show file tree
Hide file tree
Showing 400 changed files with 19,268 additions and 31,279 deletions.
32 changes: 16 additions & 16 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ race, religion, or sexual identity and orientation.
Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
- The use of sexualized language or imagery and unwelcome sexual attention or
advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic
address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Expand Down Expand Up @@ -69,8 +69,8 @@ dispute. If you are unable to resolve the matter for any reason, or if the
behavior is threatening or harassing, report it. We are dedicated to providing
an environment where participants feel welcome and safe.

Reports should be directed to *[PROJECT STEWARD NAME(s) AND EMAIL(s)]*, the
Project Steward(s) for *[PROJECT NAME]*. It is the Project Steward’s duty to
Reports should be directed to _[PROJECT STEWARD NAME(s) AND EMAIL(s)]_, the
Project Steward(s) for _[PROJECT NAME]_. It is the Project Steward’s duty to
receive and address reported violations of the code of conduct. They will then
work with a committee consisting of representatives from the Open Source
Programs Office and the Google Open Source Strategy team. If for any reason you
Expand All @@ -90,4 +90,4 @@ harassment or threats to anyone's safety, we may take action without notice.

This Code of Conduct is adapted from the Contributor Covenant, version 1.4,
available at
https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
44 changes: 22 additions & 22 deletions .github/workflows/assign_reviewers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,26 @@ jobs:
requested-reviewer:
runs-on: ubuntu-latest
steps:
- name: Assign requested reviewer
uses: actions/github-script@v5
with:
script: |
try {
if (context.payload.pull_request === undefined) {
throw new Error("Can't get pull_request payload. " +
'Check a request reviewer event was triggered.');
- name: Assign requested reviewer
uses: actions/github-script@v5
with:
script: |
try {
if (context.payload.pull_request === undefined) {
throw new Error("Can't get pull_request payload. " +
'Check a request reviewer event was triggered.');
}
const reviewers = context.payload.pull_request.requested_reviewers;
// Assignees takes in a list of logins rather than the
// reviewer object.
const reviewerNames = reviewers.map(reviewer => reviewer.login);
const {number:issue_number} = context.payload.pull_request;
github.rest.issues.addAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
assignees: reviewerNames
});
} catch (error) {
core.setFailed(error.message);
}
const reviewers = context.payload.pull_request.requested_reviewers;
// Assignees takes in a list of logins rather than the
// reviewer object.
const reviewerNames = reviewers.map(reviewer => reviewer.login);
const {number:issue_number} = context.payload.pull_request;
github.rest.issues.addAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
assignees: reviewerNames
});
} catch (error) {
core.setFailed(error.message);
}
40 changes: 20 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,35 @@ jobs:
matrix:
node-version: [16.x, 18.x, 20.x]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Npm Install
run: npm install
- name: Npm Install
run: npm install

- name: Build
run: npm run build -- -- -- --skip-lint
- name: Build
run: npm run build

- name: Test
run: npm run test -- -- -- --skip-lint
- name: Test
run: npm run test

lint:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v2

- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 20
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 20

- name: Npm Install
run: npm install
- name: Npm Install
run: npm install

- name: Lint
run: npm run lint
- name: Lint
run: npm run lint
2 changes: 1 addition & 1 deletion .github/workflows/clean_install_examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

name: Check examples install status

on:
on:
pull_request:
paths:
- 'examples/**'
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/dependabot_update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
name: Clean up after dependabot

# Triggered when a PR is (re)opened or synchronized
on:
on:
pull_request:
paths:
- "plugins/**"
- 'plugins/**'

permissions:
pull-requests: write # This action modifies PRs
Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:
# Install packages
- name: Npm install
run: npm ci

# Run lerna bootstrap again, this time using `install` instead of `ci` so that
# it will do the magic update we need to remove local dependencies.
- name: Fix package locks
Expand Down
68 changes: 34 additions & 34 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
name: publish

on:
workflow_dispatch: # Manually trigger. Colon is required.
workflow_dispatch: # Manually trigger. Colon is required.
schedule:
- cron: '5 17 * * 4' # Thursdays at 17:05 UTC (09:05 PST / 10:05 PDT)

permissions:
contents: write # For checkout and tag.
packages: write # For publish.
contents: write # For checkout and tag.
packages: write # For publish.

jobs:
publish:
Expand All @@ -21,44 +21,44 @@ jobs:
environment: release

steps:
- name: Checkout
uses: actions/checkout@v3
# fetch all tags and commits so that lerna can version appropriately
with:
fetch-depth: 0
ref: 'master'
- name: Checkout
uses: actions/checkout@v3
# fetch all tags and commits so that lerna can version appropriately
with:
fetch-depth: 0
ref: 'master'

# This uses a reverse-engineered email for the github actions bot. See
# https://github.com/actions/checkout/issues/13#issuecomment-724415212
- name: Git Identity
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email '<41898282+github-actions[bot]@users.noreply.github.com'
# This uses a reverse-engineered email for the github actions bot. See
# https://github.com/actions/checkout/issues/13#issuecomment-724415212
- name: Git Identity
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email '<41898282+github-actions[bot]@users.noreply.github.com'
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 20
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 20

- name: Configure npm
run: npm config set //wombat-dressing-room.appspot.com/:_authToken=$NODE_AUTH_TOKEN
env:
NODE_AUTH_TOKEN: ${{ secrets.RELEASE_BACKED_NPM_TOKEN }}
- name: Configure npm
run: npm config set //wombat-dressing-room.appspot.com/:_authToken=$NODE_AUTH_TOKEN
env:
NODE_AUTH_TOKEN: ${{ secrets.RELEASE_BACKED_NPM_TOKEN }}

- name: NPM install
# Use CI so that we don't update dependencies in this step.
run: npm ci
- name: NPM install
# Use CI so that we don't update dependencies in this step.
run: npm ci

- name: Build
run: npm run build -- -- -- --skip-lint
- name: Build
run: npm run build

- name: Test
run: npm run test -- -- -- --skip-lint
- name: Test
run: npm run test

- name: Publish
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx lerna publish --no-private --conventional-commits --create-release github --yes
- name: Publish
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx lerna publish --no-private --conventional-commits --create-release github --yes

update-gh-pages:
name: Update GitHub Pages
Expand Down
58 changes: 29 additions & 29 deletions .github/workflows/update_gh_pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
name: Update GitHub Pages

on:
workflow_dispatch: # Manually trigger. Colon is required.
workflow_dispatch: # Manually trigger. Colon is required.
inputs:
branch:
description: 'Branch to publish from'
Expand All @@ -13,37 +13,37 @@ on:
workflow_call: # Allow this workflow to be called from publish workflow.

permissions:
contents: write # For checkout and push.
contents: write # For checkout and push.

jobs:
update-github-pages:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ inputs.branch || 'master' }}

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 20

- name: NPM install
# Use CI so that we don't update dependencies in this step.
# TODO(#1511): remove --force flag from installing examples
# Until then, don't block updating just because some dependencies are out of date.
run: |
npm ci
(cd examples && npm ci --force)
- name: Deploy to GH Pages
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# deploys to the current repo,
# so you can use this workflow from a fork to update your personal gh-pages
run: |
npm run deploy:prepare
git remote set-url origin https://git:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
npx gh-pages -d gh-pages -t -u "github-actions-bot <[email protected]>"
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ inputs.branch || 'master' }}

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 20

- name: NPM install
# Use CI so that we don't update dependencies in this step.
# TODO(#1511): remove --force flag from installing examples
# Until then, don't block updating just because some dependencies are out of date.
run: |
npm ci
(cd examples && npm ci --force)
- name: Deploy to GH Pages
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# deploys to the current repo,
# so you can use this workflow from a fork to update your personal gh-pages
run: |
npm run deploy:prepare
git remote set-url origin https://git:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
npx gh-pages -d gh-pages -t -u "github-actions-bot <[email protected]>"
18 changes: 18 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# All examples, codelabs, etc.
examples/*
node_modules/*
codelabs/*
gh-pages/*

# All build artifacts, etc.
**/dist/*
**/build/*
**/node_modules/*
**/CHANGELOG.md
CHANGELOG.md
PULL_REQUEST_TEMPLATE.md

# Specific examples that are sometimes copied into plugins
plugins/dev-create/templates/sample-app/*
plugins/dev-create/templates/sample-app-ts/*

13 changes: 13 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// This config attempts to match google-style code.

module.exports = {
// Prefer single quotes, but minimize escaping.
singleQuote: true,
// Some properties must be quoted to preserve closure compiler behavior.
// Don't ever change whether properties are quoted.
quoteProps: 'preserve',
// Don't add spaces around braces for object literals.
bracketSpacing: false,
// Put HTML tag closing brackets on same line as last attribute.
bracketSameLine: true,
};
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Please see our [GitHub Pages site](https://google.github.io/blockly-samples/inde

Blockly has an active [developer forum](https://groups.google.com/forum/#!forum/blockly). Please drop by and say hello. Show us your prototypes early; collectively we have a lot of experience and can offer hints which will save you time. We actively monitor the forums and typically respond to questions within 2 working days.


## License

Apache 2.0
Loading

0 comments on commit 82f1c35

Please sign in to comment.