From acd09a8a4e490623b3279c9691f5bf09297bddd6 Mon Sep 17 00:00:00 2001 From: mserranom Date: Mon, 17 Feb 2020 18:33:01 +0100 Subject: [PATCH] decaffeinate: update build scripts to es --- services/track-changes/.dockerignore | 2 - services/track-changes/.eslintrc | 65 ++++++++++++++++++++++++++ services/track-changes/.prettierrc | 8 ++++ services/track-changes/Dockerfile | 1 - services/track-changes/Jenkinsfile | 7 +++ services/track-changes/Makefile | 15 ++++-- services/track-changes/buildscript.txt | 2 +- services/track-changes/nodemon.json | 7 ++- services/track-changes/package.json | 18 ++++--- 9 files changed, 102 insertions(+), 23 deletions(-) create mode 100644 services/track-changes/.eslintrc create mode 100644 services/track-changes/.prettierrc diff --git a/services/track-changes/.dockerignore b/services/track-changes/.dockerignore index 386f26df30..ba1c3442de 100644 --- a/services/track-changes/.dockerignore +++ b/services/track-changes/.dockerignore @@ -5,5 +5,3 @@ gitrev .npm .nvmrc nodemon.json -app.js -**/js/* diff --git a/services/track-changes/.eslintrc b/services/track-changes/.eslintrc new file mode 100644 index 0000000000..42a4b5cace --- /dev/null +++ b/services/track-changes/.eslintrc @@ -0,0 +1,65 @@ +// 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.5 +{ + "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/**/*.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" + } + }, + { + // Backend specific rules + "files": ["app/**/*.js", "app.js", "index.js"], + "rules": { + // don't allow console.log in backend code + "no-console": "error" + } + } + ] +} diff --git a/services/track-changes/.prettierrc b/services/track-changes/.prettierrc new file mode 100644 index 0000000000..5845b82113 --- /dev/null +++ b/services/track-changes/.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.5 +{ + "semi": false, + "singleQuote": true +} diff --git a/services/track-changes/Dockerfile b/services/track-changes/Dockerfile index e538fb48d9..2d8b097e26 100644 --- a/services/track-changes/Dockerfile +++ b/services/track-changes/Dockerfile @@ -17,7 +17,6 @@ RUN npm install --quiet COPY . /app -RUN npm run compile:all FROM base diff --git a/services/track-changes/Jenkinsfile b/services/track-changes/Jenkinsfile index 23be6d5d33..71f95c3c14 100644 --- a/services/track-changes/Jenkinsfile +++ b/services/track-changes/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/track-changes/Makefile b/services/track-changes/Makefile index b139b47573..73702fc5b1 100644 --- a/services/track-changes/Makefile +++ b/services/track-changes/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 "track-changes has no unit tests" || $(DOCKER_COMPOSE) run --rm test_unit diff --git a/services/track-changes/buildscript.txt b/services/track-changes/buildscript.txt index 039db45c26..d68e80b307 100644 --- a/services/track-changes/buildscript.txt +++ b/services/track-changes/buildscript.txt @@ -1,6 +1,6 @@ track-changes --public-repo=True ---language=coffeescript +--language=es --env-add=AWS_BUCKET=bucket --node-version=10.19.0 --acceptance-creds=None diff --git a/services/track-changes/nodemon.json b/services/track-changes/nodemon.json index 98db38d71b..5826281b84 100644 --- a/services/track-changes/nodemon.json +++ b/services/track-changes/nodemon.json @@ -10,10 +10,9 @@ }, "watch": [ - "app/coffee/", - "app.coffee", + "app/js/", + "app.js", "config/" ], - "ext": "coffee" - + "ext": "js" } diff --git a/services/track-changes/package.json b/services/track-changes/package.json index 72e3e7dbed..c975e2e15e 100644 --- a/services/track-changes/package.json +++ b/services/track-changes/package.json @@ -7,17 +7,15 @@ "url": "https://github.com/sharelatex/track-changes-sharelatex.git" }, "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", - "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", + "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", "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" + "lint": "node_modules/.bin/eslint .", + "format": "node_modules/.bin/prettier-eslint '**/*.js' --list-different", + "format:fix": "node_modules/.bin/prettier-eslint '**/*.js' --write" }, "dependencies": { "JSONStream": "^1.0.4",