@codacy/tools-eslint-9 0.10.1 → 0.12.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.
Files changed (2) hide show
  1. package/dist/index.js +27 -8
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -30757,6 +30757,11 @@ function removeRuleFromFlatConfig(config, ruleId) {
30757
30757
  function isParserServicesError(message) {
30758
30758
  return /requires parserServices|parserOptions\.project|requires type information/.test(message);
30759
30759
  }
30760
+ function isConfigLoadError(message) {
30761
+ return /Cannot find package|Cannot find module|ERR_MODULE_NOT_FOUND|ERR_REQUIRE_ESM|Failed to load config|Could not find config file|Cannot read config file/i.test(
30762
+ message
30763
+ );
30764
+ }
30760
30765
  function rulePluginPrefix(ruleId) {
30761
30766
  const slashIdx = ruleId.indexOf("/");
30762
30767
  if (slashIdx <= 0) return void 0;
@@ -30936,7 +30941,10 @@ var adapter = {
30936
30941
  return (0, import_tooling.buildResult)(TOOL_ID2, startedAt, completedAt2, issues, errors, ctx.targetFiles.length);
30937
30942
  }
30938
30943
  const eslintOptions = { cwd: ctx.repositoryRoot };
30939
- if (codacyConfig.useLocalConfigurationFile && codacyConfig.localConfigurationFile) {
30944
+ const usingLocalConfig = Boolean(
30945
+ codacyConfig.useLocalConfigurationFile && codacyConfig.localConfigurationFile
30946
+ );
30947
+ if (usingLocalConfig) {
30940
30948
  const projectESLint = await resolveProjectESLint(ctx.repositoryRoot);
30941
30949
  if (projectESLint) {
30942
30950
  ESLintClass = projectESLint.ESLintClass;
@@ -31160,13 +31168,24 @@ var adapter = {
31160
31168
  }
31161
31169
  }
31162
31170
  } catch (err) {
31163
- errors.push({
31164
- toolId: TOOL_ID2,
31165
- phase: "toolInvoke",
31166
- kind: "InvocationError",
31167
- message: `ESLint failed: ${err instanceof Error ? err.message : String(err)}`,
31168
- level: "error"
31169
- });
31171
+ const rawMessage = err instanceof Error ? err.message : String(err);
31172
+ if (usingLocalConfig && isConfigLoadError(rawMessage)) {
31173
+ errors.push({
31174
+ toolId: TOOL_ID2,
31175
+ phase: "toolConfig",
31176
+ kind: "ConfigLoadError",
31177
+ message: `Local ESLint configuration file "${codacyConfig.localConfigurationFile}" failed to load. This usually means the config imports plugins or presets that are not installed in the project (install the project's dependencies, e.g. \`npm install\` or \`pnpm install\`, and try again), or the config file is missing or unreadable. Underlying error: ${truncateForError(rawMessage)}`,
31178
+ level: "error"
31179
+ });
31180
+ } else {
31181
+ errors.push({
31182
+ toolId: TOOL_ID2,
31183
+ phase: "toolInvoke",
31184
+ kind: "InvocationError",
31185
+ message: `ESLint failed: ${rawMessage}`,
31186
+ level: "error"
31187
+ });
31188
+ }
31170
31189
  }
31171
31190
  const completedAt = /* @__PURE__ */ new Date();
31172
31191
  const durationMs = Date.now() - startMs;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codacy/tools-eslint-9",
3
- "version": "0.10.1",
3
+ "version": "0.12.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.10.1"
82
+ "@codacy/tooling": "0.12.0"
83
83
  },
84
84
  "license": "MIT",
85
85
  "author": "Codacy <support@codacy.com> (https://www.codacy.com)",