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/h/package.json b/@commitlint/config-nx-scopes/fixtures/nx17/nx/h/package.json new file mode 100644 index 0000000000..3badb57d77 --- /dev/null +++ b/@commitlint/config-nx-scopes/fixtures/nx17/nx/h/package.json @@ -0,0 +1,4 @@ +{ + "name": "h", + "version": "1.0.0" +} diff --git a/@commitlint/config-nx-scopes/fixtures/nx17/nx/h/project.json b/@commitlint/config-nx-scopes/fixtures/nx17/nx/h/project.json new file mode 100644 index 0000000000..76f93a4bf2 --- /dev/null +++ b/@commitlint/config-nx-scopes/fixtures/nx17/nx/h/project.json @@ -0,0 +1,29 @@ +{ + "root": "nx/h", + "sourceRoot": "nx/h/src", + "projectType": "library", + "targets": { + "lint": { + "executor": "@nx/linter:eslint", + "outputs": [ + "{options.outputFile}" + ], + "options": { + "lintFilePatterns": [ + "nx/h/**/*.ts" + ] + } + }, + "test": { + "executor": "@nx/jest:jest", + "outputs": [ + "coverage/nx/h" + ], + "options": { + "jestConfig": "nx/h/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..aae5453d44 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(['g', 'h']); +}); 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": {