Skip to content

Commit

Permalink
feat(linter): add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
meeroslav committed Nov 23, 2023
1 parent 38b6188 commit ebe48e5
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions packages/eslint/src/generators/lint-project/lint-project.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
import { Linter } from '../utils/linter';
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
import { lintProjectGenerator } from './lint-project';
import { eslintVersion } from '../../utils/versions';

describe('@nx/eslint:lint-project', () => {
let tree: Tree;
Expand Down Expand Up @@ -221,4 +222,31 @@ describe('@nx/eslint:lint-project', () => {
analyzeSourceFiles: true,
});
});

it('should extend root config', async () => {
await lintProjectGenerator(tree, {
...defaultOptions,
linter: Linter.EsLint,
eslintFilePatterns: ['libs/test-lib/**/*.ts'],
project: 'test-lib',
setParserOptionsProject: false,
});

const eslintConfig = readJson(tree, 'libs/test-lib/.eslintrc.json');
expect(eslintConfig.extends).toBeDefined();
});

it('should not extend root config if rootProject is set', async () => {
await lintProjectGenerator(tree, {
...defaultOptions,
linter: Linter.EsLint,
eslintFilePatterns: ['libs/test-lib/**/*.ts'],
project: 'test-lib',
setParserOptionsProject: false,
rootProject: true,
});

const eslintConfig = readJson(tree, 'libs/test-lib/.eslintrc.json');
expect(eslintConfig.extends).toBeUndefined();
});
});

0 comments on commit ebe48e5

Please sign in to comment.