From 3223e764f2b5a2331982c5d73ccfa5e24d432c3a Mon Sep 17 00:00:00 2001 From: Felix Becker Date: Sat, 4 Apr 2020 13:40:05 +0200 Subject: [PATCH] Remove unused eslint disables (#9572) * Remove unused eslint-disable comments * Add stylelintignore file Else this causes broken fixes in TSX files --- .github/CODEOWNERS | 1 + .stylelintignore | 5 +++++ browser/src/libs/phabricator/extension.ts | 1 - cmd/precise-code-intel/src/shared/api/pagination/cursor.ts | 2 -- cmd/precise-code-intel/src/shared/input.test.ts | 1 - dev/release/src/google-calendar.ts | 2 -- shared/src/api/client/types/textDocument.ts | 1 - shared/src/api/extension/worker.ts | 1 - shared/src/commands/commands.ts | 1 - shared/src/components/Tabs.tsx | 1 - shared/src/util/LocalStorageSubject.ts | 2 -- shared/src/util/url.ts | 1 - web/src/api/APIConsole.tsx | 2 -- web/src/components/FilteredConnection.tsx | 1 - .../enterprise/campaigns/detail/CampaignDetails.test.tsx | 7 ++----- web/src/enterprise/search/stats/SearchStatsPage.test.tsx | 2 -- web/src/enterprise/search/stats/SearchStatsPage.tsx | 1 - .../user/productSubscriptions/PaymentTokenFormControl.tsx | 1 - .../UserSubscriptionsNewProductSubscriptionPage.tsx | 1 - web/src/extensions/ExtensionsList.tsx | 1 - web/src/extensions/ExtensionsQueryInputToolbar.tsx | 6 +----- web/src/extensions/extension/extension.ts | 1 - web/src/extensions/extension/routes.tsx | 1 - web/src/nav/UserNavItem.tsx | 2 -- web/src/repo/RepoContainer.tsx | 1 - web/src/repo/blob/actions/ToggleRenderedFileMode.tsx | 1 - web/src/repo/blob/discussions/DiscussionsCreate.tsx | 1 - web/src/repo/blob/discussions/DiscussionsGutterOverlay.tsx | 1 - web/src/repo/blob/discussions/DiscussionsNavbar.tsx | 1 - web/src/repo/blob/discussions/DiscussionsThread.tsx | 3 +-- web/src/repo/index.tsx | 1 - web/src/repo/stats/RepositoryStatsContributorsPage.tsx | 1 - web/src/search/input/QueryInput.tsx | 1 - web/src/search/results/SearchResults.tsx | 1 - web/src/site-admin/SiteAdminAddExternalServicesPage.tsx | 1 - web/src/tree/File.tsx | 1 - web/src/tree/Tree.tsx | 1 - web/src/tree/TreeLayer.tsx | 1 - web/src/tree/TreeRoot.tsx | 1 - web/src/util/url.ts | 2 -- 40 files changed, 10 insertions(+), 54 deletions(-) create mode 100644 .stylelintignore diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index c349f5c0b68..8a978acf9d0 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -58,6 +58,7 @@ /internal/linkheader @efritz /renovate.json @felixfbecker /.stylelintrc.json @felixfbecker +/.stylelintignore @felixfbecker /graphql-schema-linter.config.js @felixfbecker /.prettierignore @felixfbecker /.github @beyang diff --git a/.stylelintignore b/.stylelintignore new file mode 100644 index 00000000000..70d51ce3436 --- /dev/null +++ b/.stylelintignore @@ -0,0 +1,5 @@ +**/*.js +**/*.jsx +**/*.ts +**/*.tsx +node_modules/ diff --git a/browser/src/libs/phabricator/extension.ts b/browser/src/libs/phabricator/extension.ts index 54d3879f7d0..af1c023d133 100644 --- a/browser/src/libs/phabricator/extension.ts +++ b/browser/src/libs/phabricator/extension.ts @@ -44,7 +44,6 @@ async function init(): Promise { return } - // eslint-disable-next-line require-atomic-updates window.SOURCEGRAPH_URL = sourcegraphURL const css = await getPhabricatorCSS(sourcegraphURL) const style = document.createElement('style') diff --git a/cmd/precise-code-intel/src/shared/api/pagination/cursor.ts b/cmd/precise-code-intel/src/shared/api/pagination/cursor.ts index 97c22284a16..d6f6d96966c 100644 --- a/cmd/precise-code-intel/src/shared/api/pagination/cursor.ts +++ b/cmd/precise-code-intel/src/shared/api/pagination/cursor.ts @@ -9,8 +9,6 @@ export function parseCursor(cursorRaw: string | undefined): T | undefined { } try { - // False positive https://github.com/typescript-eslint/typescript-eslint/issues/1269 - // eslint-disable-next-line @typescript-eslint/return-await return JSON.parse(Buffer.from(cursorRaw, 'base64').toString()) } catch { throw Object.assign(new Error(`Malformed cursor supplied ${cursorRaw}`), { status: 400 }) diff --git a/cmd/precise-code-intel/src/shared/input.test.ts b/cmd/precise-code-intel/src/shared/input.test.ts index 80cb59f38da..ba80ada6653 100644 --- a/cmd/precise-code-intel/src/shared/input.test.ts +++ b/cmd/precise-code-intel/src/shared/input.test.ts @@ -127,7 +127,6 @@ async function* generate(values: T[]): AsyncIterable { async function consume(iterable: AsyncIterable): Promise { // We need to consume the iterable but can't make a meaningful // binding for each element of the iteration. - // eslint-disable-next-line @typescript-eslint/no-unused-vars for await (const _ of iterable) { // no-op body, just consume iterable } diff --git a/dev/release/src/google-calendar.ts b/dev/release/src/google-calendar.ts index 82530bd4ab5..6772df511b9 100644 --- a/dev/release/src/google-calendar.ts +++ b/dev/release/src/google-calendar.ts @@ -24,8 +24,6 @@ export async function getClient(): Promise { async function getAccessToken(oauth2Client: OAuth2Client): Promise { try { const content = await readFile(TOKEN_PATH, { encoding: 'utf8' }) - // False positive https://github.com/typescript-eslint/typescript-eslint/issues/1269 - // eslint-disable-next-line @typescript-eslint/return-await return JSON.parse(content) } catch (err) { const token = await getAccessTokenNoCache(oauth2Client) diff --git a/shared/src/api/client/types/textDocument.ts b/shared/src/api/client/types/textDocument.ts index bb969037911..ab43ca5b5a4 100644 --- a/shared/src/api/client/types/textDocument.ts +++ b/shared/src/api/client/types/textDocument.ts @@ -115,7 +115,6 @@ function score1(selector: DocumentSelector[0], candidateUri: URL, candidateLangu } } if (baseUri) { - // eslint-disable-next-line @typescript-eslint/no-base-to-string if (candidateUri.href.startsWith(baseUri.toString())) { ret = 5 } else { diff --git a/shared/src/api/extension/worker.ts b/shared/src/api/extension/worker.ts index 1e568984a52..fe9ed739d51 100644 --- a/shared/src/api/extension/worker.ts +++ b/shared/src/api/extension/worker.ts @@ -1,5 +1,4 @@ import { Observable } from 'rxjs' -// eslint-disable-next-line import/extensions import ExtensionHostWorker from 'worker-loader?inline&name=extensionHostWorker.bundle.js!./main.worker.ts' import { EndpointPair } from '../../platform/context' diff --git a/shared/src/commands/commands.ts b/shared/src/commands/commands.ts index 27bb56e7040..717309989a8 100644 --- a/shared/src/commands/commands.ts +++ b/shared/src/commands/commands.ts @@ -133,7 +133,6 @@ export function urlForOpenPanel(viewID: string, urlHash: string): string { params.set('tab', viewID) // In the URL fragment, the 'L1:2-3:4' is treated as a parameter with no value. Undo the escaping of ':' // and the addition of the '=' for the empty value, for aesthetic reasons. - // eslint-disable-next-line @typescript-eslint/no-base-to-string const paramsString = params.toString().replace(/%3A/g, ':').replace(/=&/g, '&') return `#${paramsString}` } diff --git a/shared/src/components/Tabs.tsx b/shared/src/components/Tabs.tsx index 69c01593f04..6d812a39c88 100644 --- a/shared/src/components/Tabs.tsx +++ b/shared/src/components/Tabs.tsx @@ -267,7 +267,6 @@ export class TabsWithURLViewStatePersistence(v: string | null, defaultValue: T): T { return defaultValue } try { - // False positive https://github.com/typescript-eslint/typescript-eslint/issues/1269 - // eslint-disable-next-line @typescript-eslint/return-await return JSON.parse(v) } catch (err) { return defaultValue diff --git a/shared/src/util/url.ts b/shared/src/util/url.ts index 13d5b5e57e9..bf9c7800950 100644 --- a/shared/src/util/url.ts +++ b/shared/src/util/url.ts @@ -596,7 +596,6 @@ export function buildSearchURLQuery( } } - // eslint-disable-next-line @typescript-eslint/no-base-to-string return searchParams.toString().replace(/%2F/g, '/').replace(/%3A/g, ':') } diff --git a/web/src/api/APIConsole.tsx b/web/src/api/APIConsole.tsx index ac92d0db699..7492cbec13d 100644 --- a/web/src/api/APIConsole.tsx +++ b/web/src/api/APIConsole.tsx @@ -233,8 +233,6 @@ async function fetcher(graphQLParams: _graphiqlModule.GraphQLParams): Promise = Connection if (arg.visible !== 0 && arg.visible !== arg.first) { q.set('visible', String(arg.visible)) } - // eslint-disable-next-line @typescript-eslint/no-base-to-string return q.toString() } diff --git a/web/src/enterprise/campaigns/detail/CampaignDetails.test.tsx b/web/src/enterprise/campaigns/detail/CampaignDetails.test.tsx index 47bd3da5858..3a7be7d84c1 100644 --- a/web/src/enterprise/campaigns/detail/CampaignDetails.test.tsx +++ b/web/src/enterprise/campaigns/detail/CampaignDetails.test.tsx @@ -11,7 +11,6 @@ import { PageTitle } from '../../../components/PageTitle' jest.mock('./form/CampaignTitleField', () => ({ CampaignTitleField: 'CampaignTitleField' })) jest.mock('./form/CampaignDescriptionField', () => ({ CampaignDescriptionField: 'CampaignDescriptionField' })) -// eslint-disable-next-line @typescript-eslint/no-explicit-any jest.mock('./CampaignStatus', () => ({ CampaignStatus: (props: CampaignStatusProps) => `CampaignStatus(state=${props.campaign.status.state})`, })) @@ -64,7 +63,6 @@ describe('CampaignDetails', () => { _noSubject={true} /> ) - // eslint-disable-next-line @typescript-eslint/no-floating-promises act(() => undefined) expect(component.toJSON()).toMatchSnapshot() }) @@ -113,7 +111,7 @@ describe('CampaignDetails', () => { describe(`viewerCanAdminister: ${String(viewerCanAdminister)}`, () => { test('viewing existing', () => { const component = renderer.create(renderCampaignDetails({ viewerCanAdminister })) - act(() => undefined) // eslint-disable-line @typescript-eslint/no-floating-promises + act(() => undefined) expect(component).toMatchSnapshot() }) }) @@ -121,8 +119,7 @@ describe('CampaignDetails', () => { test('editing existing', () => { const component = renderer.create(renderCampaignDetails({ viewerCanAdminister: true })) - act(() => undefined) // eslint-disable-line @typescript-eslint/no-floating-promises - // eslint-disable-next-line @typescript-eslint/no-floating-promises + act(() => undefined) act(() => component.root.findByProps({ id: 'e2e-campaign-edit' }).props.onClick({ preventDefault: () => undefined }) ) diff --git a/web/src/enterprise/search/stats/SearchStatsPage.test.tsx b/web/src/enterprise/search/stats/SearchStatsPage.test.tsx index 57cdb4880f9..8ff6528bedd 100644 --- a/web/src/enterprise/search/stats/SearchStatsPage.test.tsx +++ b/web/src/enterprise/search/stats/SearchStatsPage.test.tsx @@ -34,7 +34,6 @@ describe('SearchStatsPage', () => { createNodeMock: () => ({ parentElement: document.implementation.createHTMLDocument().body }), } ) - // eslint-disable-next-line @typescript-eslint/no-floating-promises act(() => undefined) // wait for _querySearchResultsStats to emit expect(component.toJSON()).toMatchSnapshot() }) @@ -62,7 +61,6 @@ describe('SearchStatsPage', () => { createNodeMock: () => ({ parentElement: document.implementation.createHTMLDocument().body }), } ) - // eslint-disable-next-line @typescript-eslint/no-floating-promises act(() => undefined) // wait for _querySearchResultsStats to emit expect(component.toJSON()).toMatchSnapshot() }) diff --git a/web/src/enterprise/search/stats/SearchStatsPage.tsx b/web/src/enterprise/search/stats/SearchStatsPage.tsx index 5d4e7a2d21f..db31776a731 100644 --- a/web/src/enterprise/search/stats/SearchStatsPage.tsx +++ b/web/src/enterprise/search/stats/SearchStatsPage.tsx @@ -34,7 +34,6 @@ export const SearchStatsPage: React.FunctionComponent = ({ const onSubmit = useCallback>( e => { e.preventDefault() - // eslint-disable-next-line @typescript-eslint/no-base-to-string history.push({ ...location, search: new URLSearchParams({ q: uncommittedQuery }).toString() }) }, [history, location, uncommittedQuery] diff --git a/web/src/enterprise/user/productSubscriptions/PaymentTokenFormControl.tsx b/web/src/enterprise/user/productSubscriptions/PaymentTokenFormControl.tsx index 0c5be8e8cd3..d7acb392572 100644 --- a/web/src/enterprise/user/productSubscriptions/PaymentTokenFormControl.tsx +++ b/web/src/enterprise/user/productSubscriptions/PaymentTokenFormControl.tsx @@ -24,7 +24,6 @@ export const PaymentTokenFormControl: React.FunctionComponent = props => props.disabled ? 'disabled' : '' }`} disabled={props.disabled} - // eslint-disable-next-line react/forbid-dom-props style={{ base: { fontFamily: diff --git a/web/src/enterprise/user/productSubscriptions/UserSubscriptionsNewProductSubscriptionPage.tsx b/web/src/enterprise/user/productSubscriptions/UserSubscriptionsNewProductSubscriptionPage.tsx index 06ce592677a..233a5a54214 100644 --- a/web/src/enterprise/user/productSubscriptions/UserSubscriptionsNewProductSubscriptionPage.tsx +++ b/web/src/enterprise/user/productSubscriptions/UserSubscriptionsNewProductSubscriptionPage.tsx @@ -144,7 +144,6 @@ export function productSubscriptionInputForLocationHash(value: GQL.IProductSubsc const params = new URLSearchParams() params.set('plan', value.billingPlanID) params.set('userCount', value.userCount.toString()) - // eslint-disable-next-line @typescript-eslint/no-base-to-string return '#' + params.toString() } diff --git a/web/src/extensions/ExtensionsList.tsx b/web/src/extensions/ExtensionsList.tsx index 8a727590f8d..5c1bb398996 100644 --- a/web/src/extensions/ExtensionsList.tsx +++ b/web/src/extensions/ExtensionsList.tsx @@ -126,7 +126,6 @@ export class ExtensionsList extends React.PureComponent { if (query) { const searchParams = new URLSearchParams() searchParams.set(ExtensionsList.URL_QUERY_PARAM, query) - // eslint-disable-next-line @typescript-eslint/no-base-to-string search = searchParams.toString() } else { search = '' diff --git a/web/src/extensions/ExtensionsQueryInputToolbar.tsx b/web/src/extensions/ExtensionsQueryInputToolbar.tsx index 5661d0ad4b5..52bfbca2779 100644 --- a/web/src/extensions/ExtensionsQueryInputToolbar.tsx +++ b/web/src/extensions/ExtensionsQueryInputToolbar.tsx @@ -47,11 +47,7 @@ export class ExtensionsQueryInputToolbar extends React.PureComponent {' '} - + Options , }, { diff --git a/web/src/nav/UserNavItem.tsx b/web/src/nav/UserNavItem.tsx index f1b41b4bf19..287f7a854f1 100644 --- a/web/src/nav/UserNavItem.tsx +++ b/web/src/nav/UserNavItem.tsx @@ -80,8 +80,6 @@ export class UserNavItem extends React.PureComponent {
Theme
- {/* render({ ...context, ...routeComponentProps })} /> ) diff --git a/web/src/repo/blob/actions/ToggleRenderedFileMode.tsx b/web/src/repo/blob/actions/ToggleRenderedFileMode.tsx index 1ddee1b4844..93526f8eb85 100644 --- a/web/src/repo/blob/actions/ToggleRenderedFileMode.tsx +++ b/web/src/repo/blob/actions/ToggleRenderedFileMode.tsx @@ -43,7 +43,6 @@ export class ToggleRenderedFileMode extends React.PureComponent { } else { q.delete(ToggleRenderedFileMode.URL_QUERY_PARAM) } - // eslint-disable-next-line @typescript-eslint/no-base-to-string return { ...location, search: q.toString() } } diff --git a/web/src/repo/blob/discussions/DiscussionsCreate.tsx b/web/src/repo/blob/discussions/DiscussionsCreate.tsx index 20c67e78265..3c8fa89c7dd 100644 --- a/web/src/repo/blob/discussions/DiscussionsCreate.tsx +++ b/web/src/repo/blob/discussions/DiscussionsCreate.tsx @@ -101,7 +101,6 @@ export class DiscussionsCreate extends React.PureComponent { hash.set('tab', 'discussions') hash.set('threadID', thread.idWithoutKind) // TODO(slimsag:discussions): ASAP: focus the new thread's range - // eslint-disable-next-line @typescript-eslint/no-base-to-string this.props.history.push(location.pathname + location.search + '#' + hash.toString()) }), map(thread => undefined), diff --git a/web/src/repo/blob/discussions/DiscussionsGutterOverlay.tsx b/web/src/repo/blob/discussions/DiscussionsGutterOverlay.tsx index 7b6830cb2d4..e1748c3bf32 100644 --- a/web/src/repo/blob/discussions/DiscussionsGutterOverlay.tsx +++ b/web/src/repo/blob/discussions/DiscussionsGutterOverlay.tsx @@ -29,7 +29,6 @@ export const DiscussionsGutterOverlay: React.FunctionComponent { } else { hash.delete('threadID') } - // eslint-disable-next-line @typescript-eslint/no-base-to-string return location.pathname + location.search + '#' + hash.toString() } } diff --git a/web/src/repo/blob/discussions/DiscussionsThread.tsx b/web/src/repo/blob/discussions/DiscussionsThread.tsx index b8201ef10f2..d6352486116 100644 --- a/web/src/repo/blob/discussions/DiscussionsThread.tsx +++ b/web/src/repo/blob/discussions/DiscussionsThread.tsx @@ -163,8 +163,7 @@ export class DiscussionsThread extends React.PureComponent { }, hash ) - : // eslint-disable-next-line @typescript-eslint/no-base-to-string - '#' + hash.toString() + : '#' + hash.toString() } private onSubmit = (title: string, contents: string): Observable => { diff --git a/web/src/repo/index.tsx b/web/src/repo/index.tsx index b6969a293f8..7245865bdfd 100644 --- a/web/src/repo/index.tsx +++ b/web/src/repo/index.tsx @@ -8,6 +8,5 @@ export function redirectToExternalHost(externalRedirectURL: string): void { redirectURL.host = externalHostURL.host redirectURL.port = externalHostURL.port redirectURL.protocol = externalHostURL.protocol - // eslint-disable-next-line @typescript-eslint/no-base-to-string window.location.replace(redirectURL.toString()) } diff --git a/web/src/repo/stats/RepositoryStatsContributorsPage.tsx b/web/src/repo/stats/RepositoryStatsContributorsPage.tsx index 6f2748cc9c1..0cad8432550 100644 --- a/web/src/repo/stats/RepositoryStatsContributorsPage.tsx +++ b/web/src/repo/stats/RepositoryStatsContributorsPage.tsx @@ -415,7 +415,6 @@ export class RepositoryStatsContributorsPage extends React.PureComponent { this.focusInputAndPositionCursorAtEnd() const q = new URLSearchParams(props.location.search) q.delete('focus') - // eslint-disable-next-line @typescript-eslint/no-base-to-string this.props.history.replace({ search: q.toString() }) }) ) diff --git a/web/src/search/results/SearchResults.tsx b/web/src/search/results/SearchResults.tsx index 39012899f03..35f006138fa 100644 --- a/web/src/search/results/SearchResults.tsx +++ b/web/src/search/results/SearchResults.tsx @@ -320,7 +320,6 @@ export class SearchResults extends React.Component { function getAddURL(id: string): string { const params = new URLSearchParams() params.append('id', id) - // eslint-disable-next-line @typescript-eslint/no-base-to-string return `?${params.toString()}` } diff --git a/web/src/tree/File.tsx b/web/src/tree/File.tsx index 4b70251cac3..e7967a1b3cb 100644 --- a/web/src/tree/File.tsx +++ b/web/src/tree/File.tsx @@ -67,7 +67,6 @@ export const File: React.FunctionComponent = props => ( draggable={false} title={props.entryInfo.path} // needed because of dynamic styling - // eslint-disable-next-line react/forbid-dom-props style={treePadding(props.depth, false)} tabIndex={-1} > diff --git a/web/src/tree/Tree.tsx b/web/src/tree/Tree.tsx index 1160cdee5b7..f7e39a8bdac 100644 --- a/web/src/tree/Tree.tsx +++ b/web/src/tree/Tree.tsx @@ -268,7 +268,6 @@ export class Tree extends React.PureComponent { // Strip the ?suggestion query param. Handle both when going from ancestor -> child and child -> ancestor. if (queryParams.has('suggestion')) { queryParams.delete('suggestion') - // eslint-disable-next-line @typescript-eslint/no-base-to-string this.props.history.replace({ search: queryParams.toString() }) } }) diff --git a/web/src/tree/TreeLayer.tsx b/web/src/tree/TreeLayer.tsx index ffc34fb511a..a7e540d3775 100644 --- a/web/src/tree/TreeLayer.tsx +++ b/web/src/tree/TreeLayer.tsx @@ -273,7 +273,6 @@ export class TreeLayer extends React.Component { { {isErrorLike(treeOrError) ? ( 0 - // eslint-disable-next-line @typescript-eslint/no-base-to-string return `#L${formatLineOrPositionOrRange(lpr)}${anyParams ? '&' + searchParams.toString() : ''}` }