Skip to content

Commit

Permalink
fix(react): setParserOptionsProject option should be respected (#15937)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashley-hunter committed Mar 29, 2023
1 parent c4a2388 commit 8fd5bcf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/react/src/generators/library/lib/add-linting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export async function addLinting(host: Tree, options: NormalizedSchema) {
eslintFilePatterns: [`${options.projectRoot}/**/*.{ts,tsx,js,jsx}`],
skipFormat: true,
skipPackageJson: options.skipPackageJson,
setParserOptionsProject: options.setParserOptionsProject,
});

updateJson(
Expand Down
15 changes: 15 additions & 0 deletions packages/react/src/generators/library/library.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,21 @@ describe('lib', () => {
});
});

describe('--setParserOptionsProject', () => {
it('should set the parserOptions.project in the eslintrc.json file', async () => {
await libraryGenerator(tree, {
...defaultSchema,
setParserOptionsProject: true,
});

const eslintConfig = readJson(tree, 'libs/my-lib/.eslintrc.json');

expect(eslintConfig.overrides[0].parserOptions.project).toEqual([
'libs/my-lib/tsconfig.*?.json',
]);
});
});

it.each`
style
${'styled-components'}
Expand Down

0 comments on commit 8fd5bcf

Please sign in to comment.