Skip to content

Commit

Permalink
Merge branch 'master' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
MonkeyDo committed Mar 8, 2021
2 parents 1b95f28 + f536747 commit fbecb79
Show file tree
Hide file tree
Showing 151 changed files with 4,908 additions and 14,643 deletions.
1 change: 1 addition & 0 deletions .babel-ts-register.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require('@babel/register')({extensions: ['.js', '.jsx', '.ts', '.tsx']});
2 changes: 0 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"plugins": [
"lodash",
"@babel/plugin-transform-modules-commonjs",
"@babel/plugin-proposal-object-rest-spread",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-classes",
Expand All @@ -14,7 +13,6 @@
]
],
"presets": [
"@babel/preset-flow",
"@babel/preset-typescript",
"@babel/preset-react",
["@babel/preset-env", {
Expand Down
122 changes: 55 additions & 67 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,25 @@ const options = {
},
extends: [
'eslint:recommended',
'plugin:flowtype/recommended',
'plugin:node/recommended',
'plugin:react/recommended',
'plugin:import/recommended'
],
parser: 'babel-eslint',
parserOptions: {
ecmaFeatures: {
experimentalObjectRestSpread: true,
generators: true,
jsx: true,
modules: false
},
ecmaVersion: 8,
sourceType: 'module'
},
'plugin:import/recommended',
'plugin:@typescript-eslint/recommended'
],
parser: '@typescript-eslint/parser',
plugins: [
'react',
'import',
'flowtype',
'babel'
'@typescript-eslint'
],
root: true,
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx']
}
},
react: {
flowVersion: '0.69',
version: 'detect'
}
}
Expand All @@ -44,24 +39,12 @@ const ERROR = 2;
const TRANSITION_WARNING = 1; // warnings that should be reviewed soon
const WARNING = 1; // warnings that should stay warnings
const TRANSITION_IGNORE = 0; // ignores that should be reviewed soon
const IGNORE = 0;

// These should not be removed at all.
const possibleErrorsRules = {
'for-direction': ERROR,
'getter-return': ERROR,
'no-await-in-loop': ERROR,
'no-console': ERROR,
'no-extra-parens': [
ERROR,
'all',
{
enforceForArrowConditionals: false,
ignoreJSX: 'multi-line',
nestedBinaryExpressions: false,
returnAssign: false
}
],
'no-prototype-builtins': ERROR,
'no-template-curly-in-string': ERROR,
'valid-jsdoc': [
ERROR,
Expand Down Expand Up @@ -148,7 +131,6 @@ const bestPracticesRules = {
'no-useless-return': ERROR,
'no-void': ERROR,
'no-warning-comments': WARNING,
'no-with': ERROR,
'prefer-promise-reject-errors': ERROR,
radix: ERROR,
'require-await': ERROR,
Expand All @@ -171,16 +153,12 @@ const variablesRules = {
'init-declarations': TRANSITION_IGNORE,
'no-catch-shadow': ERROR,
'no-label-var': ERROR,
'no-shadow': ERROR,
'no-shadow-restricted-names': ERROR,
'no-undef-init': ERROR,
'no-undefined': ERROR,
'no-unused-vars': WARNING,
'no-use-before-define': ERROR
'no-undefined': ERROR
};

const nodeAndCommonJSRules = {
'callback-return': [
'node/callback-return': [
ERROR,
[
'callback',
Expand All @@ -189,14 +167,21 @@ const nodeAndCommonJSRules = {
'done'
]
],
'global-require': ERROR,
'handle-callback-err': ERROR,
'no-mixed-requires': ERROR,
'no-new-require': ERROR,
'no-path-concat': ERROR,
'no-process-env': TRANSITION_WARNING,
'no-process-exit': ERROR,
'no-sync': ERROR
'node/global-require': ERROR,
'node/handle-callback-err': ERROR,
'node/no-missing-import': [
ERROR,
{tryExtensions: ['.js', '.jsx', '.ts', '.tsx']}
],
'node/no-mixed-requires': ERROR,
'node/no-new-require': ERROR,
'node/no-path-concat': ERROR,
'node/no-process-env': TRANSITION_WARNING,
'node/no-process-exit': ERROR,
'node/no-sync': ERROR,
'node/no-unpublished-import': IGNORE,
'node/no-unsupported-features/es-builtins': IGNORE,
'node/no-unsupported-features/es-syntax': IGNORE
};

// Agreement of all project leads needed before changing these.
Expand Down Expand Up @@ -303,6 +288,12 @@ const stylisticIssuesRules = {
TRANSITION_IGNORE,
15
],
'new-cap': [
ERROR,
{
capIsNew: false
}
],
'new-parens': ERROR,
'no-array-constructor': ERROR,
'no-bitwise': ERROR,
Expand All @@ -319,10 +310,8 @@ const stylisticIssuesRules = {
'no-trailing-spaces': ERROR,
'no-unneeded-ternary': ERROR,
'no-whitespace-before-property': ERROR,
'object-curly-newline': [
ERROR,
{consistent: true}
],
'object-curly-newline': ERROR,
'object-curly-spacing': ERROR,
'one-var': [
ERROR,
'never'
Expand Down Expand Up @@ -380,12 +369,7 @@ const ecmaScript6Rules = {
before: false
}
],
'no-confusing-arrow': [
ERROR,
{
allowParens: true
}
],
'no-confusing-arrow': ERROR,
'no-duplicate-imports': ERROR,
'no-useless-computed-key': ERROR,
'no-useless-constructor': ERROR,
Expand All @@ -409,20 +393,25 @@ const ecmaScript6Rules = {
'yield-star-spacing': ERROR
};

const babelRules = {
'babel/new-cap': [
const typescriptRules = {
'@typescript-eslint/ban-types': TRANSITION_WARNING,
'@typescript-eslint/explicit-module-boundary-types': TRANSITION_IGNORE,
'@typescript-eslint/no-explicit-any': TRANSITION_IGNORE,
'@typescript-eslint/no-extra-parens': [
ERROR,
'all',
{
capIsNew: false
enforceForArrowConditionals: false,
ignoreJSX: 'multi-line',
nestedBinaryExpressions: false,
returnAssign: false
}
],
'babel/no-invalid-this': ERROR,
'babel/object-curly-spacing': ERROR,
'babel/semi': ERROR
};

const flowTypeRules = {
'flowtype/semi': ERROR
'@typescript-eslint/no-invalid-this': ERROR,
'@typescript-eslint/no-shadow': ERROR,
'@typescript-eslint/no-unused-vars': WARNING,
'@typescript-eslint/no-use-before-define': ERROR,
'@typescript-eslint/semi': ERROR
};

const reactRules = {
Expand Down Expand Up @@ -562,8 +551,7 @@ options.rules = Object.assign(
nodeAndCommonJSRules,
stylisticIssuesRules,
ecmaScript6Rules,
babelRules,
flowTypeRules,
typescriptRules,
reactRules,
es6ImportRules
);
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Run ESLint with autofix

name: Lint

# Controls when the action will run.
on:
# Triggers the workflow on push events for the master branch
push:
branches: [ master ]
# Triggers the workflow on pull request events in the context of the fork
# trying to sidestep limitations here: https://github.com/wearerequired/lint-action/issues/13
pull_request_target:

jobs:
run-linters:
name: Run linters
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2
with:
# Also check out Lobes bootstrap theme submodule
submodules: true

- name: NPM install
uses: bahmutov/npm-install@v1

- name: Run linters
uses: wearerequired/lint-action@feature/pull_request_target
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
# Enable linters with auto-fix
auto_fix: true
eslint: true
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@

# react-hot-loader files
/static/hot
/static/**/*.hot-update.js
*.hot-update.js
*.hot-update.json
/static/**/*.jpg
/static/**/*.svg

### Node ###
# Logs
Expand Down Expand Up @@ -81,3 +84,6 @@ typings/

# Visual Studio Code config files
.vscode

# Git revision file used in the website
.git-revision
2 changes: 1 addition & 1 deletion .mocharc.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
exit: true
recursive: true
require: '@babel/register'
require: '.babel-ts-register.js'
timeout: 50000
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
language: node_js
node_js:
- "node"
- "lts/*"
- "8"
- "10"

notifications:
email: false
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ to BookBrainz:
* Variable names should be camelCase
* Use ES6/ES7 features - they make life easier and result in cleaner code
* Use [JSDoc](http://usejsdoc.org/) for commenting code
* Use [Flow](https://flow.org/) annotations everywhere - static type checking is useful
* Use [TypeScript](https://www.typescriptlang.org/) everywhere - static type checking is useful

## Commits

Expand Down
17 changes: 11 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
FROM metabrainz/node:10 as bookbrainz-base

ARG DEPLOY_ENV
ARG GIT_COMMIT_SHA

ARG BUILD_DEPS=" \
build-essential \
git \
python-dev \
libpq-dev"

ARG RUN_DEPS=" \
bzip2 \
git \
rsync"


Expand All @@ -26,12 +27,18 @@ RUN apt-get update \
&& apt-get install -y --no-install-recommends postgresql-client-$PG_MAJOR \
&& rm -rf /var/lib/apt/lists/*

# Clean up files that aren't needed for production
RUN apt-get remove -y $BUILD_DEPS && \
apt-get autoremove -y

RUN useradd --create-home --shell /bin/bash bookbrainz

ARG BB_ROOT=/home/bookbrainz/bookbrainz-site
WORKDIR $BB_ROOT
RUN chown bookbrainz:bookbrainz $BB_ROOT

RUN echo $GIT_COMMIT_SHA > .git-version

# Files necessary to complete the JavaScript build
COPY scripts/ scripts/
COPY .babelrc ./
Expand All @@ -43,10 +50,6 @@ COPY package-lock.json ./

RUN npm install --no-audit

# Clean up files that aren't needed for production
RUN apt-get remove -y $BUILD_DEPS && \
apt-get autoremove -y

COPY static/ static/
COPY config/ config/
COPY sql/ sql/
Expand Down Expand Up @@ -85,6 +88,7 @@ RUN chmod 0644 /etc/cron.d/bookbrainz && crontab -u bookbrainz /etc/cron.d/bookb

# Build JS project and assets
RUN ["npm", "run", "build"]
RUN ["npm", "prune", "--production"]

# API target
FROM bookbrainz-base as bookbrainz-webservice
Expand All @@ -100,4 +104,5 @@ COPY ./docker/$DEPLOY_ENV/webserver.service /etc/service/webserver/run
RUN chmod 755 /etc/service/webserver/run
RUN touch /etc/service/webserver/down
# Build API JS
RUN ["npm", "run", "build-api-js"]
RUN ["npm", "run", "build-api-js"]
RUN ["npm", "prune", "--production"]
Loading

0 comments on commit fbecb79

Please sign in to comment.