Skip to content

Commit 25bda11

Browse files
committed
feat(plugin-eslint): include NPM package name and version
1 parent 53c8f60 commit 25bda11

File tree

3 files changed

+27
-11
lines changed

3 files changed

+27
-11
lines changed

packages/plugin-eslint/src/lib/__snapshots__/eslint-plugin.spec.ts.snap

+4
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ Custom options:
437437
],
438438
"description": "Official Code PushUp ESLint plugin",
439439
"icon": "eslint",
440+
"packageName": "@code-pushup/eslint-plugin",
440441
"runner": {
441442
"args": [
442443
"eslint",
@@ -451,6 +452,7 @@ Custom options:
451452
},
452453
"slug": "eslint",
453454
"title": "ESLint",
455+
"version": "0.0.1",
454456
}
455457
`;
456458
@@ -742,6 +744,7 @@ exports[`eslintPlugin > should initialize ESLint plugin for React application 1`
742744
],
743745
"description": "Official Code PushUp ESLint plugin",
744746
"icon": "eslint",
747+
"packageName": "@code-pushup/eslint-plugin",
745748
"runner": {
746749
"args": [
747750
"eslint",
@@ -756,5 +759,6 @@ exports[`eslintPlugin > should initialize ESLint plugin for React application 1`
756759
},
757760
"slug": "eslint",
758761
"title": "ESLint",
762+
"version": "0.0.1",
759763
}
760764
`;

packages/plugin-eslint/src/lib/eslint-plugin.spec.ts

+12-10
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,21 @@ describe('eslintPlugin', () => {
2424

2525
it('should initialize ESLint plugin for React application', async () => {
2626
cwdSpy.mockReturnValue(join(fixturesDir, 'todos-app'));
27-
const plugin = await eslintPlugin({
28-
eslintrc: '.eslintrc.js',
29-
patterns: ['src/**/*.js', 'src/**/*.jsx'],
30-
});
31-
expect(plugin).toMatchSnapshot();
27+
await expect(
28+
eslintPlugin({
29+
eslintrc: '.eslintrc.js',
30+
patterns: ['src/**/*.js', 'src/**/*.jsx'],
31+
}),
32+
).resolves.toMatchSnapshot();
3233
});
3334

3435
it('should initialize ESLint plugin for Nx project', async () => {
3536
cwdSpy.mockReturnValue(join(fixturesDir, 'nx-monorepo'));
36-
const plugin = await eslintPlugin({
37-
eslintrc: './packages/utils/.eslintrc.json',
38-
patterns: ['packages/utils/**/*.ts', 'packages/utils/**/*.json'],
39-
});
40-
expect(plugin).toMatchSnapshot();
37+
await expect(
38+
eslintPlugin({
39+
eslintrc: './packages/utils/.eslintrc.json',
40+
patterns: ['packages/utils/**/*.ts', 'packages/utils/**/*.json'],
41+
}),
42+
).resolves.toMatchSnapshot();
4143
});
4244
});

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

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { PluginConfig } from '@quality-metrics/models';
22
import { toArray } from '@quality-metrics/utils';
33
import { ESLint } from 'eslint';
4+
import { name, version } from '../../package.json';
45
import { listAudits } from './meta/audits';
56

67
export type ESLintPluginConfig = {
@@ -24,8 +25,17 @@ export async function eslintPlugin({
2425
title: 'ESLint',
2526
icon: 'eslint',
2627
description: 'Official Code PushUp ESLint plugin',
27-
// TODO: docsUrl (package README)
28+
// TODO: docsUrl (package README, once published)
29+
packageName: name,
30+
version,
31+
2832
audits,
33+
34+
// TODO: groups?
35+
// - could be `problem`/`suggestion`/`layout` if based on `meta.type`
36+
// - `meta.category` (deprecated, but still used by some) could also be a source of groups
37+
38+
// TODO: implement actual runner which converts results to audits: https://github.com/flowup/quality-metrics-cli/issues/27
2939
runner: {
3040
command: 'npx',
3141
args: [

0 commit comments

Comments
 (0)