1
0
mirror of https://github.com/funamitech/mastodon synced 2024-11-30 15:58:28 +09:00

Format JSON and YAML using Prettier (#17823)

* Format JSON and YAML using Prettier

* Add prettier to devDep
This commit is contained in:
Yamagishi Kazutoshi 2022-03-21 12:46:11 +09:00 committed by GitHub
parent cf5435bb27
commit 584d8b977b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 203 additions and 129 deletions

View File

@ -1,4 +1,4 @@
version: "2" version: '2'
checks: checks:
argument-count: argument-count:
enabled: false enabled: false
@ -34,8 +34,8 @@ plugins:
sass-lint: sass-lint:
enabled: true enabled: true
exclude_patterns: exclude_patterns:
- spec/ - spec/
- vendor/asset/ - vendor/asset/
- app/javascript/mastodon/locales/**/*.json - app/javascript/mastodon/locales/**/*.json
- config/locales/**/*.yml - config/locales/**/*.yml

View File

@ -5,22 +5,22 @@
"workspaceFolder": "/workspaces/mastodon", "workspaceFolder": "/workspaces/mastodon",
// Set *default* container specific settings.json values on container create. // Set *default* container specific settings.json values on container create.
"settings": {}, "settings": {},
// Add the IDs of extensions you want installed when the container is created. // Add the IDs of extensions you want installed when the container is created.
"extensions": [ "extensions": [
"EditorConfig.EditorConfig", "EditorConfig.EditorConfig",
"dbaeumer.vscode-eslint", "dbaeumer.vscode-eslint",
"rebornix.Ruby" "rebornix.Ruby"
], ],
// Use 'forwardPorts' to make a list of ports inside the container available locally. // Use 'forwardPorts' to make a list of ports inside the container available locally.
// This can be used to network with other containers or the host. // This can be used to network with other containers or the host.
"forwardPorts": [3000, 4000], "forwardPorts": [3000, 4000],
// Use 'postCreateCommand' to run commands after the container is created. // Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "bundle install --path vendor/bundle && yarn install && ./bin/rails db:setup", "postCreateCommand": "bundle install --path vendor/bundle && yarn install && ./bin/rails db:setup",
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode" "remoteUser": "vscode"
} }

View File

@ -9,9 +9,9 @@ services:
# Update 'VARIANT' to pick a version of Ruby: 3, 3.1, 3.0, 2, 2.7, 2.6 # Update 'VARIANT' to pick a version of Ruby: 3, 3.1, 3.0, 2, 2.7, 2.6
# Append -bullseye or -buster to pin to an OS version. # Append -bullseye or -buster to pin to an OS version.
# Use -bullseye variants on local arm64/Apple Silicon. # Use -bullseye variants on local arm64/Apple Silicon.
VARIANT: "3.0-bullseye" VARIANT: '3.0-bullseye'
# Optional Node.js version to install # Optional Node.js version to install
NODE_VERSION: "14" NODE_VERSION: '14'
volumes: volumes:
- ..:/workspaces/mastodon:cached - ..:/workspaces/mastodon:cached
environment: environment:
@ -34,7 +34,6 @@ services:
- internal_network - internal_network
user: vscode user: vscode
db: db:
image: postgres:14-alpine image: postgres:14-alpine
restart: unless-stopped restart: unless-stopped

View File

@ -6,7 +6,7 @@
version: 2 version: 2
updates: updates:
- package-ecosystem: npm - package-ecosystem: npm
directory: "/" directory: '/'
schedule: schedule:
interval: weekly interval: weekly
open-pull-requests-limit: 99 open-pull-requests-limit: 99
@ -14,7 +14,7 @@ updates:
- dependency-type: direct - dependency-type: direct
- package-ecosystem: bundler - package-ecosystem: bundler
directory: "/" directory: '/'
schedule: schedule:
interval: weekly interval: weekly
open-pull-requests-limit: 99 open-pull-requests-limit: 99

View File

@ -3,9 +3,9 @@ on:
workflow_dispatch: workflow_dispatch:
push: push:
branches: branches:
- "main" - 'main'
tags: tags:
- "*" - '*'
pull_request: pull_request:
paths: paths:
- .github/workflows/build-image.yml - .github/workflows/build-image.yml

View File

@ -2,9 +2,9 @@ name: Check i18n
on: on:
push: push:
branches: [ main ] branches: [main]
pull_request: pull_request:
branches: [ main ] branches: [main]
env: env:
RAILS_ENV: test RAILS_ENV: test
@ -14,21 +14,21 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Install system dependencies - name: Install system dependencies
run: | run: |
sudo apt-get update sudo apt-get update
sudo apt-get install -y libicu-dev libidn11-dev sudo apt-get install -y libicu-dev libidn11-dev
- name: Set up Ruby - name: Set up Ruby
uses: ruby/setup-ruby@v1 uses: ruby/setup-ruby@v1
with: with:
ruby-version: '3.0' ruby-version: '3.0'
bundler-cache: true bundler-cache: true
- name: Check locale file normalization - name: Check locale file normalization
run: bundle exec i18n-tasks check-normalized run: bundle exec i18n-tasks check-normalized
- name: Check for unused strings - name: Check for unused strings
run: bundle exec i18n-tasks unused -l en run: bundle exec i18n-tasks unused -l en
- name: Check for wrong string interpolations - name: Check for wrong string interpolations
run: bundle exec i18n-tasks check-consistent-interpolations run: bundle exec i18n-tasks check-consistent-interpolations
- name: Check that all required locale files exist - name: Check that all required locale files exist
run: bundle exec rake repo:check_locales_files run: bundle exec rake repo:check_locales_files

78
.prettierignore Normal file
View File

@ -0,0 +1,78 @@
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'
# Ignore bundler config and downloaded libraries.
/.bundle
/vendor/bundle
# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal
# Ignore all logfiles and tempfiles.
.eslintcache
/log/*
!/log/.keep
/tmp
/coverage
/public/system
/public/assets
/public/packs
/public/packs-test
.env
.env.production
.env.development
/node_modules/
/build/
# Ignore Vagrant files
.vagrant/
# Ignore Capistrano customizations
/config/deploy/*
# Ignore IDE files
.vscode/
.idea/
# Ignore postgres + redis + elasticsearch volume optionally created by docker-compose
/postgres
/postgres14
/redis
/elasticsearch
# ignore Helm dependency charts
/chart/charts/*.tgz
# Ignore Apple files
.DS_Store
# Ignore vim files
*~
*.swp
# Ignore npm debug log
npm-debug.log
# Ignore yarn log files
yarn-error.log
yarn-debug.log
# Ignore vagrant log files
*-cloudimg-console.log
# Ignore Docker option files
docker-compose.override.yml
# Ignore Helm files
/chart
# Ignore emoji map file
/app/javascript/mastodon/features/emoji/emoji_map.json
# Ignore locale files
/app/javascript/mastodon/locales
/config/locales

3
.prettierrc.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = {
singleQuote: true
}

View File

@ -5,17 +5,17 @@ AllCops:
TargetRubyVersion: 2.5 TargetRubyVersion: 2.5
NewCops: disable NewCops: disable
Exclude: Exclude:
- 'spec/**/*' - 'spec/**/*'
- 'db/**/*' - 'db/**/*'
- 'app/views/**/*' - 'app/views/**/*'
- 'config/**/*' - 'config/**/*'
- 'bin/*' - 'bin/*'
- 'Rakefile' - 'Rakefile'
- 'node_modules/**/*' - 'node_modules/**/*'
- 'Vagrantfile' - 'Vagrantfile'
- 'vendor/**/*' - 'vendor/**/*'
- 'lib/json_ld/*' - 'lib/json_ld/*'
- 'lib/templates/**/*' - 'lib/templates/**/*'
Bundler/OrderedGems: Bundler/OrderedGems:
Enabled: false Enabled: false

View File

@ -95,8 +95,5 @@
"scripts": { "scripts": {
"postdeploy": "bundle exec rails db:migrate && bundle exec rails db:seed" "postdeploy": "bundle exec rails db:migrate && bundle exec rails db:seed"
}, },
"addons": [ "addons": ["heroku-postgresql", "heroku-redis"]
"heroku-postgresql",
"heroku-redis"
]
} }

View File

@ -43,20 +43,19 @@ run.config:
fs_watch: true fs_watch: true
deploy.config: deploy.config:
extra_steps: extra_steps:
- NODE_ENV=production bundle exec rake assets:precompile - NODE_ENV=production bundle exec rake assets:precompile
transform: transform:
- "envsubst < /app/.env.nanobox > /app/.env.production" - 'envsubst < /app/.env.nanobox > /app/.env.production'
- |- - |-
if [ -z "$LOCAL_DOMAIN" ] if [ -z "$LOCAL_DOMAIN" ]
then then
. /app/.env.production . /app/.env.production
export LOCAL_DOMAIN export LOCAL_DOMAIN
fi fi
erb /app/nanobox/nginx-web.conf.erb > /app/nanobox/nginx-web.conf erb /app/nanobox/nginx-web.conf.erb > /app/nanobox/nginx-web.conf
erb /app/nanobox/nginx-stream.conf.erb > /app/nanobox/nginx-stream.conf erb /app/nanobox/nginx-stream.conf.erb > /app/nanobox/nginx-stream.conf
- touch /app/log/production.log - touch /app/log/production.log
before_live: before_live:
web.web: web.web:
@ -65,11 +64,10 @@ deploy.config:
after_live: after_live:
worker.sidekiq: worker.sidekiq:
- |- - |-
if [[ "${ES_ENABLED}" != "false" ]] if [[ "${ES_ENABLED}" != "false" ]]
then then
bin/tootctl search deploy bin/tootctl search deploy
fi fi
web.web: web.web:
start: start:
@ -89,7 +87,6 @@ web.web:
data.storage: data.storage:
- public/system - public/system
web.stream: web.stream:
start: start:
nginx: nginx -c /app/nanobox/nginx-stream.conf nginx: nginx -c /app/nanobox/nginx-stream.conf
@ -103,7 +100,6 @@ web.stream:
writable_dirs: writable_dirs:
- tmp - tmp
worker.sidekiq: worker.sidekiq:
start: start:
default: bundle exec sidekiq -c 5 -q default -L /app/log/sidekiq.log default: bundle exec sidekiq -c 5 -q default -L /app/log/sidekiq.log
@ -123,7 +119,6 @@ worker.sidekiq:
data.storage: data.storage:
- public/system - public/system
data.db: data.db:
image: nanobox/postgresql:9.6 image: nanobox/postgresql:9.6
@ -145,7 +140,6 @@ data.db:
curl -k -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/${file} -X DELETE curl -k -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/${file} -X DELETE
done done
data.elastic: data.elastic:
image: nanobox/elasticsearch:5 image: nanobox/elasticsearch:5
@ -171,7 +165,6 @@ data.elastic:
curl -k -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/${file} -X DELETE curl -k -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/${file} -X DELETE
done done
data.redis: data.redis:
image: nanobox/redis:4.0 image: nanobox/redis:4.0
@ -191,7 +184,6 @@ data.redis:
curl -k -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/${file} -X DELETE curl -k -H "X-AUTH-TOKEN: ${WAREHOUSE_DATA_HOARDER_TOKEN}" https://${WAREHOUSE_DATA_HOARDER_HOST}:7410/blobs/${file} -X DELETE
done done
data.storage: data.storage:
image: nanobox/unfs:0.9 image: nanobox/unfs:0.9

View File

@ -32,4 +32,3 @@ production:
host: <%= ENV['DB_HOST'] || 'localhost' %> host: <%= ENV['DB_HOST'] || 'localhost' %>
port: <%= ENV['DB_PORT'] || 5432 %> port: <%= ENV['DB_PORT'] || 5432 %>
prepared_statements: <%= ENV['PREPARED_STATEMENTS'] || 'true' %> prepared_statements: <%= ENV['PREPARED_STATEMENTS'] || 'true' %>

View File

@ -17,8 +17,8 @@ data:
search: search:
paths: paths:
- app/ - app/
- config/navigation.rb - config/navigation.rb
relative_roots: relative_roots:
- app/controllers - app/controllers

View File

@ -1,6 +1,5 @@
version: '3' version: '3'
services: services:
db: db:
restart: always restart: always
image: postgres:14-alpine image: postgres:14-alpine
@ -8,11 +7,11 @@ services:
networks: networks:
- internal_network - internal_network
healthcheck: healthcheck:
test: ["CMD", "pg_isready", "-U", "postgres"] test: ['CMD', 'pg_isready', '-U', 'postgres']
volumes: volumes:
- ./postgres14:/var/lib/postgresql/data - ./postgres14:/var/lib/postgresql/data
environment: environment:
- "POSTGRES_HOST_AUTH_METHOD=trust" - 'POSTGRES_HOST_AUTH_METHOD=trust'
redis: redis:
restart: always restart: always
@ -20,28 +19,28 @@ services:
networks: networks:
- internal_network - internal_network
healthcheck: healthcheck:
test: ["CMD", "redis-cli", "ping"] test: ['CMD', 'redis-cli', 'ping']
volumes: volumes:
- ./redis:/data - ./redis:/data
# es: # es:
# restart: always # restart: always
# image: docker.elastic.co/elasticsearch/elasticsearch-oss:7.10.2 # image: docker.elastic.co/elasticsearch/elasticsearch-oss:7.10.2
# environment: # environment:
# - "ES_JAVA_OPTS=-Xms512m -Xmx512m" # - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
# - "cluster.name=es-mastodon" # - "cluster.name=es-mastodon"
# - "discovery.type=single-node" # - "discovery.type=single-node"
# - "bootstrap.memory_lock=true" # - "bootstrap.memory_lock=true"
# networks: # networks:
# - internal_network # - internal_network
# healthcheck: # healthcheck:
# test: ["CMD-SHELL", "curl --silent --fail localhost:9200/_cluster/health || exit 1"] # test: ["CMD-SHELL", "curl --silent --fail localhost:9200/_cluster/health || exit 1"]
# volumes: # volumes:
# - ./elasticsearch:/usr/share/elasticsearch/data # - ./elasticsearch:/usr/share/elasticsearch/data
# ulimits: # ulimits:
# memlock: # memlock:
# soft: -1 # soft: -1
# hard: -1 # hard: -1
web: web:
build: . build: .
@ -53,13 +52,14 @@ services:
- external_network - external_network
- internal_network - internal_network
healthcheck: healthcheck:
test: ["CMD-SHELL", "wget -q --spider --proxy=off localhost:3000/health || exit 1"] # prettier-ignore
test: ['CMD-SHELL', 'wget -q --spider --proxy=off localhost:3000/health || exit 1']
ports: ports:
- "127.0.0.1:3000:3000" - '127.0.0.1:3000:3000'
depends_on: depends_on:
- db - db
- redis - redis
# - es # - es
volumes: volumes:
- ./public/system:/mastodon/public/system - ./public/system:/mastodon/public/system
@ -73,9 +73,10 @@ services:
- external_network - external_network
- internal_network - internal_network
healthcheck: healthcheck:
test: ["CMD-SHELL", "wget -q --spider --proxy=off localhost:4000/api/v1/streaming/health || exit 1"] # prettier-ignore
test: ['CMD-SHELL', 'wget -q --spider --proxy=off localhost:4000/api/v1/streaming/health || exit 1']
ports: ports:
- "127.0.0.1:4000:4000" - '127.0.0.1:4000:4000'
depends_on: depends_on:
- db - db
- redis - redis
@ -95,24 +96,24 @@ services:
volumes: volumes:
- ./public/system:/mastodon/public/system - ./public/system:/mastodon/public/system
healthcheck: healthcheck:
test: ["CMD-SHELL", "ps aux | grep '[s]idekiq\ 6' || false"] test: ['CMD-SHELL', "ps aux | grep '[s]idekiq\ 6' || false"]
## Uncomment to enable federation with tor instances along with adding the following ENV variables ## Uncomment to enable federation with tor instances along with adding the following ENV variables
## http_proxy=http://privoxy:8118 ## http_proxy=http://privoxy:8118
## ALLOW_ACCESS_TO_HIDDEN_SERVICE=true ## ALLOW_ACCESS_TO_HIDDEN_SERVICE=true
# tor: # tor:
# image: sirboops/tor # image: sirboops/tor
# networks: # networks:
# - external_network # - external_network
# - internal_network # - internal_network
# #
# privoxy: # privoxy:
# image: sirboops/privoxy # image: sirboops/privoxy
# volumes: # volumes:
# - ./priv-config:/opt/config # - ./priv-config:/opt/config
# networks: # networks:
# - external_network # - external_network
# - internal_network # - internal_network
networks: networks:
external_network: external_network:

View File

@ -14,7 +14,9 @@
"test:lint": "${npm_execpath} run test:lint:js && ${npm_execpath} run test:lint:sass", "test:lint": "${npm_execpath} run test:lint:js && ${npm_execpath} run test:lint:sass",
"test:lint:js": "eslint --ext=js . --cache", "test:lint:js": "eslint --ext=js . --cache",
"test:lint:sass": "sass-lint -v", "test:lint:sass": "sass-lint -v",
"test:jest": "cross-env NODE_ENV=test jest" "test:jest": "cross-env NODE_ENV=test jest",
"format": "prettier --write '**/*.{json,yml}",
"format-check": "prettier --write '**/*.{json,yml}"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -182,6 +184,7 @@
"eslint-plugin-promise": "~6.0.0", "eslint-plugin-promise": "~6.0.0",
"eslint-plugin-react": "~7.29.3", "eslint-plugin-react": "~7.29.3",
"jest": "^27.5.1", "jest": "^27.5.1",
"prettier": "^2.6.0",
"raf": "^3.4.1", "raf": "^3.4.1",
"react-intl-translations-manager": "^5.0.3", "react-intl-translations-manager": "^5.0.3",
"react-test-renderer": "^16.14.0", "react-test-renderer": "^16.14.0",

View File

@ -92,8 +92,5 @@
"scripts": { "scripts": {
"postdeploy": "bundle exec rails db:migrate && bundle exec rails db:seed" "postdeploy": "bundle exec rails db:migrate && bundle exec rails db:seed"
}, },
"addons": [ "addons": ["postgresql", "redis"]
"postgresql",
"redis"
]
} }

View File

@ -8651,6 +8651,11 @@ prelude-ls@~1.1.2:
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54"
integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ= integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=
prettier@^2.6.0:
version "2.6.0"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.6.0.tgz#12f8f504c4d8ddb76475f441337542fa799207d4"
integrity sha512-m2FgJibYrBGGgQXNzfd0PuDGShJgRavjUoRCw1mZERIWVSXF0iLzLm+aOqTAbLnC3n6JzUhAA8uZnFVghHJ86A==
pretty-format@^25.2.1, pretty-format@^25.5.0: pretty-format@^25.2.1, pretty-format@^25.5.0:
version "25.5.0" version "25.5.0"
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-25.5.0.tgz#7873c1d774f682c34b8d48b6743a2bf2ac55791a" resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-25.5.0.tgz#7873c1d774f682c34b8d48b6743a2bf2ac55791a"