]> cat aescling's git repositories - mastodon.git/commitdiff
Format JSON and YAML using Prettier (#17823)
authorYamagishi Kazutoshi <ykzts@desire.sh>
Mon, 21 Mar 2022 03:46:11 +0000 (12:46 +0900)
committerGitHub <noreply@github.com>
Mon, 21 Mar 2022 03:46:11 +0000 (04:46 +0100)
* Format JSON and YAML using Prettier

* Add prettier to devDep

17 files changed:
.codeclimate.yml
.devcontainer/devcontainer.json
.devcontainer/docker-compose.yml
.github/dependabot.yml
.github/workflows/build-image.yml
.github/workflows/check-i18n.yml
.prettierignore [new file with mode: 0644]
.prettierrc.js [new file with mode: 0644]
.rubocop.yml
app.json
boxfile.yml
config/database.yml
config/i18n-tasks.yml
docker-compose.yml
package.json
scalingo.json
yarn.lock

index c253bd95a7ce3f803565cfa71703f8c5e96278e3..ee9022cdaf839f39d4f305d59b4a4ff14799b6df 100644 (file)
@@ -1,4 +1,4 @@
-version: "2"
+version: '2'
 checks:
   argument-count:
     enabled: false
@@ -34,8 +34,8 @@ plugins:
   sass-lint:
     enabled: true
 exclude_patterns:
-- spec/
-- vendor/asset/
+  - spec/
+  - vendor/asset/
 
-- app/javascript/mastodon/locales/**/*.json
-- config/locales/**/*.yml
+  - app/javascript/mastodon/locales/**/*.json
+  - config/locales/**/*.yml
index 78e940763c306f75d7de1e51ce9aef9a906bf2e6..628efc8ec5c21f00b3372ffc40390bd8e795b1f4 100644 (file)
@@ -5,22 +5,22 @@
   "workspaceFolder": "/workspaces/mastodon",
 
   // 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.
-       "extensions": [
+  "extensions": [
     "EditorConfig.EditorConfig",
     "dbaeumer.vscode-eslint",
-               "rebornix.Ruby"
-       ],
+    "rebornix.Ruby"
+  ],
 
   // 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.
-       "forwardPorts": [3000, 4000],
+  // This can be used to network with other containers or the host.
+  "forwardPorts": [3000, 4000],
 
-       // Use 'postCreateCommand' to run commands after the container is created.
-       "postCreateCommand": "bundle install --path vendor/bundle && yarn install && ./bin/rails db:setup",
+  // Use 'postCreateCommand' to run commands after the container is created.
+  "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.
-       "remoteUser": "vscode"
+  // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
+  "remoteUser": "vscode"
 }
index 906fce430cb0ecc13911f6d8ce8f274b4ef0178f..538f6cccde8c209575319faf5e3f8163e042c8bc 100644 (file)
@@ -9,9 +9,9 @@ services:
         # 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.
         # Use -bullseye variants on local arm64/Apple Silicon.
-        VARIANT: "3.0-bullseye"
+        VARIANT: '3.0-bullseye'
         # Optional Node.js version to install
-        NODE_VERSION: "14"
+        NODE_VERSION: '14'
     volumes:
       - ..:/workspaces/mastodon:cached
     environment:
@@ -34,7 +34,6 @@ services:
       - internal_network
     user: vscode
 
-
   db:
     image: postgres:14-alpine
     restart: unless-stopped
index c4cd4887876a0d6ab75f446742300532e8b9ce9e..bb1fccf7ca4ddd89df9959ca8b42bab167895a67 100644 (file)
@@ -6,7 +6,7 @@
 version: 2
 updates:
   - package-ecosystem: npm
-    directory: "/"
+    directory: '/'
     schedule:
       interval: weekly
     open-pull-requests-limit: 99
@@ -14,7 +14,7 @@ updates:
       - dependency-type: direct
 
   - package-ecosystem: bundler
-    directory: "/"
+    directory: '/'
     schedule:
       interval: weekly
     open-pull-requests-limit: 99
index bae18548494f3d08dd174899582f24f8a4e9ae01..75c7b54a65db278ce53e3198d575fc67aa2deb20 100644 (file)
@@ -3,9 +3,9 @@ on:
   workflow_dispatch:
   push:
     branches:
-      - "main"
+      - 'main'
     tags:
-      - "*"
+      - '*'
   pull_request:
     paths:
       - .github/workflows/build-image.yml
index 9cb98dd125641fce7da7311eff52c9f082027445..be38a096de6f15353ab4fdf952efd102d4a261b6 100644 (file)
@@ -2,9 +2,9 @@ name: Check i18n
 
 on:
   push:
-    branches: [ main ]
+    branches: [main]
   pull_request:
-    branches: [ main ]
+    branches: [main]
 
 env:
   RAILS_ENV: test
@@ -14,21 +14,21 @@ jobs:
     runs-on: ubuntu-latest
 
     steps:
-    - uses: actions/checkout@v2
-    - name: Install system dependencies
-      run: |
-        sudo apt-get update
-        sudo apt-get install -y libicu-dev libidn11-dev
-    - name: Set up Ruby
-      uses: ruby/setup-ruby@v1
-      with:
-        ruby-version: '3.0'
-        bundler-cache: true
-    - name: Check locale file normalization
-      run: bundle exec i18n-tasks check-normalized
-    - name: Check for unused strings
-      run: bundle exec i18n-tasks unused -l en
-    - name: Check for wrong string interpolations
-      run: bundle exec i18n-tasks check-consistent-interpolations
-    - name: Check that all required locale files exist
-      run: bundle exec rake repo:check_locales_files
+      - uses: actions/checkout@v2
+      - name: Install system dependencies
+        run: |
+          sudo apt-get update
+          sudo apt-get install -y libicu-dev libidn11-dev
+      - name: Set up Ruby
+        uses: ruby/setup-ruby@v1
+        with:
+          ruby-version: '3.0'
+          bundler-cache: true
+      - name: Check locale file normalization
+        run: bundle exec i18n-tasks check-normalized
+      - name: Check for unused strings
+        run: bundle exec i18n-tasks unused -l en
+      - name: Check for wrong string interpolations
+        run: bundle exec i18n-tasks check-consistent-interpolations
+      - name: Check that all required locale files exist
+        run: bundle exec rake repo:check_locales_files
diff --git a/.prettierignore b/.prettierignore
new file mode 100644 (file)
index 0000000..de7673e
--- /dev/null
@@ -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
diff --git a/.prettierrc.js b/.prettierrc.js
new file mode 100644 (file)
index 0000000..1d70813
--- /dev/null
@@ -0,0 +1,3 @@
+module.exports = {
+  singleQuote: true
+}
index 4948aea5ae3b7cf88f45e7afcc279eefca6facf7..a7693742645609b26eebcd7281fd43d8b1298224 100644 (file)
@@ -5,17 +5,17 @@ AllCops:
   TargetRubyVersion: 2.5
   NewCops: disable
   Exclude:
-  - 'spec/**/*'
-  - 'db/**/*'
-  - 'app/views/**/*'
-  - 'config/**/*'
-  - 'bin/*'
-  - 'Rakefile'
-  - 'node_modules/**/*'
-  - 'Vagrantfile'
-  - 'vendor/**/*'
-  - 'lib/json_ld/*'
-  - 'lib/templates/**/*'
+    - 'spec/**/*'
+    - 'db/**/*'
+    - 'app/views/**/*'
+    - 'config/**/*'
+    - 'bin/*'
+    - 'Rakefile'
+    - 'node_modules/**/*'
+    - 'Vagrantfile'
+    - 'vendor/**/*'
+    - 'lib/json_ld/*'
+    - 'lib/templates/**/*'
 
 Bundler/OrderedGems:
   Enabled: false
index 6b436538348ca17d47591daaf487dbc355c38c21..c694908c539fb19276d7bad5c328ab09593f5f3b 100644 (file)
--- a/app.json
+++ b/app.json
@@ -95,8 +95,5 @@
   "scripts": {
     "postdeploy": "bundle exec rails db:migrate && bundle exec rails db:seed"
   },
-  "addons": [
-    "heroku-postgresql",
-    "heroku-redis"
-  ]
+  "addons": ["heroku-postgresql", "heroku-redis"]
 }
index c1d89bb159febf8b6a75845f70a3e33875f50470..27166cec9f733605954518e7075f021c1d68cdfe 100644 (file)
@@ -43,20 +43,19 @@ run.config:
 
   fs_watch: true
 
-
 deploy.config:
   extra_steps:
     - NODE_ENV=production bundle exec rake assets:precompile
   transform:
-    - "envsubst < /app/.env.nanobox > /app/.env.production"
+    - 'envsubst < /app/.env.nanobox > /app/.env.production'
     - |-
-        if [ -z "$LOCAL_DOMAIN" ]
-        then
-          . /app/.env.production
-          export LOCAL_DOMAIN
-        fi
-        erb /app/nanobox/nginx-web.conf.erb > /app/nanobox/nginx-web.conf
-        erb /app/nanobox/nginx-stream.conf.erb > /app/nanobox/nginx-stream.conf
+      if [ -z "$LOCAL_DOMAIN" ]
+      then
+        . /app/.env.production
+        export LOCAL_DOMAIN
+      fi
+      erb /app/nanobox/nginx-web.conf.erb > /app/nanobox/nginx-web.conf
+      erb /app/nanobox/nginx-stream.conf.erb > /app/nanobox/nginx-stream.conf
     - touch /app/log/production.log
   before_live:
     web.web:
@@ -65,11 +64,10 @@ deploy.config:
   after_live:
     worker.sidekiq:
       - |-
-          if [[ "${ES_ENABLED}" != "false" ]]
-          then
-            bin/tootctl search deploy
-          fi
-
+        if [[ "${ES_ENABLED}" != "false" ]]
+        then
+          bin/tootctl search deploy
+        fi
 
 web.web:
   start:
@@ -89,7 +87,6 @@ web.web:
     data.storage:
       - public/system
 
-
 web.stream:
   start:
     nginx: nginx -c /app/nanobox/nginx-stream.conf
@@ -103,7 +100,6 @@ web.stream:
   writable_dirs:
     - tmp
 
-
 worker.sidekiq:
   start:
     default: bundle exec sidekiq -c 5 -q default -L /app/log/sidekiq.log
@@ -123,7 +119,6 @@ worker.sidekiq:
     data.storage:
       - public/system
 
-
 data.db:
   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
         done
 
-
 data.elastic:
   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
         done
 
-
 data.redis:
   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
         done
 
-
 data.storage:
   image: nanobox/unfs:0.9
 
index 9b8d096e9043119149723a10bebb964471ccd18b..127a78abfab39cb37be63552595bd3116af2eea5 100644 (file)
@@ -32,4 +32,3 @@ production:
   host: <%= ENV['DB_HOST'] || 'localhost' %>
   port: <%= ENV['DB_PORT'] || 5432 %>
   prepared_statements: <%= ENV['PREPARED_STATEMENTS'] || 'true' %>
-
index 7f879b1aa35e58c9bd5f4434f5a46d651484ec0f..bc48323e4fb5b26555bbb9e217e422c42e246260 100644 (file)
@@ -17,8 +17,8 @@ data:
 
 search:
   paths:
-   - app/
-   - config/navigation.rb
+    - app/
+    - config/navigation.rb
 
   relative_roots:
     - app/controllers
index 01fe320a48f70cbc4838f5f36b106c1cbe36ead6..5c2c0c5dfe99f3316ae3031db8deaae6f0ebbe87 100644 (file)
@@ -1,6 +1,5 @@
 version: '3'
 services:
-
   db:
     restart: always
     image: postgres:14-alpine
@@ -8,11 +7,11 @@ services:
     networks:
       - internal_network
     healthcheck:
-      test: ["CMD", "pg_isready", "-U", "postgres"]
+      test: ['CMD', 'pg_isready', '-U', 'postgres']
     volumes:
       - ./postgres14:/var/lib/postgresql/data
     environment:
-      - "POSTGRES_HOST_AUTH_METHOD=trust"
+      - 'POSTGRES_HOST_AUTH_METHOD=trust'
 
   redis:
     restart: always
@@ -20,28 +19,28 @@ services:
     networks:
       - internal_network
     healthcheck:
-      test: ["CMD", "redis-cli", "ping"]
+      test: ['CMD', 'redis-cli', 'ping']
     volumes:
       - ./redis:/data
 
- es:
-   restart: always
-   image: docker.elastic.co/elasticsearch/elasticsearch-oss:7.10.2
-   environment:
-     - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
-     - "cluster.name=es-mastodon"
-     - "discovery.type=single-node"
-     - "bootstrap.memory_lock=true"
-   networks:
-#      - internal_network
-   healthcheck:
-#      test: ["CMD-SHELL", "curl --silent --fail localhost:9200/_cluster/health || exit 1"]
-   volumes:
-#      - ./elasticsearch:/usr/share/elasticsearch/data
-   ulimits:
-     memlock:
-       soft: -1
-       hard: -1
+  # es:
+  #   restart: always
+  #   image: docker.elastic.co/elasticsearch/elasticsearch-oss:7.10.2
+  #   environment:
+  #     - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
+  #     - "cluster.name=es-mastodon"
+  #     - "discovery.type=single-node"
+  #     - "bootstrap.memory_lock=true"
+  #   networks:
+  #      - internal_network
+  #   healthcheck:
+  #      test: ["CMD-SHELL", "curl --silent --fail localhost:9200/_cluster/health || exit 1"]
+  #   volumes:
+  #      - ./elasticsearch:/usr/share/elasticsearch/data
+  #   ulimits:
+  #     memlock:
+  #       soft: -1
+  #       hard: -1
 
   web:
     build: .
@@ -53,13 +52,14 @@ services:
       - external_network
       - internal_network
     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:
-      - "127.0.0.1:3000:3000"
+      - '127.0.0.1:3000:3000'
     depends_on:
       - db
       - redis
-#      - es
+      # - es
     volumes:
       - ./public/system:/mastodon/public/system
 
@@ -73,9 +73,10 @@ services:
       - external_network
       - internal_network
     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:
-      - "127.0.0.1:4000:4000"
+      - '127.0.0.1:4000:4000'
     depends_on:
       - db
       - redis
@@ -95,24 +96,24 @@ services:
     volumes:
       - ./public/system:/mastodon/public/system
     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
-## http_proxy=http://privoxy:8118
-## ALLOW_ACCESS_TO_HIDDEN_SERVICE=true
- tor:
-   image: sirboops/tor
-   networks:
-#      - external_network
-#      - internal_network
-#
- privoxy:
-   image: sirboops/privoxy
-   volumes:
-     - ./priv-config:/opt/config
-   networks:
-     - external_network
-     - internal_network
+  ## Uncomment to enable federation with tor instances along with adding the following ENV variables
+  ## http_proxy=http://privoxy:8118
+  ## ALLOW_ACCESS_TO_HIDDEN_SERVICE=true
+  # tor:
+  #   image: sirboops/tor
+  #   networks:
+  #      - external_network
+  #      - internal_network
+  #
+  # privoxy:
+  #   image: sirboops/privoxy
+  #   volumes:
+  #     - ./priv-config:/opt/config
+  #   networks:
+  #     - external_network
+  #     - internal_network
 
 networks:
   external_network:
index d42c92cedae495fc5162649ffcba14672dca2191..61b3622f788aa095c1f8f8e93a0b20e94b7a3170 100644 (file)
@@ -14,7 +14,9 @@
     "test:lint": "${npm_execpath} run test:lint:js && ${npm_execpath} run test:lint:sass",
     "test:lint:js": "eslint --ext=js . --cache",
     "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": {
     "type": "git",
     "eslint-plugin-promise": "~6.0.0",
     "eslint-plugin-react": "~7.29.3",
     "jest": "^27.5.1",
+    "prettier": "^2.6.0",
     "raf": "^3.4.1",
     "react-intl-translations-manager": "^5.0.3",
     "react-test-renderer": "^16.14.0",
index 51d9b5b9f5c43a6b9d95a4bd05309b42fe14e2f2..511c1802a99409910aee114edbdb1ad5a040f2a7 100644 (file)
@@ -92,8 +92,5 @@
   "scripts": {
     "postdeploy": "bundle exec rails db:migrate && bundle exec rails db:seed"
   },
-  "addons": [
-    "postgresql",
-    "redis"
-  ]
+  "addons": ["postgresql", "redis"]
 }
index 45e459c4056fb4c03cbffe4f6d592915b23e7403..1327e9f731b94a814f8b734f95f3c42f2f570f6b 100644 (file)
--- a/yarn.lock
+++ b/yarn.lock
@@ -8651,6 +8651,11 @@ prelude-ls@~1.1.2:
   resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54"
   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:
   version "25.5.0"
   resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-25.5.0.tgz#7873c1d774f682c34b8d48b6743a2bf2ac55791a"