Skip to content

Commit

Permalink
test(plugin-eslint): add test case for code-pushup.eslintrc resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
matejchalk committed Dec 4, 2023
1 parent ab62f2f commit 52642c8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/plugin-eslint/src/lib/nx.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']],
Expand All @@ -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),
);

Expand Down
15 changes: 15 additions & 0 deletions packages/plugin-eslint/src/lib/nx/utils.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand Down

0 comments on commit 52642c8

Please sign in to comment.