Merge pull request #3275 from github/nora/add-eslint-deprecation
Start using eslint-plugin-deprecation to find deprecated code
This commit is contained in:
@@ -28,6 +28,7 @@ const baseConfig = {
|
||||
"plugin:@typescript-eslint/recommended",
|
||||
"plugin:import/recommended",
|
||||
"plugin:import/typescript",
|
||||
"plugin:deprecation/recommended",
|
||||
],
|
||||
rules: {
|
||||
"@typescript-eslint/await-thenable": "error",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import * as React from "react";
|
||||
import { addons, types } from "@storybook/manager-api";
|
||||
import { addons } from "@storybook/manager-api";
|
||||
import { Addon_TypesEnum } from "@storybook/types";
|
||||
import { ThemeSelector } from "./ThemeSelector";
|
||||
|
||||
const ADDON_ID = "vscode-theme-addon";
|
||||
@@ -7,7 +8,7 @@ const ADDON_ID = "vscode-theme-addon";
|
||||
addons.register(ADDON_ID, () => {
|
||||
addons.add(ADDON_ID, {
|
||||
title: "VSCode Themes",
|
||||
type: types.TOOL,
|
||||
type: Addon_TypesEnum.TOOL,
|
||||
match: ({ viewMode }) => !!(viewMode && viewMode.match(/^(story|docs)$/)),
|
||||
render: () => <ThemeSelector />,
|
||||
});
|
||||
|
||||
16
extensions/ql-vscode/package-lock.json
generated
16
extensions/ql-vscode/package-lock.json
generated
@@ -106,6 +106,7 @@
|
||||
"eslint": "^8.56.0",
|
||||
"eslint-config-prettier": "^9.0.0",
|
||||
"eslint-import-resolver-typescript": "^3.6.1",
|
||||
"eslint-plugin-deprecation": "^2.0.0",
|
||||
"eslint-plugin-etc": "^2.0.2",
|
||||
"eslint-plugin-github": "^4.4.1",
|
||||
"eslint-plugin-import": "^2.29.1",
|
||||
@@ -15664,6 +15665,21 @@
|
||||
"ms": "^2.1.1"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-deprecation": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint-plugin-deprecation/-/eslint-plugin-deprecation-2.0.0.tgz",
|
||||
"integrity": "sha512-OAm9Ohzbj11/ZFyICyR5N6LbOIvQMp7ZU2zI7Ej0jIc8kiGUERXPNMfw2QqqHD1ZHtjMub3yPZILovYEYucgoQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/utils": "^6.0.0",
|
||||
"tslib": "^2.3.1",
|
||||
"tsutils": "^3.21.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eslint": "^7.0.0 || ^8.0.0",
|
||||
"typescript": "^4.2.4 || ^5.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/eslint-plugin-escompat": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint-plugin-escompat/-/eslint-plugin-escompat-3.4.0.tgz",
|
||||
|
||||
@@ -2024,6 +2024,7 @@
|
||||
"eslint": "^8.56.0",
|
||||
"eslint-config-prettier": "^9.0.0",
|
||||
"eslint-import-resolver-typescript": "^3.6.1",
|
||||
"eslint-plugin-deprecation": "^2.0.0",
|
||||
"eslint-plugin-etc": "^2.0.2",
|
||||
"eslint-plugin-github": "^4.4.1",
|
||||
"eslint-plugin-import": "^2.29.1",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { Meta, StoryFn } from "@storybook/react";
|
||||
|
||||
import { faker } from "@faker-js/faker";
|
||||
import { customAlphabet } from "nanoid";
|
||||
|
||||
import { VariantAnalysisContainer } from "../../view/variant-analysis/VariantAnalysisContainer";
|
||||
import { VariantAnalysisAnalyzedRepos } from "../../view/variant-analysis/VariantAnalysisAnalyzedRepos";
|
||||
@@ -125,11 +126,10 @@ Example.args = {
|
||||
};
|
||||
|
||||
faker.seed(42);
|
||||
const uniqueStore = {};
|
||||
|
||||
const manyScannedRepos = Array.from({ length: 1000 }, (_, i) => {
|
||||
const mockedScannedRepo = createMockScannedRepo();
|
||||
|
||||
const nanoid = customAlphabet("123456789");
|
||||
return {
|
||||
...mockedScannedRepo,
|
||||
analysisStatus: VariantAnalysisRepoStatus.Succeeded,
|
||||
@@ -137,12 +137,8 @@ const manyScannedRepos = Array.from({ length: 1000 }, (_, i) => {
|
||||
repository: {
|
||||
...mockedScannedRepo.repository,
|
||||
// We need to ensure the ID is unique for React keys
|
||||
id: faker.helpers.unique(faker.number.int, [], {
|
||||
store: uniqueStore,
|
||||
}),
|
||||
fullName: `octodemo/${faker.helpers.unique(faker.word.sample, [], {
|
||||
store: uniqueStore,
|
||||
})}`,
|
||||
id: parseInt(nanoid()),
|
||||
fullName: `octodemo/${nanoid()}`,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
@@ -25,7 +25,7 @@ const Message = styled.div`
|
||||
padding: 1.5rem;
|
||||
`;
|
||||
|
||||
export function Compare(_: Record<string, never>): JSX.Element {
|
||||
export function Compare(_: Record<string, never>): React.JSX.Element {
|
||||
const [queryInfo, setQueryInfo] =
|
||||
useState<SetComparisonQueryInfoMessage | null>(null);
|
||||
const [comparison, setComparison] = useState<SetComparisonsMessage | null>(
|
||||
|
||||
@@ -32,7 +32,7 @@ export const DataFlowPaths = ({
|
||||
dataFlowPaths,
|
||||
}: {
|
||||
dataFlowPaths: DataFlowPathsDomainModel;
|
||||
}): JSX.Element => {
|
||||
}): React.JSX.Element => {
|
||||
const [selectedCodeFlow, setSelectedCodeFlow] = useState(
|
||||
dataFlowPaths.codeFlows[0],
|
||||
);
|
||||
|
||||
@@ -9,7 +9,7 @@ export type DataFlowPathsViewProps = {
|
||||
|
||||
export function DataFlowPathsView({
|
||||
dataFlowPaths: initialDataFlowPaths,
|
||||
}: DataFlowPathsViewProps): JSX.Element {
|
||||
}: DataFlowPathsViewProps): React.JSX.Element {
|
||||
const [dataFlowPaths, setDataFlowPaths] = useState<
|
||||
DataFlowPathsDomainModel | undefined
|
||||
>(initialDataFlowPaths);
|
||||
|
||||
@@ -64,7 +64,7 @@ export const MethodModeling = ({
|
||||
method,
|
||||
isModelingInProgress,
|
||||
onChange,
|
||||
}: MethodModelingProps): JSX.Element => {
|
||||
}: MethodModelingProps): React.JSX.Element => {
|
||||
return (
|
||||
<Container>
|
||||
<Title>
|
||||
|
||||
@@ -39,7 +39,7 @@ export const MethodModelingInputs = ({
|
||||
modelingStatus,
|
||||
isModelingInProgress,
|
||||
onChange,
|
||||
}: MethodModelingInputsProps): JSX.Element => {
|
||||
}: MethodModelingInputsProps): React.JSX.Element => {
|
||||
const inputProps = {
|
||||
language,
|
||||
method,
|
||||
|
||||
@@ -16,7 +16,9 @@ type Props = {
|
||||
initialViewState?: MethodModelingPanelViewState;
|
||||
};
|
||||
|
||||
export function MethodModelingView({ initialViewState }: Props): JSX.Element {
|
||||
export function MethodModelingView({
|
||||
initialViewState,
|
||||
}: Props): React.JSX.Element {
|
||||
const [viewState, setViewState] = useState<
|
||||
MethodModelingPanelViewState | undefined
|
||||
>(initialViewState);
|
||||
|
||||
@@ -22,7 +22,7 @@ const TypeMethodName = (method: Method) => {
|
||||
);
|
||||
};
|
||||
|
||||
export const MethodName = (method: Method): JSX.Element => {
|
||||
export const MethodName = (method: Method): React.JSX.Element => {
|
||||
return (
|
||||
<Name>
|
||||
{method.packageName && <>{method.packageName}.</>}
|
||||
|
||||
@@ -85,7 +85,7 @@ export function ModelEditor({
|
||||
initialMethods = [],
|
||||
initialModeledMethods = {},
|
||||
initialHideModeledMethods = INITIAL_HIDE_MODELED_METHODS_VALUE,
|
||||
}: Props): JSX.Element {
|
||||
}: Props): React.JSX.Element {
|
||||
const [viewState, setViewState] = useState<ModelEditorViewState | undefined>(
|
||||
initialViewState,
|
||||
);
|
||||
|
||||
@@ -27,7 +27,7 @@ export const ModelInputDropdown = ({
|
||||
modeledMethod,
|
||||
modelingStatus,
|
||||
onChange,
|
||||
}: Props): JSX.Element => {
|
||||
}: Props): React.JSX.Element => {
|
||||
const options = useMemo(() => {
|
||||
const modelsAsDataLanguage = getModelsAsDataLanguage(language);
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ export const ModelOutputDropdown = ({
|
||||
modeledMethod,
|
||||
modelingStatus,
|
||||
onChange,
|
||||
}: Props): JSX.Element => {
|
||||
}: Props): React.JSX.Element => {
|
||||
const options = useMemo(() => {
|
||||
const modelsAsDataLanguage = getModelsAsDataLanguage(language);
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ export const ModelTypeDropdown = ({
|
||||
modeledMethod,
|
||||
modelingStatus,
|
||||
onChange,
|
||||
}: Props): JSX.Element => {
|
||||
}: Props): React.JSX.Element => {
|
||||
const options = useMemo(() => {
|
||||
const baseOptions: Array<{ value: ModeledMethodType; label: string }> = [
|
||||
{ value: "none", label: "Unmodeled" },
|
||||
|
||||
@@ -24,7 +24,7 @@ export const ModelTypeTextbox = ({
|
||||
typeInfo,
|
||||
onChange,
|
||||
...props
|
||||
}: Props): JSX.Element => {
|
||||
}: Props): React.JSX.Element => {
|
||||
const [value, setValue] = useState<string | undefined>(
|
||||
modeledMethod[typeInfo],
|
||||
);
|
||||
|
||||
@@ -6,7 +6,7 @@ interface Props {
|
||||
showRawResults: () => void;
|
||||
}
|
||||
|
||||
export function AlertTableNoResults(props: Props): JSX.Element {
|
||||
export function AlertTableNoResults(props: Props): React.JSX.Element {
|
||||
if (props.nonemptyRawResults) {
|
||||
return (
|
||||
<span>
|
||||
|
||||
@@ -2,7 +2,9 @@ interface Props {
|
||||
numTruncatedResults: number;
|
||||
}
|
||||
|
||||
export function AlertTableTruncatedMessage(props: Props): JSX.Element | null {
|
||||
export function AlertTableTruncatedMessage(
|
||||
props: Props,
|
||||
): React.JSX.Element | null {
|
||||
if (props.numTruncatedResults === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ const Container = styled.span`
|
||||
text-align: center;
|
||||
`;
|
||||
|
||||
export function EmptyQueryResultsMessage(): JSX.Element {
|
||||
export function EmptyQueryResultsMessage(): React.JSX.Element {
|
||||
return (
|
||||
<Root>
|
||||
<Container>
|
||||
|
||||
@@ -10,7 +10,7 @@ interface Props {
|
||||
handleCheckboxChanged: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
||||
}
|
||||
|
||||
export function ProblemsViewCheckbox(props: Props): JSX.Element | null {
|
||||
export function ProblemsViewCheckbox(props: Props): React.JSX.Element | null {
|
||||
const { selectedTable, problemsViewSelected, handleCheckboxChanged } = props;
|
||||
|
||||
if (selectedTable !== ALERTS_TABLE_NAME) {
|
||||
|
||||
@@ -13,7 +13,7 @@ export default function RawTableValue({
|
||||
value,
|
||||
databaseUri,
|
||||
onSelected,
|
||||
}: Props): JSX.Element {
|
||||
}: Props): React.JSX.Element {
|
||||
switch (value.type) {
|
||||
case "boolean":
|
||||
return <span>{value.value.toString()}</span>;
|
||||
|
||||
@@ -14,7 +14,7 @@ function getResultCount(resultSet: ResultSet): number {
|
||||
}
|
||||
}
|
||||
|
||||
export function ResultCount(props: Props): JSX.Element | null {
|
||||
export function ResultCount(props: Props): React.JSX.Element | null {
|
||||
if (!props.resultSet) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ export function ClickableLocation({
|
||||
label,
|
||||
databaseUri,
|
||||
onClick: onClick,
|
||||
}: Props): JSX.Element {
|
||||
}: Props): React.JSX.Element {
|
||||
const handleClick = useCallback(
|
||||
(e: React.MouseEvent) => {
|
||||
e.preventDefault();
|
||||
|
||||
@@ -22,7 +22,7 @@ export function Location({
|
||||
databaseUri,
|
||||
title,
|
||||
onClick,
|
||||
}: Props): JSX.Element {
|
||||
}: Props): React.JSX.Element {
|
||||
const displayLabel = useMemo(() => convertNonPrintableChars(label), [label]);
|
||||
|
||||
if (loc === undefined) {
|
||||
|
||||
@@ -51,7 +51,7 @@ export function VariantAnalysis({
|
||||
variantAnalysis: initialVariantAnalysis,
|
||||
repoStates: initialRepoStates = [],
|
||||
repoResults: initialRepoResults = [],
|
||||
}: VariantAnalysisProps): JSX.Element {
|
||||
}: VariantAnalysisProps): React.JSX.Element {
|
||||
const [variantAnalysis, setVariantAnalysis] = useState<
|
||||
VariantAnalysisDomainModel | undefined
|
||||
>(initialVariantAnalysis);
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export type WebviewDefinition = {
|
||||
component: JSX.Element;
|
||||
component: React.JSX.Element;
|
||||
};
|
||||
|
||||
@@ -115,7 +115,7 @@ describe("Releases API consumer", () => {
|
||||
|
||||
await expect(
|
||||
consumer.getLatestRelease(new Range("5.*.*")),
|
||||
).rejects.toThrowError();
|
||||
).rejects.toThrow();
|
||||
});
|
||||
|
||||
it("picked release passes additional compatibility test if an additional compatibility test is specified", async () => {
|
||||
@@ -140,7 +140,7 @@ describe("Releases API consumer", () => {
|
||||
(asset) => asset.name === "otherExampleAsset.txt",
|
||||
),
|
||||
),
|
||||
).rejects.toThrowError();
|
||||
).rejects.toThrow();
|
||||
});
|
||||
|
||||
it("picked release is the most recent prerelease when includePrereleases is set", async () => {
|
||||
|
||||
@@ -154,7 +154,7 @@ describe(VariantAnalysisResultsManager.name, () => {
|
||||
async function* generateInParts() {
|
||||
const partLength = fileContents.length / 5;
|
||||
for (let i = 0; i < 5; i++) {
|
||||
yield fileContents.slice(i * partLength, (i + 1) * partLength);
|
||||
yield fileContents.subarray(i * partLength, (i + 1) * partLength);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -296,9 +296,7 @@ describe("local databases", () => {
|
||||
Uri.parse("file:/sourceArchive-uri/"),
|
||||
);
|
||||
(db as any).contents.sourceArchiveUri = undefined;
|
||||
expect(() => db.resolveSourceFile("abc")).toThrowError(
|
||||
"Scheme is missing",
|
||||
);
|
||||
expect(() => db.resolveSourceFile("abc")).toThrow("Scheme is missing");
|
||||
});
|
||||
|
||||
it("should fail to resolve when not a file uri", () => {
|
||||
@@ -308,7 +306,7 @@ describe("local databases", () => {
|
||||
Uri.parse("file:/sourceArchive-uri/"),
|
||||
);
|
||||
(db as any).contents.sourceArchiveUri = undefined;
|
||||
expect(() => db.resolveSourceFile("http://abc")).toThrowError(
|
||||
expect(() => db.resolveSourceFile("http://abc")).toThrow(
|
||||
"Invalid uri scheme",
|
||||
);
|
||||
});
|
||||
|
||||
@@ -123,7 +123,7 @@ describe("listDatabases", () => {
|
||||
it("throws an error", async () => {
|
||||
await expect(
|
||||
listDatabases(owner, repo, credentials, config),
|
||||
).rejects.toThrowError("Not found");
|
||||
).rejects.toThrow("Not found");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -150,7 +150,7 @@ describe("listDatabases", () => {
|
||||
it("throws an error", async () => {
|
||||
await expect(
|
||||
listDatabases(owner, repo, credentials, config),
|
||||
).rejects.toThrowError("Internal server error");
|
||||
).rejects.toThrow("Internal server error");
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -199,7 +199,7 @@ describe("listDatabases", () => {
|
||||
it("throws an error", async () => {
|
||||
await expect(
|
||||
listDatabases(owner, repo, credentials, config),
|
||||
).rejects.toThrowError("Internal server error");
|
||||
).rejects.toThrow("Internal server error");
|
||||
expect(mockListCodeqlDatabases).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -270,7 +270,7 @@ describe("listDatabases", () => {
|
||||
it("throws an error", async () => {
|
||||
await expect(
|
||||
listDatabases(owner, repo, credentials, config),
|
||||
).rejects.toThrowError("Not found");
|
||||
).rejects.toThrow("Not found");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -297,7 +297,7 @@ describe("listDatabases", () => {
|
||||
it("throws an error", async () => {
|
||||
await expect(
|
||||
listDatabases(owner, repo, credentials, config),
|
||||
).rejects.toThrowError("Internal server error");
|
||||
).rejects.toThrow("Internal server error");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -112,7 +112,7 @@ describe("resolveQueries", () => {
|
||||
"tags contain": ["ide-contextual-queries/print-ast"],
|
||||
},
|
||||
),
|
||||
).rejects.toThrowError(
|
||||
).rejects.toThrow(
|
||||
'No my query queries (kind "graph", tagged "ide-contextual-queries/print-ast") could be found in the current library path (tried searching the following packs: my-qlpack). Try upgrading the CodeQL libraries. If that doesn\'t work, then my query queries are not yet available for this language.',
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user