From d2ed80a1fbf81f256c12da8fdec425613e686962 Mon Sep 17 00:00:00 2001 From: Tim Alby Date: Mon, 13 Jan 2020 19:35:22 +0100 Subject: [PATCH] decaffeinate: update build scripts to es --- services/notifications/.dockerignore | 2 - services/notifications/.eslintrc | 74 ++++++++++++++++++++++++++ services/notifications/.prettierrc | 8 +++ services/notifications/Dockerfile | 1 - services/notifications/Jenkinsfile | 7 +++ services/notifications/Makefile | 15 ++++-- services/notifications/buildscript.txt | 2 +- services/notifications/nodemon.json | 7 ++- services/notifications/package.json | 15 +++--- 9 files changed, 112 insertions(+), 19 deletions(-) create mode 100644 services/notifications/.eslintrc create mode 100644 services/notifications/.prettierrc diff --git a/services/notifications/.dockerignore b/services/notifications/.dockerignore index 386f26df30..ba1c3442de 100644 --- a/services/notifications/.dockerignore +++ b/services/notifications/.dockerignore @@ -5,5 +5,3 @@ gitrev .npm .nvmrc nodemon.json -app.js -**/js/* diff --git a/services/notifications/.eslintrc b/services/notifications/.eslintrc new file mode 100644 index 0000000000..0e4b23dc44 --- /dev/null +++ b/services/notifications/.eslintrc @@ -0,0 +1,74 @@ +// this file was auto-generated, do not edit it directly. +// instead run bin/update_build_scripts from +// https://github.com/sharelatex/sharelatex-dev-environment +// Version: 1.3.1 +{ + "extends": [ + "standard", + "prettier", + "prettier/standard" + ], + "parserOptions": { + "ecmaVersion": 2017 + }, + "plugins": [ + "mocha", + "chai-expect", + "chai-friendly" + ], + "env": { + "node": true, + "mocha": true + }, + "rules": { + // Swap the no-unused-expressions rule with a more chai-friendly one + "no-unused-expressions": 0, + "chai-friendly/no-unused-expressions": "error" + }, + "overrides": [ + { + // Test specific rules + "files": ["**/test/*/src/**/*.js"], + "globals": { + "expect": true + }, + "rules": { + // mocha-specific rules + "mocha/handle-done-callback": "error", + "mocha/no-exclusive-tests": "error", + "mocha/no-global-tests": "error", + "mocha/no-identical-title": "error", + "mocha/no-nested-tests": "error", + "mocha/no-pending-tests": "error", + "mocha/no-skipped-tests": "error", + "mocha/no-mocha-arrows": "error", + + // chai-specific rules + "chai-expect/missing-assertion": "error", + "chai-expect/terminating-properties": "error", + + // prefer-arrow-callback applies to all callbacks, not just ones in mocha tests. + // we don't enforce this at the top-level - just in tests to manage `this` scope + // based on mocha's context mechanism + "mocha/prefer-arrow-callback": "error" + } + }, + { + // Frontend test specific rules + "files": ["**/test/frontend/**/*.js"], + "globals": { + "expect": true, + "define": true, + "$": true + } + }, + { + // Backend specific rules + "files": ["**/app/src/**/*.js"], + "rules": { + // don't allow console.log in backend code + "no-console": "error" + } + } + ] +} diff --git a/services/notifications/.prettierrc b/services/notifications/.prettierrc new file mode 100644 index 0000000000..159e073fd4 --- /dev/null +++ b/services/notifications/.prettierrc @@ -0,0 +1,8 @@ +# This file was auto-generated, do not edit it directly. +# Instead run bin/update_build_scripts from +# https://github.com/sharelatex/sharelatex-dev-environment +# Version: 1.3.1 +{ + "semi": false, + "singleQuote": true +} diff --git a/services/notifications/Dockerfile b/services/notifications/Dockerfile index ef0696e5ca..c3a42c6b72 100644 --- a/services/notifications/Dockerfile +++ b/services/notifications/Dockerfile @@ -15,7 +15,6 @@ RUN npm install --quiet COPY . /app -RUN npm run compile:all FROM node:10.16.3 diff --git a/services/notifications/Jenkinsfile b/services/notifications/Jenkinsfile index 98a6156b2f..b4e187b826 100644 --- a/services/notifications/Jenkinsfile +++ b/services/notifications/Jenkinsfile @@ -37,6 +37,13 @@ pipeline { } } + stage('Linting') { + steps { + sh 'DOCKER_COMPOSE_FLAGS="-f docker-compose.ci.yml" make format' + sh 'DOCKER_COMPOSE_FLAGS="-f docker-compose.ci.yml" make lint' + } + } + stage('Unit Tests') { steps { sh 'DOCKER_COMPOSE_FLAGS="-f docker-compose.ci.yml" make test_unit' diff --git a/services/notifications/Makefile b/services/notifications/Makefile index 4201ed9d78..7655f8a79f 100644 --- a/services/notifications/Makefile +++ b/services/notifications/Makefile @@ -16,12 +16,17 @@ DOCKER_COMPOSE := BUILD_NUMBER=$(BUILD_NUMBER) \ clean: docker rmi ci/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) docker rmi gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) - rm -f app.js - rm -rf app/js - rm -rf test/unit/js - rm -rf test/acceptance/js -test: test_unit test_acceptance +format: + $(DOCKER_COMPOSE) run --rm test_unit npm run format + +format_fix: + $(DOCKER_COMPOSE) run --rm test_unit npm run format:fix + +lint: + $(DOCKER_COMPOSE) run --rm test_unit npm run lint + +test: format lint test_unit test_acceptance test_unit: @[ ! -d test/unit ] && echo "notifications has no unit tests" || $(DOCKER_COMPOSE) run --rm test_unit diff --git a/services/notifications/buildscript.txt b/services/notifications/buildscript.txt index 41bcde56a7..94bb7e6eff 100644 --- a/services/notifications/buildscript.txt +++ b/services/notifications/buildscript.txt @@ -1,6 +1,6 @@ notifications --public-repo=True ---language=coffeescript +--language=es --env-add= --node-version=10.16.3 --acceptance-creds=None diff --git a/services/notifications/nodemon.json b/services/notifications/nodemon.json index 98db38d71b..5826281b84 100644 --- a/services/notifications/nodemon.json +++ b/services/notifications/nodemon.json @@ -10,10 +10,9 @@ }, "watch": [ - "app/coffee/", - "app.coffee", + "app/js/", + "app.js", "config/" ], - "ext": "coffee" - + "ext": "js" } diff --git a/services/notifications/package.json b/services/notifications/package.json index 44f28ff6f3..e8b9f38e61 100644 --- a/services/notifications/package.json +++ b/services/notifications/package.json @@ -5,16 +5,19 @@ "main": "app.js", "scripts": { "compile:app": "([ -e app/coffee ] && coffee -m $COFFEE_OPTIONS -o app/js -c app/coffee || echo 'No CoffeeScript folder to compile') && ( [ -e app.coffee ] && coffee -m $COFFEE_OPTIONS -c app.coffee || echo 'No CoffeeScript app to compile')", - "start": "npm run compile:app && node $NODE_APP_OPTIONS app.js", - "test:acceptance:_run": "mocha --recursive --reporter spec --timeout 30000 --exit $@ test/acceptance/js", - "test:acceptance": "npm run compile:app && npm run compile:acceptance_tests && npm run test:acceptance:_run -- --grep=$MOCHA_GREP", - "test:unit:_run": "mocha --recursive --reporter spec --exit $@ test/unit/js", - "test:unit": "npm run compile:app && npm run compile:unit_tests && npm run test:unit:_run -- --grep=$MOCHA_GREP", + "start": "node $NODE_APP_OPTIONS app.js", + "test:acceptance:_run": "mocha --recursive --reporter spec --timeout 15000 --exit $@ test/acceptance/js", + "test:acceptance": "npm run test:acceptance:_run -- --grep=$MOCHA_GREP", + "test:unit:_run": "mocha --recursive --reporter spec $@ test/unit/js", + "test:unit": "npm run test:unit:_run -- --grep=$MOCHA_GREP", "compile:unit_tests": "[ ! -e test/unit/coffee ] && echo 'No unit tests to compile' || coffee -o test/unit/js -c test/unit/coffee", "compile:acceptance_tests": "[ ! -e test/acceptance/coffee ] && echo 'No acceptance tests to compile' || coffee -o test/acceptance/js -c test/acceptance/coffee", "compile:all": "npm run compile:app && npm run compile:unit_tests && npm run compile:acceptance_tests && npm run compile:smoke_tests", "nodemon": "nodemon --config nodemon.json", - "compile:smoke_tests": "[ ! -e test/smoke/coffee ] && echo 'No smoke tests to compile' || coffee -o test/smoke/js -c test/smoke/coffee" + "compile:smoke_tests": "[ ! -e test/smoke/coffee ] && echo 'No smoke tests to compile' || coffee -o test/smoke/js -c test/smoke/coffee", + "lint": "node_modules/.bin/eslint .", + "format": "node_modules/.bin/prettier-eslint '**/*.js' --list-different", + "format:fix": "node_modules/.bin/prettier-eslint '**/*.js' --write" }, "author": "", "license": "ISC",