diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100644 index 000000000..e04586a83 --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,32 @@ +--- +name: lint + +on: + pull_request: + branches-ignore: + - q/*/** + +permissions: + contents: read + +jobs: + prettier: + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-node@v6 + with: + node-version: '22' + cache: yarn + - name: Install dependencies + run: yarn install --ignore-engines --frozen-lockfile --network-concurrency 1 + - name: Prettier (changed files) + shell: bash + env: + BASE_REF: ${{ github.event.pull_request.base.ref }} + run: | + MERGE_BASE=$(git merge-base HEAD "origin/${BASE_REF}") + yarn run --silent prettier:diff --check "${MERGE_BASE}..HEAD" diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000..e39a159a4 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,3 @@ +node_modules/ +coverage/ +bucket-scanner/ diff --git a/package.json b/package.json index 5d1b941d3..9122c73c5 100644 --- a/package.json +++ b/package.json @@ -1,103 +1,106 @@ { - "name": "backbeat", - "version": "9.4.0", - "description": "Asynchronous queue and job manager", - "main": "index.js", - "scripts": { - "queue_populator": "BACKBEAT_QUEUEPOPULATOR_EXTENSIONS=replication,lifecycle node bin/queuePopulator.js", - "queue_processor": "node extensions/replication/queueProcessor/task.js", - "replication_populator": "BACKBEAT_QUEUEPOPULATOR_EXTENSIONS=replication node bin/queuePopulator.js", - "ingestion_populator": "node bin/ingestion.js", - "replication_status_processor": "node extensions/replication/replicationStatusProcessor/task.js", - "lifecycle_populator": "BACKBEAT_QUEUEPOPULATOR_EXTENSIONS=lifecycle node bin/queuePopulator.js", - "lifecycle_conductor": "node extensions/lifecycle/conductor/service.js", - "lifecycle_bucket_processor": "node extensions/lifecycle/bucketProcessor/task.js", - "lifecycle_object_processor": "node extensions/lifecycle/objectProcessor/task.js", - "lifecycle_object_transition_processor": "LIFECYCLE_OBJECT_PROCESSOR_TYPE=transition node extensions/lifecycle/objectProcessor/task.js", - "oplog_populator": "node extensions/oplogPopulator/OplogPopulatorTask.js", - "mongo_queue_processor": "node extensions/mongoProcessor/mongoProcessorTask.js", - "garbage_collector": "node extensions/gc/service.js", - "test": "mocha --recursive tests/unit --timeout 30000 --exit", - "cover": "cross-env TEST_SUITE=${TEST_SUITE:-test} nyc --clean --silent yarn run $TEST_SUITE && nyc report --reporter=lcov --report-dir ./coverage/$TEST_SUITE", - "ft_test": "mocha --recursive $(find tests/functional -name '*.js') --timeout 30000 --exit", - "ft_test:notification": "mocha --recursive $(find tests/functional/notification -name '*.js') --timeout 30000 --exit", - "ft_test:replication": "mocha --recursive $(find tests/functional/replication -name '*.js') --timeout 30000 --exit", - "ft_test:lib": "mocha --recursive $(find tests/functional/lib -name '*.js') --timeout 30000 --exit", - "ft_test:lifecycle": "mocha --recursive $(find tests/functional/lifecycle -name '*.js') --timeout 30000 --exit", - "ft_test:ingestion": "mocha --recursive $(find tests/functional/ingestion -name '*.js') --timeout 30000 --exit", - "ft_test:oplogPopulator": "mocha --recursive $(find tests/functional/oplogPopulator -name '*.js') --timeout 30000 --exit", - "ft_test:api:routes": "mocha tests/functional/api/routes.js --timeout 30000 --exit", - "ft_test:api:retry": "mocha tests/functional/api/retry.js --timeout 30000 --exit", - "ft_test:queuepopulator": "mocha --recursive $(find tests/functional/queuePopulator -name '*.js') --timeout 30000 --exit", - "bh_test": "mocha --recursive tests/behavior --exit", - "lint": "eslint $(git ls-files '*.js')", - "lint_md": "mdlint $(git ls-files '[^bucket-scanner/]*.md')", - "start": "node bin/backbeat.js", - "notification_populator": "BACKBEAT_QUEUEPOPULATOR_EXTENSIONS=notification node bin/queuePopulator.js", - "notification_processor": "node extensions/notification/queueProcessor/task.js" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/scality/backbeat.git" - }, - "author": "Scality Inc.", - "license": "Apache-2.0", - "bugs": { - "url": "https://github.com/scality/backbeat/issues" - }, - "homepage": "https://github.com/scality/backbeat#readme", - "dependencies": { - "@aws-sdk/client-iam": "^3.921.0", - "@aws-sdk/client-s3": "^3.921.0", - "@aws-sdk/client-sts": "^3.921.0", - "@aws-sdk/credential-providers": "^3.921.0", - "@scality/cloudserverclient": "^1.0.8", - "@smithy/node-http-handler": "^3.3.3", - "JSONStream": "^1.3.5", - "arsenal": "git+https://github.com/scality/arsenal#8.3.9", - "async": "^2.3.0", - "backo": "^1.1.0", - "breakbeat": "scality/breakbeat#v1.0.3", - "bucketclient": "scality/bucketclient#8.2.4", - "commander": "^13.0.0", - "fcntl": "github:scality/node-fcntl#0.2.2", - "httpagent": "git+https://github.com/scality/httpagent#1.0.6", - "ioredis": "^5.4.2", - "joi": "^17.13.3", - "minimatch": "^10.0.1", - "mongodb": "^6.11.0", - "node-forge": "^1.3.1", - "node-rdkafka": "^3.6.0", - "node-rdkafka-prometheus": "^1.0.0", - "node-schedule": "^2.1.1", - "node-zookeeper-client": "^1.1.3", - "prom-client": "^15.1.3", - "semver": "^7.6.3", - "uuid": "^11.0.4", - "vaultclient": "scality/vaultclient#8.5.4", - "werelogs": "scality/werelogs#8.2.1" - }, - "resolutions": { - "node-rdkafka-prometheus/prom-client": "^15.1.3" - }, - "devDependencies": { - "@types/node": "^20.11.20", - "@zenko/cloudserver": "git+https://github.com/scality/cloudserver#9.1.4", - "c8": "^10.1.3", - "cross-env": "^7.0.3", - "eslint": "^9.12.0", - "eslint-config-airbnb-base": "^13.1.0", - "eslint-config-scality": "scality/Guidelines#8.3.0", - "eslint-plugin-import": "^2.31.0", - "eslint-plugin-mocha": "^10.5.0", - "lolex": "^6.0.0", - "mocha": "^11.0.1", - "nyc": "^17.1.0", - "sinon": "^10.0.0", - "typescript": "^5.7.3", - "zookeeper-mock": "^1.2.0" - }, - "engines": { - "node": ">=20" - } + "name": "backbeat", + "version": "9.4.0", + "description": "Asynchronous queue and job manager", + "main": "index.js", + "scripts": { + "queue_populator": "BACKBEAT_QUEUEPOPULATOR_EXTENSIONS=replication,lifecycle node bin/queuePopulator.js", + "queue_processor": "node extensions/replication/queueProcessor/task.js", + "replication_populator": "BACKBEAT_QUEUEPOPULATOR_EXTENSIONS=replication node bin/queuePopulator.js", + "ingestion_populator": "node bin/ingestion.js", + "replication_status_processor": "node extensions/replication/replicationStatusProcessor/task.js", + "lifecycle_populator": "BACKBEAT_QUEUEPOPULATOR_EXTENSIONS=lifecycle node bin/queuePopulator.js", + "lifecycle_conductor": "node extensions/lifecycle/conductor/service.js", + "lifecycle_bucket_processor": "node extensions/lifecycle/bucketProcessor/task.js", + "lifecycle_object_processor": "node extensions/lifecycle/objectProcessor/task.js", + "lifecycle_object_transition_processor": "LIFECYCLE_OBJECT_PROCESSOR_TYPE=transition node extensions/lifecycle/objectProcessor/task.js", + "oplog_populator": "node extensions/oplogPopulator/OplogPopulatorTask.js", + "mongo_queue_processor": "node extensions/mongoProcessor/mongoProcessorTask.js", + "garbage_collector": "node extensions/gc/service.js", + "test": "mocha --recursive tests/unit --timeout 30000 --exit", + "cover": "cross-env TEST_SUITE=${TEST_SUITE:-test} nyc --clean --silent yarn run $TEST_SUITE && nyc report --reporter=lcov --report-dir ./coverage/$TEST_SUITE", + "ft_test": "mocha --recursive $(find tests/functional -name '*.js') --timeout 30000 --exit", + "ft_test:notification": "mocha --recursive $(find tests/functional/notification -name '*.js') --timeout 30000 --exit", + "ft_test:replication": "mocha --recursive $(find tests/functional/replication -name '*.js') --timeout 30000 --exit", + "ft_test:lib": "mocha --recursive $(find tests/functional/lib -name '*.js') --timeout 30000 --exit", + "ft_test:lifecycle": "mocha --recursive $(find tests/functional/lifecycle -name '*.js') --timeout 30000 --exit", + "ft_test:ingestion": "mocha --recursive $(find tests/functional/ingestion -name '*.js') --timeout 30000 --exit", + "ft_test:oplogPopulator": "mocha --recursive $(find tests/functional/oplogPopulator -name '*.js') --timeout 30000 --exit", + "ft_test:api:routes": "mocha tests/functional/api/routes.js --timeout 30000 --exit", + "ft_test:api:retry": "mocha tests/functional/api/retry.js --timeout 30000 --exit", + "ft_test:queuepopulator": "mocha --recursive $(find tests/functional/queuePopulator -name '*.js') --timeout 30000 --exit", + "bh_test": "mocha --recursive tests/behavior --exit", + "lint": "eslint $(git ls-files '*.js')", + "lint_md": "mdlint $(git ls-files '[^bucket-scanner/]*.md')", + "prettier": "prettier", + "prettier:diff": "scality-prettier-diff", + "start": "node bin/backbeat.js", + "notification_populator": "BACKBEAT_QUEUEPOPULATOR_EXTENSIONS=notification node bin/queuePopulator.js", + "notification_processor": "node extensions/notification/queueProcessor/task.js" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/scality/backbeat.git" + }, + "author": "Scality Inc.", + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/scality/backbeat/issues" + }, + "homepage": "https://github.com/scality/backbeat#readme", + "dependencies": { + "@aws-sdk/client-iam": "^3.921.0", + "@aws-sdk/client-s3": "^3.921.0", + "@aws-sdk/client-sts": "^3.921.0", + "@aws-sdk/credential-providers": "^3.921.0", + "@scality/cloudserverclient": "^1.0.8", + "@smithy/node-http-handler": "^3.3.3", + "JSONStream": "^1.3.5", + "arsenal": "git+https://github.com/scality/arsenal#8.3.9", + "async": "^2.3.0", + "backo": "^1.1.0", + "breakbeat": "scality/breakbeat#v1.0.3", + "bucketclient": "scality/bucketclient#8.2.4", + "commander": "^13.0.0", + "fcntl": "github:scality/node-fcntl#0.2.2", + "httpagent": "git+https://github.com/scality/httpagent#1.0.6", + "ioredis": "^5.4.2", + "joi": "^17.13.3", + "minimatch": "^10.0.1", + "mongodb": "^6.11.0", + "node-forge": "^1.3.1", + "node-rdkafka": "^3.6.0", + "node-rdkafka-prometheus": "^1.0.0", + "node-schedule": "^2.1.1", + "node-zookeeper-client": "^1.1.3", + "prom-client": "^15.1.3", + "semver": "^7.6.3", + "uuid": "^11.0.4", + "vaultclient": "scality/vaultclient#8.5.4", + "werelogs": "scality/werelogs#8.2.1" + }, + "resolutions": { + "node-rdkafka-prometheus/prom-client": "^15.1.3" + }, + "devDependencies": { + "@types/node": "^20.11.20", + "@zenko/cloudserver": "git+https://github.com/scality/cloudserver#9.1.4", + "c8": "^10.1.3", + "cross-env": "^7.0.3", + "eslint": "^9.12.0", + "eslint-config-airbnb-base": "^13.1.0", + "eslint-config-scality": "scality/Guidelines#8.3.2", + "eslint-plugin-import": "^2.31.0", + "eslint-plugin-mocha": "^10.5.0", + "lolex": "^6.0.0", + "mocha": "^11.0.1", + "nyc": "^17.1.0", + "prettier": "^3.8.3", + "sinon": "^10.0.0", + "typescript": "^5.7.3", + "zookeeper-mock": "^1.2.0" + }, + "engines": { + "node": ">=20" + } } diff --git a/prettier.config.cjs b/prettier.config.cjs new file mode 100644 index 000000000..9dd868b19 --- /dev/null +++ b/prettier.config.cjs @@ -0,0 +1,2 @@ +// Reuse the shared Prettier rules from the eslint-config-scality package. +module.exports = require('eslint-config-scality/prettier.config.cjs'); diff --git a/yarn.lock b/yarn.lock index aa740f23e..a100b1462 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6240,9 +6240,9 @@ eslint-config-airbnb-base@^13.1.0: object.assign "^4.1.0" object.entries "^1.1.0" -eslint-config-scality@scality/Guidelines#8.3.0: - version "8.3.0" - resolved "https://codeload.github.com/scality/Guidelines/tar.gz/666b90495dc7e9a401a37ba4d58c7eba89db90ac" +eslint-config-scality@scality/Guidelines#8.3.2: + version "8.3.2" + resolved "https://codeload.github.com/scality/Guidelines/tar.gz/8ae4ae7142af24c28e2d92f463f2a375d5130e0f" dependencies: commander "11.1.0" markdownlint "0.31.1" @@ -9213,6 +9213,11 @@ prelude-ls@^1.2.1: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.2.1.tgz#debc6489d7a6e6b0e7611888cec880337d316396" integrity sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g== +prettier@^3.8.3: + version "3.8.3" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.8.3.tgz#560f2de55bf01b4c0503bc629d5df99b9a1d09b0" + integrity sha512-7igPTM53cGHMW8xWuVTydi2KO233VFiTNyF5hLJqpilHfmn8C8gPf+PS7dUT64YcXFbiMGZxS9pCSxL/Dxm/Jw== + proc-log@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/proc-log/-/proc-log-5.0.0.tgz#e6c93cf37aef33f835c53485f314f50ea906a9d8"