-
Notifications
You must be signed in to change notification settings - Fork 360
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This also updates our `eslint` version to 8.57.0, which is the most recent version that works with our YAML config file for `eslint`. Updating our config for the 9.x version didn't seem trivial.
- Loading branch information
Showing
20 changed files
with
1,311 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,16 @@ const ( | |
goimportsVersion = "v0.22.0" | ||
goimportsPkg = "golang.org/x/tools/cmd/goimports@" + goimportsVersion | ||
|
||
// For JS tools like eslint and prettier, these versions need to match the ones in the | ||
// `package.json` file. To update to a new version, run a command like this: | ||
// | ||
// npm install --save-dev --save-exact [email protected] | ||
// | ||
// Then update the version in this file as well. | ||
|
||
// This is the latest version to support a YAML config file. Updating to | ||
// the new config file syntax did not seem trivial. | ||
eslintVersion = "8.57.0" | ||
golangCILintVersion = "1.59.1" | ||
golinesVersion = "0.12.2" | ||
gosecVersion = "2.20.0" | ||
|
@@ -46,7 +56,7 @@ func SAInstallDevTools(ctx *task.Context) error { | |
if err := installPrecious(ctx); err != nil { | ||
return err | ||
} | ||
return installPrettier(ctx) | ||
return installJSTools(ctx) | ||
} | ||
|
||
// Install goimports. | ||
|
@@ -251,28 +261,55 @@ func installBinaryTool( | |
) | ||
} | ||
|
||
func installPrettier(ctx *task.Context) error { | ||
// We have to install all the JS tools at once. If we run `npm install <tool>` multiple times, each | ||
// execution wipes the entire `node_modules` directory, so we only end up with one tool (the last | ||
// one) installed. | ||
func installJSTools(ctx *task.Context) error { | ||
eslint, err := eslintPath() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
exists, err := executableExistsWithVersion(ctx, eslint, eslintVersion) | ||
if err != nil { | ||
return err | ||
} | ||
if !exists { | ||
return runNPMInstall(ctx) | ||
} | ||
|
||
prettier, err := prettierPath() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
exists, err := executableExistsWithVersion(ctx, prettier, prettierVersion) | ||
exists, err = executableExistsWithVersion(ctx, prettier, prettierVersion) | ||
if err != nil { | ||
return err | ||
} | ||
if exists { | ||
return nil | ||
} | ||
|
||
return runNPMInstall(ctx) | ||
} | ||
|
||
func runNPMInstall(ctx *task.Context) error { | ||
return sh.Run( | ||
ctx, | ||
"npm", "install", | ||
"--no-save", | ||
fmt.Sprintf("prettier@%s", prettierVersion), | ||
) | ||
} | ||
|
||
func eslintPath() (string, error) { | ||
root, err := repoRoot() | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
return filepath.Join(root, "node_modules", ".bin", "eslint"), nil | ||
} | ||
|
||
func prettierPath() (string, error) { | ||
root, err := repoRoot() | ||
if err != nil { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1624,21 +1624,6 @@ tasks: | |
set -e | ||
./dev-bin/precious lint --all | ||
- name: lint-js | ||
commands: | ||
- func: "fetch source" | ||
- command: shell.exec | ||
type: test | ||
params: | ||
working_dir: src/github.com/mongodb/mongo-tools | ||
script: | | ||
set -x | ||
set -v | ||
set -e | ||
PATH="/opt/nodejs/node-v16.17.0-linux-x64/bin:$PATH" | ||
npm install [email protected] | ||
node node_modules/eslint/bin/eslint.js test/qa-tests/jstests/**/*.js | ||
- name: qa-tests-5.0 | ||
tags: ["5.0"] | ||
commands: | ||
|
@@ -1898,7 +1883,6 @@ buildvariants: | |
_platform: rhel80 | ||
tasks: | ||
- name: lint | ||
- name: lint-js | ||
- name: mod-tidy | ||
- name: evergreen-validate | ||
- name: vet | ||
|
Oops, something went wrong.