Skip to content

chore: bump typescript-eslint to v7 #10271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -342,6 +342,7 @@ module.exports = {
'react/require-default-props': [ERROR, {ignoreFunctionalComponents: true}],

'@typescript-eslint/consistent-type-definitions': OFF,
'@typescript-eslint/no-explicit-any': OFF,
'@typescript-eslint/require-await': OFF,

'@typescript-eslint/ban-ts-comment': [
@@ -379,7 +380,6 @@ module.exports = {
// function placeholder params are always ignored, and any other unused
// locals must be justified with a disable comment.
'@typescript-eslint/no-unused-vars': [ERROR, {ignoreRestSiblings: true}],
'@typescript-eslint/prefer-optional-chain': ERROR,
Copy link
Contributor Author

@JoshuaKGoldberg JoshuaKGoldberg Jul 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As much as I love this rule, it needs linting with type information to be bug-free. typescript-eslint/typescript-eslint#6397 changed the rule to require type info in typescript-eslint v6.

I briefly tried adding typed linting in this PR but:

...so my suggestion would be to wait until v8 to use the stabilized parserOptions.projectService.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, we had a weird type checking setup (to make tests type checked), and I don't remember a good way to deal with it.

'@docusaurus/no-html-links': ERROR,
'@docusaurus/prefer-docusaurus-heading': ERROR,
'@docusaurus/no-untranslated-text': [
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -80,8 +80,8 @@
"@types/react-test-renderer": "^18.0.0",
"@types/semver": "^7.5.0",
"@types/shelljs": "^0.8.12",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"@typescript-eslint/eslint-plugin": "^7.15.0",
"@typescript-eslint/parser": "^7.15.0",
"cross-env": "^7.0.3",
"cspell": "^8.1.0",
"eslint": "^8.45.0",
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ import dedent from 'dedent';
import npm2yarn from '../index';

const process = async (
content: any,
content: vfile.Compatible | undefined,
options?: Parameters<typeof npm2yarn>[0],
) => {
const {remark} = await import('remark');
2 changes: 1 addition & 1 deletion packages/docusaurus-remark-plugin-npm2yarn/src/index.ts
Original file line number Diff line number Diff line change
@@ -111,7 +111,7 @@ const transformNode = (
...converters.flatMap(createConvertedTabItem),
],
},
] as any[];
];
};

const isMdxEsmLiteral = (node: Node): node is Literal =>
2 changes: 0 additions & 2 deletions packages/docusaurus-theme-classic/src/theme-classic.d.ts
Original file line number Diff line number Diff line change
@@ -957,7 +957,6 @@ declare module '@theme/MDXComponents' {
readonly h6: (props: ComponentProps<'h6'>) => JSX.Element;
readonly admonition: typeof Admonition;
readonly mermaid: typeof Mermaid;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[tagName: string]: ComponentType<any>;
};

@@ -1203,7 +1202,6 @@ declare module '@theme/NavbarItem/ComponentTypes' {
readonly docSidebar: typeof DocSidebarNavbarItem;
readonly docsVersion: typeof DocsVersionNavbarItem;
readonly docsVersionDropdown: typeof DocsVersionDropdownNavbarItem;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[customComponentType: string]: ComponentType<any>;
};

1 change: 0 additions & 1 deletion packages/docusaurus-types/src/routing.d.ts
Original file line number Diff line number Diff line change
@@ -194,7 +194,6 @@ export type RouteChunkNames = {
*/
export type Registry = {
readonly [chunkName: string]: [
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Loader: () => Promise<any>,
ModuleName: string,
ResolvedModuleName: string,
1 change: 0 additions & 1 deletion packages/docusaurus-types/src/swizzle.d.ts
Original file line number Diff line number Diff line change
@@ -30,7 +30,6 @@ export type SwizzleConfig = {
* @see https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/60766
*/
export type WrapperProps<
// eslint-disable-next-line @typescript-eslint/no-explicit-any
T extends keyof JSX.IntrinsicElements | JSXElementConstructor<any>,
> = T extends JSXElementConstructor<infer P>
? unknown extends P
3 changes: 1 addition & 2 deletions packages/docusaurus-utils/src/markdownUtils.ts
Original file line number Diff line number Diff line change
@@ -74,7 +74,6 @@ export function unwrapMdxCodeBlocks(content: string): string {
const regexp4 =
/(?<begin>^|\r?\n)(?<indentStart>\x20*)````(?<spaces>\x20*)mdx-code-block\r?\n(?<children>.*?)\r?\n(?<indentEnd>\x20*)````(?<end>\r?\n|$)/gs;

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const replacer = (substring: string, ...args: any[]) => {
const groups = args.at(-1);
return `${groups.begin}${groups.children}${groups.end}`;
@@ -105,7 +104,7 @@ export function admonitionTitleToDirectiveLabel(
'gm',
);

return content.replaceAll(regexp, (substring, ...args: any[]) => {
return content.replaceAll(regexp, (substring, ...args) => {
const groups = args.at(-1);

return `${groups.quote ?? ''}${groups.indentation ?? ''}${
Original file line number Diff line number Diff line change
@@ -45,7 +45,6 @@ export default function ComponentCreator(
}

const chunkNames = routesChunkNames[`${path}-${hash}`]!;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const loader: {[key: string]: () => Promise<any>} = {};
const modules: string[] = [];
const optsWebpack: string[] = [];
Original file line number Diff line number Diff line change
@@ -10,12 +10,12 @@ import {fromPartial} from '@total-typescript/shoehorn';
import {loadPlugins, reloadPlugin} from '../plugins';
import type {LoadContext, Plugin, PluginConfig} from '@docusaurus/types';

async function testLoad({
async function testLoad<Content = unknown>({
plugins,
themes,
}: {
plugins: PluginConfig<any>[];
themes: PluginConfig<any>[];
plugins: PluginConfig<Content>[];
themes: PluginConfig<Content>[];
}) {
const siteDir = path.join(__dirname, '__fixtures__/site-with-plugin');

2 changes: 1 addition & 1 deletion packages/eslint-plugin/package.json
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@
"build": "tsc"
},
"dependencies": {
"@typescript-eslint/utils": "^5.62.0",
"@typescript-eslint/utils": "^7.15.0",
"tslib": "^2.6.0"
},
"devDependencies": {
3 changes: 1 addition & 2 deletions packages/eslint-plugin/src/rules/no-html-links.ts
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
*/

import {createRule} from '../util';
import type {TSESTree} from '@typescript-eslint/types/dist/ts-estree';
import type {TSESTree} from '@typescript-eslint/types';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Package exports were cleaned up in typescript-eslint v6: https://typescript-eslint.io/blog/announcing-typescript-eslint-v6#package-exports


const docsUrl = 'https://docusaurus.io/docs/docusaurus-core#link';

@@ -35,7 +35,6 @@ export default createRule<Options, MessageIds>({
type: 'problem',
docs: {
description: 'enforce using Docusaurus Link component instead of <a> tag',
recommended: false,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are no longer required in types for rules, and it looks to me that these weren't used anywhere in Docusaurus code.

},
schema: [
{
3 changes: 1 addition & 2 deletions packages/eslint-plugin/src/rules/no-untranslated-text.ts
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
*/

import {isTextLabelChild, createRule} from '../util';
import type {TSESTree} from '@typescript-eslint/types/dist/ts-estree';
import type {TSESTree} from '@typescript-eslint/types';

type Options = [
{
@@ -22,7 +22,6 @@ export default createRule<Options, MessageIds>({
docs: {
description:
'enforce text labels in JSX to be wrapped by translate calls',
recommended: false,
},
schema: [
{
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
*/

import {createRule} from '../util';
import type {TSESTree} from '@typescript-eslint/types/dist/ts-estree';
import type {TSESTree} from '@typescript-eslint/types';

type Options = [];
type MessageIds = 'headings';
@@ -18,7 +18,6 @@ export default createRule<Options, MessageIds>({
docs: {
description:
'enforce using Docusaurus theme Heading component instead of any <hn> tag',
recommended: false,
},
schema: [],
messages: {
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ import {
isStringWithoutExpressions,
createRule,
} from '../util';
import type {TSESTree} from '@typescript-eslint/types/dist/ts-estree';
import type {TSESTree} from '@typescript-eslint/types';

type Options = [];
type MessageIds = 'translateChildren' | 'translateArg';
@@ -21,7 +21,6 @@ export default createRule<Options, MessageIds>({
type: 'problem',
docs: {
description: 'enforce translate APIs to be called on plain text labels',
recommended: 'error',
},
schema: [],
messages: {
2 changes: 1 addition & 1 deletion packages/eslint-plugin/src/util.ts
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
*/

import {ESLintUtils} from '@typescript-eslint/utils';
import type {TSESTree} from '@typescript-eslint/types/dist/ts-estree';
import type {TSESTree} from '@typescript-eslint/types';

type CheckTranslateChildOptions = {
ignoredStrings?: string[];
Original file line number Diff line number Diff line change
@@ -27,7 +27,6 @@ function CannyWidget({basePath}: {basePath: string}) {

const theme = useCannyTheme();
useEffect(() => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const {Canny} = window as any;
Canny('render', {
boardToken: BOARD_TOKEN,
186 changes: 102 additions & 84 deletions yarn.lock

Large diffs are not rendered by default.