@code-pushup/eslint-plugin 0.18.0 → 0.19.0

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.
package/bin.js CHANGED
@@ -603,19 +603,6 @@ function compareIssueSeverity(severity1, severity2) {
603
603
  return levels[severity1] - levels[severity2];
604
604
  }
605
605
 
606
- // packages/utils/src/lib/git.ts
607
- import { simpleGit } from "simple-git";
608
- var git = simpleGit();
609
-
610
- // packages/utils/src/lib/progress.ts
611
- import chalk2 from "chalk";
612
- import { MultiProgressBars } from "multi-progress-bars";
613
-
614
- // packages/utils/src/lib/reports/generate-stdout-summary.ts
615
- import cliui from "@isaacs/cliui";
616
- import chalk3 from "chalk";
617
- import CliTable3 from "cli-table3";
618
-
619
606
  // packages/utils/src/lib/transform.ts
620
607
  function toArray(val) {
621
608
  return Array.isArray(val) ? val : [val];
@@ -632,16 +619,21 @@ function countOccurrences(values) {
632
619
  function distinct(array) {
633
620
  return [...new Set(array)];
634
621
  }
635
- function toUnixPath(path, options) {
636
- const unixPath = path.replace(/\\/g, "/");
637
- if (options?.toRelative) {
638
- return unixPath.replace(`${process.cwd().replace(/\\/g, "/")}/`, "");
639
- }
640
- return unixPath;
641
- }
622
+
623
+ // packages/utils/src/lib/git.ts
624
+ import { simpleGit } from "simple-git";
642
625
 
643
626
  // packages/utils/src/lib/logging.ts
627
+ import chalk2 from "chalk";
628
+
629
+ // packages/utils/src/lib/progress.ts
630
+ import chalk3 from "chalk";
631
+ import { MultiProgressBars } from "multi-progress-bars";
632
+
633
+ // packages/utils/src/lib/reports/generate-stdout-summary.ts
634
+ import cliui from "@isaacs/cliui";
644
635
  import chalk4 from "chalk";
636
+ import CliTable3 from "cli-table3";
645
637
 
646
638
  // packages/plugin-eslint/src/lib/setup.ts
647
639
  import { ESLint } from "eslint";
@@ -659,15 +651,9 @@ async function lint({
659
651
  patterns
660
652
  }) {
661
653
  const eslint = setupESLint(eslintrc);
662
- const lintResults = await eslint.lintFiles(patterns);
663
- const results = lintResults.map(
664
- (result) => ({
665
- ...result,
666
- relativeFilePath: toUnixPath(result.filePath, { toRelative: true })
667
- })
668
- );
654
+ const results = await eslint.lintFiles(patterns);
669
655
  const ruleOptionsPerFile = await results.reduce(
670
- async (acc, { filePath, relativeFilePath, messages }) => {
656
+ async (acc, { filePath, messages }) => {
671
657
  const filesMap = await acc;
672
658
  const config = await eslint.calculateConfigForFile(
673
659
  filePath
@@ -683,8 +669,8 @@ async function lint({
683
669
  );
684
670
  return {
685
671
  ...filesMap,
686
- [relativeFilePath]: {
687
- ...filesMap[relativeFilePath],
672
+ [filePath]: {
673
+ ...filesMap[filePath],
688
674
  ...rulesMap
689
675
  }
690
676
  };
@@ -713,14 +699,14 @@ function lintResultsToAudits({
713
699
  ruleOptionsPerFile
714
700
  }) {
715
701
  const issuesPerAudit = results.flatMap(
716
- ({ messages, relativeFilePath }) => messages.map((message) => ({ ...message, relativeFilePath }))
702
+ ({ messages, filePath }) => messages.map((message) => ({ ...message, filePath }))
717
703
  ).reduce((acc, issue) => {
718
- const { ruleId, message, relativeFilePath } = issue;
704
+ const { ruleId, message, filePath } = issue;
719
705
  if (!ruleId) {
720
706
  console.warn(`ESLint core error - ${message}`);
721
707
  return acc;
722
708
  }
723
- const options = ruleOptionsPerFile[relativeFilePath]?.[ruleId] ?? [];
709
+ const options = ruleOptionsPerFile[filePath]?.[ruleId] ?? [];
724
710
  const auditSlug = ruleIdToSlug(ruleId, options);
725
711
  return { ...acc, [auditSlug]: [...acc[auditSlug] ?? [], issue] };
726
712
  }, {});
@@ -748,7 +734,7 @@ function convertIssue(issue) {
748
734
  message: truncateIssueMessage(issue.message),
749
735
  severity: convertSeverity(issue.severity),
750
736
  source: {
751
- file: issue.relativeFilePath,
737
+ file: issue.filePath,
752
738
  position: {
753
739
  startLine: issue.line,
754
740
  startColumn: issue.column,
package/index.js CHANGED
@@ -5,7 +5,7 @@ import { fileURLToPath } from "node:url";
5
5
 
6
6
  // packages/plugin-eslint/package.json
7
7
  var name = "@code-pushup/eslint-plugin";
8
- var version = "0.18.0";
8
+ var version = "0.19.0";
9
9
 
10
10
  // packages/plugin-eslint/src/lib/config.ts
11
11
  import { z } from "zod";
@@ -606,19 +606,6 @@ function pluginWorkDir(slug) {
606
606
  return join("node_modules", ".code-pushup", slug);
607
607
  }
608
608
 
609
- // packages/utils/src/lib/git.ts
610
- import { simpleGit } from "simple-git";
611
- var git = simpleGit();
612
-
613
- // packages/utils/src/lib/progress.ts
614
- import chalk2 from "chalk";
615
- import { MultiProgressBars } from "multi-progress-bars";
616
-
617
- // packages/utils/src/lib/reports/generate-stdout-summary.ts
618
- import cliui from "@isaacs/cliui";
619
- import chalk3 from "chalk";
620
- import CliTable3 from "cli-table3";
621
-
622
609
  // packages/utils/src/lib/transform.ts
623
610
  function toArray(val) {
624
611
  return Array.isArray(val) ? val : [val];
@@ -630,8 +617,20 @@ function distinct(array) {
630
617
  return [...new Set(array)];
631
618
  }
632
619
 
620
+ // packages/utils/src/lib/git.ts
621
+ import { simpleGit } from "simple-git";
622
+
633
623
  // packages/utils/src/lib/logging.ts
624
+ import chalk2 from "chalk";
625
+
626
+ // packages/utils/src/lib/progress.ts
627
+ import chalk3 from "chalk";
628
+ import { MultiProgressBars } from "multi-progress-bars";
629
+
630
+ // packages/utils/src/lib/reports/generate-stdout-summary.ts
631
+ import cliui from "@isaacs/cliui";
634
632
  import chalk4 from "chalk";
633
+ import CliTable3 from "cli-table3";
635
634
 
636
635
  // packages/plugin-eslint/src/lib/meta/hash.ts
637
636
  import { createHash } from "node:crypto";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-pushup/eslint-plugin",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
4
4
  "license": "MIT",
5
5
  "dependencies": {
6
6
  "@code-pushup/utils": "*",
@@ -1,11 +1,8 @@
1
1
  import type { ESLint } from 'eslint';
2
2
  export type LinterOutput = {
3
- results: LintResult[];
3
+ results: ESLint.LintResult[];
4
4
  ruleOptionsPerFile: RuleOptionsPerFile;
5
5
  };
6
- export type LintResult = ESLint.LintResult & {
7
- relativeFilePath: string;
8
- };
9
6
  export type RuleOptionsPerFile = {
10
7
  [filePath: string]: {
11
8
  [ruleId: string]: unknown[];