Skip to content

Lint - #5113

Merged
fregante merged 31 commits into
refined-github:mainfrom
kidonng:lint
Dec 10, 2021
Merged

Lint#5113
fregante merged 31 commits into
refined-github:mainfrom
kidonng:lint

Conversation

@kidonng

@kidonng kidonng commented Nov 28, 2021 •

Copy link
Copy Markdown
Member

A long-overdue thanksgiving gift 🦃️

Test URLs

Screenshot

  • Fix file-finder-buffer left margin

Before:

2021-11-29 20 25 06-0001

After:

2021-11-29 20 25 35-0002

@yakov116 yakov116 added the meta Related to Refined GitHub itself label Nov 28, 2021
Kid and others added 4 commits November 29, 2021 20:29
Comment thread package.json Resolved
Kid added 2 commits November 30, 2021 01:19
it looks especially out of place in hovercards.
Browser is smart most of the type, especially if you are not reading
it but setting it.
Comment thread source/features/index.tsx Outdated
console.group('❌', id, version, pageDetect.isEnterprise() ? 'GHE →' : '→', error);

const searchIssueUrl = new URL('https://github.com/refined-github/refined-github/issues');
searchIssueUrl.searchParams.set('q', `is:issue "${message}"`);

ghost Nov 29, 2021

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not sure if quoting them is better, at least that's how it looks to me.

ghost Dec 3, 2021

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe not, issues may still be useful even if they're not identical

ghost Dec 7, 2021 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Maybe not, issues may still be useful even if they're not identical

Somehow I missed this message 😅

Comment thread source/features/index.tsx
const newIssueUrl = new URL('https://github.com/refined-github/refined-github/issues/new?labels=bug&template=1_bug_report.md');
const newIssueUrl = new URL('https://github.com/refined-github/refined-github/issues/new');
newIssueUrl.searchParams.set('labels', 'bug');
newIssueUrl.searchParams.set('template', '1_bug_report.yml');

ghost Nov 29, 2021 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yup, a bug of bug report (.md -> .yml) 😄
You cannot click this line (here, with linkify-code or your editor) to create a bug report anymore but who would do that anyway.

ghost Nov 29, 2021

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does it work with the new issue form though? Does it auto-fill?

ghost Nov 29, 2021 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not yet but I'm fixing it Fixed.

ghost left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM so far other than the open reviews. I'm reviewing as we go 😅

Comment thread source/features/index.tsx Resolved
Comment thread source/features/index.tsx Outdated
\`\`\`
`));
newIssueUrl.searchParams.set('example_url', location.href);
newIssueUrl.searchParams.set('browser_s_used', navigator.userAgent);

ghost Nov 30, 2021 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

NIIICE. The user agent is no longer being updated though, I think we should drop it so the user is forced to specify the real one. Also example_url can be moved above description

ghost Dec 1, 2021 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The user agent is no longer being updated though, I think we should drop it so the user is forced to specify the real one.

I do not intend to use navigator.userAgent directly as most of it is useless. However I think a sensible default would be very helpful.

Also example_url can be moved above description

It is following the order of the template.

Kid added 2 commits December 1, 2021 22:58
This feature does not make sense there.
Comment thread source/features/index.tsx Outdated
Comment on lines +80 to +83
// @ts-expect-error navigator.userAgentData is not typed
const {platform} = navigator.userAgentData || navigator;
const browser = /(Chrome|Firefox|Safari)\/\d+/.exec(navigator.userAgent)?.[0];
newIssueUrl.searchParams.set('browser_s_used', [platform, browser].join(' '));

ghost Dec 1, 2021 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not jumping into the rabbit hole but this should be enough (platform/OS name + browser name + major browser version).

"Chrome" here matches any Chromium-based browser, since we only care about its version.

For example, it produces macOS Chrome/96, MacIntel Firefox/94 and MacIntel Safari/605 on some of my browsers.

@kidonng kidonng mentioned this pull request Dec 2, 2021
@kidonng

ghost commented Dec 2, 2021

Copy link
Copy Markdown
Member Author

I've moved many changes into separate PR (refer to the timeline) to keep things precise. This PR is now reduced to lint, cleanup & refactor and one line fixes...

except for that bug report change (source/features/index.tsx), because conversations here cannot be moved.

Future changes to this PR should fall into the above categories.

Comment thread source/features/index.tsx Outdated
Comment on lines +81 to +87
const browser = /(Chrome|Firefox|Safari)\/\d+/.exec(navigator.userAgent);
// Unknown browsers will need to be specified manually
if (browser) {
// @ts-expect-error navigator.userAgentData is not typed
const {platform} = navigator.userAgentData || navigator;
newIssueUrl.searchParams.set('browser_s_used', `${platform as string} ${browser[0]}`);
}

ghost Dec 3, 2021

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As mentioned before, but we should not do this. Let the user enter the browser, which may be reported as "chrome" when in reality it's Vivaldi. We don't need to parse this information because it's so fickle

Suggested change
const browser = /(Chrome|Firefox|Safari)\/\d+/.exec(navigator.userAgent);
// Unknown browsers will need to be specified manually
if (browser) {
// @ts-expect-error navigator.userAgentData is not typed
const {platform} = navigator.userAgentData || navigator;
newIssueUrl.searchParams.set('browser_s_used', `${platform as string} ${browser[0]}`);
}

Comment on lines +32 to +34
if (!issueLink) {
return;
}

ghost Dec 3, 2021

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

When does this happen?

ghost Dec 6, 2021

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

ghost Dec 7, 2021

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should use a URL-based exclusion instead because this silences any future errors we might have. Example:

eclude: [
	() => location.search === ''
]

No need for a full, custom detection in github-url-detection

Comment thread source/features/index.tsx Resolved
@fregante

ghost commented Dec 6, 2021

Copy link
Copy Markdown
Member

I would not add actual changes in lint PRs because they get lost and there's no argument/screenshot for the change. Lint PRs are for refactorings and code cleanups, not bugfixes nor new features

@yakov116

ghost commented Dec 6, 2021

Copy link
Copy Markdown
Member

because they get lost

I learned this the hard way 👍

ghost left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🚢

@fregante
fregante marked this pull request as ready for review December 10, 2021 08:27
@fregante
fregante merged commit cc03a67 into refined-github:main Dec 10, 2021
@fregante

ghost commented Dec 10, 2021

Copy link
Copy Markdown
Member

Let's not keep lint PRs around for too long. It's good as is for now. You can review the "restore" commits I made and reviews I left and open separate PRs for those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

meta Related to Refined GitHub itself

Development

Successfully merging this pull request may close these issues.

4 participants