AriPerkkio / eslint-remote-tester

CLI tool for testing given ESlint rules against multiple repositories at once.

Home Page:https://www.npmjs.com/package/eslint-remote-tester

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Slow lint warnings: disable by default, allow enabling by config

AriPerkkio opened this issue · comments

Currently when a file takes more than 5 seconds to lint, a warning is logged. This is considered as "slow lint". While this may be useful for rule development, it is causing false positives and verbose logging when testing rule configurations. Rule configurations typically have multiple rules enabled.

const MAX_LINT_TIME_SECONDS = 5;

result = await executionTimeWarningWrapper(
() => linter.lintFiles(path),
// Warn about files taking more than 5s to lint
// Useful to identify minified files committed to remote
lintTime =>
postMessage({
type: 'FILE_LINT_SLOW',
payload: { path, lintTime },
}),
MAX_LINT_TIME_SECONDS
);

/**
* Log warning about slow linting
*/
onFileLintSlow(repository: string, lintTime: number, file: string) {
const isNewWarning = this.addWarningToTask(repository, file);
if (isNewWarning) {
this.addNewMessage({
content: Templates.LINT_SLOW_TEMPLATE(lintTime, file),
color: 'yellow',
level: 'warn',
});
}
}

export const LINT_SLOW_TEMPLATE = (lintTime: number, file: string): string => {
const path = file.replace(`${CACHE_LOCATION}/`, '').split('/');
const fileName = path.pop();
return `[WARN] Linting ${fileName} took ${lintTime}s at ${path.join('/')}`;
};

  • Disable slow lint warnings by default.
  • Allow users to enable slow lint warnings throught eslint-remote-tester.config.ts.
  • The default value should be null. Allowed values are numbers.
  • The current log level "warning" is preserved. No changes here.