From caaa2345c49b23ba1014084e50edf6969b399177 Mon Sep 17 00:00:00 2001 From: Tommy Nguyen <4123478+tido64@users.noreply.github.com> Date: Fri, 1 Jul 2022 15:48:50 +0200 Subject: [PATCH] chore: replace `@ts-ignore` with `@ts-expect-error` (#1711) With `@ts-expect-error`, TypeScript will let you know if the comment is no longer necessary. See also https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-9.html#-ts-expect-error-comments --- .changeset/grumpy-guests-compete.md | 2 ++ docsite/plugins/remark-include.js | 3 +-- packages/babel-preset-metro-react-native/package.json | 5 +---- packages/cli/src/start.ts | 3 +-- packages/jest-preset/package.json | 5 +---- packages/jest-preset/src/index.js | 4 ++-- packages/metro-config/src/index.js | 9 +++------ packages/metro-service/src/config.ts | 3 +-- packages/typescript-service/src/project.ts | 3 +-- scripts/src/commands/updateApiReadme.js | 3 +-- 10 files changed, 14 insertions(+), 26 deletions(-) create mode 100644 .changeset/grumpy-guests-compete.md diff --git a/.changeset/grumpy-guests-compete.md b/.changeset/grumpy-guests-compete.md new file mode 100644 index 000000000..a845151cc --- /dev/null +++ b/.changeset/grumpy-guests-compete.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/docsite/plugins/remark-include.js b/docsite/plugins/remark-include.js index 5f753e42a..db8005904 100644 --- a/docsite/plugins/remark-include.js +++ b/docsite/plugins/remark-include.js @@ -95,8 +95,7 @@ function plugin() { } } - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore -- The visit() overloads are bound to UnistNode, but we use the expanded MdAstNode + // @ts-expect-error -- The visit() overloads are bound to UnistNode, but we use the expanded MdAstNode visit(root, isInclude, processIncludeDirective); // Replace all include comments with the included file's AST. Do this in diff --git a/packages/babel-preset-metro-react-native/package.json b/packages/babel-preset-metro-react-native/package.json index 89986708e..e68b183fd 100644 --- a/packages/babel-preset-metro-react-native/package.json +++ b/packages/babel-preset-metro-react-native/package.json @@ -46,10 +46,7 @@ ] }, "eslintConfig": { - "extends": "@rnx-kit/eslint-config", - "rules": { - "@typescript-eslint/ban-ts-comment": "off" - } + "extends": "@rnx-kit/eslint-config" }, "jest": { "roots": [ diff --git a/packages/cli/src/start.ts b/packages/cli/src/start.ts index db108a53a..bcd925992 100644 --- a/packages/cli/src/start.ts +++ b/packages/cli/src/start.ts @@ -159,8 +159,7 @@ export async function rnxStart( // merge the Metro config middleware with our middleware const enhanceMiddleware = metroConfig.server.enhanceMiddleware; - // eslint-disable-next-line - // @ts-ignore + // @ts-expect-error We want to assign to read-only `enhanceMiddleware` metroConfig.server.enhanceMiddleware = ( metroMiddleware: Middleware, metroServer: Server diff --git a/packages/jest-preset/package.json b/packages/jest-preset/package.json index b4b2f8fd1..49543a263 100644 --- a/packages/jest-preset/package.json +++ b/packages/jest-preset/package.json @@ -52,10 +52,7 @@ ] }, "eslintConfig": { - "extends": "@rnx-kit/eslint-config", - "rules": { - "@typescript-eslint/ban-ts-comment": "off" - } + "extends": "@rnx-kit/eslint-config" }, "jest": { "preset": "@rnx-kit/scripts" diff --git a/packages/jest-preset/src/index.js b/packages/jest-preset/src/index.js index 6813f72e2..18a6ea83a 100644 --- a/packages/jest-preset/src/index.js +++ b/packages/jest-preset/src/index.js @@ -79,9 +79,9 @@ function getTargetPlatform(defaultPlatform) { /** @type {() => CLIConfig} */ const loadConfig = - // @ts-ignore could not find a declaration file + // @ts-expect-error could not find a declaration file require("@react-native-community/cli").loadConfig || - // @ts-ignore could not find a declaration file + // @ts-expect-error could not find a declaration file require("@react-native-community/cli/build/tools/config").default; const { platforms } = loadConfig(); diff --git a/packages/metro-config/src/index.js b/packages/metro-config/src/index.js index 06ee39486..68f251abc 100644 --- a/packages/metro-config/src/index.js +++ b/packages/metro-config/src/index.js @@ -153,13 +153,11 @@ function exclusionList(additionalExclusions = [], projectRoot = process.cwd()) { /** @type {(additionalExclusions: (string | RegExp)[]) => RegExp} */ const exclusionList = (() => { try { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore There are no type definition files for `metro-config` + // @ts-expect-error There are no type definition files for `metro-config` return require("metro-config/src/defaults/exclusionList"); } catch (_) { // `blacklist` was renamed to `exclusionList` in 0.60 - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore There are no type definition files for `metro-config` + // @ts-expect-error There are no type definition files for `metro-config` return require("metro-config/src/defaults/blacklist"); } })(); @@ -195,8 +193,7 @@ module.exports = { * @returns {MetroConfig} */ makeMetroConfig: (customConfig = {}) => { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore There are no type definition files for `metro-config` + // @ts-expect-error There are no type definition files for `metro-config` const { mergeConfig } = require("metro-config"); const { enhanceMiddleware } = require("./assetPluginForMonorepos"); diff --git a/packages/metro-service/src/config.ts b/packages/metro-service/src/config.ts index 20ea2e988..009f0d9fd 100644 --- a/packages/metro-service/src/config.ts +++ b/packages/metro-service/src/config.ts @@ -180,8 +180,7 @@ export function loadMetroConfig( defaultConfig.reporter = overrides.reporter; } if (overrides.assetPlugins) { - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore + // @ts-expect-error We want to assign to read-only `assetPlugins` defaultConfig.transformer.assetPlugins = assetPlugins; } diff --git a/packages/typescript-service/src/project.ts b/packages/typescript-service/src/project.ts index 640e65ce3..6bd8d217e 100644 --- a/packages/typescript-service/src/project.ts +++ b/packages/typescript-service/src/project.ts @@ -195,8 +195,7 @@ export class Project { dispose(): void { this.languageService.dispose(); - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore `languageService` cannot be used after calling dispose + // @ts-expect-error `languageService` cannot be used after calling dispose this.languageService = null; } } diff --git a/scripts/src/commands/updateApiReadme.js b/scripts/src/commands/updateApiReadme.js index d7b6bf4e3..1932f9381 100644 --- a/scripts/src/commands/updateApiReadme.js +++ b/scripts/src/commands/updateApiReadme.js @@ -171,8 +171,7 @@ function updateReadme(exportedTypes, exportedFunctions) { }; /** @type {(table: string[][], options?: {}) => string} */ - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore + // @ts-expect-error const markdownTable = require("markdown-table"); const types =