From 8db9d3efb5a5ec68504b71f7d45fa925cd26502d Mon Sep 17 00:00:00 2001 From: Clemens Horn Date: Thu, 26 Oct 2023 10:25:33 +0200 Subject: [PATCH 1/2] fix(commitlint-config-nx-scopes): support nx version 17 updated peer dependencies to support nx version 17 --- .../config-nx-scopes/fixtures/nx17/nx.json | 38 +++++++++++++++++++ .../fixtures/nx17/nx/g/package.json | 4 ++ .../fixtures/nx17/nx/g/project.json | 29 ++++++++++++++ .../fixtures/nx17/nx/o/package.json | 4 ++ .../fixtures/nx17/nx/o/project.json | 29 ++++++++++++++ .../fixtures/nx17/package.json | 7 ++++ @commitlint/config-nx-scopes/index.test.js | 8 ++++ @commitlint/config-nx-scopes/package.json | 2 +- 8 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 @commitlint/config-nx-scopes/fixtures/nx17/nx.json create mode 100644 @commitlint/config-nx-scopes/fixtures/nx17/nx/g/package.json create mode 100644 @commitlint/config-nx-scopes/fixtures/nx17/nx/g/project.json create mode 100644 @commitlint/config-nx-scopes/fixtures/nx17/nx/o/package.json create mode 100644 @commitlint/config-nx-scopes/fixtures/nx17/nx/o/project.json create mode 100644 @commitlint/config-nx-scopes/fixtures/nx17/package.json diff --git a/@commitlint/config-nx-scopes/fixtures/nx17/nx.json b/@commitlint/config-nx-scopes/fixtures/nx17/nx.json new file mode 100644 index 0000000000..d9442f84fe --- /dev/null +++ b/@commitlint/config-nx-scopes/fixtures/nx17/nx.json @@ -0,0 +1,38 @@ +{ + "affected": { + "defaultBase": "main" + }, + "cli": { + "defaultCollection": "@nx/react" + }, + "tasksRunnerOptions": { + "default": { + "runner": "nx-cloud", + "options": { + "cacheableOperations": [ + "build", + "lint", + "test", + "e2e" + ] + } + } + }, + "generators": { + "@nx/react": { + "application": { + "style": "css", + "linter": "eslint", + "babel": true + }, + "component": { + "style": "css" + }, + "library": { + "style": "css", + "linter": "eslint" + } + } + }, + "defaultProject": "g" +} diff --git a/@commitlint/config-nx-scopes/fixtures/nx17/nx/g/package.json b/@commitlint/config-nx-scopes/fixtures/nx17/nx/g/package.json new file mode 100644 index 0000000000..757f60613e --- /dev/null +++ b/@commitlint/config-nx-scopes/fixtures/nx17/nx/g/package.json @@ -0,0 +1,4 @@ +{ + "name": "g", + "version": "1.0.0" +} diff --git a/@commitlint/config-nx-scopes/fixtures/nx17/nx/g/project.json b/@commitlint/config-nx-scopes/fixtures/nx17/nx/g/project.json new file mode 100644 index 0000000000..6e48e966bd --- /dev/null +++ b/@commitlint/config-nx-scopes/fixtures/nx17/nx/g/project.json @@ -0,0 +1,29 @@ +{ + "root": "nx/g", + "sourceRoot": "nx/g/src", + "projectType": "library", + "targets": { + "lint": { + "executor": "@nx/linter:eslint", + "outputs": [ + "{options.outputFile}" + ], + "options": { + "lintFilePatterns": [ + "nx/g/**/*.ts" + ] + } + }, + "test": { + "executor": "@nx/jest:jest", + "outputs": [ + "coverage/nx/g" + ], + "options": { + "jestConfig": "nx/g/jest.config.js", + "passWithNoTests": true + } + } + }, + "tags": [] +} diff --git a/@commitlint/config-nx-scopes/fixtures/nx17/nx/o/package.json b/@commitlint/config-nx-scopes/fixtures/nx17/nx/o/package.json new file mode 100644 index 0000000000..f9b098b001 --- /dev/null +++ b/@commitlint/config-nx-scopes/fixtures/nx17/nx/o/package.json @@ -0,0 +1,4 @@ +{ + "name": "o", + "version": "1.0.0" +} diff --git a/@commitlint/config-nx-scopes/fixtures/nx17/nx/o/project.json b/@commitlint/config-nx-scopes/fixtures/nx17/nx/o/project.json new file mode 100644 index 0000000000..f146249c08 --- /dev/null +++ b/@commitlint/config-nx-scopes/fixtures/nx17/nx/o/project.json @@ -0,0 +1,29 @@ +{ + "root": "nx/o", + "sourceRoot": "nx/o/src", + "projectType": "library", + "targets": { + "lint": { + "executor": "@nx/linter:eslint", + "outputs": [ + "{options.outputFile}" + ], + "options": { + "lintFilePatterns": [ + "nx/o/**/*.ts" + ] + } + }, + "test": { + "executor": "@nx/jest:jest", + "outputs": [ + "coverage/nx/o" + ], + "options": { + "jestConfig": "nx/o/jest.config.js", + "passWithNoTests": true + } + } + }, + "tags": [] +} diff --git a/@commitlint/config-nx-scopes/fixtures/nx17/package.json b/@commitlint/config-nx-scopes/fixtures/nx17/package.json new file mode 100644 index 0000000000..c8f6b3a845 --- /dev/null +++ b/@commitlint/config-nx-scopes/fixtures/nx17/package.json @@ -0,0 +1,7 @@ +{ + "name": "basic", + "version": "1.0.0", + "devDependencies": { + "nx": "^17.0.0" + } +} diff --git a/@commitlint/config-nx-scopes/index.test.js b/@commitlint/config-nx-scopes/index.test.js index 2650706f93..a384ae2aa0 100644 --- a/@commitlint/config-nx-scopes/index.test.js +++ b/@commitlint/config-nx-scopes/index.test.js @@ -74,3 +74,11 @@ test('expect correct result from Nx 15', async () => { const [, , value] = await fn({cwd}); expect(value).toEqual(['e', 'f']); }); + +test('expect correct result from Nx 17', async () => { + const {'scope-enum': fn} = config.rules; + const cwd = await npm.bootstrap('fixtures/nx17', __dirname); + + const [, , value] = await fn({cwd}); + expect(value).toEqual(['a', 'b']); +}); diff --git a/@commitlint/config-nx-scopes/package.json b/@commitlint/config-nx-scopes/package.json index 21a22c8c43..d45937ecb2 100644 --- a/@commitlint/config-nx-scopes/package.json +++ b/@commitlint/config-nx-scopes/package.json @@ -27,7 +27,7 @@ }, "homepage": "https://commitlint.js.org/", "peerDependencies": { - "nx": "^14.0.0 || ^15.0.0 || ^16.0.0" + "nx": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" }, "peerDependenciesMeta": { "nx": { From 5ea052513a82f288a55316c5d9c8224d6d693444 Mon Sep 17 00:00:00 2001 From: Clemens Horn Date: Thu, 26 Oct 2023 10:32:31 +0200 Subject: [PATCH 2/2] refactor(commitlint-config-nx-scopes): follow package name convention renamed packages in fixtures to follow the subsequent name convention --- .../fixtures/nx17/nx/{o => h}/package.json | 2 +- .../fixtures/nx17/nx/{o => h}/project.json | 10 +++++----- @commitlint/config-nx-scopes/index.test.js | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) rename @commitlint/config-nx-scopes/fixtures/nx17/nx/{o => h}/package.json (62%) rename @commitlint/config-nx-scopes/fixtures/nx17/nx/{o => h}/project.json (73%) diff --git a/@commitlint/config-nx-scopes/fixtures/nx17/nx/o/package.json b/@commitlint/config-nx-scopes/fixtures/nx17/nx/h/package.json similarity index 62% rename from @commitlint/config-nx-scopes/fixtures/nx17/nx/o/package.json rename to @commitlint/config-nx-scopes/fixtures/nx17/nx/h/package.json index f9b098b001..3badb57d77 100644 --- a/@commitlint/config-nx-scopes/fixtures/nx17/nx/o/package.json +++ b/@commitlint/config-nx-scopes/fixtures/nx17/nx/h/package.json @@ -1,4 +1,4 @@ { - "name": "o", + "name": "h", "version": "1.0.0" } diff --git a/@commitlint/config-nx-scopes/fixtures/nx17/nx/o/project.json b/@commitlint/config-nx-scopes/fixtures/nx17/nx/h/project.json similarity index 73% rename from @commitlint/config-nx-scopes/fixtures/nx17/nx/o/project.json rename to @commitlint/config-nx-scopes/fixtures/nx17/nx/h/project.json index f146249c08..76f93a4bf2 100644 --- a/@commitlint/config-nx-scopes/fixtures/nx17/nx/o/project.json +++ b/@commitlint/config-nx-scopes/fixtures/nx17/nx/h/project.json @@ -1,6 +1,6 @@ { - "root": "nx/o", - "sourceRoot": "nx/o/src", + "root": "nx/h", + "sourceRoot": "nx/h/src", "projectType": "library", "targets": { "lint": { @@ -10,17 +10,17 @@ ], "options": { "lintFilePatterns": [ - "nx/o/**/*.ts" + "nx/h/**/*.ts" ] } }, "test": { "executor": "@nx/jest:jest", "outputs": [ - "coverage/nx/o" + "coverage/nx/h" ], "options": { - "jestConfig": "nx/o/jest.config.js", + "jestConfig": "nx/h/jest.config.js", "passWithNoTests": true } } diff --git a/@commitlint/config-nx-scopes/index.test.js b/@commitlint/config-nx-scopes/index.test.js index a384ae2aa0..aae5453d44 100644 --- a/@commitlint/config-nx-scopes/index.test.js +++ b/@commitlint/config-nx-scopes/index.test.js @@ -80,5 +80,5 @@ test('expect correct result from Nx 17', async () => { const cwd = await npm.bootstrap('fixtures/nx17', __dirname); const [, , value] = await fn({cwd}); - expect(value).toEqual(['a', 'b']); + expect(value).toEqual(['g', 'h']); });