Skip to content

Commit

Permalink
run the new go formatter, which mangles comments
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Aug 2, 2022
1 parent 21deb41 commit af0ab3e
Show file tree
Hide file tree
Showing 16 changed files with 223 additions and 237 deletions.
9 changes: 4 additions & 5 deletions internal/bundler/bundler_default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5772,11 +5772,10 @@ func TestToESMWrapperOmission(t *testing.T) {

// This is coverage for a past bug in esbuild. We used to generate this, which is wrong:
//
// let x = function(foo) {
// var foo2;
// return foo2;
// };
//
// let x = function(foo) {
// var foo2;
// return foo2;
// };
func TestNamedFunctionExpressionArgumentCollision(t *testing.T) {
loader_suite.expectBundled(t, bundled{
files: map[string]string{
Expand Down
7 changes: 3 additions & 4 deletions internal/bundler/bundler_ts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1969,10 +1969,9 @@ func TestTSEnumExportClause(t *testing.T) {
// This checks that we don't generate a warning for code that the TypeScript
// compiler generates that looks like this:
//
// var __rest = (this && this.__rest) || function (s, e) {
// ...
// };
//
// var __rest = (this && this.__rest) || function (s, e) {
// ...
// };
func TestTSThisIsUndefinedWarning(t *testing.T) {
ts_suite.expectBundled(t, bundled{
files: map[string]string{
Expand Down
20 changes: 10 additions & 10 deletions internal/bundler/linker.go
Original file line number Diff line number Diff line change
Expand Up @@ -2974,11 +2974,11 @@ func sanitizeFilePathForVirtualModulePath(path string) string {
// order that JavaScript modules were evaluated in before the top-level await
// feature was introduced.
//
// A
// / \
// B C
// \ /
// D
// A
// / \
// B C
// \ /
// D
//
// If A imports B and then C, B imports D, and C imports D, then the JavaScript
// traversal order is D B C A.
Expand Down Expand Up @@ -3042,11 +3042,11 @@ func (c *linkerContext) findImportedCSSFilesInJSOrder(entryPoint uint32) (order
// CSS file multiple times is equivalent to evaluating it once at the last
// location. So we drop all but the last evaluation in the order.
//
// A
// / \
// B C
// \ /
// D
// A
// / \
// B C
// \ /
// D
//
// If A imports B and then C, B imports D, and C imports D, then the CSS
// traversal order is B D C A.
Expand Down
35 changes: 17 additions & 18 deletions internal/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,25 @@ import (
// able to reuse the results of parsing between builds and make subsequent
// builds faster by avoiding redundant parsing work. This only works if:
//
// * The AST information in the cache must be considered immutable. There is
// no way to enforce this in Go, but please be disciplined about this. The
// ASTs are shared in between builds. Any information that must be mutated
// in the AST during a build must be done on a shallow clone of the data if
// the mutation happens after parsing (i.e. a clone that clones everything
// that will be mutated and shares only the parts that won't be mutated).
// - The AST information in the cache must be considered immutable. There is
// no way to enforce this in Go, but please be disciplined about this. The
// ASTs are shared in between builds. Any information that must be mutated
// in the AST during a build must be done on a shallow clone of the data if
// the mutation happens after parsing (i.e. a clone that clones everything
// that will be mutated and shares only the parts that won't be mutated).
//
// * The information in the cache must not depend at all on the contents of
// any file other than the file being cached. Invalidating an entry in the
// cache does not also invalidate any entries that depend on that file, so
// caching information that depends on other files can result in incorrect
// results due to reusing stale data. For example, do not "bake in" some
// value imported from another file.
//
// * Cached ASTs must only be reused if the parsing options are identical
// between builds. For example, it would be bad if the AST parser depended
// on options inherited from a nearby "package.json" file but those options
// were not part of the cache key. Then the cached AST could incorrectly be
// reused even if the contents of that "package.json" file have changed.
// - The information in the cache must not depend at all on the contents of
// any file other than the file being cached. Invalidating an entry in the
// cache does not also invalidate any entries that depend on that file, so
// caching information that depends on other files can result in incorrect
// results due to reusing stale data. For example, do not "bake in" some
// value imported from another file.
//
// - Cached ASTs must only be reused if the parsing options are identical
// between builds. For example, it would be bad if the AST parser depended
// on options inherited from a nearby "package.json" file but those options
// were not part of the cache key. Then the cached AST could incorrectly be
// reused even if the contents of that "package.json" file have changed.
type CacheSet struct {
FSCache FSCache
CSSCache CSSCache
Expand Down
33 changes: 16 additions & 17 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,32 +339,31 @@ type UnusedImportFlagsTS uint8

// With !UnusedImportKeepStmt && !UnusedImportKeepValues:
//
// "import 'foo'" => "import 'foo'"
// "import * as unused from 'foo'" => ""
// "import { unused } from 'foo'" => ""
// "import { type unused } from 'foo'" => ""
// "import 'foo'" => "import 'foo'"
// "import * as unused from 'foo'" => ""
// "import { unused } from 'foo'" => ""
// "import { type unused } from 'foo'" => ""
//
// With UnusedImportKeepStmt && !UnusedImportKeepValues:
//
// "import 'foo'" => "import 'foo'"
// "import * as unused from 'foo'" => "import 'foo'"
// "import { unused } from 'foo'" => "import 'foo'"
// "import { type unused } from 'foo'" => "import 'foo'"
// "import 'foo'" => "import 'foo'"
// "import * as unused from 'foo'" => "import 'foo'"
// "import { unused } from 'foo'" => "import 'foo'"
// "import { type unused } from 'foo'" => "import 'foo'"
//
// With !UnusedImportKeepStmt && UnusedImportKeepValues:
//
// "import 'foo'" => "import 'foo'"
// "import * as unused from 'foo'" => "import * as unused from 'foo'"
// "import { unused } from 'foo'" => "import { unused } from 'foo'"
// "import { type unused } from 'foo'" => ""
// "import 'foo'" => "import 'foo'"
// "import * as unused from 'foo'" => "import * as unused from 'foo'"
// "import { unused } from 'foo'" => "import { unused } from 'foo'"
// "import { type unused } from 'foo'" => ""
//
// With UnusedImportKeepStmt && UnusedImportKeepValues:
//
// "import 'foo'" => "import 'foo'"
// "import * as unused from 'foo'" => "import * as unused from 'foo'"
// "import { unused } from 'foo'" => "import { unused } from 'foo'"
// "import { type unused } from 'foo'" => "import {} from 'foo'"
//
// "import 'foo'" => "import 'foo'"
// "import * as unused from 'foo'" => "import * as unused from 'foo'"
// "import { unused } from 'foo'" => "import { unused } from 'foo'"
// "import { type unused } from 'foo'" => "import {} from 'foo'"
const (
UnusedImportKeepStmt UnusedImportFlagsTS = 1 << iota // "importsNotUsedAsValues" != "remove"
UnusedImportKeepValues // "preserveValueImports" == true
Expand Down
15 changes: 7 additions & 8 deletions internal/css_parser/css_decls_box.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,14 @@ const (
// We want to avoid a situation where the browser treats some of the original
// rules as valid and others as invalid.
//
// Safe:
// top: 1px; left: 0; bottom: 1px; right: 0;
// top: 1Q; left: 2Q; bottom: 3Q; right: 4Q;
//
// Unsafe:
// top: 1vh; left: 2vw; bottom: 3vh; right: 4vw;
// top: 1Q; left: 2Q; bottom: 3Q; right: 0;
// inset: 1Q 0 0 0; top: 0;
// Safe:
// top: 1px; left: 0; bottom: 1px; right: 0;
// top: 1Q; left: 2Q; bottom: 3Q; right: 4Q;
//
// Unsafe:
// top: 1vh; left: 2vw; bottom: 3vh; right: 4vw;
// top: 1Q; left: 2Q; bottom: 3Q; right: 0;
// inset: 1Q 0 0 0; top: 0;
type unitSafetyTracker struct {
unit string
status unitSafetyStatus
Expand Down
18 changes: 9 additions & 9 deletions internal/css_parser/css_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,17 +521,17 @@ var nonDeprecatedElementsSupportedByIE7 = map[string]bool{
// if any of the selectors are unsafe, since then browsers which don't support
// that particular feature would ignore the entire merged qualified rule:
//
// Input:
// a { color: red }
// b { color: red }
// input::-moz-placeholder { color: red }
// Input:
// a { color: red }
// b { color: red }
// input::-moz-placeholder { color: red }
//
// Valid output:
// a, b { color: red }
// input::-moz-placeholder { color: red }
// Valid output:
// a, b { color: red }
// input::-moz-placeholder { color: red }
//
// Invalid output:
// a, b, input::-moz-placeholder { color: red }
// Invalid output:
// a, b, input::-moz-placeholder { color: red }
//
// This considers IE 7 and above to be a browser that a user could possibly use.
// Versions of IE less than 6 are not considered.
Expand Down
18 changes: 9 additions & 9 deletions internal/fs/filepath.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,13 +343,13 @@ func (fp goFilepath) fromSlash(path string) string {
// by purely lexical processing. It applies the following rules
// iteratively until no further processing can be done:
//
// 1. Replace multiple Separator elements with a single one.
// 2. Eliminate each . path name element (the current directory).
// 3. Eliminate each inner .. path name element (the parent directory)
// along with the non-.. element that precedes it.
// 4. Eliminate .. elements that begin a rooted path:
// that is, replace "/.." by "/" at the beginning of a path,
// assuming Separator is '/'.
// 1. Replace multiple Separator elements with a single one.
// 2. Eliminate each . path name element (the current directory).
// 3. Eliminate each inner .. path name element (the parent directory)
// along with the non-.. element that precedes it.
// 4. Eliminate .. elements that begin a rooted path:
// that is, replace "/.." by "/" at the beginning of a path,
// assuming Separator is '/'.
//
// The returned path ends in a slash only if it represents a root directory,
// such as "/" on Unix or `C:\` on Windows.
Expand All @@ -359,8 +359,8 @@ func (fp goFilepath) fromSlash(path string) string {
// If the result of this process is an empty string, Clean
// returns the string ".".
//
// See also Rob Pike, ``Lexical File Names in Plan 9 or
// Getting Dot-Dot Right,''
// See also Rob Pike, Lexical File Names in Plan 9 or
// Getting Dot-Dot Right,
// https://9p.io/sys/doc/lexnames.html
func (fp goFilepath) clean(path string) string {
originalPath := path
Expand Down
46 changes: 23 additions & 23 deletions internal/js_ast/js_ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -982,11 +982,11 @@ type SSwitch struct {

// This object represents all of these types of import statements:
//
// import 'path'
// import {item1, item2} from 'path'
// import * as ns from 'path'
// import defaultItem, {item1, item2} from 'path'
// import defaultItem, * as ns from 'path'
// import 'path'
// import {item1, item2} from 'path'
// import * as ns from 'path'
// import defaultItem, {item1, item2} from 'path'
// import defaultItem, * as ns from 'path'
//
// Many parts are optional and can be combined in different ways. The only
// restriction is that you cannot have both a clause and a star namespace.
Expand Down Expand Up @@ -1542,27 +1542,27 @@ func (s *Scope) RecursiveSetStrictMode(kind StrictModeKind) {
// block are merged into a single namespace while the non-exported code is
// still scoped to just within that block:
//
// let x = 1;
// namespace Foo {
// let x = 2;
// export let y = 3;
// }
// namespace Foo {
// console.log(x); // 1
// console.log(y); // 3
// }
// let x = 1;
// namespace Foo {
// let x = 2;
// export let y = 3;
// }
// namespace Foo {
// console.log(x); // 1
// console.log(y); // 3
// }
//
// Doing this also works inside an enum:
//
// enum Foo {
// A = 3,
// B = A + 1,
// }
// enum Foo {
// C = A + 2,
// }
// console.log(Foo.B) // 4
// console.log(Foo.C) // 5
// enum Foo {
// A = 3,
// B = A + 1,
// }
// enum Foo {
// C = A + 2,
// }
// console.log(Foo.B) // 4
// console.log(Foo.C) // 5
//
// This is a form of identifier lookup that works differently than the
// hierarchical scope-based identifier lookup in JavaScript. Lookup now needs
Expand Down
Loading

0 comments on commit af0ab3e

Please sign in to comment.