Skip to content

chore(website): update report as issue to use new issue forms #4916

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 4 commits into from
May 23, 2022
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: 4 additions & 4 deletions packages/website/src/components/OptionsSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import CopyIcon from '@site/src/icons/copy.svg';

import useDebouncedToggle from './hooks/useDebouncedToggle';

import { createMarkdown } from './lib/markdown';
import { createMarkdown, createMarkdownParams } from './lib/markdown';

import type { RuleDetails } from './types';

Expand Down Expand Up @@ -97,8 +97,8 @@ function OptionsSelector({
}
window
.open(
`https://github.com/typescript-eslint/typescript-eslint/issues/new?body=${encodeURIComponent(
createMarkdown(state),
`https://github.com/typescript-eslint/typescript-eslint/issues/new?${createMarkdownParams(
state,
)}`,
'_blank',
)
Expand Down Expand Up @@ -202,7 +202,7 @@ function OptionsSelector({
</Tooltip>
</button>
<button className={styles.optionLabel} onClick={openIssue}>
Report Issue
Report as Issue
<CopyIcon />
</button>
</Expander>
Expand Down
4 changes: 2 additions & 2 deletions packages/website/src/components/Playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function Playground(): JSX.Element {
rules: {},
tsConfig: {},
});
const { isDarkTheme } = useColorMode();
const { colorMode } = useColorMode();
const [esAst, setEsAst] = useState<TSESTree.Program | string | null>();
const [tsAst, setTsAST] = useState<SourceFile | string | null>();
const [scope, setScope] = useState<Record<string, unknown> | string | null>();
Expand Down Expand Up @@ -83,7 +83,7 @@ function Playground(): JSX.Element {
jsx={state.jsx}
code={state.code}
tsConfig={state.tsConfig}
darkTheme={isDarkTheme}
darkTheme={colorMode === 'dark'}
sourceType={state.sourceType}
rules={state.rules}
showAST={state.showAST}
Expand Down
4 changes: 2 additions & 2 deletions packages/website/src/components/editor/useSandboxServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const useSandboxServices = (
): Error | SandboxServices | undefined => {
const [services, setServices] = useState<Error | SandboxServices>();
const [loadedTs, setLoadedTs] = useState<string>(props.ts);
const { isDarkTheme } = useColorMode();
const { colorMode } = useColorMode();

useEffect(() => {
if (props.ts !== loadedTs) {
Expand Down Expand Up @@ -77,7 +77,7 @@ export const useSandboxServices = (
ts,
);
sandboxInstance.monaco.editor.setTheme(
isDarkTheme ? 'vs-dark' : 'vs-light',
colorMode === 'dark' ? 'vs-dark' : 'vs-light',
);

const libMap = await sandboxInstance.tsvfs.createDefaultMapFromCDN(
Expand Down
49 changes: 37 additions & 12 deletions packages/website/src/components/lib/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,50 @@ function createSummaryJson(
return '';
}

export function genVersions(state: ConfigModel): string {
return [
'| package | version |',
'| -- | -- |',
`| \`@typescript-eslint/eslint-plugin\` | \`${process.env.TS_ESLINT_VERSION}\` |`,
`| \`@typescript-eslint/parser\` | \`${process.env.TS_ESLINT_VERSION}\` |`,
`| \`TypeScript\` | \`${state.ts}\` |`,
`| \`ESLint\` | \`${process.env.ESLINT_VERSION}\` |`,
`| \`node\` | \`web\` |`,
].join('\n');
}

export function createMarkdown(state: ConfigModel): string {
return [
'## Repro',
`[Playground](${document.location.toString()})`,
createSummary(state.code, 'Code', 'ts', 30),
createSummaryJson(state.rules, 'rules', 'Eslint config'),
createSummaryJson(state.tsConfig, 'compilerOptions', 'TypeScript config'),
'## Expected Result\n',
'## Actual Result\n',
'## Additional Info\n',
'## Versions',
`| package | version |
| ---------------------------------- | ------- |
| \`@typescript-eslint/eslint-plugin\` | \`${process.env.TS_ESLINT_VERSION}\` |
| \`@typescript-eslint/parser\` | \`${process.env.TS_ESLINT_VERSION}\` |
| \`TypeScript\` | \`${state.ts}\` |
| \`ESLint\` | \`${process.env.ESLINT_VERSION}\` |
| \`Env\` | \`web\` |`,
genVersions(state),
]
.filter(Boolean)
.join('\n\n');
}

export function createMarkdownParams(state: ConfigModel): string {
const params = {
template: '1-bug-report-plugin.yaml',
title: 'Bug: [rule name here] <short description of the issue>',
'playground-link': document.location.toString(),
'repro-code': state.code,
'eslint-config':
`module.exports = ` +
JSON.stringify(
{ parser: '@typescript-eslint/parser', rules: state.rules },
null,
2,
),
'typescript-config': JSON.stringify(
{ compilerOptions: state.tsConfig },
null,
2,
),
versions: genVersions(state),
};

return new URLSearchParams(params).toString();
}