Skip to content

Commit

Permalink
ci(docs): linting and formatting (#1403)
Browse files Browse the repository at this point in the history
* ci: eslint and prettier

* fix: eslint issues

* fix: prettier issues

* ci: add workflow

* ci: fix doc check

* ci: update linter configs

* docs: formatting fixes
  • Loading branch information
gotbadger authored Nov 17, 2023
1 parent 5b5a1c8 commit cc619e4
Show file tree
Hide file tree
Showing 71 changed files with 4,268 additions and 1,054 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/command_doc_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,25 @@ jobs:
go-version: 1.21
- name: Generate command docs
run: go run ./scripts/gen-doc-yaml.go
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "16"
- name: Cache dependencies
uses: actions/cache@v3
working-directory: ./docs
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: npm ci
working-directory: ./docs
- name: prettier
run: npm run prettier:fix
working-directory: ./docs
- name: Pick up any new files
run: git add .
- name: Check no uncommited changes
run: git diff --exit-code
2 changes: 2 additions & 0 deletions .github/workflows/e2e_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ on:
- opened
- synchronize
- reopened
paths-ignore:
- 'docs/**'
permissions:
contents: read
jobs:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
- opened
- synchronize
- reopened
paths-ignore:
- 'docs/**'
permissions:
contents: read
jobs:
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/lint_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Lint Docs
on:
pull_request:
types:
- opened
- synchronize
- reopened
paths:
- 'docs/**'
permissions:
contents: read
jobs:
lint:
defaults:
run:
working-directory: docs
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "16"
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: npm ci
- name: eslint
run: npm run lint
- name: prettier
run: npm run prettier

2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ on:
- opened
- synchronize
- reopened
paths-ignore:
- 'docs/**'
permissions:
contents: read
jobs:
Expand Down
9 changes: 5 additions & 4 deletions docs/.eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const mdSetup = markdownIt({ html: true })
mdSetup.renderer.rules.code_inline = (tokens, idx, { langPrefix = "" }) => {
const token = tokens[idx]
return `<code class="${langPrefix}">${mdSetup.utils.escapeHtml(
token.content
token.content,
)}</code>`
}

Expand Down Expand Up @@ -66,7 +66,7 @@ module.exports = function (eleventyConfig) {
eleventyConfig.addShortcode("yamlExample", function (exampleName) {
const example = fs.readFileSync(
`./_data/examples/${exampleName}.yaml`,
"utf8"
"utf8",
)
return "```yaml\n" + example + "\n```"
})
Expand Down Expand Up @@ -122,7 +122,8 @@ module.exports = function (eleventyConfig) {
})
eleventyConfig.addFilter("deduplicate", (arr) => {
const result = arr.filter(
(value, index, self) => index === self.findIndex((t) => t.id === value.id)
(value, index, self) =>
index === self.findIndex((t) => t.id === value.id),
)
return result
})
Expand Down Expand Up @@ -218,7 +219,7 @@ module.exports = function (eleventyConfig) {
return `<div class="elv-callout${
level ? ` elv-callout-${level}` : ""
}">${labelHtml}${contentHtml}</div>`
}
},
)

return {
Expand Down
12 changes: 12 additions & 0 deletions docs/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
env: {
browser: true,
commonjs: true,
es2021: true,
node: true,
},
extends: ["standard", "prettier"],
parserOptions: {
ecmaVersion: "latest",
},
}
2 changes: 1 addition & 1 deletion docs/404.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ Sorry, but we couldn't find the page you were looking for.
- Want to get started right away? Head over to the [quick start guide](/quickstart/).
- Bearer CLI detects [all sorts of data types](/reference/datatypes/) and has [built-in rules](/reference/rules/) to check for data security risks.

If you're looking for help using Bearer CLI, you can [create a new issue on GitHub]({{meta.links.issues}}) or join our [discord community]({{meta.links.discord}}).
If you're looking for help using Bearer CLI, you can [create a new issue on GitHub]({{meta.links.issues}}) or join our [discord community]({{meta.links.discord}}).
20 changes: 10 additions & 10 deletions docs/_data/bearer.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: bearer
options:
- name: help
shorthand: h
default_value: "false"
usage: help for bearer
- name: help
shorthand: h
default_value: "false"
usage: help for bearer
see_also:
- bearer completion - Generate the autocompletion script for the your shell.
- bearer ignore - Manage ignored fingerprints
- bearer init - Generates a default config to `bearer.yml`
- bearer scan - Scan a directory or file
- bearer version - Print the version
aliases:
- bearer completion - Generate the autocompletion script for the your shell.
- bearer ignore - Manage ignored fingerprints
- bearer init - Generates a default config to `bearer.yml`
- bearer scan - Scan a directory or file
- bearer version - Print the version
aliases:
18 changes: 9 additions & 9 deletions docs/_data/bearerAction.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
const EleventyFetch = require("@11ty/eleventy-fetch");
const yaml = require("js-yaml");
const EleventyFetch = require("@11ty/eleventy-fetch")
const yaml = require("js-yaml")
module.exports = async function () {
let action;
let action
try {
const response = await EleventyFetch(
"https://raw.githubusercontent.com/Bearer/bearer-action/main/action.yml",
{
duration: "60m",
type: "text",
}
);
action = yaml.load(response);
},
)
action = yaml.load(response)
} catch (err) {
console.log("Could not fetch release");
console.log("Could not fetch release")
}
return {
...action,
};
};
}
}
12 changes: 6 additions & 6 deletions docs/_data/bearer_completion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: bearer completion
synopsis: Generate the autocompletion script for the your shell.
usage: bearer completion [command]
options:
- name: help
shorthand: h
default_value: "false"
usage: help for completion
- name: help
shorthand: h
default_value: "false"
usage: help for completion
see_also:
- 'bearer - '
aliases:
- "bearer - "
aliases:
98 changes: 49 additions & 49 deletions docs/_data/bearer_ignore_add.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,54 @@ name: bearer ignore add
synopsis: Add an ignored fingerprint
usage: bearer ignore add <fingerprint> [flags]
options:
- name: api-key
usage: Use your Bearer API Key to send the report to Bearer.
- name: author
shorthand: a
usage: |
Add author information to this ignored finding. (default output of "git config user.name")
- name: comment
usage: Add a comment to this ignored finding.
- name: config-file
default_value: bearer.yml
usage: Load configuration from the specified path.
- name: debug
default_value: "false"
usage: Enable debug logs. Equivalent to --log-level=debug
- name: debug-profile
default_value: "false"
usage: Generate profiling data for debugging
- name: disable-version-check
default_value: "false"
usage: Disable Bearer version checking
- name: false-positive
default_value: "false"
usage: Mark an this ignored finding as false positive.
- name: force
default_value: "false"
usage: Overwrite an existing ignored finding.
- name: help
shorthand: h
default_value: "false"
usage: help for add
- name: host
default_value: my.bearer.sh
usage: Specify the Host for sending the report.
- name: ignore-file
default_value: bearer.ignore
usage: Load ignore file from the specified path.
- name: ignore-git
default_value: "false"
usage: Ignore Git listing
- name: log-level
default_value: info
usage: Set log level (error, info, debug, trace)
- name: no-color
default_value: "false"
usage: Disable color in output
- name: api-key
usage: Use your Bearer API Key to send the report to Bearer.
- name: author
shorthand: a
usage: |
Add author information to this ignored finding. (default output of "git config user.name")
- name: comment
usage: Add a comment to this ignored finding.
- name: config-file
default_value: bearer.yml
usage: Load configuration from the specified path.
- name: debug
default_value: "false"
usage: Enable debug logs. Equivalent to --log-level=debug
- name: debug-profile
default_value: "false"
usage: Generate profiling data for debugging
- name: disable-version-check
default_value: "false"
usage: Disable Bearer version checking
- name: false-positive
default_value: "false"
usage: Mark an this ignored finding as false positive.
- name: force
default_value: "false"
usage: Overwrite an existing ignored finding.
- name: help
shorthand: h
default_value: "false"
usage: help for add
- name: host
default_value: my.bearer.sh
usage: Specify the Host for sending the report.
- name: ignore-file
default_value: bearer.ignore
usage: Load ignore file from the specified path.
- name: ignore-git
default_value: "false"
usage: Ignore Git listing
- name: log-level
default_value: info
usage: Set log level (error, info, debug, trace)
- name: no-color
default_value: "false"
usage: Disable color in output
example: |-
# Add an ignored fingerprint to your ignore file
$ bearer ignore add <fingerprint> --author Mish --comment "Possible false positive"
# Add an ignored fingerprint to your ignore file
$ bearer ignore add <fingerprint> --author Mish --comment "Possible false positive"
see_also:
- bearer ignore - Manage ignored fingerprints
aliases:
- bearer ignore - Manage ignored fingerprints
aliases:
Loading

0 comments on commit cc619e4

Please sign in to comment.