Skip to content

Commit

Permalink
fix some lints
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Mar 14, 2024
1 parent dfa6206 commit b0765ae
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 63 deletions.
5 changes: 1 addition & 4 deletions internal/bundler/bundler.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ func parseFile(args parseArgs) {
} else {
result, ok := runOnLoadPlugins(
args.options.Plugins,
args.res,
args.fs,
&args.caches.FSCache,
args.log,
Expand Down Expand Up @@ -540,7 +539,7 @@ func parseFile(args parseArgs) {
tracker := logger.MakeLineColumnTracker(&source)

if path, contents := extractSourceMapFromComment(args.log, args.fs, &args.caches.FSCache,
args.res, &source, &tracker, sourceMapComment, absResolveDir); contents != nil {
&source, &tracker, sourceMapComment, absResolveDir); contents != nil {
prettyPath := resolver.PrettyPath(args.fs, path)
log := logger.NewDeferLog(logger.DeferLogNoVerboseOrDebug, args.log.Overrides)

Expand Down Expand Up @@ -743,7 +742,6 @@ func extractSourceMapFromComment(
log logger.Log,
fs fs.FS,
fsCache *cache.FSCache,
res *resolver.Resolver,
source *logger.Source,
tracker *logger.LineColumnTracker,
comment logger.Span,
Expand Down Expand Up @@ -982,7 +980,6 @@ type loaderPluginResult struct {

func runOnLoadPlugins(
plugins []config.Plugin,
res *resolver.Resolver,
fs fs.FS,
fsCache *cache.FSCache,
log logger.Log,
Expand Down
4 changes: 0 additions & 4 deletions internal/linker/linker.go
Original file line number Diff line number Diff line change
Expand Up @@ -4599,8 +4599,6 @@ func (c *linkerContext) generateCodeForFileInChunkJS(
r renamer.Renamer,
waitGroup *sync.WaitGroup,
partRange partRange,
entryBits helpers.BitSet,
chunkAbsDir string,
toCommonJSRef ast.Ref,
toESMRef ast.Ref,
runtimeRequireRef ast.Ref,
Expand Down Expand Up @@ -5549,8 +5547,6 @@ func (c *linkerContext) generateChunkJS(chunkIndex int, chunkWaitGroup *sync.Wai
r,
&waitGroup,
partRange,
chunk.entryBits,
chunkAbsDir,
toCommonJSRef,
toESMRef,
runtimeRequireRef,
Expand Down
6 changes: 2 additions & 4 deletions internal/resolver/yarnpnp.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func (r resolverQuery) resolveToUnqualified(specifier string, parentURL string,
}

// If parentLocator isn't in manifest.fallbackExclusionList, then
if set, _ := manifest.fallbackExclusionList[parentLocator.ident]; !set[parentLocator.reference] {
if set := manifest.fallbackExclusionList[parentLocator.ident]; !set[parentLocator.reference] {
// Let fallback be RESOLVE_VIA_FALLBACK(manifest, ident)
fallback, _ := r.resolveViaFallback(manifest, ident)

Expand Down Expand Up @@ -302,9 +302,7 @@ func (r resolverQuery) findLocator(manifest *pnpData, moduleUrl string) (pnpIden
}

// The relative path must not start with ./; trim it if needed
if strings.HasPrefix(relativeUrl, "./") {
relativeUrl = relativeUrl[2:]
}
relativeUrl = strings.TrimPrefix(relativeUrl, "./")

// If relativeUrl matches manifest.ignorePatternData, then
if manifest.ignorePatternData != nil && manifest.ignorePatternData.MatchString(relativeUrl) {
Expand Down
50 changes: 0 additions & 50 deletions pkg/api/api_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,25 +276,6 @@ func validateLoader(value Loader) config.Loader {
}
}

func validateEngine(value EngineName) compat.Engine {
switch value {
case EngineChrome:
return compat.Chrome
case EngineEdge:
return compat.Edge
case EngineFirefox:
return compat.Firefox
case EngineIOS:
return compat.IOS
case EngineNode:
return compat.Node
case EngineSafari:
return compat.Safari
default:
panic("Invalid loader")
}
}

var versionRegex = regexp.MustCompile(`^([0-9]+)(?:\.([0-9]+))?(?:\.([0-9]+))?(-[A-Za-z0-9]+(?:\.[A-Za-z0-9]+)*)?$`)

func validateFeatures(log logger.Log, target Target, engines []Engine) (compat.JSFeature, compat.CSSFeature, map[css_ast.D]compat.CSSPrefix, string) {
Expand Down Expand Up @@ -454,37 +435,6 @@ func validateExternals(log logger.Log, fs fs.FS, paths []string) config.External
return result
}

func esmParsePackageName(packageSpecifier string) (packageName string, packageSubpath string, ok bool) {
if packageSpecifier == "" {
return
}

slash := strings.IndexByte(packageSpecifier, '/')
if !strings.HasPrefix(packageSpecifier, "@") {
if slash == -1 {
slash = len(packageSpecifier)
}
packageName = packageSpecifier[:slash]
} else {
if slash == -1 {
return
}
slash2 := strings.IndexByte(packageSpecifier[slash+1:], '/')
if slash2 == -1 {
slash2 = len(packageSpecifier[slash+1:])
}
packageName = packageSpecifier[:slash+1+slash2]
}

if strings.HasPrefix(packageName, ".") || strings.ContainsAny(packageName, "\\%") {
return
}

packageSubpath = "." + packageSpecifier[len(packageName):]
ok = true
return
}

func validateAlias(log logger.Log, fs fs.FS, alias map[string]string) map[string]string {
valid := make(map[string]string, len(alias))

Expand Down
2 changes: 1 addition & 1 deletion pkg/api/serve_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (h *apiHandler) ServeHTTP(res http.ResponseWriter, req *http.Request) {
maybeWriteResponseBody := func(bytes []byte) { res.Write(bytes) }
isHEAD := req.Method == "HEAD"
if isHEAD {
maybeWriteResponseBody = func(bytes []byte) { res.Write(nil) }
maybeWriteResponseBody = func([]byte) { res.Write(nil) }
}

// Handle GET and HEAD requests
Expand Down

0 comments on commit b0765ae

Please sign in to comment.