@codacy/tools-eslint-9 0.3.0 → 0.5.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/dist/index.js CHANGED
@@ -33,9 +33,10 @@ __export(index_exports, {
33
33
  default: () => index_default
34
34
  });
35
35
  module.exports = __toCommonJS(index_exports);
36
- var import_tooling = require("@codacy/tooling");
36
+ var import_tooling2 = require("@codacy/tooling");
37
37
 
38
38
  // src/adapter.ts
39
+ var import_tooling = require("@codacy/tooling");
39
40
  var import_path = __toESM(require("path"));
40
41
  var import_fs = __toESM(require("fs"));
41
42
 
@@ -25710,6 +25711,32 @@ function extractPluginPrefix(ruleId) {
25710
25711
  // src/config-builder.ts
25711
25712
  var TOOL_ID = "ESLint9";
25712
25713
  var PREFIX = `${TOOL_ID}_`;
25714
+ var CORE_TO_TS_EXTENSION = /* @__PURE__ */ new Map([
25715
+ ["class-methods-use-this", "@typescript-eslint/class-methods-use-this"],
25716
+ ["consistent-return", "@typescript-eslint/consistent-return"],
25717
+ ["default-param-last", "@typescript-eslint/default-param-last"],
25718
+ ["dot-notation", "@typescript-eslint/dot-notation"],
25719
+ ["init-declarations", "@typescript-eslint/init-declarations"],
25720
+ ["max-params", "@typescript-eslint/max-params"],
25721
+ ["no-array-constructor", "@typescript-eslint/no-array-constructor"],
25722
+ ["no-dupe-class-members", "@typescript-eslint/no-dupe-class-members"],
25723
+ ["no-empty-function", "@typescript-eslint/no-empty-function"],
25724
+ ["no-implied-eval", "@typescript-eslint/no-implied-eval"],
25725
+ ["no-invalid-this", "@typescript-eslint/no-invalid-this"],
25726
+ ["no-loop-func", "@typescript-eslint/no-loop-func"],
25727
+ ["no-loss-of-precision", "@typescript-eslint/no-loss-of-precision"],
25728
+ ["no-magic-numbers", "@typescript-eslint/no-magic-numbers"],
25729
+ ["no-redeclare", "@typescript-eslint/no-redeclare"],
25730
+ ["no-restricted-imports", "@typescript-eslint/no-restricted-imports"],
25731
+ ["no-shadow", "@typescript-eslint/no-shadow"],
25732
+ ["no-unused-expressions", "@typescript-eslint/no-unused-expressions"],
25733
+ ["no-unused-vars", "@typescript-eslint/no-unused-vars"],
25734
+ ["no-use-before-define", "@typescript-eslint/no-use-before-define"],
25735
+ ["no-useless-constructor", "@typescript-eslint/no-useless-constructor"],
25736
+ ["prefer-destructuring", "@typescript-eslint/prefer-destructuring"],
25737
+ ["prefer-promise-reject-errors", "@typescript-eslint/prefer-promise-reject-errors"],
25738
+ ["require-await", "@typescript-eslint/require-await"]
25739
+ ]);
25713
25740
  function decodePatternId(patternId) {
25714
25741
  if (!patternId.startsWith(PREFIX)) return patternId;
25715
25742
  const raw = patternId.slice(PREFIX.length);
@@ -25788,6 +25815,22 @@ async function buildESLintConfig(patterns) {
25788
25815
  }
25789
25816
  configs.push(configItem);
25790
25817
  }
25818
+ const tsOverrideRules = {};
25819
+ if (coreRules["no-undef"] !== void 0) {
25820
+ tsOverrideRules["no-undef"] = "off";
25821
+ }
25822
+ const enabledTsRuleIds = new Set(tsRules ? Object.keys(tsRules) : []);
25823
+ for (const [coreRule, tsRule] of CORE_TO_TS_EXTENSION) {
25824
+ if (coreRules[coreRule] !== void 0 && enabledTsRuleIds.has(tsRule)) {
25825
+ tsOverrideRules[coreRule] = "off";
25826
+ }
25827
+ }
25828
+ if (Object.keys(tsOverrideRules).length > 0) {
25829
+ configs.push({
25830
+ files: ["**/*.ts", "**/*.tsx"],
25831
+ rules: tsOverrideRules
25832
+ });
25833
+ }
25791
25834
  return configs;
25792
25835
  }
25793
25836
  function buildRuleValue(pattern) {
@@ -25828,6 +25871,18 @@ async function loadTsParser() {
25828
25871
  return mod.default?.parser ?? mod.parser;
25829
25872
  }
25830
25873
 
25874
+ // src/metadata.ts
25875
+ var descriptor = {
25876
+ id: "ESLint9",
25877
+ displayName: "ESLint 9",
25878
+ preferredVersion: "9.0.0",
25879
+ languages: ["Javascript", "TypeScript"],
25880
+ filePatterns: ["**/*.js", "**/*.jsx", "**/*.mjs", "**/*.cjs", "**/*.ts", "**/*.tsx"],
25881
+ supportedOS: ["linux", "darwin", "win32"],
25882
+ supportedArch: ["x64", "arm64"],
25883
+ supportedRunners: ["local", "container"]
25884
+ };
25885
+
25831
25886
  // src/adapter.ts
25832
25887
  var TOOL_ID2 = "ESLint9";
25833
25888
  var LOCAL_CONFIG_FILES = [
@@ -25861,16 +25916,9 @@ function readLine(filePath, lineNumber) {
25861
25916
  }
25862
25917
  }
25863
25918
  var adapter = {
25864
- id: TOOL_ID2,
25865
- displayName: "ESLint 9",
25866
- preferredVersion: "9.0.0",
25919
+ ...descriptor,
25867
25920
  compatibleVersions: ">=9.0.0 <10.0.0",
25868
25921
  website: "https://eslint.org",
25869
- languages: ["Javascript", "TypeScript"],
25870
- filePatterns: ["**/*.js", "**/*.jsx", "**/*.mjs", "**/*.cjs", "**/*.ts", "**/*.tsx"],
25871
- supportedOS: ["linux", "darwin", "win32"],
25872
- supportedArch: ["x64", "arm64"],
25873
- supportedRunners: ["local", "container"],
25874
25922
  prerequisites: [],
25875
25923
  /**
25876
25924
  * Verifies that the ESLint npm package is loadable and returns its version.
@@ -25933,7 +25981,7 @@ var adapter = {
25933
25981
  const absoluteFiles = ctx.targetFiles.map((f) => import_path.default.resolve(ctx.repositoryRoot, f));
25934
25982
  if (absoluteFiles.length === 0) {
25935
25983
  const completedAt2 = /* @__PURE__ */ new Date();
25936
- return buildResult(startedAt, completedAt2, issues, errors, ctx.targetFiles.length);
25984
+ return (0, import_tooling.buildResult)(TOOL_ID2, startedAt, completedAt2, issues, errors, ctx.targetFiles.length);
25937
25985
  }
25938
25986
  let ESLintClass;
25939
25987
  try {
@@ -25948,7 +25996,7 @@ var adapter = {
25948
25996
  message: `Failed to load eslint: ${err instanceof Error ? err.message : String(err)}`,
25949
25997
  level: "error"
25950
25998
  });
25951
- return buildResult(startedAt, completedAt2, issues, errors, ctx.targetFiles.length);
25999
+ return (0, import_tooling.buildResult)(TOOL_ID2, startedAt, completedAt2, issues, errors, ctx.targetFiles.length);
25952
26000
  }
25953
26001
  const eslintOptions = { cwd: ctx.repositoryRoot };
25954
26002
  if (codacyConfig.useLocalConfigurationFile && codacyConfig.localConfigurationFile) {
@@ -25966,13 +26014,13 @@ var adapter = {
25966
26014
  message: `Failed to build ESLint config: ${err instanceof Error ? err.message : String(err)}`,
25967
26015
  level: "error"
25968
26016
  });
25969
- return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
26017
+ return (0, import_tooling.buildResult)(TOOL_ID2, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
25970
26018
  }
25971
26019
  } else {
25972
26020
  ctx.logger.info("Skipping analysis: no local config and no patterns enabled", {
25973
26021
  toolId: TOOL_ID2
25974
26022
  });
25975
- return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
26023
+ return (0, import_tooling.buildResult)(TOOL_ID2, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
25976
26024
  }
25977
26025
  const enabledPatterns = new Set(codacyConfig.patterns.map((p) => p.patternId));
25978
26026
  try {
@@ -26023,29 +26071,9 @@ var adapter = {
26023
26071
  errorCount: errors.length,
26024
26072
  durationMs
26025
26073
  });
26026
- return buildResult(startedAt, completedAt, issues, errors, ctx.targetFiles.length);
26074
+ return (0, import_tooling.buildResult)(TOOL_ID2, startedAt, completedAt, issues, errors, ctx.targetFiles.length);
26027
26075
  }
26028
26076
  };
26029
- function buildResult(startedAt, completedAt, issues, errors, filesAnalyzed) {
26030
- const durationMs = completedAt.getTime() - startedAt.getTime();
26031
- return {
26032
- metadata: {
26033
- startedAt: startedAt.toISOString(),
26034
- completedAt: completedAt.toISOString(),
26035
- durationMs
26036
- },
26037
- issues,
26038
- errors,
26039
- summary: {
26040
- toolId: TOOL_ID2,
26041
- status: errors.some((e) => e.level === "error") ? "partial" : "success",
26042
- issueCount: issues.length,
26043
- errorCount: errors.length,
26044
- durationMs,
26045
- filesAnalyzed
26046
- }
26047
- };
26048
- }
26049
26077
 
26050
26078
  // src/index.ts
26051
- var index_default = (0, import_tooling.defineToolAdapter)(adapter);
26079
+ var index_default = (0, import_tooling2.defineToolAdapter)(adapter);
@@ -0,0 +1,13 @@
1
+ import { AdapterDescriptor } from '@codacy/tooling';
2
+
3
+ /**
4
+ * Lightweight adapter descriptor for lazy loading.
5
+ *
6
+ * This module contains only plain-data metadata fields and has zero heavy
7
+ * imports (no patterns.json, no runtime utilities). The CLI imports this
8
+ * at startup for adapter registration without loading the full adapter module.
9
+ */
10
+
11
+ declare const descriptor: AdapterDescriptor;
12
+
13
+ export { descriptor };
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/metadata.ts
21
+ var metadata_exports = {};
22
+ __export(metadata_exports, {
23
+ descriptor: () => descriptor
24
+ });
25
+ module.exports = __toCommonJS(metadata_exports);
26
+ var descriptor = {
27
+ id: "ESLint9",
28
+ displayName: "ESLint 9",
29
+ preferredVersion: "9.0.0",
30
+ languages: ["Javascript", "TypeScript"],
31
+ filePatterns: ["**/*.js", "**/*.jsx", "**/*.mjs", "**/*.cjs", "**/*.ts", "**/*.tsx"],
32
+ supportedOS: ["linux", "darwin", "win32"],
33
+ supportedArch: ["x64", "arm64"],
34
+ supportedRunners: ["local", "container"]
35
+ };
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ descriptor
39
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codacy/tools-eslint-9",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "ESLint 9 adapter — Library-mode JavaScript/TypeScript linter",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -79,7 +79,7 @@
79
79
  "eslint-plugin-wdio": "^9.0.0",
80
80
  "eslint-plugin-xss": "^0.1.0",
81
81
  "eslint-plugin-yml": "^1.0.0",
82
- "@codacy/tooling": "0.3.0"
82
+ "@codacy/tooling": "0.5.0"
83
83
  },
84
84
  "license": "MIT",
85
85
  "author": "Codacy <support@codacy.com> (https://www.codacy.com)",
@@ -92,8 +92,18 @@
92
92
  "engines": {
93
93
  "node": ">=20.0.0"
94
94
  },
95
+ "exports": {
96
+ ".": {
97
+ "types": "./dist/index.d.ts",
98
+ "default": "./dist/index.js"
99
+ },
100
+ "./metadata": {
101
+ "types": "./dist/metadata.d.ts",
102
+ "default": "./dist/metadata.js"
103
+ }
104
+ },
95
105
  "scripts": {
96
- "build": "tsup src/index.ts --format cjs --dts --clean",
106
+ "build": "tsup src/index.ts src/metadata.ts --format cjs --dts --clean",
97
107
  "test": "vitest run",
98
108
  "lint": "eslint src/",
99
109
  "clean": "rm -rf dist",