From 52642c840d73256385cb0755037e6d030b0f18f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Chalk?= Date: Mon, 4 Dec 2023 13:18:26 +0100 Subject: [PATCH] test(plugin-eslint): add test case for code-pushup.eslintrc resolution --- .../plugin-eslint/src/lib/nx.integration.test.ts | 6 +++--- .../plugin-eslint/src/lib/nx/utils.unit.test.ts | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/packages/plugin-eslint/src/lib/nx.integration.test.ts b/packages/plugin-eslint/src/lib/nx.integration.test.ts index 8c9ccae59..f8fbcafc8 100644 --- a/packages/plugin-eslint/src/lib/nx.integration.test.ts +++ b/packages/plugin-eslint/src/lib/nx.integration.test.ts @@ -105,8 +105,8 @@ describe('Nx helpers', () => { * utils ◄──────┘ */ - const allProjects = ['cli', 'core', 'nx-plugin', 'utils'] as const; - type Project = (typeof allProjects)[number]; + const ALL_PROJECTS = ['cli', 'core', 'nx-plugin', 'utils'] as const; + type Project = (typeof ALL_PROJECTS)[number]; it.each<[Project, Project[]]>([ ['cli', ['cli', 'core', 'utils']], @@ -116,7 +116,7 @@ describe('Nx helpers', () => { ])( 'project %j - expected configurations for projects %j', async (project, expectedProjects) => { - const otherProjects = allProjects.filter( + const otherProjects = ALL_PROJECTS.filter( p => !expectedProjects.includes(p), ); diff --git a/packages/plugin-eslint/src/lib/nx/utils.unit.test.ts b/packages/plugin-eslint/src/lib/nx/utils.unit.test.ts index 9aa1c1f40..ee6a39479 100644 --- a/packages/plugin-eslint/src/lib/nx/utils.unit.test.ts +++ b/packages/plugin-eslint/src/lib/nx/utils.unit.test.ts @@ -46,6 +46,21 @@ describe('find code-pushup.eslintrc.* file', () => { ).resolves.toBe('./packages/core/code-pushup.eslintrc.js'); }); + it('should look for JSON extension before JavaScript', async () => { + vol.fromJSON( + { + 'libs/utils/code-pushup.eslintrc.js': + "module.exports = { extends: '@code-pushup' };", + 'libs/utils/code-pushup.eslintrc.json': '{ "extends": "@code-pushup" }', + }, + MEMFS_VOLUME, + ); + + await expect(findCodePushupEslintrc({ root: 'libs/utils' })).resolves.toBe( + './libs/utils/code-pushup.eslintrc.json', + ); + }); + it('should look for JavaScript extensions before YAML', async () => { vol.fromJSON( {