Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[pull] main from typescript-eslint:main #96

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

Merged
merged 2 commits into from
May 26, 2025
Merged
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions docs/troubleshooting/typed-linting/Performance.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ In particular for typed linting:
- [Performance Tracing](https://github.com/microsoft/TypeScript/wiki/Performance#performance-tracing) can spotlight specific slow types within your project.
- [Using Project References](https://github.com/microsoft/TypeScript/wiki/Performance#using-project-references) -which requires enabling the [new "project service" (`parserOptions.projectService`) in v8](/blog/announcing-typescript-eslint-v8-beta#project-service)- can be helpful to speed up type checking on larger projects.

If none of the above work, you can try adjusting the `--max-semi-space-size` of Node. Increasing the max size of a semi-space can improve performance at the cost of more memory consumption. You can [read more about setting space size in Node.js here](https://nodejs.org/api/cli.html#--max-semi-space-sizesize-in-mib).

You can enable the setting by prepending your ESLint command like:

```bash
NODE_OPTIONS=--max-semi-space-size=256 eslint <rest of your command>
```

## Wide includes in your `tsconfig`

When using type-aware linting, you provide us with one or more tsconfigs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,13 @@ function getRuleDefaultOptions(page: RuleDocsPage): string {

return typeof recommended === 'object'
? [
`const defaultOptionsRecommended: Options = ${defaults};`,
'',
'// These options are merged on top of the recommended defaults',
...(recommended.recommended
? [
`const defaultOptionsRecommended: Options = ${defaults};`,
'',
'// These options are merged on top of the recommended defaults',
]
: []),
`const defaultOptionsStrict: Options = ${JSON.stringify(recommended.strict)};`,
].join('\n')
: `const defaultOptions: Options = ${defaults};`;
Expand Down
24 changes: 6 additions & 18 deletions packages/website/src/components/RulesTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import React, { useMemo } from 'react';
import type { HistorySelector } from '../../hooks/useHistorySelector';

import { useHistorySelector } from '../../hooks/useHistorySelector';
import { getRecommendationWithEmoji } from '../../theme/MDXComponents/RuleAttributes';
import {
CONFIG_EMOJI,
DEPRECATED_RULE_EMOJI,
Expand All @@ -35,9 +36,9 @@ function interpolateCode(

function getActualRecommended({
docs,
}: RulesMeta[number]): RuleRecommendation | undefined {
}: RulesMeta[number]): ['', ''] | [string, RuleRecommendation] {
const recommended = docs.recommended;
return typeof recommended === 'object' ? 'recommended' : recommended;
return recommended ? getRecommendationWithEmoji(recommended) : ['', ''];
}

function RuleRow({
Expand All @@ -50,7 +51,7 @@ function RuleRow({
}
const { deprecated, fixable, hasSuggestions } = rule;
const { extendsBaseRule, requiresTypeChecking } = rule.docs;
const actualRecommended = getActualRecommended(rule);
const [emoji, actualRecommended] = getActualRecommended(rule);
return (
<tr>
<td>
Expand All @@ -61,20 +62,7 @@ function RuleRow({
{interpolateCode(rule.docs.description)}
</td>
<td className={styles.attrCol} title={actualRecommended}>
{(() => {
switch (actualRecommended) {
case 'recommended':
return RECOMMENDED_CONFIG_EMOJI;
case 'strict':
return STRICT_CONFIG_EMOJI;
case 'stylistic':
return STYLISTIC_CONFIG_EMOJI;
default:
// for some reason the current version of babel loader won't elide
// this correctly recommended satisfies undefined;
return '';
}
})()}
{emoji}
</td>
<td
className={styles.attrCol}
Expand Down Expand Up @@ -172,7 +160,7 @@ export default function RulesTable(): React.JSX.Element {
const relevantRules = useMemo(
() =>
rules.filter(r => {
const actualRecommended = getActualRecommended(r);
const actualRecommended = getActualRecommended(r)[1];
const opinions = [
match(filters.recommended, actualRecommended === 'recommended'),
match(
Expand Down
23 changes: 15 additions & 8 deletions packages/website/src/theme/MDXComponents/RuleAttributes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ import {
import { Feature } from './Feature';
import styles from './RuleAttributes.module.css';

const recommendations = {
const recommendations: Record<
RuleRecommendation,
[string, RuleRecommendation]
> = {
recommended: [RECOMMENDED_CONFIG_EMOJI, 'recommended'],
strict: [STRICT_CONFIG_EMOJI, 'strict'],
stylistic: [STYLISTIC_CONFIG_EMOJI, 'stylistic'],
Expand All @@ -45,19 +48,23 @@ const resolveRecommendation = (
};

const getRecommendation = (docs: RecommendedRuleMetaDataDocs): string[] => {
const recommended = docs.recommended;
const recommendation =
recommendations[
typeof recommended === 'object'
? resolveRecommendation(recommended)
: recommended
];
const recommendation = getRecommendationWithEmoji(docs.recommended);

return docs.requiresTypeChecking
? [recommendation[0], `${recommendation[1]}-type-checked`]
: recommendation;
};

export function getRecommendationWithEmoji(
recommended: RecommendedRuleMetaDataDocs['recommended'],
): [string, RuleRecommendation] {
const recommendationKey =
typeof recommended === 'object'
? resolveRecommendation(recommended)
: recommended;
return recommendations[recommendationKey];
}

export function RuleAttributes({ name }: { name: string }): React.ReactNode {
const rules = useRulesMeta();
const rule = rules.find(rule => rule.name === name);
Expand Down