Skip to content

refactor: switch to tab indentation rather than spaces - #1309

Merged
petebacondarwin merged 4 commits into
cloudflare:mainfrom
petebacondarwin:pretty-tabs
Jun 28, 2022
Merged

petebacondarwin merged 4 commits into
cloudflare:mainfrom
petebacondarwin:pretty-tabs

Conversation

@petebacondarwin

Copy link
Copy Markdown
Contributor

Fixes #1298

@petebacondarwin
petebacondarwin requested review from a team and threepointone as code owners June 20, 2022 13:55
@changeset-bot

changeset-bot Bot commented Jun 20, 2022 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0d5d40c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
wrangler Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Jun 20, 2022 •

Copy link
Copy Markdown
Contributor

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.developers.workers.dev/runs/2575033552/npm-package-wrangler-1309

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.developers.workers.dev/prs/1309/npm-package-wrangler-1309

Or you can use npx with this latest build directly:

npx https://prerelease-registry.developers.workers.dev/runs/2575033552/npm-package-wrangler-1309 dev path/to/script.js

@petebacondarwin

petebacondarwin commented Jun 20, 2022 •

Copy link
Copy Markdown
Contributor Author

Sadly Prettier and eslint are not playing nicely together here...

For example this code:

export async function getUserInfo(): Promise<UserInfo | undefined> {
	const apiToken = getAPIToken();
	const apiTokenFromEnv = getCloudflareAPITokenFromEnv();
	return apiToken
		? {
				apiToken,
				authType: apiTokenFromEnv ? "API" : "OAuth",
				email: await getEmail(),
				accounts: await getAccounts(),
		  }
		: undefined;
}

Note that the line before the : undefined has two tabs followed by two spaces. The spaces are there to align the } with its corresponding {.

But eslint doesn't like this

@Cherry

Cherry commented Jun 20, 2022 •

Copy link
Copy Markdown
Contributor

If you add "no-mixed-spaces-and-tabs": ["error", "smart-tabs"] to the ESLint rules, that should resolve that. smart-tabs allows mixed tabs and spaces when the spaces are used for alignment - though personally I do think the alignment is superfluous. 👍

@Cherry

Cherry commented Jun 20, 2022 •

Copy link
Copy Markdown
Contributor

I'd also recommend adding an .editorconfig to the root with something like this, for reasonable 4 char width defaults:

# https://editorconfig.org
root = true

[*]
end_of_line = lf
indent_style = tab
tab_width = 4

That way, you avoid the default 8 spacing GitHub (and other tooling) uses:
Example code with 8 character tab width

And instead see this:
Example code with 4 character tab width

@petebacondarwin

Copy link
Copy Markdown
Contributor Author

Thanks for the tips @Cherry! We currently default to 2 spaces for indentation. But otherwise I have implemented your suggestions.

@petebacondarwin

Copy link
Copy Markdown
Contributor Author

Now the tricky dance of landing this without breaking too many other PRs :-D

@petebacondarwin
petebacondarwin force-pushed the pretty-tabs branch 2 times, most recently from a23ac13 to 6a94895 Compare June 27, 2022 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Switch to hard tabs for indentation

3 participants