Skip to content

Commit

Permalink
feat: telemetry added for current linter (appsmithorg#36400)
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushpahwa authored and Shivam-z committed Sep 26, 2024
1 parent f9e2986 commit 2e43edf
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions app/client/src/plugins/Linting/utils/getLintingErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ import setters from "workers/Evaluation/setters";
import { isMemberExpressionNode } from "@shared/ast/src";
import { generate } from "astring";
import getInvalidModuleInputsError from "ee/plugins/Linting/utils/getInvalidModuleInputsError";
import { startAndEndSpanForFn } from "UITelemetry/generateTraces";
import { objectKeys } from "@appsmith/utils";

const EvaluationScriptPositions: Record<string, Position> = {};

Expand Down Expand Up @@ -67,7 +69,7 @@ function generateLintingGlobalData(data: Record<string, unknown>) {

libAccessors.forEach((accessor) => (globalData[accessor] = true));
// Add all supported web apis
Object.keys(SUPPORTED_WEB_APIS).forEach(
objectKeys(SUPPORTED_WEB_APIS).forEach(
(apiName) => (globalData[apiName] = true),
);

Expand Down Expand Up @@ -195,7 +197,16 @@ export default function getLintingErrors({
const lintingGlobalData = generateLintingGlobalData(data);
const lintingOptions = lintOptions(lintingGlobalData);

jshint(script, lintingOptions);
startAndEndSpanForFn(
"Linter",
// adding some metrics to compare the performance changes with eslint
{
linter: "JSHint",
linesOfCodeLinted: originalBinding.split("\n").length,
codeSizeInChars: originalBinding.length,
},
() => jshint(script, lintingOptions),
);
const sanitizedJSHintErrors = sanitizeJSHintErrors(jshint.errors, scriptPos);
const jshintErrors: LintError[] = sanitizedJSHintErrors.map((lintError) =>
convertJsHintErrorToAppsmithLintError(
Expand Down

0 comments on commit 2e43edf

Please sign in to comment.