diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 2593ec87..00000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1 +0,0 @@ -Thank you for the pull request! diff --git a/README.md b/README.md index 11c9f0f0..0ee91b62 100644 --- a/README.md +++ b/README.md @@ -1 +1,43 @@ -See the documentation in our website [golangci-lint.run](https://golangci-lint.run). + + +

+ golangci-lint logo +

golangci-lint

+

Fast linters runner for Go

+

+ +--- + +`golangci-lint` is a fast Go linters runner. It runs linters in parallel, uses caching, supports `yaml` config, has integrations +with all major IDE and has dozens of linters included. + +## Install `golangci-lint` + +- [On my machine](https://golangci-lint.run/usage/install/#ci-installation); +- [On CI/CD systems](https://golangci-lint.run/usage/install/#local-installation). + +## Documentation + +Documentation is hosted at https://golangci-lint.run. + +## Badges + +![Build Status](https://github.com/golangci/golangci-lint/workflows/CI/badge.svg) +[![License](https://img.shields.io/github/license/golangci/golangci-lint)](/LICENSE) +[![Release](https://img.shields.io/github/release/golangci/golangci-lint.svg)](https://github.com/golangci/golangci-lint/releases/latest) +[![Docker](https://img.shields.io/docker/pulls/golangci/golangci-lint)](https://hub.docker.com/r/golangci/golangci-lint) +[![Github Releases Stats of golangci-lint](https://img.shields.io/github/downloads/golangci/golangci-lint/total.svg?logo=github)](https://somsubhra.com/github-release-stats/?username=golangci&repository=golangci-lint) + +## Contributors + +This project exists thanks to all the people who contribute. + + + + + + + +## Stargazers over time + +[![Stargazers over time](https://starchart.cc/golangci/golangci-lint.svg)](https://starchart.cc/golangci/golangci-lint) diff --git a/docs/src/components/SearchBar/README.md b/docs/src/components/SearchBar/README.md new file mode 100644 index 00000000..809e5bed --- /dev/null +++ b/docs/src/components/SearchBar/README.md @@ -0,0 +1,3 @@ +The source code copy-pasted from [here](https://github.com/facebook/docusaurus/blob/master/packages/docusaurus-theme-search-algolia/src/theme/SearchBar/). + +Waiting for [the official component](https://github.com/algolia/docsearch/issues/689). diff --git a/docs/src/components/SearchBar/algolia.css b/docs/src/components/SearchBar/algolia.css new file mode 100644 index 00000000..03b7b672 --- /dev/null +++ b/docs/src/components/SearchBar/algolia.css @@ -0,0 +1,328 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/* Bottom border of each suggestion */ +.algolia-docsearch-suggestion { + border-bottom-color: #3a3dd1; +} +/* Main category headers */ +.algolia-docsearch-suggestion--category-header { + background-color: #4b54de; +} +/* Highlighted search terms */ +.algolia-docsearch-suggestion--highlight { + color: #3a33d1; +} +/* Highligted search terms in the main category headers */ +.algolia-docsearch-suggestion--category-header + .algolia-docsearch-suggestion--highlight { + background-color: #4d47d5; +} +/* Currently selected suggestion */ +.aa-cursor .algolia-docsearch-suggestion--content { + color: #272296; +} +.aa-cursor .algolia-docsearch-suggestion { + background: #ebebfb; +} + +/* For bigger screens, when displaying results in two columns */ +@media (min-width: 768px) { + /* Bottom border of each suggestion */ + .algolia-docsearch-suggestion { + border-bottom-color: #7671df; + } + /* Left column, with secondary category header */ + .algolia-docsearch-suggestion--subcategory-column { + border-right-color: #7671df; + color: #4e4726; + } +} + +.algolia-autocomplete pre { + padding: 0; + right: 0; +} + +.algolia-autocomplete .ds-dropdown-menu:before { + display: block; + position: absolute; + content: ""; + width: 14px; + height: 14px; + background: #373940; + z-index: 1000; + top: -7px; + border-top: 1px solid #373940; + border-right: 1px solid #373940; + -webkit-transform: rotate(-45deg); + transform: rotate(-45deg); + border-radius: 2px; +} + +.algolia-autocomplete .ds-dropdown-menu { + box-shadow: 0 1px 0 0 rgba(0, 0, 0, 0.2), 0 2px 3px 0 rgba(0, 0, 0, 0.1); +} + +@media (min-width: 601px) { + .algolia-autocomplete.algolia-autocomplete-right .ds-dropdown-menu { + right: 0 !important; + left: inherit !important; + } + + .algolia-autocomplete.algolia-autocomplete-right .ds-dropdown-menu:before { + right: 48px; + } + + .algolia-autocomplete .ds-dropdown-menu { + position: relative; + top: -6px; + border-radius: 4px; + margin: 6px 0 0; + padding: 0; + text-align: left; + height: auto; + background: transparent; + border: none; + z-index: 999; + max-width: 600px; + min-width: 500px; + } +} + +@media (max-width: 600px) { + .algolia-autocomplete .ds-dropdown-menu { + z-index: 100; + position: fixed !important; + top: 50px !important; + left: auto !important; + right: 1rem !important; + width: 600px; + max-width: calc(100% - 2rem); + max-height: calc(100% - 5rem); + display: block; + } + + .algolia-autocomplete .ds-dropdown-menu:before { + right: 6rem; + } +} + +.algolia-autocomplete .ds-dropdown-menu .ds-suggestion { + cursor: pointer; +} + +.algolia-autocomplete .ds-dropdown-menu [class^="ds-dataset-"] { + border-radius: 4px; + overflow: auto; +} + +.algolia-autocomplete .algolia-docsearch-suggestion { + display: block; + padding: 0; + overflow: hidden; + text-decoration: none; +} + +.algolia-autocomplete .ds-cursor .algolia-docsearch-suggestion--wrapper { + background: #f1f1f1; + box-shadow: inset -2px 0 0 #61dafb; +} + +.algolia-autocomplete .algolia-docsearch-suggestion--highlight { + background: #ffe564; + padding: 0 0.05em; +} + +.algolia-autocomplete + .algolia-docsearch-suggestion--category-header + .algolia-docsearch-suggestion--category-header-lvl0 + .algolia-docsearch-suggestion--highlight, +.algolia-autocomplete + .algolia-docsearch-suggestion--category-header + .algolia-docsearch-suggestion--category-header-lvl1 + .algolia-docsearch-suggestion--highlight { + color: inherit; + background: inherit; +} + +.algolia-autocomplete + .algolia-docsearch-suggestion--text + .algolia-docsearch-suggestion--highlight { + padding: 0 0 1px; + background: inherit; + box-shadow: inset 0 -2px 0 0 rgba(69, 142, 225, 0.8); + color: inherit; +} + +.algolia-autocomplete .algolia-docsearch-suggestion--content { + display: block; + float: right; + width: 70%; + position: relative; + padding: 13.33333px 0 13.33333px 10.66667px; + cursor: pointer; +} + +.algolia-autocomplete .algolia-docsearch-suggestion--content:before { + content: ""; + position: absolute; + display: block; + top: 0; + height: 100%; + width: 1px; + background: #ececec; + left: -1px; +} + +.algolia-autocomplete .algolia-docsearch-suggestion--category-header { + position: relative; + display: none; + font-size: 14px; + letter-spacing: 0.08em; + font-weight: 700; + background-color: #373940; + text-transform: uppercase; + color: #fff; + padding: 5px 8px; +} + +.algolia-autocomplete .algolia-docsearch-suggestion--wrapper { + background-color: #fff; + width: 100%; + float: left; +} + +.algolia-autocomplete .algolia-docsearch-suggestion--subcategory-column { + float: left; + width: 30%; + display: none; + padding-left: 0; + text-align: right; + position: relative; + padding: 13.33333px 10.66667px; + color: #777; + font-size: 0.9em; + word-wrap: break-word; +} + +.algolia-autocomplete .algolia-docsearch-suggestion--subcategory-column:before { + content: ""; + position: absolute; + display: block; + top: 0; + height: 100%; + width: 1px; + background: #ececec; + right: 0; +} + +.algolia-autocomplete + .algolia-docsearch-suggestion.algolia-docsearch-suggestion__main + .algolia-docsearch-suggestion--category-header, +.algolia-autocomplete + .algolia-docsearch-suggestion.algolia-docsearch-suggestion__secondary { + display: block; +} + +.algolia-autocomplete + .algolia-docsearch-suggestion--subcategory-column + .algolia-docsearch-suggestion--highlight { + background-color: inherit; + color: inherit; +} + +.algolia-autocomplete .algolia-docsearch-suggestion--subcategory-inline { + display: none; +} + +.algolia-autocomplete .algolia-docsearch-suggestion--title { + color: #02060c; + font-size: 0.9em; + font-weight: bold; +} + +.algolia-autocomplete .algolia-docsearch-suggestion--text { + display: block; + line-height: 1.2em; + font-size: 0.85em; + color: #63676d; + padding-right: 2px; +} + +.algolia-autocomplete .algolia-docsearch-suggestion--no-results { + width: 100%; + padding: 8px 0; + text-align: center; + font-size: 1.2em; + background-color: #373940; + margin-top: -8px; +} + +.algolia-autocomplete + .algolia-docsearch-suggestion--no-results + .algolia-docsearch-suggestion--text { + color: #ffffff; + margin-top: 4px; +} + +.algolia-autocomplete .algolia-docsearch-suggestion--no-results::before { + display: none; +} + +.algolia-autocomplete .algolia-docsearch-suggestion code { + padding: 1px 5px; + font-size: 90%; + border: none; + color: #222222; + background-color: #ebebeb; + border-radius: 3px; + font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", + monospace; +} + +.algolia-autocomplete + .algolia-docsearch-suggestion + code + .algolia-docsearch-suggestion--highlight { + background: none; +} + +.algolia-autocomplete + .algolia-docsearch-suggestion.algolia-docsearch-suggestion__main + .algolia-docsearch-suggestion--category-header { + color: white; + display: block; +} + +.algolia-autocomplete + .algolia-docsearch-suggestion.algolia-docsearch-suggestion__secondary + .algolia-docsearch-suggestion--subcategory-column { + display: block; +} + +.algolia-autocomplete .algolia-docsearch-footer { + background-color: #fff; + width: 100%; + height: 30px; + z-index: 2000; + font-size: 0; + line-height: 0; + border-top: 1px solid #ececec; +} + +.algolia-autocomplete .algolia-docsearch-footer--logo { + background: url('data:image/svg+xml;utf8,') + center no-repeat; + background-size: 100%; + overflow: hidden; + text-indent: -9000px; + width: 110px; + height: 100%; + display: block; + margin: 0 5px 0 auto; +} diff --git a/docs/src/components/SearchBar/index.js b/docs/src/components/SearchBar/index.js new file mode 100644 index 00000000..7f0cc2ce --- /dev/null +++ b/docs/src/components/SearchBar/index.js @@ -0,0 +1,120 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +import React, { useState, useRef, useCallback } from "react"; +import classnames from "classnames"; + +import { useHistory } from "react-router-dom"; + +import "./styles.css"; + +const algolia = { + // TODO +}; + +const Search = (props) => { + const [algoliaLoaded, setAlgoliaLoaded] = useState(false); + const searchBarRef = useRef(null); + const history = useHistory(); + + function initAlgolia(focus) { + window.docsearch({ + appId: algolia.appId, + apiKey: algolia.apiKey, + indexName: algolia.indexName, + inputSelector: "#search_input_react", + algoliaOptions: algolia.algoliaOptions, + // Override algolia's default selection event, allowing us to do client-side + // navigation and avoiding a full page refresh. + handleSelected: (_input, _event, suggestion) => { + // Use an anchor tag to parse the absolute url into a relative url + // Alternatively, we can use new URL(suggestion.url) but it's not supported in IE. + const a = document.createElement("a"); + a.href = suggestion.url; + + // Algolia use closest parent element id #__docusaurus when a h1 page title does + // not have an id, so we can safely remove it. + // See https://github.com/facebook/docusaurus/issues/1828 for more details. + const routePath = + `#__docusaurus` === a.hash + ? `${a.pathname}` + : `${a.pathname}${a.hash}`; + history.push(routePath); + }, + }); + + if (focus) { + searchBarRef.current.focus(); + } + } + + const loadAlgolia = (focus = true) => { + if (algoliaLoaded) { + return; + } + + Promise.all([import("docsearch.js"), import("./algolia.css")]).then( + ([{ default: docsearch }]) => { + setAlgoliaLoaded(true); + window.docsearch = docsearch; + initAlgolia(focus); + } + ); + }; + + const handleSearchIcon = useCallback(() => { + loadAlgolia(); + + if (algoliaLoaded) { + searchBarRef.current.focus(); + } + + props.handleSearchBarToggle(!props.isSearchBarExpanded); + }, [props.isSearchBarExpanded]); + + const handleSearchInputBlur = useCallback(() => { + props.handleSearchBarToggle(!props.isSearchBarExpanded); + }, [props.isSearchBarExpanded]); + + const handleSearchInput = useCallback((e) => { + const needFocus = e.type !== "mouseover"; + + loadAlgolia(needFocus); + }); + + return ( +
+ + +
+ ); +}; + +export default Search; diff --git a/docs/src/components/SearchBar/styles.css b/docs/src/components/SearchBar/styles.css new file mode 100644 index 00000000..f9053f58 --- /dev/null +++ b/docs/src/components/SearchBar/styles.css @@ -0,0 +1,40 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +.search-icon { + background-image: var(--ifm-navbar-search-input-icon); + height: auto; + width: 24px; + cursor: pointer; + padding: 8px; + line-height: 32px; + background-repeat: no-repeat; + background-position: center; + display: none; +} + +.search-icon-hidden { + visibility: hidden; +} + +@media (max-width: 360px) { + .search-bar { + width: 0 !important; + background: none !important; + padding: 0 !important; + transition: none !important; + } + + .search-bar-expanded { + width: 9rem !important; + } + + .search-icon { + display: inline; + vertical-align: sub; + } +} diff --git a/docs/src/docs/index.mdx b/docs/src/docs/index.mdx index 638391f1..39563949 100644 --- a/docs/src/docs/index.mdx +++ b/docs/src/docs/index.mdx @@ -11,7 +11,7 @@ import { IconContainer } from "lib/icons"; [![Docker](https://img.shields.io/docker/pulls/golangci/golangci-lint)](https://hub.docker.com/r/golangci/golangci-lint) [![Github Releases Stats of golangci-lint](https://img.shields.io/github/downloads/golangci/golangci-lint/total.svg?logo=github)](https://somsubhra.com/github-release-stats/?username=golangci&repository=golangci-lint) -`golangci-lint` is a linters aggregator. +`golangci-lint` is a Go linters aggregator. Join our slack channel by [joining Gophers workspace](https://invite.slack.golangbridge.org/) and then [joining](https://gophers.slack.com/archives/CS0TBRKPC) channel [`#golangci-lint`](https://gophers.slack.com/archives/CS0TBRKPC). @@ -41,3 +41,15 @@ Short 1.5 min video demo of analyzing [beego](https://github.com/astaxie/beego). ## License Scan [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fgolangci%2Fgolangci-lint.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fgolangci%2Fgolangci-lint?ref=badge_large) + +## Contributors + +This project exists thanks to all the people who contribute. + +[![golangci-lint contributors](https://contributors-img.web.app/image?repo=golangci/golangci-lint)](https://github.com/golangci/golangci-lint/graphs/contributors) + + + +## Stargazers over time + +[![Stargazers over time](https://starchart.cc/golangci/golangci-lint.svg)](https://starchart.cc/golangci/golangci-lint) diff --git a/docs/src/docs/usage/install/annotations.png b/docs/src/docs/usage/install/annotations.png new file mode 100644 index 00000000..45671aec Binary files /dev/null and b/docs/src/docs/usage/install/annotations.png differ diff --git a/docs/src/docs/usage/install.mdx b/docs/src/docs/usage/install/index.mdx similarity index 71% rename from docs/src/docs/usage/install.mdx rename to docs/src/docs/usage/install/index.mdx index 791fad47..456a26d7 100644 --- a/docs/src/docs/usage/install.mdx +++ b/docs/src/docs/usage/install/index.mdx @@ -2,9 +2,23 @@ title: "Install" --- -## Binary +## CI installation -Most installations are done for CI (e.g. Travis CI, CircleCI). It's important to have reproducible CI: +Most installations of `golangci-lint` are performed for CI. + +### GitHub Actions + +We recommend using [our GitHub Action](https://github.com/golangci/golangci-lint-action) for running `golangci-lint` in CI for GitHub projects. +It's [fast and uses smart caching](https://github.com/golangci/golangci-lint-action#performance) inside +and it can be much faster than simple binary installation. + +Also, the action creates GitHub annotations for found issues: you don't need to dig into build log to see found by `golangci-lint` issues: + +![GitHub annotations of the action](./annotations.png) + +### Other CI + +It's important to have reproducible CI: don't start to fail all builds at the same time. With golangci-lint this can happen if you use deprecated option `--enable-all` and a new linter is added or even without `--enable-all`: when one upstream linter is upgraded. @@ -28,7 +42,9 @@ golangci-lint --version It is advised that you periodically update version of golangci-lint as the project is under active development and is constantly being improved. For any problems with golangci-lint, check out recent [GitHub issues](https://github.com/golangci/golangci-lint/issues) and update if needed. -## macOS +## Local Installation + +### macOS You can also install a binary release on macOS using [brew](https://brew.sh/): @@ -37,13 +53,13 @@ brew install golangci/tap/golangci-lint brew upgrade golangci/tap/golangci-lint ``` -## Docker +### Docker ```bash docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:{.LatestVersion} golangci-lint run -v ``` -## Go +### Install from Source Go source installations are supported for the two most recent Go releases. diff --git a/docs/src/docs/usage/integrations.mdx b/docs/src/docs/usage/integrations.mdx index 945dde18..19e0ea5a 100644 --- a/docs/src/docs/usage/integrations.mdx +++ b/docs/src/docs/usage/integrations.mdx @@ -58,3 +58,7 @@ source ~/.bashrc ### Linux See [kubectl instructions](https://kubernetes.io/docs/tasks/tools/install-kubectl/#enabling-shell-autocompletion) and don't forget to replace `kubectl` with `golangci-lint`. + +## CI Integration + +See our [GitHub Action](/usage/install#github-actions).