Skip to content

Commit

Permalink
make a few code edits from some random github bot
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Dec 18, 2023
1 parent aa46b2c commit 7a225ff
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 20 deletions.
5 changes: 1 addition & 4 deletions internal/bundler/bundler.go
Original file line number Diff line number Diff line change
Expand Up @@ -682,10 +682,7 @@ func ResolveFailureErrorTextSuggestionNotes(
}

if platform != config.PlatformNode {
pkg := path
if strings.HasPrefix(pkg, "node:") {
pkg = pkg[5:]
}
pkg := strings.TrimPrefix(path, "node:")
if resolver.BuiltInNodeModules[pkg] {
var how string
switch logger.API {
Expand Down
8 changes: 4 additions & 4 deletions internal/css_parser/css_parser_selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -854,8 +854,8 @@ func (p *parser) parseNthIndex() (css_ast.NthIndex, bool) {
if strings.HasPrefix(text0, "-") {
bNeg = true
text0 = text0[1:]
} else if strings.HasPrefix(text0, "+") {
text0 = text0[1:]
} else {
text0 = strings.TrimPrefix(text0, "+")
}
if b, ok := parseInteger(text0); ok {
if bNeg {
Expand Down Expand Up @@ -887,8 +887,8 @@ func (p *parser) parseNthIndex() (css_ast.NthIndex, bool) {
if strings.HasPrefix(text0, "-") {
aSign = negative
text0 = text0[1:]
} else if strings.HasPrefix(text0, "+") {
text0 = text0[1:]
} else {
text0 = strings.TrimPrefix(text0, "+")
}
}

Expand Down
5 changes: 1 addition & 4 deletions internal/fs/fs_zip.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,7 @@ func tryToReadZipArchive(zipPath string, archive *zipFile) {

// Build an index of all files in the archive
for _, file := range reader.File {
baseName := file.Name
if strings.HasSuffix(baseName, "/") {
baseName = baseName[:len(baseName)-1]
}
baseName := strings.TrimSuffix(file.Name, "/")
dirPath := ""
if slash := strings.LastIndexByte(baseName, '/'); slash != -1 {
dirPath = baseName[:slash]
Expand Down
2 changes: 1 addition & 1 deletion internal/js_parser/js_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -17410,7 +17410,7 @@ func (p *parser) prepareForVisitPass() {
if jsxImportSource := p.lexer.JSXImportSourcePragmaComment; jsxImportSource.Text != "" {
if !p.options.jsx.AutomaticRuntime {
p.log.AddIDWithNotes(logger.MsgID_JS_UnsupportedJSXComment, logger.Warning, &p.tracker, jsxImportSource.Range,
fmt.Sprintf("The JSX import source cannot be set without also enabling React's \"automatic\" JSX transform"),
"The JSX import source cannot be set without also enabling React's \"automatic\" JSX transform",
[]logger.MsgData{{Text: "You can enable React's \"automatic\" JSX transform for this file by using a \"@jsxRuntime automatic\" comment."}})
} else {
p.options.jsx.ImportSource = jsxImportSource.Text
Expand Down
1 change: 0 additions & 1 deletion internal/resolver/package_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -1376,7 +1376,6 @@ func (r resolverQuery) esmPackageTargetReverseResolve(
return true, keyWithoutTrailingStar + starData, target.firstToken
}
}
break
}

case pjObject:
Expand Down
10 changes: 4 additions & 6 deletions pkg/api/api_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,13 +540,11 @@ func validateResolveExtensions(log logger.Log, order []string) []string {

func validateLoaders(log logger.Log, loaders map[string]Loader) map[string]config.Loader {
result := bundler.DefaultExtensionToLoaderMap()
if loaders != nil {
for ext, loader := range loaders {
if ext != "" && !isValidExtension(ext) {
log.AddError(nil, logger.Range{}, fmt.Sprintf("Invalid file extension: %q", ext))
}
result[ext] = validateLoader(loader)
for ext, loader := range loaders {
if ext != "" && !isValidExtension(ext) {
log.AddError(nil, logger.Range{}, fmt.Sprintf("Invalid file extension: %q", ext))
}
result[ext] = validateLoader(loader)
}
return result
}
Expand Down

0 comments on commit 7a225ff

Please sign in to comment.