Browse Source
This is a massive PR, so apologies for the poor performance viewing it! This merges in the content of Mastodon 4.3.0. *This PR isn't ready to deploy to production*, and I don't recommend trying it in a production environment. Since I started by merging 4.3.0, this will likely have reverted at least some of the content of the post-4.3.0 security patches in the 4.2.x series; those will be brought back as I merge in 4.4.0 and 4.5.0. I haven't yet tested this PR, so it may not actually run without additional tweaks. I'm putting it up now for discussion and so multiple people can test if we want. --- Here's a few notes on things I ran into and thoughts I had while working on it: * We may want to look at `server_banner.jsx,` where I ended up undoing the v3-style rewrite due to the new react component being used. I'm not sure what the current goal for it is. * I may not have 100% merged in all content from `status_action_bar` correctly. * There's a number of places where I updated the links for remote usernames, and they should be tested to make sure they work. They're all `<Permalink>` elements. I have in my notes that `status_content` might need double-checking. * I may also not have gotten the spoiler display right in `status_content`. * It looks like previous versions of Hometown had customizations to the `media_item` display, not all of which was preserved as-is due to surrounding rewrites. I'm not sure what the vision is and could use another set of eyes. * The character count rendering clashed with the newly-introduced handling of a character count variable upstream, and I'm not sure if the version I've got here 100% works or not. * The navigation bar was completely rewritten and no longer has the components Hometown was customizing; did I properly catch any replacements? Did we handle all links to accounts to make sure they go to the remote instance? * Polls: I reverted the single/multiple choice toggle because upstream has an actual proper UI for this that should be integrated in one of the versions we’re merging in. Please double-check that the current version looks fine to you. * The font icons will need double-checking. Hometown made some custom use of the font-awesome icons, while Mastodon 4.3.0 replaced font-awesome with something else. I may not have caught all places that font-awesome icons were being used. * We’ll want to make sure the post display is correct, including Hometown customizations, because the previous static post page has been replaced with the React one. --------- Co-authored-by: Claire <claire.github-309c@sitedethib.com> Co-authored-by: Matt Jankowski <matt@jankowski.online> Co-authored-by: Renaud Chaput <renchap@gmail.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: David Roetzel <david@roetzel.de> Co-authored-by: Emelia Smith <ThisIsMissEm@users.noreply.github.com> Co-authored-by: Jeong Arm <kjwonmail@gmail.com> Co-authored-by: Christian Schmidt <github@chsc.dk> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: GitHub Actions <noreply@github.com> Co-authored-by: Eugen Rochko <eugen@zeonfederated.com> Co-authored-by: Darius Kazemi <darius.kazemi@gmail.com> Co-authored-by: diondiondion <mail@diondiondion.com> Co-authored-by: Echo <ChaosExAnima@users.noreply.github.com> Co-authored-by: Shugo Maeda <shugo.maeda@gmail.com> Co-authored-by: emilweth <7402764+emilweth@users.noreply.github.com> Co-authored-by: Shlee <github@shl.ee> Co-authored-by: Joshua Rogers <MegaManSec@users.noreply.github.com> Co-authored-by: Jessica Stokes <hello@jessicastokes.net> Co-authored-by: PGray <77597544+PGrayCS@users.noreply.github.com>pull/1390/head v4.5.6+hometown-1.2.0
5137 changed files with 251566 additions and 121726 deletions
@ -0,0 +1,59 @@
|
||||
--- |
||||
:position: before |
||||
:position_in_additional_file_patterns: before |
||||
:position_in_class: before |
||||
:position_in_factory: before |
||||
:position_in_fixture: before |
||||
:position_in_routes: before |
||||
:position_in_serializer: before |
||||
:position_in_test: before |
||||
:classified_sort: true |
||||
:exclude_controllers: true |
||||
:exclude_factories: true |
||||
:exclude_fixtures: true |
||||
:exclude_helpers: true |
||||
:exclude_scaffolds: true |
||||
:exclude_serializers: true |
||||
:exclude_sti_subclasses: true |
||||
:exclude_tests: true |
||||
:force: false |
||||
:format_markdown: false |
||||
:format_rdoc: false |
||||
:format_yard: false |
||||
:frozen: false |
||||
:ignore_model_sub_dir: false |
||||
:ignore_unknown_models: false |
||||
:include_version: false |
||||
:show_complete_foreign_keys: false |
||||
:show_foreign_keys: false |
||||
:show_indexes: false |
||||
:simple_indexes: false |
||||
:sort: false |
||||
:timestamp: false |
||||
:trace: false |
||||
:with_comment: true |
||||
:with_column_comments: true |
||||
:with_table_comments: true |
||||
:active_admin: false |
||||
:command: |
||||
:debug: false |
||||
:hide_default_column_types: '' |
||||
:hide_limit_column_types: 'integer,boolean' |
||||
:ignore_columns: |
||||
:ignore_routes: |
||||
:models: true |
||||
:routes: false |
||||
:skip_on_db_migrate: false |
||||
:target_action: :do_annotations |
||||
:wrapper: |
||||
:wrapper_close: |
||||
:wrapper_open: |
||||
:classes_default_to_s: [] |
||||
:additional_file_patterns: [] |
||||
:model_dir: |
||||
- app/models |
||||
:require: [] |
||||
:root_dir: |
||||
- '' |
||||
|
||||
:show_check_constraints: false |
||||
@ -1,7 +1,6 @@
|
||||
[production] |
||||
defaults |
||||
not IE 11 |
||||
> 0.2% |
||||
firefox >= 78 |
||||
ios >= 15.6 |
||||
not dead |
||||
|
||||
[development] |
||||
supports es6-module |
||||
not OperaMini all |
||||
|
||||
@ -1,10 +0,0 @@
|
||||
--- |
||||
ignore: |
||||
# devise-two-factor advisory about brute-forcing TOTP |
||||
# We have rate-limits on authentication endpoints in place (including second |
||||
# factor verification) since Mastodon v3.2.0 |
||||
- CVE-2024-0227 |
||||
# devise-two-factor advisory about generated secrets being weaker than expected |
||||
# We call `generate_otp_secret` ourselves with a requested length of 32 characters, |
||||
# which exceeds the recommended remediation of 26 characters, so we're safe |
||||
- CVE-2024-8796 |
||||
@ -1,20 +1,18 @@
|
||||
# For details, see https://github.com/devcontainers/images/tree/main/src/ruby |
||||
FROM mcr.microsoft.com/devcontainers/ruby:1-3.2-bullseye |
||||
FROM mcr.microsoft.com/devcontainers/ruby:1-3.3-bookworm |
||||
|
||||
# Install Rails |
||||
# RUN gem install rails webdrivers |
||||
# Install node version from .nvmrc |
||||
WORKDIR /app |
||||
COPY .nvmrc . |
||||
RUN /bin/bash --login -i -c "nvm install" |
||||
|
||||
ARG NODE_VERSION="16" |
||||
RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1" |
||||
# Install additional OS packages |
||||
RUN apt-get update && \ |
||||
export DEBIAN_FRONTEND=noninteractive && \ |
||||
apt-get -y install --no-install-recommends libicu-dev libidn11-dev ffmpeg imagemagick libvips42 libpam-dev |
||||
|
||||
# [Optional] Uncomment this section to install additional OS packages. |
||||
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ |
||||
&& apt-get -y install --no-install-recommends libicu-dev libidn11-dev ffmpeg imagemagick libpam-dev |
||||
# Disable download prompt for Corepack |
||||
ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0 |
||||
|
||||
# [Optional] Uncomment this line to install additional gems. |
||||
RUN gem install foreman |
||||
|
||||
# [Optional] Uncomment this line to install global node packages. |
||||
RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g yarn" 2>&1 |
||||
|
||||
COPY welcome-message.txt /usr/local/etc/vscode-dev-containers/first-run-notice.txt |
||||
# Move welcome message to where VS Code expects it |
||||
COPY .devcontainer/welcome-message.txt /usr/local/etc/vscode-dev-containers/first-run-notice.txt |
||||
|
||||
@ -0,0 +1,93 @@
|
||||
services: |
||||
app: |
||||
working_dir: /workspaces/mastodon/ |
||||
build: |
||||
context: .. |
||||
dockerfile: .devcontainer/Dockerfile |
||||
volumes: |
||||
- ..:/workspaces/mastodon:cached |
||||
environment: |
||||
RAILS_ENV: development |
||||
NODE_ENV: development |
||||
VITE_RUBY_HOST: 0.0.0.0 |
||||
BIND: 0.0.0.0 |
||||
BOOTSNAP_CACHE_DIR: /tmp |
||||
REDIS_HOST: redis |
||||
REDIS_PORT: '6379' |
||||
DB_HOST: db |
||||
DB_USER: postgres |
||||
DB_PASS: postgres |
||||
DB_PORT: '5432' |
||||
ES_ENABLED: 'true' |
||||
ES_HOST: es |
||||
ES_PORT: '9200' |
||||
LIBRE_TRANSLATE_ENDPOINT: http://libretranslate:5000 |
||||
LOCAL_DOMAIN: ${LOCAL_DOMAIN:-localhost:3000} |
||||
VITE_DEV_SERVER_PUBLIC: ${VITE_DEV_SERVER_PUBLIC:-localhost:3036} |
||||
# Overrides default command so things don't shut down after the process ends. |
||||
command: sleep infinity |
||||
ports: |
||||
- '3000:3000' |
||||
- '3036:3036' |
||||
- '4000:4000' |
||||
networks: |
||||
- external_network |
||||
- internal_network |
||||
|
||||
db: |
||||
image: postgres:14-alpine |
||||
restart: unless-stopped |
||||
volumes: |
||||
- postgres-data:/var/lib/postgresql/data |
||||
environment: |
||||
POSTGRES_USER: postgres |
||||
POSTGRES_DB: postgres |
||||
POSTGRES_PASSWORD: postgres |
||||
POSTGRES_HOST_AUTH_METHOD: trust |
||||
networks: |
||||
- internal_network |
||||
|
||||
redis: |
||||
image: redis:7-alpine |
||||
restart: unless-stopped |
||||
volumes: |
||||
- redis-data:/data |
||||
networks: |
||||
- internal_network |
||||
|
||||
es: |
||||
image: docker.elastic.co/elasticsearch/elasticsearch-oss:7.10.2 |
||||
restart: unless-stopped |
||||
environment: |
||||
ES_JAVA_OPTS: -Xms512m -Xmx512m |
||||
cluster.name: es-mastodon |
||||
discovery.type: single-node |
||||
bootstrap.memory_lock: 'true' |
||||
volumes: |
||||
- es-data:/usr/share/elasticsearch/data |
||||
networks: |
||||
- internal_network |
||||
ulimits: |
||||
memlock: |
||||
soft: -1 |
||||
hard: -1 |
||||
|
||||
libretranslate: |
||||
image: libretranslate/libretranslate:v1.6.2 |
||||
restart: unless-stopped |
||||
volumes: |
||||
- lt-data:/home/libretranslate/.local |
||||
networks: |
||||
- external_network |
||||
- internal_network |
||||
|
||||
volumes: |
||||
postgres-data: |
||||
redis-data: |
||||
es-data: |
||||
lt-data: |
||||
|
||||
networks: |
||||
external_network: |
||||
internal_network: |
||||
internal: true |
||||
@ -1,90 +0,0 @@
|
||||
version: '3' |
||||
|
||||
services: |
||||
app: |
||||
build: |
||||
context: . |
||||
dockerfile: Dockerfile |
||||
volumes: |
||||
- ../..:/workspaces:cached |
||||
environment: |
||||
RAILS_ENV: development |
||||
NODE_ENV: development |
||||
BIND: 0.0.0.0 |
||||
REDIS_HOST: redis |
||||
REDIS_PORT: '6379' |
||||
DB_HOST: db |
||||
DB_USER: postgres |
||||
DB_PASS: postgres |
||||
DB_PORT: '5432' |
||||
ES_ENABLED: 'true' |
||||
ES_HOST: es |
||||
ES_PORT: '9200' |
||||
LIBRE_TRANSLATE_ENDPOINT: http://libretranslate:5000 |
||||
# Overrides default command so things don't shut down after the process ends. |
||||
command: sleep infinity |
||||
ports: |
||||
- '127.0.0.1:3000:3000' |
||||
- '127.0.0.1:3035:3035' |
||||
- '127.0.0.1:4000:4000' |
||||
networks: |
||||
- external_network |
||||
- internal_network |
||||
|
||||
db: |
||||
image: postgres:14-alpine |
||||
restart: unless-stopped |
||||
volumes: |
||||
- postgres-data:/var/lib/postgresql/data |
||||
environment: |
||||
POSTGRES_USER: postgres |
||||
POSTGRES_DB: postgres |
||||
POSTGRES_PASSWORD: postgres |
||||
POSTGRES_HOST_AUTH_METHOD: trust |
||||
networks: |
||||
- internal_network |
||||
|
||||
redis: |
||||
image: redis:7-alpine |
||||
restart: unless-stopped |
||||
volumes: |
||||
- redis-data:/data |
||||
networks: |
||||
- internal_network |
||||
|
||||
es: |
||||
image: docker.elastic.co/elasticsearch/elasticsearch-oss:7.10.2 |
||||
restart: unless-stopped |
||||
environment: |
||||
ES_JAVA_OPTS: -Xms512m -Xmx512m |
||||
cluster.name: es-mastodon |
||||
discovery.type: single-node |
||||
bootstrap.memory_lock: 'true' |
||||
volumes: |
||||
- es-data:/usr/share/elasticsearch/data |
||||
networks: |
||||
- internal_network |
||||
ulimits: |
||||
memlock: |
||||
soft: -1 |
||||
hard: -1 |
||||
|
||||
libretranslate: |
||||
image: libretranslate/libretranslate:v1.3.11 |
||||
restart: unless-stopped |
||||
volumes: |
||||
- lt-data:/home/libretranslate/.local |
||||
networks: |
||||
- external_network |
||||
- internal_network |
||||
|
||||
volumes: |
||||
postgres-data: |
||||
redis-data: |
||||
es-data: |
||||
lt-data: |
||||
|
||||
networks: |
||||
external_network: |
||||
internal_network: |
||||
internal: true |
||||
@ -1,26 +0,0 @@
|
||||
#!/bin/bash |
||||
|
||||
set -e # Fail the whole script on first error |
||||
|
||||
# Fetch Ruby gem dependencies |
||||
bundle config path 'vendor/bundle' |
||||
bundle config with 'development test' |
||||
bundle install |
||||
|
||||
# Make Gemfile.lock pristine again |
||||
git checkout -- Gemfile.lock |
||||
|
||||
# Fetch Javascript dependencies |
||||
yarn --frozen-lockfile |
||||
|
||||
# [re]create, migrate, and seed the test database |
||||
RAILS_ENV=test ./bin/rails db:setup |
||||
|
||||
# [re]create, migrate, and seed the development database |
||||
RAILS_ENV=development ./bin/rails db:setup |
||||
|
||||
# Precompile assets for development |
||||
RAILS_ENV=development ./bin/rails assets:precompile |
||||
|
||||
# Precompile assets for test |
||||
RAILS_ENV=test NODE_ENV=tests ./bin/rails assets:precompile |
||||
@ -0,0 +1,4 @@
|
||||
# Required by ActiveRecord encryption feature |
||||
ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY=fkSxKD2bF396kdQbrP1EJ7WbU7ZgNokR |
||||
ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT=r0hvVmzBVsjxC7AMlwhOzmtc36ZCOS1E |
||||
ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY=PhdFyyfy5xJ7WVd2lWBpcPScRQHzRTNr |
||||
@ -1,5 +1,11 @@
|
||||
# Node.js |
||||
NODE_ENV=tests |
||||
# In test, compile the NodeJS code as if we are in production |
||||
NODE_ENV=production |
||||
# Federation |
||||
LOCAL_DOMAIN=cb6e6126.ngrok.io |
||||
LOCAL_HTTPS=true |
||||
|
||||
# Secret values required by ActiveRecord encryption feature |
||||
# Use `bin/rails db:encryption:init` to generate fresh secrets |
||||
ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY=test_determinist_key_DO_NOT_USE_IN_PRODUCTION |
||||
ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT=test_salt_DO_NOT_USE_IN_PRODUCTION |
||||
ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY=test_primary_key_DO_NOT_USE_IN_PRODUCTION |
||||
|
||||
@ -1,13 +0,0 @@
|
||||
/build/** |
||||
/coverage/** |
||||
/db/** |
||||
/lib/** |
||||
/log/** |
||||
/node_modules/** |
||||
/nonobox/** |
||||
/public/** |
||||
!/public/embed.js |
||||
/spec/** |
||||
/tmp/** |
||||
/vendor/** |
||||
!.eslintrc.js |
||||
@ -1,384 +0,0 @@
|
||||
module.exports = { |
||||
root: true, |
||||
|
||||
extends: [ |
||||
'eslint:recommended', |
||||
'plugin:react/recommended', |
||||
'plugin:react-hooks/recommended', |
||||
'plugin:jsx-a11y/recommended', |
||||
'plugin:import/recommended', |
||||
'plugin:promise/recommended', |
||||
'plugin:jsdoc/recommended', |
||||
'plugin:prettier/recommended', |
||||
], |
||||
|
||||
env: { |
||||
browser: true, |
||||
node: true, |
||||
es6: true, |
||||
}, |
||||
|
||||
globals: { |
||||
ATTACHMENT_HOST: false, |
||||
}, |
||||
|
||||
parser: '@typescript-eslint/parser', |
||||
|
||||
plugins: [ |
||||
'react', |
||||
'jsx-a11y', |
||||
'import', |
||||
'promise', |
||||
'@typescript-eslint', |
||||
'formatjs', |
||||
], |
||||
|
||||
parserOptions: { |
||||
sourceType: 'module', |
||||
ecmaFeatures: { |
||||
jsx: true, |
||||
}, |
||||
ecmaVersion: 2021, |
||||
requireConfigFile: false, |
||||
babelOptions: { |
||||
configFile: false, |
||||
presets: ['@babel/react', '@babel/env'], |
||||
}, |
||||
}, |
||||
|
||||
settings: { |
||||
react: { |
||||
version: 'detect', |
||||
}, |
||||
'import/ignore': [ |
||||
'node_modules', |
||||
'\\.(css|scss|json)$', |
||||
], |
||||
'import/resolver': { |
||||
typescript: {}, |
||||
}, |
||||
}, |
||||
|
||||
rules: { |
||||
'consistent-return': 'error', |
||||
'dot-notation': 'error', |
||||
eqeqeq: ['error', 'always', { 'null': 'ignore' }], |
||||
'jsx-quotes': ['error', 'prefer-single'], |
||||
'no-case-declarations': 'off', |
||||
'no-catch-shadow': 'error', |
||||
'no-console': [ |
||||
'warn', |
||||
{ |
||||
allow: [ |
||||
'error', |
||||
'warn', |
||||
], |
||||
}, |
||||
], |
||||
'no-empty': 'off', |
||||
'no-restricted-properties': [ |
||||
'error', |
||||
{ property: 'substring', message: 'Use .slice instead of .substring.' }, |
||||
{ property: 'substr', message: 'Use .slice instead of .substr.' }, |
||||
], |
||||
'no-restricted-syntax': [ |
||||
'error', |
||||
{ |
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
selector: 'Literal[value=/•/], JSXText[value=/•/]', |
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
message: "Use '·' (middle dot) instead of '•' (bullet)", |
||||
}, |
||||
], |
||||
'no-self-assign': 'off', |
||||
'no-unused-expressions': 'error', |
||||
'no-unused-vars': 'off', |
||||
'@typescript-eslint/no-unused-vars': [ |
||||
'error', |
||||
{ |
||||
vars: 'all', |
||||
args: 'after-used', |
||||
destructuredArrayIgnorePattern: '^_', |
||||
ignoreRestSiblings: true, |
||||
}, |
||||
], |
||||
'valid-typeof': 'error', |
||||
|
||||
'react/jsx-filename-extension': ['error', { extensions: ['.jsx', 'tsx'] }], |
||||
'react/jsx-boolean-value': 'error', |
||||
'react/display-name': 'off', |
||||
'react/jsx-fragments': ['error', 'syntax'], |
||||
'react/jsx-equals-spacing': 'error', |
||||
'react/jsx-no-bind': 'error', |
||||
'react/jsx-no-useless-fragment': 'error', |
||||
'react/jsx-no-target-blank': 'off', |
||||
'react/jsx-tag-spacing': 'error', |
||||
'react/jsx-uses-react': 'off', // not needed with new JSX transform
|
||||
'react/jsx-wrap-multilines': 'error', |
||||
'react/no-deprecated': 'off', |
||||
'react/no-unknown-property': 'off', |
||||
'react/react-in-jsx-scope': 'off', // not needed with new JSX transform
|
||||
'react/self-closing-comp': 'error', |
||||
|
||||
// recommended values found in https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/main/src/index.js
|
||||
'jsx-a11y/accessible-emoji': 'warn', |
||||
'jsx-a11y/click-events-have-key-events': 'off', |
||||
'jsx-a11y/label-has-associated-control': 'off', |
||||
'jsx-a11y/media-has-caption': 'off', |
||||
'jsx-a11y/no-autofocus': 'off', |
||||
// recommended rule is:
|
||||
// 'jsx-a11y/no-interactive-element-to-noninteractive-role': [
|
||||
// 'error',
|
||||
// {
|
||||
// tr: ['none', 'presentation'],
|
||||
// canvas: ['img'],
|
||||
// },
|
||||
// ],
|
||||
'jsx-a11y/no-interactive-element-to-noninteractive-role': 'off', |
||||
// recommended rule is:
|
||||
// 'jsx-a11y/no-noninteractive-element-interactions': [
|
||||
// 'error',
|
||||
// {
|
||||
// body: ['onError', 'onLoad'],
|
||||
// iframe: ['onError', 'onLoad'],
|
||||
// img: ['onError', 'onLoad'],
|
||||
// },
|
||||
// ],
|
||||
'jsx-a11y/no-noninteractive-element-interactions': [ |
||||
'warn', |
||||
{ |
||||
handlers: [ |
||||
'onClick', |
||||
], |
||||
}, |
||||
], |
||||
// recommended rule is:
|
||||
// 'jsx-a11y/no-noninteractive-tabindex': [
|
||||
// 'error',
|
||||
// {
|
||||
// tags: [],
|
||||
// roles: ['tabpanel'],
|
||||
// allowExpressionValues: true,
|
||||
// },
|
||||
// ],
|
||||
'jsx-a11y/no-noninteractive-tabindex': 'off', |
||||
'jsx-a11y/no-onchange': 'warn', |
||||
// recommended is full 'error'
|
||||
'jsx-a11y/no-static-element-interactions': [ |
||||
'warn', |
||||
{ |
||||
handlers: [ |
||||
'onClick', |
||||
], |
||||
}, |
||||
], |
||||
|
||||
// See https://github.com/import-js/eslint-plugin-import/blob/main/config/recommended.js
|
||||
'import/extensions': [ |
||||
'error', |
||||
'always', |
||||
{ |
||||
js: 'never', |
||||
jsx: 'never', |
||||
mjs: 'never', |
||||
ts: 'never', |
||||
tsx: 'never', |
||||
}, |
||||
], |
||||
'import/first': 'error', |
||||
'import/newline-after-import': 'error', |
||||
'import/no-anonymous-default-export': 'error', |
||||
'import/no-extraneous-dependencies': [ |
||||
'error', |
||||
{ |
||||
devDependencies: [ |
||||
'config/webpack/**', |
||||
'app/javascript/mastodon/performance.js', |
||||
'app/javascript/mastodon/test_setup.js', |
||||
'app/javascript/**/__tests__/**', |
||||
], |
||||
}, |
||||
], |
||||
'import/no-amd': 'error', |
||||
'import/no-commonjs': 'error', |
||||
'import/no-import-module-exports': 'error', |
||||
'import/no-relative-packages': 'error', |
||||
'import/no-self-import': 'error', |
||||
'import/no-useless-path-segments': 'error', |
||||
'import/no-webpack-loader-syntax': 'error', |
||||
|
||||
'import/order': [ |
||||
'error', |
||||
{ |
||||
alphabetize: { order: 'asc' }, |
||||
'newlines-between': 'always', |
||||
groups: [ |
||||
'builtin', |
||||
'external', |
||||
'internal', |
||||
'parent', |
||||
['index', 'sibling'], |
||||
'object', |
||||
], |
||||
pathGroups: [ |
||||
// React core packages
|
||||
{ |
||||
pattern: '{react,react-dom,react-dom/client,prop-types}', |
||||
group: 'builtin', |
||||
position: 'after', |
||||
}, |
||||
// I18n
|
||||
{ |
||||
pattern: '{react-intl,intl-messageformat}', |
||||
group: 'builtin', |
||||
position: 'after', |
||||
}, |
||||
// Common React utilities
|
||||
{ |
||||
pattern: '{classnames,react-helmet,react-router-dom}', |
||||
group: 'external', |
||||
position: 'before', |
||||
}, |
||||
// Immutable / Redux / data store
|
||||
{ |
||||
pattern: '{immutable,react-redux,react-immutable-proptypes,react-immutable-pure-component,reselect}', |
||||
group: 'external', |
||||
position: 'before', |
||||
}, |
||||
// Internal packages
|
||||
{ |
||||
pattern: '{mastodon/**}', |
||||
group: 'internal', |
||||
position: 'after', |
||||
}, |
||||
], |
||||
pathGroupsExcludedImportTypes: [], |
||||
}, |
||||
], |
||||
|
||||
'promise/always-return': 'off', |
||||
'promise/catch-or-return': [ |
||||
'error', |
||||
{ |
||||
allowFinally: true, |
||||
}, |
||||
], |
||||
'promise/no-callback-in-promise': 'off', |
||||
'promise/no-nesting': 'off', |
||||
'promise/no-promise-in-callback': 'off', |
||||
|
||||
'formatjs/blocklist-elements': 'error', |
||||
'formatjs/enforce-default-message': ['error', 'literal'], |
||||
'formatjs/enforce-description': 'off', // description values not currently used
|
||||
'formatjs/enforce-id': 'off', // Explicit IDs are used in the project
|
||||
'formatjs/enforce-placeholders': 'off', // Issues in short_number.jsx
|
||||
'formatjs/enforce-plural-rules': 'error', |
||||
'formatjs/no-camel-case': 'off', // disabledAccount is only non-conforming
|
||||
'formatjs/no-complex-selectors': 'error', |
||||
'formatjs/no-emoji': 'error', |
||||
'formatjs/no-id': 'off', // IDs are used for translation keys
|
||||
'formatjs/no-invalid-icu': 'error', |
||||
'formatjs/no-literal-string-in-jsx': 'off', // Should be looked at, but mainly flagging punctuation outside of strings
|
||||
'formatjs/no-multiple-plurals': 'off', // Only used by hashtag.jsx
|
||||
'formatjs/no-multiple-whitespaces': 'error', |
||||
'formatjs/no-offset': 'error', |
||||
'formatjs/no-useless-message': 'error', |
||||
'formatjs/prefer-formatted-message': 'error', |
||||
'formatjs/prefer-pound-in-plural': 'error', |
||||
|
||||
'jsdoc/check-types': 'off', |
||||
'jsdoc/no-undefined-types': 'off', |
||||
'jsdoc/require-jsdoc': 'off', |
||||
'jsdoc/require-param-description': 'off', |
||||
'jsdoc/require-property-description': 'off', |
||||
'jsdoc/require-returns-description': 'off', |
||||
'jsdoc/require-returns': 'off', |
||||
}, |
||||
|
||||
overrides: [ |
||||
{ |
||||
files: [ |
||||
'*.config.js', |
||||
'.*rc.js', |
||||
'ide-helper.js', |
||||
'config/webpack/**/*', |
||||
'config/formatjs-formatter.js', |
||||
], |
||||
|
||||
env: { |
||||
commonjs: true, |
||||
}, |
||||
|
||||
parserOptions: { |
||||
sourceType: 'script', |
||||
}, |
||||
|
||||
rules: { |
||||
'import/no-commonjs': 'off', |
||||
}, |
||||
}, |
||||
{ |
||||
files: [ |
||||
'**/*.ts', |
||||
'**/*.tsx', |
||||
], |
||||
|
||||
extends: [ |
||||
'eslint:recommended', |
||||
'plugin:@typescript-eslint/strict-type-checked', |
||||
'plugin:@typescript-eslint/stylistic-type-checked', |
||||
'plugin:react/recommended', |
||||
'plugin:react-hooks/recommended', |
||||
'plugin:jsx-a11y/recommended', |
||||
'plugin:import/recommended', |
||||
'plugin:import/typescript', |
||||
'plugin:promise/recommended', |
||||
'plugin:jsdoc/recommended-typescript', |
||||
'plugin:prettier/recommended', |
||||
], |
||||
|
||||
parserOptions: { |
||||
project: true, |
||||
tsconfigRootDir: __dirname, |
||||
}, |
||||
|
||||
rules: { |
||||
'import/consistent-type-specifier-style': ['error', 'prefer-top-level'], |
||||
|
||||
'@typescript-eslint/consistent-type-definitions': ['warn', 'interface'], |
||||
'@typescript-eslint/consistent-type-exports': 'error', |
||||
'@typescript-eslint/consistent-type-imports': 'error', |
||||
"@typescript-eslint/prefer-nullish-coalescing": ['error', {ignorePrimitives: {boolean: true}}], |
||||
|
||||
'jsdoc/require-jsdoc': 'off', |
||||
|
||||
// Those rules set stricter rules for TS files
|
||||
// to enforce better practices when converting from JS
|
||||
'import/no-default-export': 'warn', |
||||
'react/prefer-stateless-function': 'warn', |
||||
'react/function-component-definition': ['error', { namedComponents: 'arrow-function' }], |
||||
'react/jsx-uses-react': 'off', // not needed with new JSX transform
|
||||
'react/react-in-jsx-scope': 'off', // not needed with new JSX transform
|
||||
'react/prop-types': 'off', |
||||
}, |
||||
}, |
||||
{ |
||||
files: [ |
||||
'**/__tests__/*.js', |
||||
'**/__tests__/*.jsx', |
||||
], |
||||
|
||||
env: { |
||||
jest: true, |
||||
}, |
||||
}, |
||||
{ |
||||
files: [ |
||||
'streaming/**/*', |
||||
], |
||||
rules: { |
||||
'import/no-commonjs': 'off', |
||||
}, |
||||
}, |
||||
], |
||||
}; |
||||
@ -0,0 +1 @@
|
||||
https://joinmastodon.org/funding.json |
||||
@ -1,3 +0,0 @@
|
||||
patreon: mastodon |
||||
open_collective: mastodon |
||||
custom: https://sponsor.joinmastodon.org |
||||
@ -1,22 +0,0 @@
|
||||
name: Feature Request |
||||
description: I have a suggestion |
||||
labels: [suggestion] |
||||
body: |
||||
- type: markdown |
||||
attributes: |
||||
value: | |
||||
Please use a concise and distinct title for the issue. |
||||
|
||||
Consider: Could it be implemented as a 3rd party app using the REST API instead? |
||||
- type: textarea |
||||
attributes: |
||||
label: Pitch |
||||
description: Describe your idea for a feature. Make sure it has not already been suggested/implemented/turned down before. |
||||
validations: |
||||
required: true |
||||
- type: textarea |
||||
attributes: |
||||
label: Motivation |
||||
description: Why do you think this feature is needed? Who would benefit from it? |
||||
validations: |
||||
required: true |
||||
@ -0,0 +1,74 @@
|
||||
name: Deployment troubleshooting |
||||
description: | |
||||
You are a server administrator and you are encountering a technical issue during installation, upgrade or operations of Mastodon. |
||||
labels: ['status/to triage'] |
||||
type: 'Troubleshooting' |
||||
body: |
||||
- type: markdown |
||||
attributes: |
||||
value: | |
||||
Make sure that you are submitting a new bug that was not previously reported or already fixed. |
||||
|
||||
Please use a concise and distinct title for the issue. |
||||
- type: textarea |
||||
attributes: |
||||
label: Steps to reproduce the problem |
||||
description: What were you trying to do? |
||||
value: | |
||||
1. |
||||
2. |
||||
3. |
||||
... |
||||
validations: |
||||
required: true |
||||
- type: input |
||||
attributes: |
||||
label: Expected behaviour |
||||
description: What should have happened? |
||||
validations: |
||||
required: true |
||||
- type: input |
||||
attributes: |
||||
label: Actual behaviour |
||||
description: What happened? |
||||
validations: |
||||
required: true |
||||
- type: textarea |
||||
attributes: |
||||
label: Detailed description |
||||
validations: |
||||
required: false |
||||
- type: input |
||||
attributes: |
||||
label: Mastodon instance |
||||
description: The address of the Mastodon instance where you experienced the issue |
||||
placeholder: mastodon.social |
||||
validations: |
||||
required: true |
||||
- type: input |
||||
attributes: |
||||
label: Mastodon version |
||||
description: | |
||||
This is displayed at the bottom of the About page, eg. `v4.4.0-alpha.1` |
||||
placeholder: v4.4.0-beta.1 |
||||
validations: |
||||
required: false |
||||
- type: textarea |
||||
attributes: |
||||
label: Environment |
||||
description: | |
||||
Details about your environment, like how Mastodon is deployed, if containers are used, version numbers, etc. |
||||
value: | |
||||
Please at least include those informations: |
||||
- Operating system: (eg. Ubuntu 24.04.2) |
||||
- Ruby version: (from `ruby --version`, eg. v3.4.4) |
||||
- Node.js version: (from `node --version`, eg. v22.16.0) |
||||
validations: |
||||
required: false |
||||
- type: textarea |
||||
attributes: |
||||
label: Technical details |
||||
description: | |
||||
Any additional technical details you may have, like logs or error traces |
||||
validations: |
||||
required: false |
||||
@ -0,0 +1,22 @@
|
||||
name: Feature Request |
||||
description: I have a suggestion |
||||
type: Suggestion |
||||
body: |
||||
- type: markdown |
||||
attributes: |
||||
value: | |
||||
Please use a concise and distinct title for the issue. |
||||
|
||||
Consider: Could it be implemented as a 3rd party app using the REST API instead? |
||||
- type: textarea |
||||
attributes: |
||||
label: Pitch |
||||
description: Describe your idea for a feature. Make sure it has not already been suggested/implemented/turned down before. |
||||
validations: |
||||
required: true |
||||
- type: textarea |
||||
attributes: |
||||
label: Motivation |
||||
description: Why do you think this feature is needed? Who would benefit from it? |
||||
validations: |
||||
required: true |
||||
@ -0,0 +1,42 @@
|
||||
name: 'Setup Javascript' |
||||
description: 'Setup a Javascript environment ready to run the Mastodon code' |
||||
inputs: |
||||
onlyProduction: |
||||
description: Only install production dependencies |
||||
default: 'false' |
||||
|
||||
runs: |
||||
using: 'composite' |
||||
steps: |
||||
- name: Set up Node.js |
||||
uses: actions/setup-node@v4 |
||||
with: |
||||
node-version-file: '.nvmrc' |
||||
|
||||
# The following is needed because we can not use `cache: true` for `setup-node`, as it does not support Corepack yet and mess up with the cache location if ran after Node is installed |
||||
- name: Enable corepack |
||||
shell: bash |
||||
run: corepack enable |
||||
|
||||
- name: Get yarn cache directory path |
||||
id: yarn-cache-dir-path |
||||
shell: bash |
||||
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT |
||||
|
||||
- uses: actions/cache@v4 |
||||
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) |
||||
with: |
||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} |
||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} |
||||
restore-keys: | |
||||
${{ runner.os }}-yarn- |
||||
|
||||
- name: Install all yarn packages |
||||
shell: bash |
||||
run: yarn install --immutable |
||||
if: inputs.onlyProduction == 'false' |
||||
|
||||
- name: Install all production yarn packages |
||||
shell: bash |
||||
run: yarn workspaces focus --production |
||||
if: inputs.onlyProduction != 'false' |
||||
@ -0,0 +1,23 @@
|
||||
name: 'Setup RUby' |
||||
description: 'Setup a Ruby environment ready to run the Mastodon code' |
||||
inputs: |
||||
ruby-version: |
||||
description: The Ruby version to install |
||||
default: '.ruby-version' |
||||
additional-system-dependencies: |
||||
description: 'Additional packages to install' |
||||
|
||||
runs: |
||||
using: 'composite' |
||||
steps: |
||||
- name: Install system dependencies |
||||
shell: bash |
||||
run: | |
||||
sudo apt-get update |
||||
sudo apt-get install -y libicu-dev libidn11-dev libvips42 ${{ inputs.additional-system-dependencies }} |
||||
|
||||
- name: Set up Ruby |
||||
uses: ruby/setup-ruby@v1 |
||||
with: |
||||
ruby-version: ${{ inputs.ruby-version }} |
||||
bundler-cache: true |
||||
@ -0,0 +1,13 @@
|
||||
comment: false # Do not leave PR comments |
||||
coverage: |
||||
status: |
||||
project: |
||||
default: |
||||
# GitHub status check is not blocking |
||||
informational: true |
||||
patch: |
||||
default: |
||||
# GitHub status check is not blocking |
||||
informational: true |
||||
github_checks: |
||||
annotations: false |
||||
@ -1,21 +0,0 @@
|
||||
{ |
||||
"problemMatcher": [ |
||||
{ |
||||
"owner": "stylelint", |
||||
"pattern": [ |
||||
{ |
||||
"regexp": "^([^\\s].*)$", |
||||
"file": 1 |
||||
}, |
||||
{ |
||||
"regexp": "^\\s+((\\d+):(\\d+))?\\s+(✖|×)\\s+(.*)\\s{2,}(.*)$", |
||||
"line": 2, |
||||
"column": 3, |
||||
"message": 5, |
||||
"code": 6, |
||||
"loop": true |
||||
} |
||||
] |
||||
} |
||||
] |
||||
} |
||||
@ -0,0 +1,62 @@
|
||||
name: Build nightly container image |
||||
on: |
||||
workflow_dispatch: |
||||
schedule: |
||||
- cron: '0 2 * * *' # run at 2 AM UTC |
||||
|
||||
permissions: |
||||
contents: read |
||||
packages: write |
||||
|
||||
jobs: |
||||
compute-suffix: |
||||
runs-on: ubuntu-latest |
||||
if: github.repository == 'mastodon/mastodon' |
||||
steps: |
||||
- id: version_vars |
||||
env: |
||||
TZ: Etc/UTC |
||||
run: | |
||||
echo mastodon_version_prerelease=nightly.$(date +'%Y-%m-%d')>> $GITHUB_OUTPUT |
||||
outputs: |
||||
prerelease: ${{ steps.version_vars.outputs.mastodon_version_prerelease }} |
||||
|
||||
build-image: |
||||
needs: compute-suffix |
||||
uses: ./.github/workflows/build-container-image.yml |
||||
with: |
||||
file_to_build: Dockerfile |
||||
cache: false |
||||
push_to_images: | |
||||
tootsuite/mastodon |
||||
ghcr.io/mastodon/mastodon |
||||
version_prerelease: ${{ needs.compute-suffix.outputs.prerelease }} |
||||
labels: | |
||||
org.opencontainers.image.description=Nightly build image used for testing purposes |
||||
flavor: | |
||||
latest=auto |
||||
tags: | |
||||
type=raw,value=edge |
||||
type=raw,value=nightly |
||||
type=schedule,pattern=${{ needs.compute-suffix.outputs.prerelease }} |
||||
secrets: inherit |
||||
|
||||
build-image-streaming: |
||||
needs: compute-suffix |
||||
uses: ./.github/workflows/build-container-image.yml |
||||
with: |
||||
file_to_build: streaming/Dockerfile |
||||
cache: false |
||||
push_to_images: | |
||||
tootsuite/mastodon-streaming |
||||
ghcr.io/mastodon/mastodon-streaming |
||||
version_prerelease: ${{ needs.compute-suffix.outputs.prerelease }} |
||||
labels: | |
||||
org.opencontainers.image.description=Nightly build image used for testing purposes |
||||
flavor: | |
||||
latest=auto |
||||
tags: | |
||||
type=raw,value=edge |
||||
type=raw,value=nightly |
||||
type=schedule,pattern=${{ needs.compute-suffix.outputs.prerelease }} |
||||
secrets: inherit |
||||
@ -0,0 +1,59 @@
|
||||
name: Build security nightly container image |
||||
on: |
||||
workflow_dispatch: |
||||
|
||||
permissions: |
||||
contents: read |
||||
packages: write |
||||
|
||||
jobs: |
||||
compute-suffix: |
||||
runs-on: ubuntu-latest |
||||
steps: |
||||
- id: version_vars |
||||
env: |
||||
TZ: Etc/UTC |
||||
run: | |
||||
echo mastodon_version_prerelease=nightly.$(date --date='next day' +'%Y-%m-%d')-security>> $GITHUB_OUTPUT |
||||
outputs: |
||||
prerelease: ${{ steps.version_vars.outputs.mastodon_version_prerelease }} |
||||
|
||||
build-image: |
||||
needs: compute-suffix |
||||
uses: ./.github/workflows/build-container-image.yml |
||||
with: |
||||
file_to_build: Dockerfile |
||||
cache: false |
||||
push_to_images: | |
||||
tootsuite/mastodon |
||||
ghcr.io/mastodon/mastodon |
||||
version_prerelease: ${{ needs.compute-suffix.outputs.prerelease }} |
||||
labels: | |
||||
org.opencontainers.image.description=Nightly build image used for testing purposes |
||||
flavor: | |
||||
latest=auto |
||||
tags: | |
||||
type=raw,value=edge |
||||
type=raw,value=nightly |
||||
type=raw,value=${{ needs.compute-suffix.outputs.prerelease }} |
||||
secrets: inherit |
||||
|
||||
build-image-streaming: |
||||
needs: compute-suffix |
||||
uses: ./.github/workflows/build-container-image.yml |
||||
with: |
||||
file_to_build: streaming/Dockerfile |
||||
cache: false |
||||
push_to_images: | |
||||
tootsuite/mastodon-streaming |
||||
ghcr.io/mastodon/mastodon-streaming |
||||
version_prerelease: ${{ needs.compute-suffix.outputs.prerelease }} |
||||
labels: | |
||||
org.opencontainers.image.description=Nightly build image used for testing purposes |
||||
flavor: | |
||||
latest=auto |
||||
tags: | |
||||
type=raw,value=edge |
||||
type=raw,value=nightly |
||||
type=raw,value=${{ needs.compute-suffix.outputs.prerelease }} |
||||
secrets: inherit |
||||
@ -0,0 +1,69 @@
|
||||
name: Crowdin / Download translations (stable branches) |
||||
on: |
||||
workflow_dispatch: |
||||
|
||||
permissions: |
||||
contents: write |
||||
pull-requests: write |
||||
|
||||
jobs: |
||||
download-translations-stable: |
||||
runs-on: ubuntu-latest |
||||
if: github.repository == 'mastodon/mastodon' |
||||
|
||||
steps: |
||||
- name: Checkout |
||||
uses: actions/checkout@v4 |
||||
|
||||
- name: Increase Git http.postBuffer |
||||
# This is needed due to a bug in Ubuntu's cURL version? |
||||
# See https://github.com/orgs/community/discussions/55820 |
||||
run: | |
||||
git config --global http.version HTTP/1.1 |
||||
git config --global http.postBuffer 157286400 |
||||
|
||||
# Download the translation files from Crowdin |
||||
- name: crowdin action |
||||
uses: crowdin/github-action@v2 |
||||
with: |
||||
upload_sources: false |
||||
upload_translations: false |
||||
download_translations: true |
||||
crowdin_branch_name: ${{ github.base_ref || github.ref_name }} |
||||
push_translations: false |
||||
create_pull_request: false |
||||
env: |
||||
CROWDIN_PROJECT_ID: ${{ vars.CROWDIN_PROJECT_ID }} |
||||
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} |
||||
|
||||
# As the files are extracted from a Docker container, they belong to root:root |
||||
# We need to fix this before the next steps |
||||
- name: Fix file permissions |
||||
run: sudo chown -R runner:docker . |
||||
|
||||
# This is needed to run the normalize step |
||||
- name: Set up Ruby environment |
||||
uses: ./.github/actions/setup-ruby |
||||
|
||||
- name: Run i18n normalize task |
||||
run: bin/i18n-tasks normalize |
||||
|
||||
# Create or update the pull request |
||||
- name: Create Pull Request |
||||
uses: peter-evans/create-pull-request@v7.0.8 |
||||
with: |
||||
commit-message: 'New Crowdin translations' |
||||
title: 'New Crowdin Translations for ${{ github.base_ref || github.ref_name }} (automated)' |
||||
author: 'GitHub Actions <noreply@github.com>' |
||||
body: | |
||||
New Crowdin translations, automated with GitHub Actions |
||||
|
||||
See `.github/workflows/crowdin-download.yml` |
||||
|
||||
This PR will be updated every day with new translations. |
||||
|
||||
Due to a limitation in GitHub Actions, checks are not running on this PR without manual action. |
||||
If you want to run the checks, then close and re-open it. |
||||
branch: i18n/crowdin/translations-${{ github.base_ref || github.ref_name }} |
||||
base: ${{ github.base_ref || github.ref_name }} |
||||
labels: i18n |
||||
@ -0,0 +1,38 @@
|
||||
name: Crowdin / Upload translations |
||||
|
||||
on: |
||||
push: |
||||
branches: |
||||
- 'main' |
||||
- 'stable-*' |
||||
paths: |
||||
- crowdin.yml |
||||
- app/javascript/mastodon/locales/en.json |
||||
- config/locales/en.yml |
||||
- config/locales/simple_form.en.yml |
||||
- config/locales/activerecord.en.yml |
||||
- config/locales/devise.en.yml |
||||
- config/locales/doorkeeper.en.yml |
||||
- .github/workflows/crowdin-upload.yml |
||||
workflow_dispatch: |
||||
|
||||
jobs: |
||||
upload-translations: |
||||
runs-on: ubuntu-latest |
||||
if: github.repository == 'mastodon/mastodon' |
||||
|
||||
steps: |
||||
- name: Checkout |
||||
uses: actions/checkout@v4 |
||||
|
||||
- name: crowdin action |
||||
uses: crowdin/github-action@v2 |
||||
with: |
||||
upload_sources: true |
||||
upload_translations: false |
||||
download_translations: false |
||||
crowdin_branch_name: ${{ github.base_ref || github.ref_name }} |
||||
|
||||
env: |
||||
CROWDIN_PROJECT_ID: ${{ vars.CROWDIN_PROJECT_ID }} |
||||
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} |
||||
@ -0,0 +1,22 @@
|
||||
name: Check formatting |
||||
on: |
||||
merge_group: |
||||
push: |
||||
branches: |
||||
- 'main' |
||||
- 'stable-*' |
||||
pull_request: |
||||
|
||||
jobs: |
||||
lint: |
||||
runs-on: ubuntu-latest |
||||
|
||||
steps: |
||||
- name: Clone repository |
||||
uses: actions/checkout@v4 |
||||
|
||||
- name: Set up Javascript environment |
||||
uses: ./.github/actions/setup-javascript |
||||
|
||||
- name: Check formatting with Prettier |
||||
run: yarn format:check |
||||
@ -1,44 +0,0 @@
|
||||
name: JSON Linting |
||||
on: |
||||
push: |
||||
branches-ignore: |
||||
- 'dependabot/**' |
||||
- 'renovate/**' |
||||
paths: |
||||
- 'package.json' |
||||
- 'yarn.lock' |
||||
- '.nvmrc' |
||||
- '.prettier*' |
||||
- '**/*.json' |
||||
- '.github/workflows/lint-json.yml' |
||||
- '!app/javascript/mastodon/locales/*.json' |
||||
|
||||
pull_request: |
||||
paths: |
||||
- 'package.json' |
||||
- 'yarn.lock' |
||||
- '.nvmrc' |
||||
- '.prettier*' |
||||
- '**/*.json' |
||||
- '.github/workflows/lint-json.yml' |
||||
- '!app/javascript/mastodon/locales/*.json' |
||||
|
||||
jobs: |
||||
lint: |
||||
runs-on: ubuntu-latest |
||||
|
||||
steps: |
||||
- name: Clone repository |
||||
uses: actions/checkout@v4 |
||||
|
||||
- name: Set up Node.js |
||||
uses: actions/setup-node@v3 |
||||
with: |
||||
cache: yarn |
||||
node-version-file: '.nvmrc' |
||||
|
||||
- name: Install all yarn packages |
||||
run: yarn --frozen-lockfile |
||||
|
||||
- name: Prettier |
||||
run: yarn lint:json |
||||
@ -1,44 +0,0 @@
|
||||
name: Markdown Linting |
||||
on: |
||||
push: |
||||
branches-ignore: |
||||
- 'dependabot/**' |
||||
- 'renovate/**' |
||||
paths: |
||||
- '.github/workflows/lint-md.yml' |
||||
- '.nvmrc' |
||||
- '.prettier*' |
||||
- '**/*.md' |
||||
- '!AUTHORS.md' |
||||
- 'package.json' |
||||
- 'yarn.lock' |
||||
|
||||
pull_request: |
||||
paths: |
||||
- '.github/workflows/lint-md.yml' |
||||
- '.nvmrc' |
||||
- '.prettier*' |
||||
- '**/*.md' |
||||
- '!AUTHORS.md' |
||||
- 'package.json' |
||||
- 'yarn.lock' |
||||
|
||||
jobs: |
||||
lint: |
||||
runs-on: ubuntu-latest |
||||
|
||||
steps: |
||||
- name: Clone repository |
||||
uses: actions/checkout@v4 |
||||
|
||||
- name: Set up Node.js |
||||
uses: actions/setup-node@v3 |
||||
with: |
||||
cache: yarn |
||||
node-version-file: '.nvmrc' |
||||
|
||||
- name: Install all yarn packages |
||||
run: yarn --frozen-lockfile |
||||
|
||||
- name: Prettier |
||||
run: yarn lint:md |
||||
@ -1,46 +0,0 @@
|
||||
name: YML Linting |
||||
on: |
||||
push: |
||||
branches-ignore: |
||||
- 'dependabot/**' |
||||
- 'renovate/**' |
||||
paths: |
||||
- 'package.json' |
||||
- 'yarn.lock' |
||||
- '.nvmrc' |
||||
- '.prettier*' |
||||
- '**/*.yaml' |
||||
- '**/*.yml' |
||||
- '.github/workflows/lint-yml.yml' |
||||
- '!config/locales/*.yml' |
||||
|
||||
pull_request: |
||||
paths: |
||||
- 'package.json' |
||||
- 'yarn.lock' |
||||
- '.nvmrc' |
||||
- '.prettier*' |
||||
- '**/*.yaml' |
||||
- '**/*.yml' |
||||
- '.github/workflows/lint-yml.yml' |
||||
- '!config/locales/*.yml' |
||||
|
||||
jobs: |
||||
lint: |
||||
runs-on: ubuntu-latest |
||||
|
||||
steps: |
||||
- name: Clone repository |
||||
uses: actions/checkout@v4 |
||||
|
||||
- name: Set up Node.js |
||||
uses: actions/setup-node@v3 |
||||
with: |
||||
cache: yarn |
||||
node-version-file: '.nvmrc' |
||||
|
||||
- name: Install all yarn packages |
||||
run: yarn --frozen-lockfile |
||||
|
||||
- name: Prettier |
||||
run: yarn lint:yml |
||||
@ -1,111 +0,0 @@
|
||||
name: Test one step migrations |
||||
on: |
||||
push: |
||||
branches-ignore: |
||||
- 'dependabot/**' |
||||
- 'renovate/**' |
||||
pull_request: |
||||
|
||||
jobs: |
||||
pre_job: |
||||
runs-on: ubuntu-latest |
||||
|
||||
outputs: |
||||
should_skip: ${{ steps.skip_check.outputs.should_skip }} |
||||
|
||||
steps: |
||||
- id: skip_check |
||||
uses: fkirc/skip-duplicate-actions@v5 |
||||
with: |
||||
paths: '["Gemfile*", ".ruby-version", "**/*.rb", ".github/workflows/test-migrations-one-step.yml", "lib/tasks/tests.rake"]' |
||||
|
||||
test: |
||||
runs-on: ubuntu-latest |
||||
needs: pre_job |
||||
if: needs.pre_job.outputs.should_skip != 'true' |
||||
|
||||
strategy: |
||||
fail-fast: false |
||||
|
||||
matrix: |
||||
postgres: |
||||
- 14-alpine |
||||
- 15-alpine |
||||
|
||||
services: |
||||
postgres: |
||||
image: postgres:${{ matrix.postgres}} |
||||
env: |
||||
POSTGRES_PASSWORD: postgres |
||||
POSTGRES_USER: postgres |
||||
options: >- |
||||
--health-cmd pg_isready |
||||
--health-interval 10s |
||||
--health-timeout 5s |
||||
--health-retries 5 |
||||
ports: |
||||
- 5432:5432 |
||||
|
||||
redis: |
||||
image: redis:7-alpine |
||||
options: >- |
||||
--health-cmd "redis-cli ping" |
||||
--health-interval 10s |
||||
--health-timeout 5s |
||||
--health-retries 5 |
||||
ports: |
||||
- 6379:6379 |
||||
|
||||
env: |
||||
CONTINUOUS_INTEGRATION: true |
||||
DB_HOST: localhost |
||||
DB_USER: postgres |
||||
DB_PASS: postgres |
||||
DISABLE_SIMPLECOV: true |
||||
RAILS_ENV: test |
||||
BUNDLE_CLEAN: true |
||||
BUNDLE_FROZEN: true |
||||
BUNDLE_WITHOUT: 'development production' |
||||
BUNDLE_JOBS: 3 |
||||
BUNDLE_RETRY: 3 |
||||
|
||||
steps: |
||||
- uses: actions/checkout@v4 |
||||
|
||||
- name: Install native Ruby dependencies |
||||
run: | |
||||
sudo apt-get update |
||||
sudo apt-get install -y libicu-dev libidn11-dev |
||||
|
||||
- name: Set up bundler cache |
||||
uses: ruby/setup-ruby@v1 |
||||
with: |
||||
ruby-version: .ruby-version |
||||
bundler-cache: true |
||||
|
||||
- name: Create database |
||||
run: './bin/rails db:create' |
||||
|
||||
- name: Run migrations up to v2.0.0 |
||||
run: './bin/rails db:migrate VERSION=20171010025614' |
||||
|
||||
- name: Populate database with test data |
||||
run: './bin/rails tests:migrations:populate_v2' |
||||
|
||||
- name: Run migrations up to v2.4.0 |
||||
run: './bin/rails db:migrate VERSION=20180514140000' |
||||
|
||||
- name: Populate database with test data |
||||
run: './bin/rails tests:migrations:populate_v2_4' |
||||
|
||||
- name: Run migrations up to v2.4.3 |
||||
run: './bin/rails db:migrate VERSION=20180707154237' |
||||
|
||||
- name: Populate database with test data |
||||
run: './bin/rails tests:migrations:populate_v2_4_3' |
||||
|
||||
- name: Run all remaining migrations |
||||
run: './bin/rails db:migrate' |
||||
|
||||
- name: Check migration result |
||||
run: './bin/rails tests:migrations:check_database' |
||||
@ -1,119 +0,0 @@
|
||||
name: Test two step migrations |
||||
on: |
||||
push: |
||||
branches-ignore: |
||||
- 'dependabot/**' |
||||
- 'renovate/**' |
||||
pull_request: |
||||
|
||||
jobs: |
||||
pre_job: |
||||
runs-on: ubuntu-latest |
||||
|
||||
outputs: |
||||
should_skip: ${{ steps.skip_check.outputs.should_skip }} |
||||
|
||||
steps: |
||||
- id: skip_check |
||||
uses: fkirc/skip-duplicate-actions@v5 |
||||
with: |
||||
paths: '["Gemfile*", ".ruby-version", "**/*.rb", ".github/workflows/test-migrations-two-step.yml", "lib/tasks/tests.rake"]' |
||||
|
||||
test: |
||||
runs-on: ubuntu-latest |
||||
needs: pre_job |
||||
if: needs.pre_job.outputs.should_skip != 'true' |
||||
|
||||
strategy: |
||||
fail-fast: false |
||||
|
||||
matrix: |
||||
postgres: |
||||
- 14-alpine |
||||
- 15-alpine |
||||
|
||||
services: |
||||
postgres: |
||||
image: postgres:${{ matrix.postgres}} |
||||
env: |
||||
POSTGRES_PASSWORD: postgres |
||||
POSTGRES_USER: postgres |
||||
options: >- |
||||
--health-cmd pg_isready |
||||
--health-interval 10s |
||||
--health-timeout 5s |
||||
--health-retries 5 |
||||
ports: |
||||
- 5432:5432 |
||||
redis: |
||||
image: redis:7-alpine |
||||
options: >- |
||||
--health-cmd "redis-cli ping" |
||||
--health-interval 10s |
||||
--health-timeout 5s |
||||
--health-retries 5 |
||||
ports: |
||||
- 6379:6379 |
||||
|
||||
env: |
||||
CONTINUOUS_INTEGRATION: true |
||||
DB_HOST: localhost |
||||
DB_USER: postgres |
||||
DB_PASS: postgres |
||||
DISABLE_SIMPLECOV: true |
||||
RAILS_ENV: test |
||||
BUNDLE_CLEAN: true |
||||
BUNDLE_FROZEN: true |
||||
BUNDLE_WITHOUT: 'development production' |
||||
BUNDLE_JOBS: 3 |
||||
BUNDLE_RETRY: 3 |
||||
|
||||
steps: |
||||
- uses: actions/checkout@v4 |
||||
|
||||
- name: Install native Ruby dependencies |
||||
run: | |
||||
sudo apt-get update |
||||
sudo apt-get install -y libicu-dev libidn11-dev |
||||
|
||||
- name: Set up bundler cache |
||||
uses: ruby/setup-ruby@v1 |
||||
with: |
||||
ruby-version: .ruby-version |
||||
bundler-cache: true |
||||
|
||||
- name: Create database |
||||
run: './bin/rails db:create' |
||||
|
||||
- name: Run migrations up to v2.0.0 |
||||
run: './bin/rails db:migrate VERSION=20171010025614' |
||||
|
||||
- name: Populate database with test data |
||||
run: './bin/rails tests:migrations:populate_v2' |
||||
|
||||
- name: Run pre-deployment migrations up to v2.4.0 |
||||
run: './bin/rails db:migrate VERSION=20180514140000' |
||||
env: |
||||
SKIP_POST_DEPLOYMENT_MIGRATIONS: true |
||||
|
||||
- name: Populate database with test data |
||||
run: './bin/rails tests:migrations:populate_v2_4' |
||||
|
||||
- name: Run migrations up to v2.4.3 |
||||
run: './bin/rails db:migrate VERSION=20180707154237' |
||||
env: |
||||
SKIP_POST_DEPLOYMENT_MIGRATIONS: true |
||||
|
||||
- name: Populate database with test data |
||||
run: './bin/rails tests:migrations:populate_v2_4_3' |
||||
|
||||
- name: Run all remaining pre-deployment migrations |
||||
run: './bin/rails db:migrate' |
||||
env: |
||||
SKIP_POST_DEPLOYMENT_MIGRATIONS: true |
||||
|
||||
- name: Run all post-deployment migrations |
||||
run: './bin/rails db:migrate' |
||||
|
||||
- name: Check migration result |
||||
run: './bin/rails tests:migrations:check_database' |
||||
@ -0,0 +1,112 @@
|
||||
name: Historical data migration test |
||||
|
||||
on: |
||||
merge_group: |
||||
push: |
||||
branches: |
||||
- 'main' |
||||
- 'stable-*' |
||||
paths: |
||||
- 'Gemfile*' |
||||
- '.ruby-version' |
||||
- '**/*.rb' |
||||
- '.github/workflows/test-migrations.yml' |
||||
- 'lib/tasks/tests.rake' |
||||
- 'lib/tasks/db.rake' |
||||
|
||||
pull_request: |
||||
paths: |
||||
- 'Gemfile*' |
||||
- '.ruby-version' |
||||
- '**/*.rb' |
||||
- '.github/workflows/test-migrations.yml' |
||||
- 'lib/tasks/tests.rake' |
||||
|
||||
jobs: |
||||
test: |
||||
runs-on: ubuntu-latest |
||||
|
||||
strategy: |
||||
fail-fast: false |
||||
|
||||
matrix: |
||||
postgres: |
||||
- 14-alpine |
||||
- 15-alpine |
||||
- 16-alpine |
||||
- 17-alpine |
||||
|
||||
services: |
||||
postgres: |
||||
image: postgres:${{ matrix.postgres}} |
||||
env: |
||||
POSTGRES_PASSWORD: postgres |
||||
POSTGRES_USER: postgres |
||||
options: >- |
||||
--health-cmd pg_isready |
||||
--health-interval 10ms |
||||
--health-timeout 3s |
||||
--health-retries 50 |
||||
ports: |
||||
- 5432:5432 |
||||
|
||||
redis: |
||||
image: redis:7-alpine |
||||
options: >- |
||||
--health-cmd "redis-cli ping" |
||||
--health-interval 10ms |
||||
--health-timeout 3s |
||||
--health-retries 50 |
||||
ports: |
||||
- 6379:6379 |
||||
|
||||
env: |
||||
DB_HOST: localhost |
||||
DB_USER: postgres |
||||
DB_PASS: postgres |
||||
RAILS_ENV: test |
||||
BUNDLE_CLEAN: true |
||||
BUNDLE_FROZEN: true |
||||
BUNDLE_WITHOUT: 'development:production' |
||||
BUNDLE_JOBS: 3 |
||||
BUNDLE_RETRY: 3 |
||||
|
||||
steps: |
||||
- uses: actions/checkout@v4 |
||||
|
||||
- name: Set up Ruby environment |
||||
uses: ./.github/actions/setup-ruby |
||||
|
||||
- name: Ensure no errors with `db:prepare` |
||||
run: | |
||||
bin/rails db:drop |
||||
bin/rails db:prepare |
||||
bin/rails db:migrate |
||||
|
||||
- name: Ensure no errors with `db:prepare` and SKIP_POST_DEPLOYMENT_MIGRATIONS |
||||
run: | |
||||
bin/rails db:drop |
||||
SKIP_POST_DEPLOYMENT_MIGRATIONS=true bin/rails db:prepare |
||||
bin/rails db:migrate |
||||
|
||||
- name: Test "one step migration" flow |
||||
run: | |
||||
bin/rails db:drop |
||||
bin/rails db:create |
||||
bin/rails tests:migrations:prepare_database |
||||
bin/rails db:migrate |
||||
bin/rails tests:migrations:check_database |
||||
|
||||
- name: Test "two step migration" flow |
||||
run: | |
||||
bin/rails db:drop |
||||
bin/rails db:create |
||||
SKIP_POST_DEPLOYMENT_MIGRATIONS=true bin/rails tests:migrations:prepare_database |
||||
|
||||
# Migrate up to v4.2.0 breakpoint |
||||
bin/rails db:migrate VERSION=20230907150100 |
||||
|
||||
# Migrate the rest |
||||
SKIP_POST_DEPLOYMENT_MIGRATIONS=true bin/rails db:migrate |
||||
bin/rails db:migrate |
||||
bin/rails tests:migrations:check_database |
||||
@ -1,47 +0,0 @@
|
||||
# This configuration was generated by |
||||
# `haml-lint --auto-gen-config` |
||||
# on 2023-07-20 09:47:50 -0400 using Haml-Lint version 0.48.0. |
||||
# The point is for the user to remove these configuration records |
||||
# one by one as the lints are removed from the code base. |
||||
# Note that changes in the inspected code, or installation of new |
||||
# versions of Haml-Lint, may require this file to be generated again. |
||||
|
||||
linters: |
||||
# Offense count: 951 |
||||
LineLength: |
||||
enabled: false |
||||
|
||||
# Offense count: 22 |
||||
UnnecessaryStringOutput: |
||||
enabled: false |
||||
|
||||
# Offense count: 57 |
||||
RuboCop: |
||||
enabled: false |
||||
|
||||
# Offense count: 3 |
||||
ViewLength: |
||||
exclude: |
||||
- 'app/views/admin/accounts/show.html.haml' |
||||
- 'app/views/admin/reports/show.html.haml' |
||||
- 'app/views/disputes/strikes/show.html.haml' |
||||
|
||||
# Offense count: 32 |
||||
InstanceVariables: |
||||
exclude: |
||||
- 'app/views/admin/reports/_actions.html.haml' |
||||
- 'app/views/admin/roles/_form.html.haml' |
||||
- 'app/views/admin/webhooks/_form.html.haml' |
||||
- 'app/views/auth/registrations/_status.html.haml' |
||||
- 'app/views/auth/sessions/two_factor/_otp_authentication_form.html.haml' |
||||
- 'app/views/authorize_interactions/_post_follow_actions.html.haml' |
||||
- 'app/views/invites/_form.html.haml' |
||||
- 'app/views/relationships/_account.html.haml' |
||||
- 'app/views/shared/_og.html.haml' |
||||
|
||||
# Offense count: 3 |
||||
IdNames: |
||||
exclude: |
||||
- 'app/views/authorize_interactions/error.html.haml' |
||||
- 'app/views/oauth/authorizations/error.html.haml' |
||||
- 'app/views/shared/_error_messages.html.haml' |
||||
@ -1,4 +1 @@
|
||||
#!/bin/sh |
||||
. "$(dirname "$0")/_/husky.sh" |
||||
|
||||
yarn lint-staged |
||||
|
||||
@ -1,19 +0,0 @@
|
||||
.DS_Store |
||||
.git/ |
||||
.gitignore |
||||
|
||||
.bundle/ |
||||
.cache/ |
||||
config/deploy/* |
||||
coverage |
||||
docs/ |
||||
.env |
||||
log/*.log |
||||
neo4j/ |
||||
node_modules/ |
||||
public/assets/ |
||||
public/system/ |
||||
spec/ |
||||
tmp/ |
||||
.vagrant/ |
||||
vendor/bundle/ |
||||
@ -1,4 +1,4 @@
|
||||
module.exports = { |
||||
singleQuote: true, |
||||
jsxSingleQuote: true |
||||
} |
||||
}; |
||||
|
||||
@ -1 +0,0 @@
|
||||
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/app/.apt/lib/x86_64-linux-gnu:/app/.apt/usr/lib/x86_64-linux-gnu/mesa:/app/.apt/usr/lib/x86_64-linux-gnu/pulseaudio:/app/.apt/usr/lib/x86_64-linux-gnu/openblas-pthread |
||||
@ -1,202 +1,36 @@
|
||||
# Can be removed once all rules are addressed or moved to this file as documented overrides |
||||
inherit_from: .rubocop_todo.yml |
||||
--- |
||||
AllCops: |
||||
CacheRootDirectory: tmp |
||||
DisplayStyleGuide: true |
||||
Exclude: |
||||
- Vagrantfile |
||||
- config/initializers/json_ld* |
||||
- lib/mastodon/migration_helpers.rb |
||||
ExtraDetails: true |
||||
NewCops: enable |
||||
TargetRubyVersion: 3.2 # Oldest supported ruby version |
||||
|
||||
inherit_from: |
||||
- .rubocop/layout.yml |
||||
- .rubocop/metrics.yml |
||||
- .rubocop/naming.yml |
||||
- .rubocop/rails.yml |
||||
- .rubocop/rspec_rails.yml |
||||
- .rubocop/rspec.yml |
||||
- .rubocop/style.yml |
||||
- .rubocop/i18n.yml |
||||
- .rubocop/custom.yml |
||||
- .rubocop_todo.yml |
||||
- .rubocop/strict.yml |
||||
|
||||
# Used for merging with exclude lists with .rubocop_todo.yml |
||||
inherit_mode: |
||||
merge: |
||||
- Exclude |
||||
|
||||
require: |
||||
plugins: |
||||
- rubocop-capybara |
||||
- rubocop-i18n |
||||
- rubocop-performance |
||||
- rubocop-rails |
||||
- rubocop-rspec |
||||
- rubocop-performance |
||||
- rubocop-capybara |
||||
- ./lib/linter/rubocop_middle_dot |
||||
|
||||
AllCops: |
||||
TargetRubyVersion: 3.0 # Set to minimum supported version of CI |
||||
DisplayCopNames: true |
||||
DisplayStyleGuide: true |
||||
ExtraDetails: true |
||||
UseCache: true |
||||
CacheRootDirectory: tmp |
||||
NewCops: enable # Opt-in to newly added rules |
||||
Exclude: |
||||
- db/schema.rb |
||||
- 'bin/*' |
||||
- 'node_modules/**/*' |
||||
- 'Vagrantfile' |
||||
- 'vendor/**/*' |
||||
- 'lib/json_ld/*' # Generated files |
||||
- 'lib/templates/**/*' |
||||
|
||||
# Reason: Prefer Hashes without extreme indentation |
||||
# https://docs.rubocop.org/rubocop/cops_layout.html#layoutfirsthashelementindentation |
||||
Layout/FirstHashElementIndentation: |
||||
EnforcedStyle: consistent |
||||
|
||||
# Reason: Currently disabled in .rubocop_todo.yml |
||||
# https://docs.rubocop.org/rubocop/cops_layout.html#layoutlinelength |
||||
Layout/LineLength: |
||||
Max: 320 # Default of 120 causes a duplicate entry in generated todo file |
||||
|
||||
# Reason: |
||||
# https://docs.rubocop.org/rubocop/cops_lint.html#lintuselessaccessmodifier |
||||
Lint/UselessAccessModifier: |
||||
ContextCreatingMethods: |
||||
- class_methods |
||||
|
||||
## Disable most Metrics/*Length cops |
||||
# Reason: those are often triggered and force significant refactors when this happend |
||||
# but the team feel they are not really improving the code quality. |
||||
|
||||
# https://docs.rubocop.org/rubocop/cops_metrics.html#metricsblocklength |
||||
Metrics/BlockLength: |
||||
Enabled: false |
||||
|
||||
# https://docs.rubocop.org/rubocop/cops_metrics.html#metricsclasslength |
||||
Metrics/ClassLength: |
||||
Enabled: false |
||||
|
||||
# https://docs.rubocop.org/rubocop/cops_metrics.html#metricsmethodlength |
||||
Metrics/MethodLength: |
||||
Enabled: false |
||||
|
||||
# https://docs.rubocop.org/rubocop/cops_metrics.html#metricsmodulelength |
||||
Metrics/ModuleLength: |
||||
Enabled: false |
||||
|
||||
## End Disable Metrics/*Length cops |
||||
|
||||
# Reason: Currently disabled in .rubocop_todo.yml |
||||
# https://docs.rubocop.org/rubocop/cops_metrics.html#metricsabcsize |
||||
Metrics/AbcSize: |
||||
Exclude: |
||||
- 'lib/mastodon/cli/*.rb' |
||||
- db/*migrate/**/* |
||||
|
||||
# Reason: |
||||
# https://docs.rubocop.org/rubocop/cops_metrics.html#metricsblocknesting |
||||
Metrics/BlockNesting: |
||||
Exclude: |
||||
- 'lib/mastodon/cli/*.rb' |
||||
|
||||
# Reason: Currently disabled in .rubocop_todo.yml |
||||
# https://docs.rubocop.org/rubocop/cops_metrics.html#metricscyclomaticcomplexity |
||||
Metrics/CyclomaticComplexity: |
||||
Exclude: |
||||
- lib/mastodon/cli/*.rb |
||||
- db/*migrate/**/* |
||||
|
||||
# Reason: |
||||
# https://docs.rubocop.org/rubocop/cops_metrics.html#metricsparameterlists |
||||
Metrics/ParameterLists: |
||||
CountKeywordArgs: false |
||||
|
||||
# Reason: Prevailing style is argument file paths |
||||
# https://docs.rubocop.org/rubocop-rails/cops_rails.html#railsfilepath |
||||
Rails/FilePath: |
||||
EnforcedStyle: arguments |
||||
|
||||
# Reason: Prevailing style uses numeric status codes, matches RSpec/Rails/HttpStatus |
||||
# https://docs.rubocop.org/rubocop-rails/cops_rails.html#railshttpstatus |
||||
Rails/HttpStatus: |
||||
EnforcedStyle: numeric |
||||
|
||||
# Reason: Allowed in `tootctl` CLI code and in boot ENV checker |
||||
# https://docs.rubocop.org/rubocop-rails/cops_rails.html#railsexit |
||||
Rails/Exit: |
||||
Exclude: |
||||
- 'config/boot.rb' |
||||
- 'lib/mastodon/cli/*.rb' |
||||
|
||||
# Reason: Some single letter camel case files shouldn't be split |
||||
# https://docs.rubocop.org/rubocop-rspec/cops_rspec.html#rspecfilepath |
||||
RSpec/FilePath: |
||||
CustomTransform: |
||||
ActivityPub: activitypub # Ignore the snake_case due to the amount of files to rename |
||||
DeepL: deepl |
||||
FetchOEmbedService: fetch_oembed_service |
||||
JsonLdHelper: jsonld_helper |
||||
OEmbedController: oembed_controller |
||||
OStatus: ostatus |
||||
NodeInfoController: nodeinfo_controller # NodeInfo isn't snake_cased for any of the instances |
||||
Exclude: |
||||
- 'spec/config/initializers/rack_attack_spec.rb' # namespaces usually have separate folder |
||||
- 'spec/lib/sanitize_config_spec.rb' # namespaces usually have separate folder |
||||
|
||||
# Reason: |
||||
# https://docs.rubocop.org/rubocop-rspec/cops_rspec.html#rspecnamedsubject |
||||
RSpec/NamedSubject: |
||||
EnforcedStyle: named_only |
||||
|
||||
# Reason: Prevailing style choice |
||||
# https://docs.rubocop.org/rubocop-rspec/cops_rspec.html#rspecnottonot |
||||
RSpec/NotToNot: |
||||
EnforcedStyle: to_not |
||||
|
||||
# Reason: Prevailing style uses numeric status codes, matches Rails/HttpStatus |
||||
# https://docs.rubocop.org/rubocop-rspec/cops_rspec_rails.html#rspecrailshttpstatus |
||||
RSpec/Rails/HttpStatus: |
||||
EnforcedStyle: numeric |
||||
|
||||
# Reason: |
||||
# https://docs.rubocop.org/rubocop/cops_style.html#styleclassandmodulechildren |
||||
Style/ClassAndModuleChildren: |
||||
Enabled: false |
||||
|
||||
# Reason: Classes mostly self-document with their names |
||||
# https://docs.rubocop.org/rubocop/cops_style.html#styledocumentation |
||||
Style/Documentation: |
||||
Enabled: false |
||||
|
||||
# Reason: Enforce modern Ruby style |
||||
# https://docs.rubocop.org/rubocop/cops_style.html#stylehashsyntax |
||||
Style/HashSyntax: |
||||
EnforcedStyle: ruby19_no_mixed_keys |
||||
|
||||
# Reason: |
||||
# https://docs.rubocop.org/rubocop/cops_style.html#stylenumericliterals |
||||
Style/NumericLiterals: |
||||
AllowedPatterns: |
||||
- \d{4}_\d{2}_\d{2}_\d{6} # For DB migration date version number readability |
||||
|
||||
# Reason: |
||||
# https://docs.rubocop.org/rubocop/cops_style.html#stylepercentliteraldelimiters |
||||
Style/PercentLiteralDelimiters: |
||||
PreferredDelimiters: |
||||
'%i': '()' |
||||
'%w': '()' |
||||
|
||||
# Reason: Prefer less indentation in conditional assignments |
||||
# https://docs.rubocop.org/rubocop/cops_style.html#styleredundantbegin |
||||
Style/RedundantBegin: |
||||
Enabled: false |
||||
|
||||
# Reason: Overridden to reduce implicit StandardError rescues |
||||
# https://docs.rubocop.org/rubocop/cops_style.html#stylerescuestandarderror |
||||
Style/RescueStandardError: |
||||
EnforcedStyle: implicit |
||||
|
||||
# Reason: Simplify some spec layouts |
||||
# https://docs.rubocop.org/rubocop/cops_style.html#stylesemicolon |
||||
Style/Semicolon: |
||||
AllowAsExpressionSeparator: true |
||||
|
||||
# Reason: Originally disabled for CodeClimate, and no config consensus has been found |
||||
# https://docs.rubocop.org/rubocop/cops_style.html#stylesymbolarray |
||||
Style/SymbolArray: |
||||
Enabled: false |
||||
|
||||
# Reason: |
||||
# https://docs.rubocop.org/rubocop/cops_style.html#styletrailingcommainarrayliteral |
||||
Style/TrailingCommaInArrayLiteral: |
||||
EnforcedStyleForMultiline: 'comma' |
||||
|
||||
# Reason: |
||||
# https://docs.rubocop.org/rubocop/cops_style.html#styletrailingcommainhashliteral |
||||
Style/TrailingCommaInHashLiteral: |
||||
EnforcedStyleForMultiline: 'comma' |
||||
|
||||
Style/MiddleDot: |
||||
Enabled: true |
||||
- rubocop-rspec_rails |
||||
|
||||
@ -0,0 +1,6 @@
|
||||
--- |
||||
require: |
||||
- ../lib/linter/rubocop_middle_dot |
||||
|
||||
Style/MiddleDot: |
||||
Enabled: true |
||||
@ -0,0 +1,12 @@
|
||||
I18n/RailsI18n: |
||||
Enabled: true |
||||
Exclude: |
||||
- 'config/**/*' |
||||
- 'db/**/*' |
||||
- 'lib/**/*' |
||||
- 'spec/**/*' |
||||
I18n/GetText: |
||||
Enabled: false |
||||
|
||||
I18n/RailsI18n/DecorateStringFormattingUsingInterpolation: |
||||
Enabled: false |
||||
@ -0,0 +1,6 @@
|
||||
--- |
||||
Layout/FirstHashElementIndentation: |
||||
EnforcedStyle: consistent |
||||
|
||||
Layout/LineLength: |
||||
Max: 300 # Default of 120 causes a duplicate entry in generated todo file |
||||
@ -0,0 +1,30 @@
|
||||
--- |
||||
Metrics/AbcSize: |
||||
Enabled: false |
||||
|
||||
Metrics/BlockLength: |
||||
Enabled: false |
||||
|
||||
Metrics/BlockNesting: |
||||
Enabled: false |
||||
|
||||
Metrics/ClassLength: |
||||
Enabled: false |
||||
|
||||
Metrics/CollectionLiteralLength: |
||||
Enabled: false |
||||
|
||||
Metrics/CyclomaticComplexity: |
||||
Enabled: false |
||||
|
||||
Metrics/MethodLength: |
||||
Enabled: false |
||||
|
||||
Metrics/ModuleLength: |
||||
Enabled: false |
||||
|
||||
Metrics/ParameterLists: |
||||
Enabled: false |
||||
|
||||
Metrics/PerceivedComplexity: |
||||
Enabled: false |
||||
@ -0,0 +1,6 @@
|
||||
--- |
||||
Naming/BlockForwarding: |
||||
EnforcedStyle: explicit |
||||
|
||||
Naming/PredicateMethod: |
||||
Enabled: false |
||||
@ -0,0 +1,26 @@
|
||||
--- |
||||
Rails/BulkChangeTable: |
||||
Enabled: false # Conflicts with strong_migrations features |
||||
|
||||
Rails/Delegate: |
||||
Enabled: false |
||||
|
||||
Rails/FilePath: |
||||
EnforcedStyle: arguments |
||||
|
||||
Rails/HttpStatus: |
||||
EnforcedStyle: numeric |
||||
|
||||
Rails/NegateInclude: |
||||
Enabled: false |
||||
|
||||
Rails/RakeEnvironment: |
||||
Exclude: # Tasks are doing local work which do not need full env loaded |
||||
- lib/tasks/auto_annotate_models.rake |
||||
- lib/tasks/emojis.rake |
||||
- lib/tasks/mastodon.rake |
||||
- lib/tasks/repo.rake |
||||
- lib/tasks/statistics.rake |
||||
|
||||
Rails/SkipsModelValidations: |
||||
Enabled: false |
||||
@ -0,0 +1,28 @@
|
||||
--- |
||||
RSpec/ExampleLength: |
||||
CountAsOne: ['array', 'heredoc', 'method_call'] |
||||
Max: 20 # Override default of 5 |
||||
|
||||
RSpec/MultipleExpectations: |
||||
Max: 10 # Overrides default of 1 |
||||
|
||||
RSpec/MultipleMemoizedHelpers: |
||||
Max: 20 # Overrides default of 5 |
||||
|
||||
RSpec/NamedSubject: |
||||
EnforcedStyle: named_only |
||||
|
||||
RSpec/NestedGroups: |
||||
Max: 10 # Overrides default of 3 |
||||
|
||||
RSpec/NotToNot: |
||||
EnforcedStyle: to_not |
||||
|
||||
RSpec/SpecFilePathFormat: |
||||
CustomTransform: |
||||
ActivityPub: activitypub |
||||
DeepL: deepl |
||||
FetchOEmbedService: fetch_oembed_service |
||||
OAuth: oauth |
||||
OEmbedController: oembed_controller |
||||
OStatus: ostatus |
||||
@ -0,0 +1,3 @@
|
||||
--- |
||||
RSpecRails/HttpStatus: |
||||
EnforcedStyle: numeric |
||||
@ -0,0 +1,24 @@
|
||||
Lint/Debugger: # Remove any `binding.pry` |
||||
Enabled: true |
||||
Exclude: [] |
||||
|
||||
RSpec/Focus: # Require full spec run on CI |
||||
Enabled: true |
||||
Exclude: [] |
||||
|
||||
Rails/Output: # Remove any `puts` debugging |
||||
inherit_mode: |
||||
merge: |
||||
- Include |
||||
Enabled: true |
||||
Exclude: [] |
||||
Include: |
||||
- spec/**/*.rb |
||||
|
||||
Rails/FindEach: # Using `each` could impact performance, use `find_each` |
||||
Enabled: true |
||||
Exclude: [] |
||||
|
||||
Rails/UniqBeforePluck: # Require `uniq.pluck` and not `pluck.uniq` |
||||
Enabled: true |
||||
Exclude: [] |
||||
@ -0,0 +1,63 @@
|
||||
--- |
||||
Style/ArrayIntersect: |
||||
Enabled: false |
||||
|
||||
Style/ClassAndModuleChildren: |
||||
Enabled: false |
||||
|
||||
Style/Documentation: |
||||
Enabled: false |
||||
|
||||
Style/FormatStringToken: |
||||
AllowedMethods: |
||||
- redirect_with_vary # Route redirects are not token-formatted |
||||
inherit_mode: |
||||
merge: |
||||
- AllowedMethods |
||||
|
||||
Style/HashAsLastArrayItem: |
||||
Enabled: false |
||||
|
||||
Style/HashSyntax: |
||||
EnforcedShorthandSyntax: either |
||||
EnforcedStyle: ruby19_no_mixed_keys |
||||
|
||||
Style/IfUnlessModifier: |
||||
Exclude: |
||||
- '**/*.haml' |
||||
|
||||
Style/KeywordArgumentsMerging: |
||||
Enabled: false |
||||
|
||||
Style/NumericLiterals: |
||||
AllowedPatterns: |
||||
- \d{4}_\d{2}_\d{2}_\d{6} |
||||
|
||||
Style/PercentLiteralDelimiters: |
||||
PreferredDelimiters: |
||||
'%i': () |
||||
'%w': () |
||||
|
||||
Style/RedundantBegin: |
||||
Enabled: false |
||||
|
||||
Style/RedundantFetchBlock: |
||||
Enabled: false |
||||
|
||||
Style/RescueStandardError: |
||||
EnforcedStyle: implicit |
||||
|
||||
Style/SafeNavigationChainLength: |
||||
Enabled: false |
||||
|
||||
Style/SymbolArray: |
||||
Enabled: false |
||||
|
||||
Style/TrailingCommaInArrayLiteral: |
||||
EnforcedStyleForMultiline: comma |
||||
|
||||
Style/TrailingCommaInHashLiteral: |
||||
EnforcedStyleForMultiline: comma |
||||
|
||||
Style/WordArray: |
||||
MinSize: 3 # Override default of 2 |
||||
@ -1,864 +1,18 @@
|
||||
# This configuration was generated by |
||||
# `rubocop --auto-gen-config --auto-gen-only-exclude --no-exclude-limit --no-offense-counts --no-auto-gen-timestamp` |
||||
# using RuboCop version 1.56.3. |
||||
# `rubocop --auto-gen-config --auto-gen-only-exclude --no-offense-counts --no-auto-gen-timestamp` |
||||
# using RuboCop version 1.80.2. |
||||
# The point is for the user to remove these configuration records |
||||
# one by one as the offenses are removed from the code base. |
||||
# Note that changes in the inspected code, or installation of new |
||||
# versions of RuboCop, may require this file to be generated again. |
||||
|
||||
# This cop supports safe autocorrection (--autocorrect). |
||||
# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include. |
||||
# Include: **/*.gemfile, **/Gemfile, **/gems.rb |
||||
Bundler/OrderedGems: |
||||
Exclude: |
||||
- 'Gemfile' |
||||
|
||||
# This cop supports safe autocorrection (--autocorrect). |
||||
# Configuration parameters: EnforcedStyle, IndentationWidth. |
||||
# SupportedStyles: with_first_argument, with_fixed_indentation |
||||
Layout/ArgumentAlignment: |
||||
Exclude: |
||||
- 'config/initializers/cors.rb' |
||||
- 'config/initializers/session_store.rb' |
||||
|
||||
# This cop supports safe autocorrection (--autocorrect). |
||||
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. |
||||
# SupportedHashRocketStyles: key, separator, table |
||||
# SupportedColonStyles: key, separator, table |
||||
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit |
||||
Layout/HashAlignment: |
||||
Exclude: |
||||
- 'config/environments/production.rb' |
||||
- 'config/initializers/rack_attack.rb' |
||||
- 'config/routes.rb' |
||||
|
||||
# This cop supports safe autocorrection (--autocorrect). |
||||
# Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment. |
||||
Layout/LeadingCommentSpace: |
||||
Exclude: |
||||
- 'config/application.rb' |
||||
- 'config/initializers/3_omniauth.rb' |
||||
|
||||
# This cop supports safe autocorrection (--autocorrect). |
||||
# Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. |
||||
# URISchemes: http, https |
||||
Layout/LineLength: |
||||
Exclude: |
||||
- 'app/models/account.rb' |
||||
|
||||
# This cop supports safe autocorrection (--autocorrect). |
||||
# Configuration parameters: EnforcedStyle. |
||||
# SupportedStyles: require_no_space, require_space |
||||
Layout/SpaceInLambdaLiteral: |
||||
Exclude: |
||||
- 'config/environments/production.rb' |
||||
- 'config/initializers/content_security_policy.rb' |
||||
|
||||
# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches. |
||||
Lint/DuplicateBranch: |
||||
Exclude: |
||||
- 'app/lib/account_statuses_filter.rb' |
||||
|
||||
# Configuration parameters: AllowComments, AllowEmptyLambdas. |
||||
Lint/EmptyBlock: |
||||
Exclude: |
||||
- 'spec/controllers/api/v2/search_controller_spec.rb' |
||||
- 'spec/fabricators/access_token_fabricator.rb' |
||||
- 'spec/fabricators/conversation_fabricator.rb' |
||||
- 'spec/fabricators/system_key_fabricator.rb' |
||||
- 'spec/lib/activitypub/adapter_spec.rb' |
||||
- 'spec/models/user_role_spec.rb' |
||||
|
||||
Lint/NonLocalExitFromIterator: |
||||
Exclude: |
||||
- 'app/helpers/jsonld_helper.rb' |
||||
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all). |
||||
Lint/OrAssignmentToConstant: |
||||
Exclude: |
||||
- 'lib/sanitize_ext/sanitize_config.rb' |
||||
|
||||
# This cop supports safe autocorrection (--autocorrect). |
||||
# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. |
||||
Lint/UnusedBlockArgument: |
||||
Exclude: |
||||
- 'config/initializers/content_security_policy.rb' |
||||
- 'config/initializers/doorkeeper.rb' |
||||
- 'config/initializers/paperclip.rb' |
||||
- 'config/initializers/simple_form.rb' |
||||
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all). |
||||
Lint/UselessAssignment: |
||||
Exclude: |
||||
- 'app/services/activitypub/process_status_update_service.rb' |
||||
- 'config/initializers/3_omniauth.rb' |
||||
- 'db/migrate/20190511134027_add_silenced_at_suspended_at_to_accounts.rb' |
||||
- 'db/post_migrate/20190511152737_remove_suspended_silenced_account_fields.rb' |
||||
- 'spec/controllers/api/v1/favourites_controller_spec.rb' |
||||
- 'spec/controllers/concerns/account_controller_concern_spec.rb' |
||||
- 'spec/helpers/jsonld_helper_spec.rb' |
||||
- 'spec/models/account_spec.rb' |
||||
- 'spec/models/domain_block_spec.rb' |
||||
- 'spec/models/status_spec.rb' |
||||
- 'spec/models/user_spec.rb' |
||||
- 'spec/models/webauthn_credentials_spec.rb' |
||||
- 'spec/services/account_search_service_spec.rb' |
||||
- 'spec/services/post_status_service_spec.rb' |
||||
- 'spec/services/precompute_feed_service_spec.rb' |
||||
- 'spec/services/resolve_url_service_spec.rb' |
||||
- 'spec/views/statuses/show.html.haml_spec.rb' |
||||
|
||||
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. |
||||
Metrics/AbcSize: |
||||
Max: 149 |
||||
|
||||
# Configuration parameters: CountBlocks, Max. |
||||
Metrics/BlockNesting: |
||||
Exclude: |
||||
- 'lib/tasks/mastodon.rake' |
||||
|
||||
# Configuration parameters: AllowedMethods, AllowedPatterns. |
||||
Metrics/CyclomaticComplexity: |
||||
Max: 25 |
||||
|
||||
# Configuration parameters: AllowedMethods, AllowedPatterns. |
||||
Metrics/PerceivedComplexity: |
||||
Max: 27 |
||||
|
||||
# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns. |
||||
# SupportedStyles: snake_case, normalcase, non_integer |
||||
# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64 |
||||
Naming/VariableNumber: |
||||
Exclude: |
||||
- 'db/migrate/20180106000232_add_index_on_statuses_for_api_v1_accounts_account_id_statuses.rb' |
||||
- 'db/migrate/20180514140000_revert_index_change_on_statuses_for_api_v1_accounts_account_id_statuses.rb' |
||||
- 'db/migrate/20190820003045_update_statuses_index.rb' |
||||
- 'db/migrate/20190823221802_add_local_index_to_statuses.rb' |
||||
- 'db/migrate/20200119112504_add_public_index_to_statuses.rb' |
||||
- 'spec/models/account_spec.rb' |
||||
- 'spec/models/domain_block_spec.rb' |
||||
- 'spec/models/user_spec.rb' |
||||
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all). |
||||
# Configuration parameters: SafeMultiline. |
||||
Performance/DeletePrefix: |
||||
Exclude: |
||||
- 'app/models/featured_tag.rb' |
||||
|
||||
Performance/MapMethodChain: |
||||
Exclude: |
||||
- 'app/models/feed.rb' |
||||
- 'lib/mastodon/cli/maintenance.rb' |
||||
- 'spec/services/bulk_import_service_spec.rb' |
||||
- 'spec/services/import_service_spec.rb' |
||||
|
||||
RSpec/AnyInstance: |
||||
Exclude: |
||||
- 'spec/controllers/activitypub/inboxes_controller_spec.rb' |
||||
- 'spec/controllers/admin/accounts_controller_spec.rb' |
||||
- 'spec/controllers/admin/resets_controller_spec.rb' |
||||
- 'spec/controllers/admin/settings/branding_controller_spec.rb' |
||||
- 'spec/controllers/api/v1/media_controller_spec.rb' |
||||
- 'spec/controllers/auth/sessions_controller_spec.rb' |
||||
- 'spec/controllers/settings/two_factor_authentication/confirmations_controller_spec.rb' |
||||
- 'spec/controllers/settings/two_factor_authentication/recovery_codes_controller_spec.rb' |
||||
- 'spec/lib/request_spec.rb' |
||||
- 'spec/lib/status_filter_spec.rb' |
||||
- 'spec/models/account_spec.rb' |
||||
- 'spec/models/setting_spec.rb' |
||||
- 'spec/services/activitypub/process_collection_service_spec.rb' |
||||
- 'spec/validators/follow_limit_validator_spec.rb' |
||||
- 'spec/workers/activitypub/delivery_worker_spec.rb' |
||||
- 'spec/workers/web/push_notification_worker_spec.rb' |
||||
|
||||
# Configuration parameters: CountAsOne. |
||||
RSpec/ExampleLength: |
||||
Max: 22 |
||||
|
||||
# This cop supports safe autocorrection (--autocorrect). |
||||
# Configuration parameters: EnforcedStyle. |
||||
# SupportedStyles: implicit, each, example |
||||
RSpec/HookArgument: |
||||
Exclude: |
||||
- 'spec/controllers/api/v1/streaming_controller_spec.rb' |
||||
- 'spec/controllers/well_known/webfinger_controller_spec.rb' |
||||
- 'spec/helpers/instance_helper_spec.rb' |
||||
- 'spec/models/user_spec.rb' |
||||
- 'spec/rails_helper.rb' |
||||
- 'spec/serializers/activitypub/note_serializer_spec.rb' |
||||
- 'spec/serializers/activitypub/update_poll_serializer_spec.rb' |
||||
- 'spec/services/import_service_spec.rb' |
||||
|
||||
# Configuration parameters: AssignmentOnly. |
||||
RSpec/InstanceVariable: |
||||
Exclude: |
||||
- 'spec/controllers/api/v1/streaming_controller_spec.rb' |
||||
- 'spec/controllers/auth/confirmations_controller_spec.rb' |
||||
- 'spec/controllers/auth/passwords_controller_spec.rb' |
||||
- 'spec/controllers/auth/sessions_controller_spec.rb' |
||||
- 'spec/controllers/concerns/export_controller_concern_spec.rb' |
||||
- 'spec/controllers/home_controller_spec.rb' |
||||
- 'spec/controllers/settings/two_factor_authentication/webauthn_credentials_controller_spec.rb' |
||||
- 'spec/controllers/statuses_cleanup_controller_spec.rb' |
||||
- 'spec/models/concerns/account_finder_concern_spec.rb' |
||||
- 'spec/models/concerns/account_interactions_spec.rb' |
||||
- 'spec/models/public_feed_spec.rb' |
||||
- 'spec/serializers/activitypub/note_serializer_spec.rb' |
||||
- 'spec/serializers/activitypub/update_poll_serializer_spec.rb' |
||||
- 'spec/services/remove_status_service_spec.rb' |
||||
- 'spec/services/search_service_spec.rb' |
||||
- 'spec/services/unblock_domain_service_spec.rb' |
||||
|
||||
RSpec/LetSetup: |
||||
Exclude: |
||||
- 'spec/controllers/admin/accounts_controller_spec.rb' |
||||
- 'spec/controllers/admin/action_logs_controller_spec.rb' |
||||
- 'spec/controllers/admin/instances_controller_spec.rb' |
||||
- 'spec/controllers/admin/reports/actions_controller_spec.rb' |
||||
- 'spec/controllers/admin/statuses_controller_spec.rb' |
||||
- 'spec/controllers/api/v1/accounts/statuses_controller_spec.rb' |
||||
- 'spec/controllers/api/v1/admin/accounts_controller_spec.rb' |
||||
- 'spec/controllers/api/v1/filters_controller_spec.rb' |
||||
- 'spec/controllers/api/v1/followed_tags_controller_spec.rb' |
||||
- 'spec/controllers/api/v2/admin/accounts_controller_spec.rb' |
||||
- 'spec/controllers/api/v2/filters/keywords_controller_spec.rb' |
||||
- 'spec/controllers/api/v2/filters/statuses_controller_spec.rb' |
||||
- 'spec/controllers/auth/confirmations_controller_spec.rb' |
||||
- 'spec/controllers/auth/passwords_controller_spec.rb' |
||||
- 'spec/controllers/auth/sessions_controller_spec.rb' |
||||
- 'spec/controllers/follower_accounts_controller_spec.rb' |
||||
- 'spec/controllers/following_accounts_controller_spec.rb' |
||||
- 'spec/controllers/oauth/authorized_applications_controller_spec.rb' |
||||
- 'spec/controllers/oauth/tokens_controller_spec.rb' |
||||
- 'spec/controllers/settings/imports_controller_spec.rb' |
||||
- 'spec/lib/activitypub/activity/delete_spec.rb' |
||||
- 'spec/lib/vacuum/applications_vacuum_spec.rb' |
||||
- 'spec/lib/vacuum/preview_cards_vacuum_spec.rb' |
||||
- 'spec/models/account_spec.rb' |
||||
- 'spec/models/account_statuses_cleanup_policy_spec.rb' |
||||
- 'spec/models/canonical_email_block_spec.rb' |
||||
- 'spec/models/status_spec.rb' |
||||
- 'spec/models/user_spec.rb' |
||||
- 'spec/services/account_statuses_cleanup_service_spec.rb' |
||||
- 'spec/services/activitypub/fetch_featured_collection_service_spec.rb' |
||||
- 'spec/services/activitypub/fetch_remote_status_service_spec.rb' |
||||
- 'spec/services/activitypub/process_account_service_spec.rb' |
||||
- 'spec/services/activitypub/process_collection_service_spec.rb' |
||||
- 'spec/services/batched_remove_status_service_spec.rb' |
||||
- 'spec/services/block_domain_service_spec.rb' |
||||
- 'spec/services/bulk_import_service_spec.rb' |
||||
- 'spec/services/delete_account_service_spec.rb' |
||||
- 'spec/services/import_service_spec.rb' |
||||
- 'spec/services/notify_service_spec.rb' |
||||
- 'spec/services/remove_status_service_spec.rb' |
||||
- 'spec/services/report_service_spec.rb' |
||||
- 'spec/services/resolve_account_service_spec.rb' |
||||
- 'spec/services/suspend_account_service_spec.rb' |
||||
- 'spec/services/unallow_domain_service_spec.rb' |
||||
- 'spec/services/unsuspend_account_service_spec.rb' |
||||
- 'spec/workers/scheduler/user_cleanup_scheduler_spec.rb' |
||||
|
||||
RSpec/MessageChain: |
||||
Exclude: |
||||
- 'spec/controllers/api/v1/media_controller_spec.rb' |
||||
- 'spec/models/concerns/remotable_spec.rb' |
||||
- 'spec/models/session_activation_spec.rb' |
||||
- 'spec/models/setting_spec.rb' |
||||
|
||||
# Configuration parameters: EnforcedStyle. |
||||
# SupportedStyles: have_received, receive |
||||
RSpec/MessageSpies: |
||||
Exclude: |
||||
- 'spec/controllers/admin/accounts_controller_spec.rb' |
||||
- 'spec/helpers/admin/account_moderation_notes_helper_spec.rb' |
||||
- 'spec/lib/webfinger_resource_spec.rb' |
||||
- 'spec/models/admin/account_action_spec.rb' |
||||
- 'spec/models/concerns/remotable_spec.rb' |
||||
- 'spec/models/follow_request_spec.rb' |
||||
- 'spec/models/identity_spec.rb' |
||||
- 'spec/models/session_activation_spec.rb' |
||||
- 'spec/models/setting_spec.rb' |
||||
- 'spec/services/activitypub/fetch_replies_service_spec.rb' |
||||
- 'spec/services/activitypub/process_collection_service_spec.rb' |
||||
- 'spec/spec_helper.rb' |
||||
- 'spec/validators/status_length_validator_spec.rb' |
||||
|
||||
RSpec/MultipleExpectations: |
||||
Max: 8 |
||||
|
||||
# Configuration parameters: AllowSubject. |
||||
RSpec/MultipleMemoizedHelpers: |
||||
Max: 21 |
||||
|
||||
# Configuration parameters: AllowedGroups. |
||||
RSpec/NestedGroups: |
||||
Max: 6 |
||||
|
||||
RSpec/RepeatedDescription: |
||||
Exclude: |
||||
- 'spec/controllers/activitypub/outboxes_controller_spec.rb' |
||||
|
||||
RSpec/RepeatedExample: |
||||
Exclude: |
||||
- 'spec/controllers/activitypub/outboxes_controller_spec.rb' |
||||
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all). |
||||
Rails/ApplicationController: |
||||
Exclude: |
||||
- 'app/controllers/health_controller.rb' |
||||
|
||||
# Configuration parameters: Include. |
||||
# Include: db/**/*.rb |
||||
Rails/CreateTableWithTimestamps: |
||||
Exclude: |
||||
- 'db/migrate/20170508230434_create_conversation_mutes.rb' |
||||
- 'db/migrate/20170823162448_create_status_pins.rb' |
||||
- 'db/migrate/20171116161857_create_list_accounts.rb' |
||||
- 'db/migrate/20180929222014_create_account_conversations.rb' |
||||
- 'db/migrate/20181007025445_create_pghero_space_stats.rb' |
||||
- 'db/migrate/20190103124649_create_scheduled_statuses.rb' |
||||
- 'db/migrate/20220824233535_create_status_trends.rb' |
||||
- 'db/migrate/20221006061337_create_preview_card_trends.rb' |
||||
|
||||
# This cop supports safe autocorrection (--autocorrect). |
||||
# Configuration parameters: Severity. |
||||
Rails/DuplicateAssociation: |
||||
Exclude: |
||||
- 'app/serializers/activitypub/collection_serializer.rb' |
||||
- 'app/serializers/activitypub/note_serializer.rb' |
||||
|
||||
# Configuration parameters: Include. |
||||
# Include: app/**/*.rb, config/**/*.rb, lib/**/*.rb |
||||
Rails/Exit: |
||||
Exclude: |
||||
- 'config/initializers/sidekiq.rb' |
||||
|
||||
# Configuration parameters: Include. |
||||
# Include: app/models/**/*.rb |
||||
Rails/HasAndBelongsToMany: |
||||
Exclude: |
||||
- 'app/models/concerns/account_associations.rb' |
||||
- 'app/models/preview_card.rb' |
||||
- 'app/models/status.rb' |
||||
- 'app/models/tag.rb' |
||||
|
||||
# Configuration parameters: Include. |
||||
# Include: app/models/**/*.rb |
||||
Rails/HasManyOrHasOneDependent: |
||||
Exclude: |
||||
- 'app/models/concerns/account_counters.rb' |
||||
- 'app/models/conversation.rb' |
||||
- 'app/models/custom_emoji.rb' |
||||
- 'app/models/custom_emoji_category.rb' |
||||
- 'app/models/domain_block.rb' |
||||
- 'app/models/invite.rb' |
||||
- 'app/models/status.rb' |
||||
- 'app/models/user.rb' |
||||
- 'app/models/web/push_subscription.rb' |
||||
|
||||
Rails/I18nLocaleTexts: |
||||
Exclude: |
||||
- 'lib/tasks/mastodon.rake' |
||||
- 'spec/helpers/flashes_helper_spec.rb' |
||||
|
||||
# Configuration parameters: Include. |
||||
# Include: app/controllers/**/*.rb, app/mailers/**/*.rb |
||||
Rails/LexicallyScopedActionFilter: |
||||
Exclude: |
||||
- 'app/controllers/auth/passwords_controller.rb' |
||||
- 'app/controllers/auth/registrations_controller.rb' |
||||
- 'app/controllers/auth/sessions_controller.rb' |
||||
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all). |
||||
Rails/NegateInclude: |
||||
Exclude: |
||||
- 'app/controllers/concerns/signature_verification.rb' |
||||
- 'app/helpers/jsonld_helper.rb' |
||||
- 'app/lib/activitypub/activity/create.rb' |
||||
- 'app/lib/activitypub/activity/move.rb' |
||||
- 'app/lib/feed_manager.rb' |
||||
- 'app/lib/link_details_extractor.rb' |
||||
- 'app/models/concerns/attachmentable.rb' |
||||
- 'app/models/concerns/remotable.rb' |
||||
- 'app/models/custom_filter.rb' |
||||
- 'app/services/activitypub/process_status_update_service.rb' |
||||
- 'app/services/fetch_link_card_service.rb' |
||||
- 'app/workers/web/push_notification_worker.rb' |
||||
- 'lib/paperclip/color_extractor.rb' |
||||
|
||||
Rails/OutputSafety: |
||||
Exclude: |
||||
- 'config/initializers/simple_form.rb' |
||||
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all). |
||||
# Configuration parameters: Include. |
||||
# Include: **/Rakefile, **/*.rake |
||||
Rails/RakeEnvironment: |
||||
Exclude: |
||||
- 'lib/tasks/auto_annotate_models.rake' |
||||
- 'lib/tasks/db.rake' |
||||
- 'lib/tasks/emojis.rake' |
||||
- 'lib/tasks/mastodon.rake' |
||||
- 'lib/tasks/repo.rake' |
||||
- 'lib/tasks/statistics.rake' |
||||
|
||||
# Configuration parameters: Include. |
||||
# Include: db/**/*.rb |
||||
Rails/ReversibleMigration: |
||||
Exclude: |
||||
- 'db/migrate/20160223164502_make_uris_nullable_in_statuses.rb' |
||||
- 'db/migrate/20161122163057_remove_unneeded_indexes.rb' |
||||
- 'db/migrate/20170205175257_remove_devices.rb' |
||||
- 'db/migrate/20170322143850_change_primary_key_to_bigint_on_statuses.rb' |
||||
- 'db/migrate/20170520145338_change_language_filter_to_opt_out.rb' |
||||
- 'db/migrate/20170609145826_remove_default_language_from_statuses.rb' |
||||
- 'db/migrate/20170711225116_fix_null_booleans.rb' |
||||
- 'db/migrate/20171129172043_add_index_on_stream_entries.rb' |
||||
- 'db/migrate/20171212195226_remove_duplicate_indexes_in_lists.rb' |
||||
- 'db/migrate/20171226094803_more_faster_index_on_notifications.rb' |
||||
- 'db/migrate/20180106000232_add_index_on_statuses_for_api_v1_accounts_account_id_statuses.rb' |
||||
- 'db/migrate/20180617162849_remove_unused_indexes.rb' |
||||
- 'db/migrate/20190726034905_add_is_exclusive_to_lists.rb' |
||||
- 'db/migrate/20220827195229_change_canonical_email_blocks_nullable.rb' |
||||
- 'db/migrate/20221202035831_add_keep_local_to_account_statuses_cleanup_policies.rb' |
||||
|
||||
# Configuration parameters: ForbiddenMethods, AllowedMethods. |
||||
# ForbiddenMethods: decrement!, decrement_counter, increment!, increment_counter, insert, insert!, insert_all, insert_all!, toggle!, touch, touch_all, update_all, update_attribute, update_column, update_columns, update_counters, upsert, upsert_all |
||||
Rails/SkipsModelValidations: |
||||
Exclude: |
||||
- 'app/controllers/admin/invites_controller.rb' |
||||
- 'app/controllers/concerns/session_tracking_concern.rb' |
||||
- 'app/models/concerns/account_merging.rb' |
||||
- 'app/models/concerns/expireable.rb' |
||||
- 'app/models/status.rb' |
||||
- 'app/models/trends/links.rb' |
||||
- 'app/models/trends/preview_card_batch.rb' |
||||
- 'app/models/trends/preview_card_provider_batch.rb' |
||||
- 'app/models/trends/status_batch.rb' |
||||
- 'app/models/trends/statuses.rb' |
||||
- 'app/models/trends/tag_batch.rb' |
||||
- 'app/models/trends/tags.rb' |
||||
- 'app/models/user.rb' |
||||
- 'app/services/activitypub/process_status_update_service.rb' |
||||
- 'app/services/approve_appeal_service.rb' |
||||
- 'app/services/block_domain_service.rb' |
||||
- 'app/services/delete_account_service.rb' |
||||
- 'app/services/process_mentions_service.rb' |
||||
- 'app/services/unallow_domain_service.rb' |
||||
- 'app/services/unblock_domain_service.rb' |
||||
- 'app/services/update_status_service.rb' |
||||
- 'app/workers/activitypub/post_upgrade_worker.rb' |
||||
- 'app/workers/move_worker.rb' |
||||
- 'app/workers/scheduler/ip_cleanup_scheduler.rb' |
||||
- 'app/workers/scheduler/scheduled_statuses_scheduler.rb' |
||||
- 'db/migrate/20161203164520_add_from_account_id_to_notifications.rb' |
||||
- 'db/migrate/20170105224407_add_shortcode_to_media_attachments.rb' |
||||
- 'db/migrate/20170209184350_add_reply_to_statuses.rb' |
||||
- 'db/migrate/20170304202101_add_type_to_media_attachments.rb' |
||||
- 'db/migrate/20180528141303_fix_accounts_unique_index.rb' |
||||
- 'db/migrate/20180609104432_migrate_web_push_subscriptions2.rb' |
||||
- 'db/migrate/20181207011115_downcase_custom_emoji_domains.rb' |
||||
- 'db/migrate/20190511134027_add_silenced_at_suspended_at_to_accounts.rb' |
||||
- 'db/migrate/20191007013357_update_pt_locales.rb' |
||||
- 'db/migrate/20220316233212_update_kurdish_locales.rb' |
||||
- 'db/post_migrate/20190511152737_remove_suspended_silenced_account_fields.rb' |
||||
- 'db/post_migrate/20200917193528_migrate_notifications_type.rb' |
||||
- 'db/post_migrate/20201017234926_fill_account_suspension_origin.rb' |
||||
- 'db/post_migrate/20220617202502_migrate_roles.rb' |
||||
- 'db/post_migrate/20221101190723_backfill_admin_action_logs.rb' |
||||
- 'db/post_migrate/20221206114142_backfill_admin_action_logs_again.rb' |
||||
- 'lib/mastodon/cli/accounts.rb' |
||||
- 'lib/mastodon/cli/main.rb' |
||||
- 'lib/mastodon/cli/maintenance.rb' |
||||
- 'spec/controllers/api/v1/admin/accounts_controller_spec.rb' |
||||
- 'spec/lib/activitypub/activity/follow_spec.rb' |
||||
- 'spec/services/follow_service_spec.rb' |
||||
- 'spec/services/update_account_service_spec.rb' |
||||
|
||||
# Configuration parameters: Include. |
||||
# Include: db/**/*.rb |
||||
Rails/ThreeStateBooleanColumn: |
||||
Exclude: |
||||
- 'db/migrate/20160325130944_add_admin_to_users.rb' |
||||
- 'db/migrate/20161123093447_add_sensitive_to_statuses.rb' |
||||
- 'db/migrate/20170123203248_add_reject_media_to_domain_blocks.rb' |
||||
- 'db/migrate/20170127165745_add_devise_two_factor_to_users.rb' |
||||
- 'db/migrate/20170209184350_add_reply_to_statuses.rb' |
||||
- 'db/migrate/20170330163835_create_imports.rb' |
||||
- 'db/migrate/20170905165803_add_local_to_statuses.rb' |
||||
- 'db/migrate/20171210213213_add_local_only_flag_to_statuses.rb' |
||||
- 'db/migrate/20181203021853_add_discoverable_to_accounts.rb' |
||||
- 'db/migrate/20190509164208_add_by_moderator_to_tombstone.rb' |
||||
- 'db/migrate/20190726034905_add_is_exclusive_to_lists.rb' |
||||
- 'db/migrate/20190805123746_add_capabilities_to_tags.rb' |
||||
- 'db/migrate/20191212163405_add_hide_collections_to_accounts.rb' |
||||
- 'db/migrate/20200309150742_add_forwarded_to_reports.rb' |
||||
- 'db/migrate/20210609202149_create_login_activities.rb' |
||||
- 'db/migrate/20210621221010_add_skip_sign_in_token_to_users.rb' |
||||
- 'db/migrate/20211031031021_create_preview_card_providers.rb' |
||||
- 'db/migrate/20211115032527_add_trendable_to_preview_cards.rb' |
||||
- 'db/migrate/20220202200743_add_trendable_to_accounts.rb' |
||||
- 'db/migrate/20220202200926_add_trendable_to_statuses.rb' |
||||
- 'db/migrate/20220303000827_add_ordered_media_attachment_ids_to_status_edits.rb' |
||||
- 'db/migrate/20221202035831_add_keep_local_to_account_statuses_cleanup_policies.rb' |
||||
|
||||
# Configuration parameters: Include. |
||||
# Include: app/models/**/*.rb |
||||
Rails/UniqueValidationWithoutIndex: |
||||
Exclude: |
||||
- 'app/models/account_alias.rb' |
||||
- 'app/models/custom_filter_status.rb' |
||||
- 'app/models/identity.rb' |
||||
- 'app/models/webauthn_credential.rb' |
||||
|
||||
# Configuration parameters: Include. |
||||
# Include: app/models/**/*.rb |
||||
Rails/UnusedIgnoredColumns: |
||||
Exclude: |
||||
- 'app/models/account.rb' |
||||
- 'app/models/account_stat.rb' |
||||
- 'app/models/admin/action_log.rb' |
||||
- 'app/models/custom_filter.rb' |
||||
- 'app/models/email_domain_block.rb' |
||||
- 'app/models/report.rb' |
||||
- 'app/models/status_edit.rb' |
||||
- 'app/models/user.rb' |
||||
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all). |
||||
# Configuration parameters: EnforcedStyle. |
||||
# SupportedStyles: exists, where |
||||
Rails/WhereExists: |
||||
Exclude: |
||||
- 'app/controllers/activitypub/inboxes_controller.rb' |
||||
- 'app/controllers/admin/email_domain_blocks_controller.rb' |
||||
- 'app/controllers/auth/registrations_controller.rb' |
||||
- 'app/lib/activitypub/activity/create.rb' |
||||
- 'app/lib/delivery_failure_tracker.rb' |
||||
- 'app/lib/feed_manager.rb' |
||||
- 'app/lib/status_cache_hydrator.rb' |
||||
- 'app/lib/suspicious_sign_in_detector.rb' |
||||
- 'app/models/concerns/account_interactions.rb' |
||||
- 'app/models/featured_tag.rb' |
||||
- 'app/models/poll.rb' |
||||
- 'app/models/session_activation.rb' |
||||
- 'app/models/status.rb' |
||||
- 'app/models/user.rb' |
||||
- 'app/policies/status_policy.rb' |
||||
- 'app/serializers/rest/announcement_serializer.rb' |
||||
- 'app/serializers/rest/tag_serializer.rb' |
||||
- 'app/services/activitypub/fetch_remote_status_service.rb' |
||||
- 'app/services/app_sign_up_service.rb' |
||||
- 'app/services/vote_service.rb' |
||||
- 'app/validators/reaction_validator.rb' |
||||
- 'app/validators/vote_validator.rb' |
||||
- 'app/workers/move_worker.rb' |
||||
- 'db/migrate/20190529143559_preserve_old_layout_for_existing_users.rb' |
||||
- 'lib/tasks/tests.rake' |
||||
- 'spec/models/account_spec.rb' |
||||
- 'spec/services/activitypub/process_collection_service_spec.rb' |
||||
- 'spec/services/purge_domain_service_spec.rb' |
||||
- 'spec/services/unallow_domain_service_spec.rb' |
||||
|
||||
# This cop supports safe autocorrection (--autocorrect). |
||||
# Configuration parameters: AllowOnConstant, AllowOnSelfClass. |
||||
Style/CaseEquality: |
||||
Exclude: |
||||
- 'config/initializers/trusted_proxies.rb' |
||||
|
||||
# This cop supports safe autocorrection (--autocorrect). |
||||
# Configuration parameters: AllowedMethods, AllowedPatterns. |
||||
# AllowedMethods: ==, equal?, eql? |
||||
Style/ClassEqualityComparison: |
||||
Exclude: |
||||
- 'app/helpers/jsonld_helper.rb' |
||||
- 'app/serializers/activitypub/outbox_serializer.rb' |
||||
|
||||
Style/ClassVars: |
||||
Exclude: |
||||
- 'config/initializers/devise.rb' |
||||
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all). |
||||
Style/CombinableLoops: |
||||
Exclude: |
||||
- 'app/models/form/custom_emoji_batch.rb' |
||||
- 'app/models/form/ip_block_batch.rb' |
||||
|
||||
# This cop supports safe autocorrection (--autocorrect). |
||||
# Configuration parameters: AllowedVars. |
||||
# Configuration parameters: AllowedVars, DefaultToNil. |
||||
Style/FetchEnvVar: |
||||
Exclude: |
||||
- 'app/lib/redis_configuration.rb' |
||||
- 'app/lib/translation_service.rb' |
||||
- 'config/environments/development.rb' |
||||
- 'config/environments/production.rb' |
||||
- 'config/initializers/2_limited_federation_mode.rb' |
||||
- 'config/initializers/3_omniauth.rb' |
||||
- 'config/initializers/blacklists.rb' |
||||
- 'config/initializers/cache_buster.rb' |
||||
- 'config/initializers/content_security_policy.rb' |
||||
- 'config/initializers/devise.rb' |
||||
- 'config/initializers/paperclip.rb' |
||||
- 'config/initializers/vapid.rb' |
||||
- 'lib/mastodon/premailer_webpack_strategy.rb' |
||||
- 'lib/mastodon/redis_config.rb' |
||||
- 'lib/tasks/repo.rake' |
||||
- 'spec/features/profile_spec.rb' |
||||
|
||||
# This cop supports safe autocorrection (--autocorrect). |
||||
# Configuration parameters: EnforcedStyle, MaxUnannotatedPlaceholdersAllowed, AllowedMethods, AllowedPatterns. |
||||
# SupportedStyles: annotated, template, unannotated |
||||
# AllowedMethods: redirect |
||||
Style/FormatStringToken: |
||||
Exclude: |
||||
- 'app/models/privacy_policy.rb' |
||||
- 'config/initializers/devise.rb' |
||||
- 'lib/paperclip/color_extractor.rb' |
||||
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all). |
||||
Style/GlobalStdStream: |
||||
Exclude: |
||||
- 'config/boot.rb' |
||||
- 'config/environments/development.rb' |
||||
- 'config/environments/production.rb' |
||||
|
||||
# This cop supports safe autocorrection (--autocorrect). |
||||
# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals. |
||||
Style/GuardClause: |
||||
Exclude: |
||||
- 'app/controllers/admin/confirmations_controller.rb' |
||||
- 'app/controllers/auth/confirmations_controller.rb' |
||||
- 'app/controllers/auth/passwords_controller.rb' |
||||
- 'app/controllers/settings/two_factor_authentication/webauthn_credentials_controller.rb' |
||||
- 'app/lib/activitypub/activity/block.rb' |
||||
- 'app/lib/request.rb' |
||||
- 'app/lib/request_pool.rb' |
||||
- 'app/lib/webfinger.rb' |
||||
- 'app/lib/webfinger_resource.rb' |
||||
- 'app/models/concerns/account_counters.rb' |
||||
- 'app/models/concerns/ldap_authenticable.rb' |
||||
- 'app/models/tag.rb' |
||||
- 'app/models/user.rb' |
||||
- 'app/services/fan_out_on_write_service.rb' |
||||
- 'app/services/post_status_service.rb' |
||||
- 'app/services/process_hashtags_service.rb' |
||||
- 'app/workers/move_worker.rb' |
||||
- 'app/workers/redownload_avatar_worker.rb' |
||||
- 'app/workers/redownload_header_worker.rb' |
||||
- 'app/workers/redownload_media_worker.rb' |
||||
- 'app/workers/remote_account_refresh_worker.rb' |
||||
- 'config/initializers/devise.rb' |
||||
- 'db/migrate/20170901141119_truncate_preview_cards.rb' |
||||
- 'db/post_migrate/20220704024901_migrate_settings_to_user_roles.rb' |
||||
- 'lib/devise/two_factor_ldap_authenticatable.rb' |
||||
- 'lib/devise/two_factor_pam_authenticatable.rb' |
||||
- 'lib/mastodon/cli/accounts.rb' |
||||
- 'lib/mastodon/cli/maintenance.rb' |
||||
- 'lib/mastodon/cli/media.rb' |
||||
- 'lib/paperclip/attachment_extensions.rb' |
||||
- 'lib/tasks/repo.rake' |
||||
|
||||
# This cop supports safe autocorrection (--autocorrect). |
||||
# Configuration parameters: EnforcedStyle. |
||||
# SupportedStyles: braces, no_braces |
||||
Style/HashAsLastArrayItem: |
||||
Exclude: |
||||
- 'app/controllers/admin/statuses_controller.rb' |
||||
- 'app/controllers/api/v1/statuses_controller.rb' |
||||
- 'app/models/concerns/account_counters.rb' |
||||
- 'app/models/concerns/status_threading_concern.rb' |
||||
- 'app/models/status.rb' |
||||
- 'app/services/batched_remove_status_service.rb' |
||||
- 'app/services/notify_service.rb' |
||||
- 'db/migrate/20181024224956_migrate_account_conversations.rb' |
||||
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all). |
||||
Style/HashTransformValues: |
||||
Exclude: |
||||
- 'app/serializers/rest/web_push_subscription_serializer.rb' |
||||
- 'app/services/import_service.rb' |
||||
|
||||
# This cop supports safe autocorrection (--autocorrect). |
||||
Style/IfUnlessModifier: |
||||
Exclude: |
||||
- 'config/environments/production.rb' |
||||
- 'config/initializers/devise.rb' |
||||
- 'config/initializers/ffmpeg.rb' |
||||
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all). |
||||
# Configuration parameters: InverseMethods, InverseBlocks. |
||||
Style/InverseMethods: |
||||
Exclude: |
||||
- 'app/models/custom_filter.rb' |
||||
- 'app/services/update_account_service.rb' |
||||
- 'spec/controllers/activitypub/replies_controller_spec.rb' |
||||
|
||||
# This cop supports safe autocorrection (--autocorrect). |
||||
# Configuration parameters: EnforcedStyle. |
||||
# SupportedStyles: line_count_dependent, lambda, literal |
||||
Style/Lambda: |
||||
Exclude: |
||||
- 'config/initializers/simple_form.rb' |
||||
- 'config/routes.rb' |
||||
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all). |
||||
Style/MapToHash: |
||||
Exclude: |
||||
- 'app/models/status.rb' |
||||
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all). |
||||
# Configuration parameters: EnforcedStyle. |
||||
# SupportedStyles: literals, strict |
||||
Style/MutableConstant: |
||||
Exclude: |
||||
- 'app/models/tag.rb' |
||||
- 'app/services/delete_account_service.rb' |
||||
- 'lib/mastodon/migration_warning.rb' |
||||
|
||||
# This cop supports safe autocorrection (--autocorrect). |
||||
Style/NilLambda: |
||||
Exclude: |
||||
- 'config/initializers/paperclip.rb' |
||||
|
||||
# Configuration parameters: AllowedMethods. |
||||
# AllowedMethods: respond_to_missing? |
||||
Style/OptionalBooleanParameter: |
||||
Exclude: |
||||
- 'app/helpers/admin/account_moderation_notes_helper.rb' |
||||
- 'app/helpers/jsonld_helper.rb' |
||||
- 'app/lib/admin/system_check/message.rb' |
||||
- 'app/lib/request.rb' |
||||
- 'app/lib/webfinger.rb' |
||||
- 'app/services/block_domain_service.rb' |
||||
- 'app/services/fetch_resource_service.rb' |
||||
- 'app/workers/domain_block_worker.rb' |
||||
- 'app/workers/unfollow_follow_worker.rb' |
||||
- 'lib/mastodon/redis_config.rb' |
||||
|
||||
# This cop supports safe autocorrection (--autocorrect). |
||||
# Configuration parameters: PreferredDelimiters. |
||||
Style/PercentLiteralDelimiters: |
||||
Exclude: |
||||
- 'config/deploy.rb' |
||||
- 'config/initializers/doorkeeper.rb' |
||||
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all). |
||||
# Configuration parameters: EnforcedStyle. |
||||
# SupportedStyles: short, verbose |
||||
Style/PreferredHashMethods: |
||||
Exclude: |
||||
- 'config/initializers/paperclip.rb' |
||||
|
||||
# This cop supports safe autocorrection (--autocorrect). |
||||
Style/RedundantConstantBase: |
||||
Exclude: |
||||
- 'config/environments/production.rb' |
||||
- 'config/initializers/sidekiq.rb' |
||||
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all). |
||||
# Configuration parameters: SafeForConstants. |
||||
Style/RedundantFetchBlock: |
||||
Exclude: |
||||
- 'config/initializers/1_hosts.rb' |
||||
- 'config/initializers/chewy.rb' |
||||
- 'config/initializers/devise.rb' |
||||
- 'config/initializers/paperclip.rb' |
||||
- 'config/puma.rb' |
||||
|
||||
# This cop supports safe autocorrection (--autocorrect). |
||||
# Configuration parameters: AllowMultipleReturnValues. |
||||
Style/RedundantReturn: |
||||
Exclude: |
||||
- 'app/controllers/api/v1/directories_controller.rb' |
||||
- 'app/controllers/auth/confirmations_controller.rb' |
||||
- 'app/lib/ostatus/tag_manager.rb' |
||||
- 'app/models/form/import.rb' |
||||
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all). |
||||
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength. |
||||
# AllowedMethods: present?, blank?, presence, try, try! |
||||
Style/SafeNavigation: |
||||
Exclude: |
||||
- 'app/models/concerns/account_finder_concern.rb' |
||||
|
||||
# This cop supports safe autocorrection (--autocorrect). |
||||
# Configuration parameters: EnforcedStyle. |
||||
# SupportedStyles: only_raise, only_fail, semantic |
||||
Style/SignalException: |
||||
Exclude: |
||||
- 'lib/devise/two_factor_ldap_authenticatable.rb' |
||||
- 'lib/devise/two_factor_pam_authenticatable.rb' |
||||
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all). |
||||
Style/SingleArgumentDig: |
||||
Exclude: |
||||
- 'lib/webpacker/manifest_extensions.rb' |
||||
|
||||
# This cop supports safe autocorrection (--autocorrect). |
||||
# Configuration parameters: EnforcedStyle. |
||||
# SupportedStyles: require_parentheses, require_no_parentheses |
||||
Style/StabbyLambdaParentheses: |
||||
Exclude: |
||||
- 'config/environments/production.rb' |
||||
- 'config/initializers/content_security_policy.rb' |
||||
|
||||
# This cop supports safe autocorrection (--autocorrect). |
||||
Style/StderrPuts: |
||||
Exclude: |
||||
- 'config/boot.rb' |
||||
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all). |
||||
# Configuration parameters: Mode. |
||||
Style/StringConcatenation: |
||||
Exclude: |
||||
- 'config/initializers/paperclip.rb' |
||||
|
||||
# This cop supports safe autocorrection (--autocorrect). |
||||
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. |
||||
# SupportedStyles: single_quotes, double_quotes |
||||
Style/StringLiterals: |
||||
Exclude: |
||||
- 'config/environments/production.rb' |
||||
- 'config/initializers/backtrace_silencers.rb' |
||||
- 'config/initializers/http_client_proxy.rb' |
||||
- 'config/initializers/rack_attack.rb' |
||||
- 'config/initializers/webauthn.rb' |
||||
- 'config/routes.rb' |
||||
|
||||
# This cop supports unsafe autocorrection (--autocorrect-all). |
||||
# Configuration parameters: AllowMethodsWithArguments, AllowedMethods, AllowedPatterns, AllowComments. |
||||
# AllowedMethods: define_method, mail, respond_to |
||||
Style/SymbolProc: |
||||
Exclude: |
||||
- 'config/initializers/3_omniauth.rb' |
||||
|
||||
# This cop supports safe autocorrection (--autocorrect). |
||||
# Configuration parameters: EnforcedStyle, AllowSafeAssignment. |
||||
# SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex |
||||
Style/TernaryParentheses: |
||||
Exclude: |
||||
- 'config/environments/development.rb' |
||||
|
||||
# This cop supports safe autocorrection (--autocorrect). |
||||
# Configuration parameters: EnforcedStyleForMultiline. |
||||
# SupportedStylesForMultiline: comma, consistent_comma, no_comma |
||||
Style/TrailingCommaInArguments: |
||||
Exclude: |
||||
- 'config/initializers/paperclip.rb' |
||||
|
||||
# This cop supports safe autocorrection (--autocorrect). |
||||
# Configuration parameters: EnforcedStyleForMultiline. |
||||
# SupportedStylesForMultiline: comma, consistent_comma, no_comma |
||||
Style/TrailingCommaInHashLiteral: |
||||
Exclude: |
||||
- 'config/environments/production.rb' |
||||
- 'config/environments/test.rb' |
||||
|
||||
# This cop supports safe autocorrection (--autocorrect). |
||||
# Configuration parameters: EnforcedStyle, MinSize, WordRegex. |
||||
# SupportedStyles: percent, brackets |
||||
Style/WordArray: |
||||
Exclude: |
||||
- 'app/helpers/languages_helper.rb' |
||||
- 'config/initializers/cors.rb' |
||||
- 'spec/controllers/settings/imports_controller_spec.rb' |
||||
- 'spec/models/form/import_spec.rb' |
||||
Enabled: false |
||||
|
||||
@ -0,0 +1,39 @@
|
||||
import { resolve } from 'node:path'; |
||||
|
||||
import type { StorybookConfig } from '@storybook/react-vite'; |
||||
|
||||
const config: StorybookConfig = { |
||||
stories: ['../app/javascript/**/*.stories.@(js|jsx|mjs|ts|tsx)'], |
||||
addons: [ |
||||
'@storybook/addon-docs', |
||||
'@storybook/addon-a11y', |
||||
'@storybook/addon-vitest', |
||||
], |
||||
framework: { |
||||
name: '@storybook/react-vite', |
||||
options: {}, |
||||
}, |
||||
staticDirs: [ |
||||
'./static', |
||||
// We need to manually specify the assets because of the symlink in public/sw.js
|
||||
...[ |
||||
'avatars', |
||||
'emoji', |
||||
'headers', |
||||
'sounds', |
||||
'badge.png', |
||||
'loading.gif', |
||||
'loading.png', |
||||
'oops.gif', |
||||
'oops.png', |
||||
].map((path) => ({ from: `../public/${path}`, to: `/${path}` })), |
||||
], |
||||
viteFinal(config) { |
||||
// For an unknown reason, Storybook does not use the root
|
||||
// from the Vite config so we need to set it manually.
|
||||
config.root = resolve(__dirname, '../app/javascript'); |
||||
return config; |
||||
}, |
||||
}; |
||||
|
||||
export default config; |
||||
@ -0,0 +1,7 @@
|
||||
import { addons } from 'storybook/manager-api'; |
||||
|
||||
import theme from './storybook-theme'; |
||||
|
||||
addons.setConfig({ |
||||
theme, |
||||
}); |
||||
@ -0,0 +1,2 @@
|
||||
<html class="no-reduce-motion"> |
||||
</html> |
||||
@ -0,0 +1,18 @@
|
||||
<style> |
||||
/* Increase docs font size */ |
||||
.sbdocs.sbdocs-content :where(p:not(.sb-anchor, .sb-unstyled, .sb-unstyled p)), |
||||
.sbdocs.sbdocs-content :where(li:not(.sb-anchor, .sb-unstyled, .sb-unstyled li)) { |
||||
font-size: 1.0666rem; /* 17px */ |
||||
line-height: 1.585; /* 27px */ |
||||
} |
||||
|
||||
.sbdocs.sbdocs-content :where(p:not(.sb-anchor, .sb-unstyled, .sb-unstyled p)) code, |
||||
.sbdocs.sbdocs-content :where(li:not(.sb-anchor, .sb-unstyled, .sb-unstyled li)) code { |
||||
font-size: 0.875rem; /* ~15px */ |
||||
} |
||||
|
||||
/* Bring numbers back for ordered lists */ |
||||
ol { |
||||
list-style: revert !important; |
||||
} |
||||
</style> |
||||
@ -0,0 +1,158 @@
|
||||
import { useEffect, useState } from 'react'; |
||||
|
||||
import { IntlProvider } from 'react-intl'; |
||||
|
||||
import { MemoryRouter, Route } from 'react-router'; |
||||
|
||||
import { configureStore } from '@reduxjs/toolkit'; |
||||
import { Provider } from 'react-redux'; |
||||
|
||||
import type { Preview } from '@storybook/react-vite'; |
||||
import { initialize, mswLoader } from 'msw-storybook-addon'; |
||||
import { action } from 'storybook/actions'; |
||||
|
||||
import type { LocaleData } from '@/mastodon/locales'; |
||||
import { reducerWithInitialState } from '@/mastodon/reducers'; |
||||
import { defaultMiddleware } from '@/mastodon/store/store'; |
||||
import { mockHandlers, unhandledRequestHandler } from '@/testing/api'; |
||||
|
||||
// If you want to run the dark theme during development,
|
||||
// you can change the below to `/application.scss`
|
||||
import '../app/javascript/styles/mastodon-light.scss'; |
||||
import './styles.css'; |
||||
|
||||
const localeFiles = import.meta.glob('@/mastodon/locales/*.json', { |
||||
query: { as: 'json' }, |
||||
}); |
||||
|
||||
// Initialize MSW
|
||||
initialize({ |
||||
onUnhandledRequest: unhandledRequestHandler, |
||||
}); |
||||
|
||||
const preview: Preview = { |
||||
// Auto-generate docs: https://storybook.js.org/docs/writing-docs/autodocs
|
||||
tags: ['autodocs'], |
||||
globalTypes: { |
||||
locale: { |
||||
description: 'Locale for the story', |
||||
toolbar: { |
||||
title: 'Locale', |
||||
icon: 'globe', |
||||
items: Object.keys(localeFiles).map((path) => |
||||
path.replace('/mastodon/locales/', '').replace('.json', ''), |
||||
), |
||||
dynamicTitle: true, |
||||
}, |
||||
}, |
||||
}, |
||||
initialGlobals: { |
||||
locale: 'en', |
||||
}, |
||||
decorators: [ |
||||
(Story, { parameters, globals, args }) => { |
||||
// Get the locale from the global toolbar
|
||||
// and merge it with any parameters or args state.
|
||||
const { locale } = globals as { locale: string }; |
||||
const { state = {} } = parameters; |
||||
const { state: argsState = {} } = args; |
||||
|
||||
const reducer = reducerWithInitialState( |
||||
{ |
||||
meta: { |
||||
locale, |
||||
}, |
||||
}, |
||||
state as Record<string, unknown>, |
||||
argsState as Record<string, unknown>, |
||||
); |
||||
|
||||
const store = configureStore({ |
||||
reducer, |
||||
middleware(getDefaultMiddleware) { |
||||
return getDefaultMiddleware(defaultMiddleware); |
||||
}, |
||||
}); |
||||
return ( |
||||
<Provider store={store}> |
||||
<Story /> |
||||
</Provider> |
||||
); |
||||
}, |
||||
(Story, { globals }) => { |
||||
const currentLocale = (globals.locale as string) || 'en'; |
||||
const [messages, setMessages] = useState< |
||||
Record<string, Record<string, string>> |
||||
>({}); |
||||
const currentLocaleData = messages[currentLocale]; |
||||
|
||||
useEffect(() => { |
||||
async function loadLocaleData() { |
||||
const { default: localeFile } = (await import( |
||||
`@/mastodon/locales/${currentLocale}.json` |
||||
)) as { default: LocaleData['messages'] }; |
||||
setMessages((prevLocales) => ({ |
||||
...prevLocales, |
||||
[currentLocale]: localeFile, |
||||
})); |
||||
} |
||||
if (!currentLocaleData) { |
||||
void loadLocaleData(); |
||||
} |
||||
}, [currentLocale, currentLocaleData]); |
||||
|
||||
return ( |
||||
<IntlProvider |
||||
locale={currentLocale} |
||||
messages={currentLocaleData} |
||||
textComponent='span' |
||||
> |
||||
<Story /> |
||||
</IntlProvider> |
||||
); |
||||
}, |
||||
(Story) => ( |
||||
<MemoryRouter> |
||||
<Story /> |
||||
<Route |
||||
path='*' |
||||
// eslint-disable-next-line react/jsx-no-bind
|
||||
render={({ location }) => { |
||||
if (location.pathname !== '/') { |
||||
action(`route change to ${location.pathname}`)(location); |
||||
} |
||||
return null; |
||||
}} |
||||
/> |
||||
</MemoryRouter> |
||||
), |
||||
], |
||||
loaders: [mswLoader], |
||||
parameters: { |
||||
layout: 'centered', |
||||
|
||||
controls: { |
||||
matchers: { |
||||
color: /(background|color)$/i, |
||||
date: /Date$/i, |
||||
}, |
||||
}, |
||||
|
||||
a11y: { |
||||
// 'todo' - show a11y violations in the test UI only
|
||||
// 'error' - fail CI on a11y violations
|
||||
// 'off' - skip a11y checks entirely
|
||||
test: 'todo', |
||||
}, |
||||
|
||||
state: {}, |
||||
|
||||
docs: {}, |
||||
|
||||
msw: { |
||||
handlers: mockHandlers, |
||||
}, |
||||
}, |
||||
}; |
||||
|
||||
export default preview; |
||||
@ -0,0 +1,348 @@
|
||||
/* eslint-disable */ |
||||
/* tslint:disable */ |
||||
|
||||
/** |
||||
* Mock Service Worker. |
||||
* @see https://github.com/mswjs/msw
|
||||
* - Please do NOT modify this file. |
||||
*/ |
||||
|
||||
const PACKAGE_VERSION = '2.11.3' |
||||
const INTEGRITY_CHECKSUM = '4db4a41e972cec1b64cc569c66952d82' |
||||
const IS_MOCKED_RESPONSE = Symbol('isMockedResponse') |
||||
const activeClientIds = new Set() |
||||
|
||||
addEventListener('install', function () { |
||||
self.skipWaiting() |
||||
}) |
||||
|
||||
addEventListener('activate', function (event) { |
||||
event.waitUntil(self.clients.claim()) |
||||
}) |
||||
|
||||
addEventListener('message', async function (event) { |
||||
const clientId = Reflect.get(event.source || {}, 'id') |
||||
|
||||
if (!clientId || !self.clients) { |
||||
return |
||||
} |
||||
|
||||
const client = await self.clients.get(clientId) |
||||
|
||||
if (!client) { |
||||
return |
||||
} |
||||
|
||||
const allClients = await self.clients.matchAll({ |
||||
type: 'window', |
||||
}) |
||||
|
||||
switch (event.data) { |
||||
case 'KEEPALIVE_REQUEST': { |
||||
sendToClient(client, { |
||||
type: 'KEEPALIVE_RESPONSE', |
||||
}) |
||||
break |
||||
} |
||||
|
||||
case 'INTEGRITY_CHECK_REQUEST': { |
||||
sendToClient(client, { |
||||
type: 'INTEGRITY_CHECK_RESPONSE', |
||||
payload: { |
||||
packageVersion: PACKAGE_VERSION, |
||||
checksum: INTEGRITY_CHECKSUM, |
||||
}, |
||||
}) |
||||
break |
||||
} |
||||
|
||||
case 'MOCK_ACTIVATE': { |
||||
activeClientIds.add(clientId) |
||||
|
||||
sendToClient(client, { |
||||
type: 'MOCKING_ENABLED', |
||||
payload: { |
||||
client: { |
||||
id: client.id, |
||||
frameType: client.frameType, |
||||
}, |
||||
}, |
||||
}) |
||||
break |
||||
} |
||||
|
||||
case 'CLIENT_CLOSED': { |
||||
activeClientIds.delete(clientId) |
||||
|
||||
const remainingClients = allClients.filter((client) => { |
||||
return client.id !== clientId |
||||
}) |
||||
|
||||
// Unregister itself when there are no more clients
|
||||
if (remainingClients.length === 0) { |
||||
self.registration.unregister() |
||||
} |
||||
|
||||
break |
||||
} |
||||
} |
||||
}) |
||||
|
||||
addEventListener('fetch', function (event) { |
||||
const requestInterceptedAt = Date.now() |
||||
|
||||
// Bypass navigation requests.
|
||||
if (event.request.mode === 'navigate') { |
||||
return |
||||
} |
||||
|
||||
// Opening the DevTools triggers the "only-if-cached" request
|
||||
// that cannot be handled by the worker. Bypass such requests.
|
||||
if ( |
||||
event.request.cache === 'only-if-cached' && |
||||
event.request.mode !== 'same-origin' |
||||
) { |
||||
return |
||||
} |
||||
|
||||
// Bypass all requests when there are no active clients.
|
||||
// Prevents the self-unregistered worked from handling requests
|
||||
// after it's been terminated (still remains active until the next reload).
|
||||
if (activeClientIds.size === 0) { |
||||
return |
||||
} |
||||
|
||||
const requestId = crypto.randomUUID() |
||||
event.respondWith(handleRequest(event, requestId, requestInterceptedAt)) |
||||
}) |
||||
|
||||
/** |
||||
* @param {FetchEvent} event |
||||
* @param {string} requestId |
||||
* @param {number} requestInterceptedAt |
||||
*/ |
||||
async function handleRequest(event, requestId, requestInterceptedAt) { |
||||
const client = await resolveMainClient(event) |
||||
const requestCloneForEvents = event.request.clone() |
||||
const response = await getResponse( |
||||
event, |
||||
client, |
||||
requestId, |
||||
requestInterceptedAt, |
||||
) |
||||
|
||||
// Send back the response clone for the "response:*" life-cycle events.
|
||||
// Ensure MSW is active and ready to handle the message, otherwise
|
||||
// this message will pend indefinitely.
|
||||
if (client && activeClientIds.has(client.id)) { |
||||
const serializedRequest = await serializeRequest(requestCloneForEvents) |
||||
|
||||
// Clone the response so both the client and the library could consume it.
|
||||
const responseClone = response.clone() |
||||
|
||||
sendToClient( |
||||
client, |
||||
{ |
||||
type: 'RESPONSE', |
||||
payload: { |
||||
isMockedResponse: IS_MOCKED_RESPONSE in response, |
||||
request: { |
||||
id: requestId, |
||||
...serializedRequest, |
||||
}, |
||||
response: { |
||||
type: responseClone.type, |
||||
status: responseClone.status, |
||||
statusText: responseClone.statusText, |
||||
headers: Object.fromEntries(responseClone.headers.entries()), |
||||
body: responseClone.body, |
||||
}, |
||||
}, |
||||
}, |
||||
responseClone.body ? [serializedRequest.body, responseClone.body] : [], |
||||
) |
||||
} |
||||
|
||||
return response |
||||
} |
||||
|
||||
/** |
||||
* Resolve the main client for the given event. |
||||
* Client that issues a request doesn't necessarily equal the client |
||||
* that registered the worker. It's with the latter the worker should |
||||
* communicate with during the response resolving phase. |
||||
* @param {FetchEvent} event |
||||
* @returns {Promise<Client | undefined>} |
||||
*/ |
||||
async function resolveMainClient(event) { |
||||
const client = await self.clients.get(event.clientId) |
||||
|
||||
if (activeClientIds.has(event.clientId)) { |
||||
return client |
||||
} |
||||
|
||||
if (client?.frameType === 'top-level') { |
||||
return client |
||||
} |
||||
|
||||
const allClients = await self.clients.matchAll({ |
||||
type: 'window', |
||||
}) |
||||
|
||||
return allClients |
||||
.filter((client) => { |
||||
// Get only those clients that are currently visible.
|
||||
return client.visibilityState === 'visible' |
||||
}) |
||||
.find((client) => { |
||||
// Find the client ID that's recorded in the
|
||||
// set of clients that have registered the worker.
|
||||
return activeClientIds.has(client.id) |
||||
}) |
||||
} |
||||
|
||||
/** |
||||
* @param {FetchEvent} event |
||||
* @param {Client | undefined} client |
||||
* @param {string} requestId |
||||
* @returns {Promise<Response>} |
||||
*/ |
||||
async function getResponse(event, client, requestId, requestInterceptedAt) { |
||||
// Clone the request because it might've been already used
|
||||
// (i.e. its body has been read and sent to the client).
|
||||
const requestClone = event.request.clone() |
||||
|
||||
function passthrough() { |
||||
// Cast the request headers to a new Headers instance
|
||||
// so the headers can be manipulated with.
|
||||
const headers = new Headers(requestClone.headers) |
||||
|
||||
// Remove the "accept" header value that marked this request as passthrough.
|
||||
// This prevents request alteration and also keeps it compliant with the
|
||||
// user-defined CORS policies.
|
||||
const acceptHeader = headers.get('accept') |
||||
if (acceptHeader) { |
||||
const values = acceptHeader.split(',').map((value) => value.trim()) |
||||
const filteredValues = values.filter( |
||||
(value) => value !== 'msw/passthrough', |
||||
) |
||||
|
||||
if (filteredValues.length > 0) { |
||||
headers.set('accept', filteredValues.join(', ')) |
||||
} else { |
||||
headers.delete('accept') |
||||
} |
||||
} |
||||
|
||||
return fetch(requestClone, { headers }) |
||||
} |
||||
|
||||
// Bypass mocking when the client is not active.
|
||||
if (!client) { |
||||
return passthrough() |
||||
} |
||||
|
||||
// Bypass initial page load requests (i.e. static assets).
|
||||
// The absence of the immediate/parent client in the map of the active clients
|
||||
// means that MSW hasn't dispatched the "MOCK_ACTIVATE" event yet
|
||||
// and is not ready to handle requests.
|
||||
if (!activeClientIds.has(client.id)) { |
||||
return passthrough() |
||||
} |
||||
|
||||
// Notify the client that a request has been intercepted.
|
||||
const serializedRequest = await serializeRequest(event.request) |
||||
const clientMessage = await sendToClient( |
||||
client, |
||||
{ |
||||
type: 'REQUEST', |
||||
payload: { |
||||
id: requestId, |
||||
interceptedAt: requestInterceptedAt, |
||||
...serializedRequest, |
||||
}, |
||||
}, |
||||
[serializedRequest.body], |
||||
) |
||||
|
||||
switch (clientMessage.type) { |
||||
case 'MOCK_RESPONSE': { |
||||
return respondWithMock(clientMessage.data) |
||||
} |
||||
|
||||
case 'PASSTHROUGH': { |
||||
return passthrough() |
||||
} |
||||
} |
||||
|
||||
return passthrough() |
||||
} |
||||
|
||||
/** |
||||
* @param {Client} client |
||||
* @param {any} message |
||||
* @param {Array<Transferable>} transferrables |
||||
* @returns {Promise<any>} |
||||
*/ |
||||
function sendToClient(client, message, transferrables = []) { |
||||
return new Promise((resolve, reject) => { |
||||
const channel = new MessageChannel() |
||||
|
||||
channel.port1.onmessage = (event) => { |
||||
if (event.data && event.data.error) { |
||||
return reject(event.data.error) |
||||
} |
||||
|
||||
resolve(event.data) |
||||
} |
||||
|
||||
client.postMessage(message, [ |
||||
channel.port2, |
||||
...transferrables.filter(Boolean), |
||||
]) |
||||
}) |
||||
} |
||||
|
||||
/** |
||||
* @param {Response} response |
||||
* @returns {Response} |
||||
*/ |
||||
function respondWithMock(response) { |
||||
// Setting response status code to 0 is a no-op.
|
||||
// However, when responding with a "Response.error()", the produced Response
|
||||
// instance will have status code set to 0. Since it's not possible to create
|
||||
// a Response instance with status code 0, handle that use-case separately.
|
||||
if (response.status === 0) { |
||||
return Response.error() |
||||
} |
||||
|
||||
const mockedResponse = new Response(response.body, response) |
||||
|
||||
Reflect.defineProperty(mockedResponse, IS_MOCKED_RESPONSE, { |
||||
value: true, |
||||
enumerable: true, |
||||
}) |
||||
|
||||
return mockedResponse |
||||
} |
||||
|
||||
/** |
||||
* @param {Request} request |
||||
*/ |
||||
async function serializeRequest(request) { |
||||
return { |
||||
url: request.url, |
||||
mode: request.mode, |
||||
method: request.method, |
||||
headers: Object.fromEntries(request.headers.entries()), |
||||
cache: request.cache, |
||||
credentials: request.credentials, |
||||
destination: request.destination, |
||||
integrity: request.integrity, |
||||
redirect: request.redirect, |
||||
referrer: request.referrer, |
||||
referrerPolicy: request.referrerPolicy, |
||||
body: await request.arrayBuffer(), |
||||
keepalive: request.keepalive, |
||||
} |
||||
} |
||||
@ -0,0 +1,7 @@
|
||||
// The addon package.json incorrectly exports types, so we need to override them here.
|
||||
// See: https://github.com/storybookjs/storybook/blob/v9.0.4/code/addons/vitest/package.json#L70-L76
|
||||
declare module '@storybook/addon-vitest/vitest-plugin' { |
||||
export * from '@storybook/addon-vitest/dist/vitest-plugin/index'; |
||||
} |
||||
|
||||
export {}; |
||||
@ -0,0 +1,7 @@
|
||||
import { create } from 'storybook/theming'; |
||||
|
||||
export default create({ |
||||
base: 'light', |
||||
brandTitle: 'Mastodon Storybook', |
||||
brandImage: 'https://joinmastodon.org/logos/wordmark-black-text.svg', |
||||
}); |
||||
@ -0,0 +1,8 @@
|
||||
a { |
||||
color: inherit; |
||||
text-decoration: none; |
||||
} |
||||
|
||||
a:hover { |
||||
text-decoration: underline; |
||||
} |
||||
@ -0,0 +1,8 @@
|
||||
import * as a11yAddonAnnotations from '@storybook/addon-a11y/preview'; |
||||
import { setProjectAnnotations } from '@storybook/react-vite'; |
||||
|
||||
import * as projectAnnotations from './preview'; |
||||
|
||||
// This is an important step to apply the right configuration when testing your stories.
|
||||
// More info at: https://storybook.js.org/docs/api/portable-stories/portable-stories-vitest#setprojectannotations
|
||||
setProjectAnnotations([a11yAddonAnnotations, projectAnnotations]); |
||||
@ -0,0 +1,13 @@
|
||||
diff --git a/lib/index.js b/lib/index.js
|
||||
index 16ed6be8be8f555cc99096c2ff60954b42dc313d..d009c069770d066ad0db7ad02de1ea473a29334e 100644
|
||||
--- a/lib/index.js
|
||||
+++ b/lib/index.js
|
||||
@@ -99,7 +99,7 @@ function lodash(_ref) {
|
||||
|
||||
var node = _ref3;
|
||||
|
||||
- if ((0, _types.isModuleDeclaration)(node)) {
|
||||
+ if ((0, _types.isImportDeclaration)(node) || (0, _types.isExportDeclaration)(node)) {
|
||||
isModule = true;
|
||||
break;
|
||||
}
|
||||
@ -1,49 +0,0 @@
|
||||
# test directories |
||||
__tests__ |
||||
test |
||||
tests |
||||
powered-test |
||||
|
||||
# asset directories |
||||
docs |
||||
doc |
||||
website |
||||
images |
||||
# assets |
||||
|
||||
# examples |
||||
example |
||||
examples |
||||
|
||||
# code coverage directories |
||||
coverage |
||||
.nyc_output |
||||
|
||||
# build scripts |
||||
Makefile |
||||
Gulpfile.js |
||||
Gruntfile.js |
||||
|
||||
# configs |
||||
.tern-project |
||||
.gitattributes |
||||
.editorconfig |
||||
.*ignore |
||||
.eslintrc |
||||
.jshintrc |
||||
.flowconfig |
||||
.documentup.json |
||||
.yarn-metadata.json |
||||
.*.yml |
||||
*.yml |
||||
|
||||
# misc |
||||
*.gz |
||||
*.md |
||||
|
||||
# for specific ignore |
||||
!.svgo.yml |
||||
!sass-lint/**/*.yml |
||||
|
||||
# breaks lint-staged or generally anything using https://github.com/eemeli/yaml/issues/384 |
||||
!**/yaml/dist/**/doc |
||||
@ -1,5 +1,5 @@
|
||||
ffmpeg |
||||
libopenblas0-pthread |
||||
libpq-dev |
||||
libxdamage1 |
||||
libxfixes3 |
||||
libidn12 |
||||
# for idn-ruby on heroku-24 stack |
||||
|
||||
# use https://github.com/heroku/heroku-buildpack-activestorage-preview |
||||
# in place for ffmpeg and its dependent packages to reduce slag size |
||||
|
||||
@ -1,15 +0,0 @@
|
||||
# frozen_string_literal: true |
||||
|
||||
require 'capistrano/setup' |
||||
require 'capistrano/deploy' |
||||
require 'capistrano/scm/git' |
||||
|
||||
install_plugin Capistrano::SCM::Git |
||||
|
||||
require 'capistrano/rbenv' |
||||
require 'capistrano/bundler' |
||||
require 'capistrano/yarn' |
||||
require 'capistrano/rails/assets' |
||||
require 'capistrano/rails/migrations' |
||||
|
||||
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r } |
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue