Skip to content

Commit ecd8264

Browse files
committed
fix(plugin-eslint): revert to explicit config file in nx helper
1 parent 74241e8 commit ecd8264

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

packages/plugin-eslint/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Detected ESLint rules are mapped to Code PushUp audits. Audit reports are calcul
4343
4444
4. Add this plugin to the `plugins` array in your Code PushUp CLI config file (e.g. `code-pushup.config.js`).
4545

46-
Pass in the glob patterns for which files you wish to target (relative to `process.cwd()`).
46+
Pass in the path to your ESLint config file, along with glob patterns for which files you wish to target (relative to `process.cwd()`).
4747

4848
```js
4949
import eslintPlugin from '@code-pushup/eslint-plugin';
@@ -52,7 +52,7 @@ Detected ESLint rules are mapped to Code PushUp audits. Audit reports are calcul
5252
// ...
5353
plugins: [
5454
// ...
55-
await eslintPlugin(['src/**/*.js']),
55+
await eslintPlugin({ eslintrc: '.eslintrc.js', patterns: ['src/**/*.js'] }),
5656
],
5757
};
5858
```

packages/plugin-eslint/src/lib/nx.integration.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ describe('Nx helpers', () => {
4242
it('should include eslintrc and patterns of each project', async () => {
4343
await expect(eslintConfigFromAllNxProjects()).resolves.toEqual([
4444
{
45+
eslintrc: './packages/cli/.eslintrc.json',
4546
patterns: [
4647
'packages/cli/**/*.ts',
4748
'packages/cli/package.json',
@@ -52,6 +53,7 @@ describe('Nx helpers', () => {
5253
],
5354
},
5455
{
56+
eslintrc: './packages/core/.eslintrc.json',
5557
patterns: [
5658
'packages/core/**/*.ts',
5759
'packages/core/package.json',
@@ -62,6 +64,7 @@ describe('Nx helpers', () => {
6264
],
6365
},
6466
{
67+
eslintrc: './packages/nx-plugin/.eslintrc.json',
6568
patterns: [
6669
'packages/nx-plugin/**/*.ts',
6770
'packages/nx-plugin/package.json',
@@ -73,6 +76,7 @@ describe('Nx helpers', () => {
7376
],
7477
},
7578
{
79+
eslintrc: './packages/utils/.eslintrc.json',
7680
patterns: [
7781
'packages/utils/**/*.ts',
7882
'packages/utils/package.json',
@@ -114,6 +118,7 @@ describe('Nx helpers', () => {
114118
expect(targets).toEqual(
115119
expectedProjects.map(
116120
(p): ESLintTarget => ({
121+
eslintrc: `./packages/${p}/.eslintrc.json`,
117122
patterns: expect.arrayContaining([`packages/${p}/**/*.ts`]),
118123
}),
119124
),
@@ -143,6 +148,7 @@ describe('Nx helpers', () => {
143148
const targets = await eslintConfigFromNxProject(project);
144149

145150
expect(targets).toEqual({
151+
eslintrc: `./packages/${project}/.eslintrc.json`,
146152
patterns: expect.arrayContaining([`packages/${project}/**/*.ts`]),
147153
});
148154
},

packages/plugin-eslint/src/lib/nx/projects-to-config.unit.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,15 @@ describe('nxProjectsToConfig', () => {
6868

6969
expect(config).toEqual<ESLintPluginConfig>([
7070
{
71+
eslintrc: './apps/client/.eslintrc.json',
7172
patterns: expect.arrayContaining(['apps/client/**/*.ts']),
7273
},
7374
{
75+
eslintrc: './apps/server/.eslintrc.json',
7476
patterns: expect.arrayContaining(['apps/server/**/*.ts']),
7577
},
7678
{
79+
eslintrc: './libs/models/.eslintrc.json',
7780
patterns: expect.arrayContaining(['libs/models/**/*.ts']),
7881
},
7982
]);
@@ -105,6 +108,7 @@ describe('nxProjectsToConfig', () => {
105108

106109
expect(config).toEqual<ESLintPluginConfig>([
107110
{
111+
eslintrc: './libs/models/.eslintrc.json',
108112
patterns: expect.arrayContaining(['libs/models/**/*.ts']),
109113
},
110114
]);
@@ -146,9 +150,11 @@ describe('nxProjectsToConfig', () => {
146150

147151
expect(config).toEqual<ESLintPluginConfig>([
148152
{
153+
eslintrc: './apps/client/.eslintrc.json',
149154
patterns: expect.arrayContaining(['apps/client/**/*.ts']),
150155
},
151156
{
157+
eslintrc: './apps/server/.eslintrc.json',
152158
patterns: expect.arrayContaining(['apps/server/**/*.ts']),
153159
},
154160
]);
@@ -212,12 +218,14 @@ describe('nxProjectsToConfig', () => {
212218

213219
await expect(nxProjectsToConfig(projectGraph)).resolves.toEqual([
214220
{
221+
eslintrc: './apps/client/.eslintrc.json',
215222
patterns: expect.arrayContaining([
216223
'apps/client/**/*.ts',
217224
'apps/client/**/*.html',
218225
]),
219226
},
220227
{
228+
eslintrc: './apps/server/.eslintrc.json',
221229
patterns: expect.arrayContaining(['apps/server/**/*.ts']),
222230
},
223231
] satisfies ESLintPluginConfig);

packages/plugin-eslint/src/lib/nx/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ export function getEslintConfig(
3535
const options = project.targets?.['lint']?.options as
3636
| { eslintConfig?: string }
3737
| undefined;
38-
return options?.eslintConfig;
38+
return options?.eslintConfig ?? `./${project.root}/.eslintrc.json`;
3939
}

0 commit comments

Comments
 (0)