Merge pull request #3212 from github/koesie10/eslint-rules

Remove more ESLint rule overrides
This commit is contained in:
Koen Vlaswinkel
2024-01-09 11:31:10 +01:00
committed by GitHub
8 changed files with 14 additions and 18 deletions

View File

@@ -47,17 +47,12 @@ const baseConfig = {
"@typescript-eslint/no-throw-literal": "error",
"@typescript-eslint/consistent-type-imports": "error",
"import/consistent-type-specifier-style": ["error", "prefer-top-level"],
"no-useless-escape": 0,
camelcase: "off",
curly: ["error", "all"],
"escompat/no-regexp-lookbehind": "off",
"etc/no-implicit-any-catch": "error",
"filenames/match-regex": "off",
"filenames/match-regexp": "off",
"func-style": "off",
"i18n-text/no-en": "off",
"no-invalid-this": "off",
"no-fallthrough": "off",
"no-console": "off",
"no-shadow": "off",
"github/array-foreach": "off",

View File

@@ -1526,7 +1526,7 @@ export class CodeQLCliServer implements Disposable {
const distribution = await this.distributionProvider.getDistribution();
switch (distribution.kind) {
case FindDistributionResultKind.CompatibleDistribution:
// eslint-disable-next-line no-fallthrough -- Intentional fallthrough
case FindDistributionResultKind.IncompatibleDistribution:
return distribution.version;

View File

@@ -27,26 +27,26 @@ export function assertNever(value: never): never {
/**
* Use to perform array filters where the predicate is asynchronous.
*/
export const asyncFilter = async function <T>(
export async function asyncFilter<T>(
arr: T[],
predicate: (arg0: T) => Promise<boolean>,
) {
const results = await Promise.all(arr.map(predicate));
return arr.filter((_, index) => results[index]);
};
}
/**
* This regex matches strings of the form `owner/repo` where:
* - `owner` is made up of alphanumeric characters, hyphens, underscores, or periods
* - `repo` is made up of alphanumeric characters, hyphens, underscores, or periods
*/
export const REPO_REGEX = /^[a-zA-Z0-9-_\.]+\/[a-zA-Z0-9-_\.]+$/;
export const REPO_REGEX = /^[a-zA-Z0-9-_.]+\/[a-zA-Z0-9-_.]+$/;
/**
* This regex matches GiHub organization and user strings. These are made up for alphanumeric
* characters, hyphens, underscores or periods.
*/
export const OWNER_REGEX = /^[a-zA-Z0-9-_\.]+$/;
export const OWNER_REGEX = /^[a-zA-Z0-9-_.]+$/;
export function getErrorMessage(e: unknown): string {
if (e instanceof RedactableError) {

View File

@@ -47,7 +47,7 @@ export function parseSarifPlainTextMessage(
// Technically we could have any uri in the target but we don't output that yet.
// The possibility of escaping outside the link is not mentioned in the sarif spec but we always output sartif this way.
const linkRegex =
/(?<=(?<!\\)(\\\\)*)\[(?<linkText>([^\\\]\[]|\\\\|\\\]|\\\[)*)\]\((?<linkTarget>[0-9]+)\)/g;
/(?<=(?<!\\)(\\\\)*)\[(?<linkText>([^\\\][]|\\\\|\\\]|\\\[)*)\]\((?<linkTarget>[0-9]+)\)/g;
let result: RegExpExecArray | null;
let curIndex = 0;
while ((result = linkRegex.exec(message)) !== null) {

View File

@@ -607,11 +607,11 @@ async function getDistributionDisplayingDistributionWarnings(
case DistributionKind.ExtensionManaged:
return 'Please update the CodeQL CLI by running the "CodeQL: Check for CLI Updates" command.';
case DistributionKind.CustomPathConfig:
return `Please update the \"CodeQL CLI Executable Path\" setting to point to a CLI in the version range ${codeQlVersionRange}.`;
return `Please update the "CodeQL CLI Executable Path" setting to point to a CLI in the version range ${codeQlVersionRange}.`;
case DistributionKind.PathEnvironmentVariable:
return (
`Please update the CodeQL CLI on your PATH to a version compatible with ${codeQlVersionRange}, or ` +
`set the \"CodeQL CLI Executable Path\" setting to the path of a CLI version compatible with ${codeQlVersionRange}.`
`set the "CodeQL CLI Executable Path" setting to the path of a CLI version compatible with ${codeQlVersionRange}.`
);
}
})();

View File

@@ -18,7 +18,7 @@ export function install() {
langConfig.wordPattern = new RegExp(langConfig.wordPattern);
langConfig.onEnterRules = onEnterRules;
langConfig.indentationRules = {
decreaseIndentPattern: /^((?!.*?\/\*).*\*\/)?\s*[\}\]].*$/,
decreaseIndentPattern: /^((?!.*?\/\*).*\*\/)?\s*[}\]].*$/,
increaseIndentPattern: /^((?!\/\/).)*(\{[^}"'`]*|\([^)"'`]*|\[[^\]"'`]*)$/,
};
delete langConfig.autoClosingPairs;
@@ -31,18 +31,18 @@ export function install() {
const onEnterRules: OnEnterRule[] = [
{
// e.g. /** | */
beforeText: /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/,
beforeText: /^\s*\/\*\*(?!\/)([^*]|\*(?!\/))*$/,
afterText: /^\s*\*\/$/,
action: { indentAction: IndentAction.IndentOutdent, appendText: " * " },
},
{
// e.g. /** ...|
beforeText: /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/,
beforeText: /^\s*\/\*\*(?!\/)([^*]|\*(?!\/))*$/,
action: { indentAction: IndentAction.None, appendText: " * " },
},
{
// e.g. * ...|
beforeText: /^(\t|[ ])*[ ]\*([ ]([^\*]|\*(?!\/))*)?$/,
beforeText: /^(\t|[ ])*[ ]\*([ ]([^*]|\*(?!\/))*)?$/,
// oneLineAboveText: /^(\s*(\/\*\*|\*)).*/,
action: { indentAction: IndentAction.None, appendText: "* " },
},

View File

@@ -356,7 +356,7 @@ async function exportToLocalMarkdown(
// This needs to use .then to ensure we aren't keeping the progress notification open. We shouldn't await the
// "Open exported results" button click.
void showInformationMessageWithAction(
`Variant analysis results exported to \"${exportedResultsPath}\".`,
`Variant analysis results exported to "${exportedResultsPath}".`,
"Open exported results",
).then(async (shouldOpenExportedResults) => {
if (!shouldOpenExportedResults) {

View File

@@ -2,6 +2,7 @@ import { expect } from "@jest/globals";
import type { MatcherFunction } from "expect";
import { pathsEqual } from "../../src/common/files";
// eslint-disable-next-line func-style -- We need to set the type of this function
const toEqualPath: MatcherFunction<[expectedPath: unknown]> = function (
actual,
expectedPath,