Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions client/web/src/search/home/SearchPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,13 @@ export const SearchPage: React.FunctionComponent<React.PropsWithChildren<SearchP
<BrandLogo className={styles.logo} isLightTheme={props.isLightTheme} variant="logo" />
{props.isSourcegraphDotCom && (
<div className="d-flex flex-row">
<div className={classNames('text-muted text-center mt-3 mr-2 pr-2 border-right')}>Search millions of open source repositories</div>
<div className={classNames('text-muted text-center mt-3 mr-2 pr-2 border-right')}>
Search millions of open source repositories
</div>
<div className="mt-3">
<Link to="https://signup.sourcegraph.com/" onClick={() => eventLogger.log('ClickedOnCloudCTA')}>Search private code</Link>
<Link to="https://signup.sourcegraph.com/" onClick={() => eventLogger.log('ClickedOnCloudCTA')}>
Search private code
</Link>
</div>
</div>
)}
Expand Down
3 changes: 2 additions & 1 deletion dev/sg/linters/linters.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
54 changes: 38 additions & 16 deletions dev/sg/sg_lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down Expand Up @@ -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
Expand All @@ -80,36 +80,49 @@ 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)
if err != nil {
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, ", "))
Expand All @@ -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
Expand All @@ -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
Expand Down
11 changes: 10 additions & 1 deletion doc/dev/background-information/sg/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion enterprise/dev/ci/internal/ci/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, " ")
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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)'",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down