@code-pushup/eslint-plugin 0.79.1 → 0.79.2-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +144 -1
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -226,6 +226,149 @@ export default {
226
226
 
227
227
  2. Run the CLI with `npx code-pushup collect` and view or upload report (refer to [CLI docs](../cli/README.md)).
228
228
 
229
+ ## Artifacts generation and loading
230
+
231
+ In addition to running ESLint from the plugin implementation, you can configure the plugin to consume pre-generated ESLint reports (artifacts). This is particularly useful for:
232
+
233
+ - **CI/CD pipelines**: Use cached lint results from your build system
234
+ - **Monorepo setups**: Aggregate results from multiple projects or targets
235
+ - **Performance optimization**: Skip ESLint execution when reports are already available
236
+ - **Custom workflows**: Integrate with existing linting infrastructure
237
+
238
+ The artifacts feature supports loading ESLint JSON reports that follow the standard `ESLint.LintResult[]` format.
239
+
240
+ ### Basic artifact configuration
241
+
242
+ Specify the path(s) to your ESLint JSON report files:
243
+
244
+ ```js
245
+ import eslintPlugin from '@code-pushup/eslint-plugin';
246
+
247
+ export default {
248
+ plugins: [
249
+ await eslintPlugin({
250
+ artifacts: {
251
+ artifactsPaths: './eslint-report.json',
252
+ },
253
+ }),
254
+ ],
255
+ };
256
+ ```
257
+
258
+ ### Multiple artifact files
259
+
260
+ Use glob patterns to aggregate results from multiple files:
261
+
262
+ ```js
263
+ export default {
264
+ plugins: [
265
+ await eslintPlugin({
266
+ artifacts: {
267
+ artifactsPaths: ['packages/**/eslint-report.json', 'apps/**/.eslint/*.json'],
268
+ },
269
+ }),
270
+ ],
271
+ };
272
+ ```
273
+
274
+ ### Generate artifacts with custom command
275
+
276
+ If you need to generate the artifacts before loading them, use the `generateArtifactsCommand` option:
277
+
278
+ ```js
279
+ export default {
280
+ plugins: [
281
+ await eslintPlugin({
282
+ artifacts: {
283
+ generateArtifactsCommand: 'npm run lint:report',
284
+ artifactsPaths: './eslint-report.json',
285
+ },
286
+ }),
287
+ ],
288
+ };
289
+ ```
290
+
291
+ You can also specify the command with arguments:
292
+
293
+ ```js
294
+ export default {
295
+ plugins: [
296
+ await eslintPlugin({
297
+ artifacts: {
298
+ generateArtifactsCommand: {
299
+ command: 'eslint',
300
+ args: ['src/**/*.{js,ts}', '--format=json', '--output-file=eslint-report.json'],
301
+ },
302
+ artifactsPaths: './eslint-report.json',
303
+ },
304
+ }),
305
+ ],
306
+ };
307
+ ```
308
+
229
309
  ## Nx Monorepo Setup
230
310
 
231
- Find all details in our [Nx setup guide](https://github.com/code-pushup/cli/wiki/Code-PushUp-integration-guide-for-Nx-monorepos#eslint-config).
311
+ ### Caching artifact generation
312
+
313
+ To leverage Nx's caching capabilities, you need to generate a JSON artifact for caching, while still being able to see the ESLint violations in the terminal or CI logs, so you can fix them.
314
+ This can be done by leveraging eslint formatter.
315
+
316
+ _lint target from nx.json_
317
+
318
+ ```json
319
+ {
320
+ "lint": {
321
+ "inputs": ["lint-eslint-inputs"],
322
+ "outputs": ["{projectRoot}/.eslint/**/*"],
323
+ "cache": true,
324
+ "executor": "nx:run-commands",
325
+ "options": {
326
+ "command": "eslint",
327
+ "args": ["{projectRoot}/**/*.ts", "{projectRoot}/package.json", "--config={projectRoot}/eslint.config.js", "--max-warnings=0", "--no-warn-ignored", "--error-on-unmatched-pattern=false", "--format=@code-pushup/eslint-formatter-multi"],
328
+ "env": {
329
+ "ESLINT_FORMATTER_CONFIG": "{\"outputDir\":\"{projectRoot}/.eslint\"}"
330
+ }
331
+ }
332
+ }
333
+ }
334
+ ```
335
+
336
+ As you can now generate the `eslint-report.json` from cache your plugin configuration can directly consume them.
337
+
338
+ _code-pushup.config.ts target from nx.json_
339
+
340
+ ```jsonc
341
+ {
342
+ "code-pushup": {
343
+ "dependsOn": ["lint"],
344
+ // also multiple targets can be merged into one report
345
+ // "dependsOn": ["lint", "lint-next"],
346
+ "executor": "nx:run-commands",
347
+ "options": {
348
+ "command": "npx code-pushup",
349
+ },
350
+ },
351
+ }
352
+ ```
353
+
354
+ and the project configuration leverages `dependsOn` to ensure the artefacts are generated when running code-pushup.
355
+
356
+ Your `code-pushup.config.ts` can then be configured to consume the cached artifacts:
357
+
358
+ ```js
359
+ import eslintPlugin from '@code-pushup/eslint-plugin';
360
+
361
+ export default {
362
+ plugins: [
363
+ await eslintPlugin({
364
+ artifacts: {
365
+ artifactsPaths: 'packages/**/.eslint/eslint-report-*.json',
366
+ },
367
+ }),
368
+ ],
369
+ };
370
+ ```
371
+
372
+ ---
373
+
374
+ Find more details in our [Nx setup guide](https://github.com/code-pushup/cli/wiki/Code-PushUp-integration-guide-for-Nx-monorepos#eslint-config).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-pushup/eslint-plugin",
3
- "version": "0.79.1",
3
+ "version": "0.79.2-alpha.1",
4
4
  "license": "MIT",
5
5
  "description": "Code PushUp plugin for detecting problems in source code using ESLint.📋",
6
6
  "homepage": "https://github.com/code-pushup/cli/tree/main/packages/plugin-eslint#readme",
@@ -39,8 +39,8 @@
39
39
  "type": "module",
40
40
  "dependencies": {
41
41
  "glob": "^11.0.0",
42
- "@code-pushup/utils": "0.79.1",
43
- "@code-pushup/models": "0.79.1",
42
+ "@code-pushup/utils": "0.79.2-alpha.1",
43
+ "@code-pushup/models": "0.79.2-alpha.1",
44
44
  "zod": "^4.0.5"
45
45
  },
46
46
  "peerDependencies": {