diff --git a/client/web/src/search/home/SearchPage.tsx b/client/web/src/search/home/SearchPage.tsx index 77d06647eb17..20f7bf543b8e 100644 --- a/client/web/src/search/home/SearchPage.tsx +++ b/client/web/src/search/home/SearchPage.tsx @@ -67,9 +67,13 @@ export const SearchPage: React.FunctionComponent {props.isSourcegraphDotCom && (
-
Search millions of open source repositories
+
+ Search millions of open source repositories +
- eventLogger.log('ClickedOnCloudCTA')}>Search private code + eventLogger.log('ClickedOnCloudCTA')}> + Search private code +
)} diff --git a/dev/sg/linters/linters.go b/dev/sg/linters/linters.go index a9ed4270fc2c..7a5886ceac9e 100644 --- a/dev/sg/linters/linters.go +++ b/dev/sg/linters/linters.go @@ -89,9 +89,10 @@ var Targets = []Target{ bashSyntax, }, }, + Formatting, } -var FormattingTarget = Target{ +var Formatting = Target{ Name: "format", Description: "Check client code and docs for formatting errors", Checks: []*linter{ diff --git a/dev/sg/sg_lint.go b/dev/sg/sg_lint.go index 0dce2b045cc6..7cd6be4ced18 100644 --- a/dev/sg/sg_lint.go +++ b/dev/sg/sg_lint.go @@ -31,10 +31,10 @@ var lintFailFast = &cli.BoolFlag{ Value: true, } -var lintNoFormatCheck = &cli.BoolFlag{ - Name: "no-format-check", - Aliases: []string{"nfc"}, - Usage: "Don't check file formatting", +var lintSkipFormatCheck = &cli.BoolFlag{ + Name: "skip-format-check", + Aliases: []string{"sfc"}, + Usage: "Skip file formatting check", Value: false, } @@ -64,7 +64,7 @@ sg lint --help generateAnnotations, lintFix, lintFailFast, - lintNoFormatCheck, + lintSkipFormatCheck, }, Before: func(cmd *cli.Context) error { // If more than 1 target is requested, hijack subcommands by setting it to nil @@ -80,24 +80,42 @@ sg lint --help if len(targets) == 0 { // If no args provided, run all - lintTargets = linters.Targets - for _, t := range lintTargets { + for _, t := range linters.Targets { + if lintSkipFormatCheck.Get(cmd) { + continue + } + + lintTargets = append(lintTargets, t) targets = append(targets, t.Name) } + } else { // Otherwise run requested set allLintTargetsMap := make(map[string]linters.Target, len(linters.Targets)) for _, c := range linters.Targets { allLintTargetsMap[c.Name] = c } + + hasFormatTarget := false for _, t := range targets { target, ok := allLintTargetsMap[t] if !ok { std.Out.WriteFailuref("unrecognized target %q provided", t) return flag.ErrHelp } + if target.Name == linters.Formatting.Name { + hasFormatTarget = true + } + lintTargets = append(lintTargets, target) } + + // If we haven't added the format target already, add it! Unless we must skip it + if !lintSkipFormatCheck.Get(cmd) && !hasFormatTarget { + lintTargets = append(lintTargets, linters.Formatting) + targets = append(targets, linters.Formatting.Name) + + } } repoState, err := repo.GetState(cmd.Context) @@ -105,11 +123,6 @@ sg lint --help return errors.Wrap(err, "repo.GetState") } - if !lintNoFormatCheck.Get(cmd) { - lintTargets = append(lintTargets, linters.FormattingTarget) - targets = append(targets, linters.FormattingTarget.Name) - } - runner := linters.NewRunner(std.Out, generateAnnotations.Get(cmd), lintTargets...) if cmd.Bool("fix") { std.Out.WriteNoticef("Fixing checks from targets: %s", strings.Join(targets, ", ")) @@ -119,7 +132,7 @@ sg lint --help std.Out.WriteNoticef("Running checks from targets: %s", strings.Join(targets, ", ")) return runner.Check(cmd.Context, repoState) }, - Subcommands: lintTargets(append(linters.Targets, linters.FormattingTarget)).Commands(), + Subcommands: lintTargets(append(linters.Targets, linters.Formatting)).Commands(), } type lintTargets []linters.Target @@ -142,13 +155,22 @@ func (lt lintTargets) Commands() (cmds []*cli.Command) { return errors.Wrap(err, "repo.GetState") } - runner := linters.NewRunner(std.Out, generateAnnotations.Get(cmd), target) + lintTargets := []linters.Target{target} + targets := []string{target.Name} + // Always add the format check, unless we must skip it! + if !lintSkipFormatCheck.Get(cmd) && target.Name != linters.Formatting.Name { + lintTargets = append(lintTargets, linters.Formatting) + targets = append(targets, linters.Formatting.Name) + + } + + runner := linters.NewRunner(std.Out, generateAnnotations.Get(cmd), lintTargets...) if lintFix.Get(cmd) { - std.Out.WriteNoticef("Fixing checks from target: %s", target.Name) + std.Out.WriteNoticef("Fixing checks from target: %s", strings.Join(targets, ", ")) return runner.Fix(cmd.Context, repoState) } runner.FailFast = lintFailFast.Get(cmd) - std.Out.WriteNoticef("Running checks from target: %s", target.Name) + std.Out.WriteNoticef("Running checks from target: %s", strings.Join(targets, ", ")) return runner.Check(cmd.Context, repoState) }, // Completions to chain multiple commands diff --git a/doc/dev/background-information/sg/reference.md b/doc/dev/background-information/sg/reference.md index 3814d6aa038a..a6ecf0c944bf 100644 --- a/doc/dev/background-information/sg/reference.md +++ b/doc/dev/background-information/sg/reference.md @@ -387,7 +387,7 @@ Flags: * `--fail-fast, --ff`: Exit immediately if an issue is encountered (not available with '-fix') * `--feedback`: provide feedback about this command by opening up a GitHub discussion * `--fix, -f`: Try to fix any lint issues -* `--no-format-check, --nfc`: Don't check file formatting +* `--skip-format-check, --sfc`: Skip file formatting check ### sg lint urls @@ -457,6 +457,15 @@ Flags: Check client code and docs for formatting errors. +Flags: + +* `--feedback`: provide feedback about this command by opening up a GitHub discussion + +### sg lint format + +Check client code and docs for formatting errors. + + Flags: * `--feedback`: provide feedback about this command by opening up a GitHub discussion diff --git a/enterprise/dev/ci/internal/ci/operations.go b/enterprise/dev/ci/internal/ci/operations.go index d3963430970d..b1781d7d92b1 100644 --- a/enterprise/dev/ci/internal/ci/operations.go +++ b/enterprise/dev/ci/internal/ci/operations.go @@ -122,7 +122,7 @@ func addSgLints(targets []string) func(pipeline *bk.Pipeline) { formatCheck := "" if runType.Is(runtype.MainBranch) || runType.Is(runtype.MainDryRun) { - formatCheck = "--no-format-check " + formatCheck = "--skip-format-check " } cmd = cmd + "lint -annotations -fail-fast=false " + formatCheck + strings.Join(targets, " ") diff --git a/package.json b/package.json index 2bd4825ff1e3..0ca0597f28be 100644 --- a/package.json +++ b/package.json @@ -11,9 +11,9 @@ "yarn": "^1.22.4" }, "scripts": { - "format": "prettier '**/{*.{js?(on),ts?(x),graphql,md,scss},.*.js?(on)}' --write --list-different --config prettier.config.js", + "format": "prettier '**/{*.{js?(on),ts?(x),graphql,md,scss},.*.js?(on)}' --list-different --config prettier.config.js --write", "format:changed": "prettier $(git diff --diff-filter=d --name-only origin/main... && git ls-files --other --modified --exclude-standard | grep -E '\\.(js|json|ts|tsx|graphql|md|scss)$' | xargs) --write --list-different --config prettier.config.js", - "format:check": "yarn run format --write=false --check --list-different=false --loglevel=warn", + "format:check": "prettier '**/{*.{js?(on),ts?(x),graphql,md,scss},.*.js?(on)}' --config prettier.config.js --check --write=false", "_lint:js": "DOCSITE_LIST=\"$(./dev/docsite.sh -config doc/docsite.json ls)\" NODE_OPTIONS=\"--max_old_space_size=16192\" eslint", "lint:js:changed": "yarn _lint:js $(git diff --diff-filter=d --name-only origin/main... | grep -E '\\.[tj]sx?$' | xargs)", "lint:js:root": "yarn run _lint:js --quiet '*.[tj]s?(x)'", @@ -318,7 +318,7 @@ "postcss-focus-visible": "^5.0.0", "postcss-loader": "^6.1.1", "postcss-modules": "^4.2.2", - "prettier": "2.2.1", + "prettier": "2.7.1", "process": "^0.11.10", "protoc-gen-ts": "0.8.1", "puppeteer": "^13.5.1", diff --git a/yarn.lock b/yarn.lock index 404ab9ec879e..443b70185da1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -28875,7 +28875,7 @@ pvutils@latest: postcss-inset: ^1.0.0 postcss-loader: ^6.1.1 postcss-modules: ^4.2.2 - prettier: 2.2.1 + prettier: 2.7.1 pretty-bytes: ^5.3.0 process: ^0.11.10 prop-types: ^15.7.2