Skip to content

Commit

Permalink
Fix lint issues in js/compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
mstoykov committed Dec 7, 2023
1 parent cb09e1a commit 2cf5c8d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions js/compiler/compiler.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Package compiler implements additional functionality for k6 to compile js code.
// more specifically transpiling through babel in case that is needed.
package compiler

import (
Expand All @@ -22,7 +24,7 @@ import (
var babelSrc string

var (
DefaultOpts = map[string]interface{}{
defaultOpts = map[string]interface{}{ //nolint:gochecknoglobals
// "presets": []string{"latest"},
"plugins": []interface{}{
// es2015 https://github.com/babel/babel/blob/v6.26.0/packages/babel-preset-es2015/src/index.js
Expand Down Expand Up @@ -111,13 +113,13 @@ func (c *Compiler) Transform(src, filename string, inputSrcMap []byte) (code str
c.babel = globalBabel
}
if err != nil {
return
return "", nil, err
}

sourceMapEnabled := c.Options.SourceMapLoader != nil
maxSrcLenForBabelSourceMapOnce.Do(func() {
// TODO: drop this code and everything it's connected to when babel is dropped
v := os.Getenv(maxSrcLenForBabelSourceMapVarName)
v := os.Getenv(maxSrcLenForBabelSourceMapVarName) //nolint:forbidigo
if len(v) > 0 {
i, err := strconv.Atoi(v) //nolint:govet // we shadow err on purpose
if err != nil {
Expand Down Expand Up @@ -145,8 +147,7 @@ func (c *Compiler) Transform(src, filename string, inputSrcMap []byte) (code str
" not be accepted by Babel, so it was disabled", filename)
}
}
code, srcMap, err = c.babel.transformImpl(c.logger, src, filename, sourceMapEnabled, inputSrcMap)
return
return c.babel.transformImpl(c.logger, src, filename, sourceMapEnabled, inputSrcMap)
}

// Options are options to the compiler
Expand Down Expand Up @@ -307,7 +308,7 @@ func (b *babel) transformImpl(
b.m.Lock()
defer b.m.Unlock()
opts := make(map[string]interface{})
for k, v := range DefaultOpts {
for k, v := range defaultOpts {
opts[k] = v
}
if sourceMapsEnabled {
Expand Down

0 comments on commit 2cf5c8d

Please sign in to comment.