MCPcopy Index your code
hub / github.com/code-pushup/cli / getLintFilePatterns

Function getLintFilePatterns

packages/plugin-eslint/src/lib/nx/utils.ts:56–85  ·  view source on GitHub ↗
(
  project: ProjectConfiguration,
  format: ConfigFormat,
)

Source from the content-addressed store, hash-verified

54}
55
56export function getLintFilePatterns(
57 project: ProjectConfiguration,
58 format: ConfigFormat,
59): string[] {
60 const options = project.targets?.['lint']?.options as
61 | { lintFilePatterns?: string | string[] }
62 | undefined;
63 // lintFilePatterns defaults to ["{projectRoot}"] - https://github.com/nrwl/nx/pull/20313
64 const defaultPatterns =
65 format === 'legacy'
66 ? `${project.root}/**/*` // files not folder needed for legacy because rules detected with ESLint.calculateConfigForFile
67 : project.root;
68 const patterns =
69 options?.lintFilePatterns == null
70 ? [defaultPatterns]
71 : toArray(options.lintFilePatterns);
72 if (format === 'legacy') {
73 return [
74 ...patterns,
75 // HACK: ESLint.calculateConfigForFile won't find rules included only for subsets of *.ts when globs used
76 // so we explicitly provide additional patterns used by @code-pushup/eslint-config to ensure those rules are included
77 // this workaround is only necessary for legacy configs (rules are detected more reliably in flat configs)
78 `${project.root}/*.spec.ts`, // jest/* and vitest/* rules
79 `${project.root}/*.cy.ts`, // cypress/* rules
80 `${project.root}/*.stories.ts`, // storybook/* rules
81 `${project.root}/.storybook/main.ts`, // storybook/no-uninstalled-addons rule
82 ];
83 }
84 return patterns;
85}
86
87async function findProjectFile(
88 project: ProjectConfiguration,

Callers 2

nxProjectsToConfigFunction · 0.85
utils.unit.test.tsFile · 0.85

Calls 1

toArrayFunction · 0.90

Tested by

no test coverage detected