Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: set markdown tabwidth: 4 #30608

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ indent_style = tab

[*.{yaml,yml,conf}]
indent_size = 2

[*.md]
indent_size = 4
40 changes: 20 additions & 20 deletions .github/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,34 +37,34 @@

Use these commands to help run your tests:

- To run a single test folder, specify the path
- To run a single test folder, specify the path

Check failure on line 40 in .github/contributing.md

View workflow job for this annotation

GitHub Actions / lint-docs

Spaces after list markers

.github/contributing.md:40:1 MD030/list-marker-space Spaces after list markers [Expected: 1; Actual: 3] https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md030.md

```bash
pnpm jest platform/gitlab
```
```bash
pnpm jest platform/gitlab
```

- To run against a single test file, specify down to the filename (suffix is not necessary)
- To run against a single test file, specify down to the filename (suffix is not necessary)

Check failure on line 46 in .github/contributing.md

View workflow job for this annotation

GitHub Actions / lint-docs

Spaces after list markers

.github/contributing.md:46:1 MD030/list-marker-space Spaces after list markers [Expected: 1; Actual: 3] https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md030.md

```bash
pnpm jest platform/gitlab/index
```
```bash
pnpm jest platform/gitlab/index
```

- To run a single test batch, the `-t` value must be part of the `describe` value of the test batch
- To run a single test batch, the `-t` value must be part of the `describe` value of the test batch

Check failure on line 52 in .github/contributing.md

View workflow job for this annotation

GitHub Actions / lint-docs

Spaces after list markers

.github/contributing.md:52:1 MD030/list-marker-space Spaces after list markers [Expected: 1; Actual: 3] https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md030.md

```bash
pnpm jest platform/gitlab/index -t "getJsonFile"
```
```bash
pnpm jest platform/gitlab/index -t "getJsonFile"
```

- To run a single test, the `-t` value must be part of the `it` value of the test batch
- To run a single test, the `-t` value must be part of the `it` value of the test batch

Check failure on line 58 in .github/contributing.md

View workflow job for this annotation

GitHub Actions / lint-docs

Spaces after list markers

.github/contributing.md:58:1 MD030/list-marker-space Spaces after list markers [Expected: 1; Actual: 3] https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md030.md

```bash
pnpm jest platform/gitlab/index -t "returns file content from given repo"
```
```bash
pnpm jest platform/gitlab/index -t "returns file content from given repo"
```

And some options:

- `--verbose=false` to avoid the test list
- `--collectCoverage=false` to avoid collecting coverage, faster for the part you need the test to pass
- `--verbose=false` to avoid the test list

Check failure on line 66 in .github/contributing.md

View workflow job for this annotation

GitHub Actions / lint-docs

Spaces after list markers

.github/contributing.md:66:1 MD030/list-marker-space Spaces after list markers [Expected: 1; Actual: 3] https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md030.md
- `--collectCoverage=false` to avoid collecting coverage, faster for the part you need the test to pass

Check failure on line 67 in .github/contributing.md

View workflow job for this annotation

GitHub Actions / lint-docs

Spaces after list markers

.github/contributing.md:67:1 MD030/list-marker-space Spaces after list markers [Expected: 1; Actual: 3] https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md030.md

## Do not force push to your pull request branch

Expand All @@ -78,8 +78,8 @@

Force pushing a PR, or using the "Update with rebase" button is OK when you:

- make large changes on a PR which require a full review anyway
- bring the branch up-to-date with the target branch and incorporating the changes is more work than to create a new PR
- make large changes on a PR which require a full review anyway

Check failure on line 81 in .github/contributing.md

View workflow job for this annotation

GitHub Actions / lint-docs

Spaces after list markers

.github/contributing.md:81:1 MD030/list-marker-space Spaces after list markers [Expected: 1; Actual: 3] https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md030.md
- bring the branch up-to-date with the target branch and incorporating the changes is more work than to create a new PR

Check failure on line 82 in .github/contributing.md

View workflow job for this annotation

GitHub Actions / lint-docs

Spaces after list markers

.github/contributing.md:82:1 MD030/list-marker-space Spaces after list markers [Expected: 1; Actual: 3] https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md030.md

## Apply maintainer provided review suggestions

Expand Down
12 changes: 6 additions & 6 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@

## Documentation (please check one with an [x])

- [ ] I have updated the documentation, or
- [ ] No documentation update is required
- [ ] I have updated the documentation, or

Check failure on line 17 in .github/pull_request_template.md

View workflow job for this annotation

GitHub Actions / lint-docs

Spaces after list markers

.github/pull_request_template.md:17:1 MD030/list-marker-space Spaces after list markers [Expected: 1; Actual: 3] https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md030.md
- [ ] No documentation update is required

Check failure on line 18 in .github/pull_request_template.md

View workflow job for this annotation

GitHub Actions / lint-docs

Spaces after list markers

.github/pull_request_template.md:18:1 MD030/list-marker-space Spaces after list markers [Expected: 1; Actual: 3] https://github.com/DavidAnson/markdownlint/blob/v0.34.0/doc/md030.md

## How I've tested my work (please select one)

I have verified these changes via:

- [ ] Code inspection only, or
- [ ] Newly added/modified unit tests, or
- [ ] No unit tests but ran on a real repository, or
- [ ] Both unit tests + ran on a real repository
- [ ] Code inspection only, or
- [ ] Newly added/modified unit tests, or
- [ ] No unit tests but ran on a real repository, or
- [ ] Both unit tests + ran on a real repository

<!-- Do you have any suggestions about this PR template? Edit it here: https://github.com/renovatebot/renovate/edit/main/.github/pull_request_template.md -->

Expand Down
24 changes: 12 additions & 12 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

To help us deliver great features and support the Renovate Open Source project we ask that you:

- are polite
- pay attention to details
- keep in mind that most maintainers are volunteers
- are respectful of the time and effort of the maintainers
- are polite
- pay attention to details
- keep in mind that most maintainers are volunteers
- are respectful of the time and effort of the maintainers

## Our priorities

Expand Down Expand Up @@ -43,9 +43,9 @@ Remember, most of the support provided by our team, including the Mend.io staff,

We quickly deal with rudeness in the community with:

- automated comments
- temporary blocks
- permanent bans
- automated comments
- temporary blocks
- permanent bans

If you keep breaking the rules or challenge our guidelines openly, you will be blocked.
For example: if you keep spamming the maintainers with `@mentions` or challenge our rules openly, you will be blocked.
Expand All @@ -59,11 +59,11 @@ Simply put: we block and unblock swiftly, what matters is how you follow the rul

Renovate's core contributors and maintainers focus on work that:

- Helps a lot of users, or
- Fixes regressions (errors introduced by recent changes), or
- Is required by a customer of Mend.io, or
- Is sponsored by third parties after independent validation, or
- We personally need or want to implement
- Helps a lot of users, or
- Fixes regressions (errors introduced by recent changes), or
- Is required by a customer of Mend.io, or
- Is sponsored by third parties after independent validation, or
- We personally need or want to implement

You may be disappointed when we focus on other work ahead of your feature or bug, but you should understand and accept this.

Expand Down
20 changes: 10 additions & 10 deletions docs/development/adding-a-package-manager.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ The manager's `index.ts` file supports the following values or functions:
Use this function to allow version bumps of updated packages.
For example:

- to increase the version of a Maven module if a package has been updated
- to bump the Helm chart version, if a subchart version has been updated
- to increase the version of a Maven module if a package has been updated
- to bump the Helm chart version, if a subchart version has been updated

### `extractPackageFile(content, packageFile, config)` (async, semi-mandatory)

This function is mandatory, unless you use `extractAllPackageFiles` instead.
It takes as arguments the file's content and optionally the file's full file pathname and config.
The function returns an array of detected or extracted dependencies, including the:

- dependency name
- dependency type (dependencies, devDependencies, etc)
- currentValue
- versioning used (like SemVer, PEP 440)
- dependency name
- dependency type (dependencies, devDependencies, etc)
- currentValue
- versioning used (like SemVer, PEP 440)

The `extractPackageFile` function doesn't need to fully _understand_ the file or syntax that it gets.
It needs to understand enough to extract a correct list of dependencies.
Expand Down Expand Up @@ -95,15 +95,15 @@ To _directly_ update dependencies in lock files: use `updateLockedDependency` in

`updateArtifacts` gets triggered:

- after a dependency update (for a package file), or
- during `lockfileMaintenance`
- after a dependency update (for a package file), or
- during `lockfileMaintenance`

### `updateDependency` (optional)

Use `updateDependency` if _both_ conditions apply:

- the manager can't be updated to use the standard replacing mechanism
- a custom replacement has to be provided
- the manager can't be updated to use the standard replacing mechanism
- a custom replacement has to be provided

### `updateLockedDependency` (optional)

Expand Down
130 changes: 65 additions & 65 deletions docs/development/best-practices.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ Finally, describe the changes in the branch in a few words.

Some good branch names:

- `feat/13732-cacache-cleanup`
- `fix/15431-gitea-automerge-strategy`
- `refactor/jest-reset-mocks`
- `docs/rewrite-packageRules-section`
- `feat/13732-cacache-cleanup`
- `fix/15431-gitea-automerge-strategy`
- `refactor/jest-reset-mocks`
- `docs/rewrite-packageRules-section`

Avoid branch names like `patch-1`.

Expand All @@ -25,27 +25,27 @@ Read the [GitHub Docs, renaming a branch](https://docs.github.com/en/repositorie

## General

- Prefer full function declarations for readability and better stack traces, so avoid `const func = ():void => {}`
- Prefer `interface` over `type` for TypeScript type declarations
- Avoid [Enums](https://github.com/renovatebot/renovate/issues/13743), use unions or [immutable objects](https://github.com/renovatebot/renovate/blob/5043379847818ac1fa71ff69c098451975e95710/lib/modules/versioning/pep440/range.ts#L8-L20) instead
- Always add unit tests for full code coverage
- Only use `istanbul` comments for unreachable code coverage that is needed for `codecov` completion
- Use descriptive `istanbul` comments
- Avoid cast or prefer `x as T` instead of `<T>x` cast
- Prefer `satisfies` operator over `as`, read the [TypeScript release notes for `satisfies` operator](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-9.html#the-satisfies-operator) to learn more
- Avoid `Boolean` instead use `is` functions from `@sindresorhus/is` package, for example: `is.string`
- Prefer full function declarations for readability and better stack traces, so avoid `const func = ():void => {}`
- Prefer `interface` over `type` for TypeScript type declarations
- Avoid [Enums](https://github.com/renovatebot/renovate/issues/13743), use unions or [immutable objects](https://github.com/renovatebot/renovate/blob/5043379847818ac1fa71ff69c098451975e95710/lib/modules/versioning/pep440/range.ts#L8-L20) instead
- Always add unit tests for full code coverage
- Only use `istanbul` comments for unreachable code coverage that is needed for `codecov` completion
- Use descriptive `istanbul` comments
- Avoid cast or prefer `x as T` instead of `<T>x` cast
- Prefer `satisfies` operator over `as`, read the [TypeScript release notes for `satisfies` operator](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-9.html#the-satisfies-operator) to learn more
- Avoid `Boolean` instead use `is` functions from `@sindresorhus/is` package, for example: `is.string`

```ts
// istanbul ignore next: can never happen
```

### Functions

- Use `function foo(){...}` to declare named functions
- Use function declaration instead of assigning function expression into local variables (`const f = function(){...}`) (TypeScript already prevents rebinding functions)
- Exception: if the function accesses the outer scope's `this` then use arrow functions assigned to variables instead of function declarations
- Regular functions _should not_ access `this`, but arrow functions and methods may access `this`
- Only use nested functions when the [lexical scope](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures) is used
- Use `function foo(){...}` to declare named functions
- Use function declaration instead of assigning function expression into local variables (`const f = function(){...}`) (TypeScript already prevents rebinding functions)
- Exception: if the function accesses the outer scope's `this` then use arrow functions assigned to variables instead of function declarations
- Regular functions _should not_ access `this`, but arrow functions and methods may access `this`
- Only use nested functions when the [lexical scope](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures) is used

#### Use arrow functions in expressions

Expand All @@ -59,7 +59,7 @@ Use:

```ts
bar(() => {
this.doSomething();
this.doSomething();
});
```

Expand Down Expand Up @@ -116,33 +116,33 @@ Nested code logic is hard to read and prone to logic mistakes.

```ts
function foo(str: string): boolean {
let result = false;
if (condition(str)) {
const x = extractData(str);
if (x) {
// do something
result = true;
let result = false;
if (condition(str)) {
const x = extractData(str);
if (x) {
// do something
result = true;
}
}
}
return result;
return result;
}
```

Simplified code:

```ts
function foo(str: string): boolean {
if (!condition(str)) {
return false;
}
if (!condition(str)) {
return false;
}

const x = extractData(str);
if (!x) {
return false;
}
const x = extractData(str);
if (!x) {
return false;
}

// do something
return true;
// do something
return true;
}
```

Expand Down Expand Up @@ -203,9 +203,9 @@ Array.from<number>({ length: 5 }).fill(0);

Use `for ( ... of ...)` loops instead of `[Array|Set|Map].prototype.forEach` and `for ( ... in ...)`.

- Using `for ( ... in ...)` for objects is error-prone. It will include enumerable properties from the prototype chain
- Using `for ( ... in ...)` to iterate over arrays, will counterintuitively return the array's indices
- Avoid `[Array|Set|Map].prototype.forEach`. It makes code harder to debug and defeats some useful compiler checks like reachability
- Using `for ( ... in ...)` for objects is error-prone. It will include enumerable properties from the prototype chain
- Using `for ( ... in ...)` to iterate over arrays, will counterintuitively return the array's indices
- Avoid `[Array|Set|Map].prototype.forEach`. It makes code harder to debug and defeats some useful compiler checks like reachability

Only use `Array.prototype.map()` when the return value is used, otherwise use `for ( ... of ...)`.

Expand Down Expand Up @@ -270,30 +270,30 @@ Use `UTC` to be time zone independent.

```ts
if (end) {
const now = DateTime.now().toUTC();
const eol = DateTime.fromISO(end, { zone: 'utc' });
return eol < now;
const now = DateTime.now().toUTC();
const eol = DateTime.fromISO(end, { zone: 'utc' });
return eol < now;
}
```

## Unit testing

- Separate the _Arrange_, _Act_ and _Assert_ phases with newlines
- Use `it.each` rather than `test.each`
- Prefer [Tagged Template Literal](https://jestjs.io/docs/api#2-testeachtablename-fn-timeout) style for `it.each`, Prettier will help with formatting
- See [Example](https://github.com/renovatebot/renovate/blob/768e178419437a98f5ce4996bafd23f169e530b4/lib/modules/platform/util.spec.ts#L8-L18)
- Mock Date/Time when testing a Date/Time dependent module
- For `Luxon` mocking see [Example](https://github.com/renovatebot/renovate/blob/5043379847818ac1fa71ff69c098451975e95710/lib/modules/versioning/distro.spec.ts#L7-L10)
- Prefer `jest.spyOn` for mocking single functions, or mock entire modules
- Avoid overwriting functions, for example: (`func = jest.fn();`)
- Prefer `toEqual`
- Use `toMatchObject` for huge objects when only parts need to be tested
- Avoid `toMatchSnapshot`, only use it for:
- huge strings like the Renovate PR body text
- huge complex objects where you only need to test parts
- Avoid exporting functions purely for the purpose of testing unless you really need to
- Avoid cast or prefer `x as T` instead of `<T>x` cast
- Use `partial<T>()` from `test/util` if only a partial object is required
- Separate the _Arrange_, _Act_ and _Assert_ phases with newlines
- Use `it.each` rather than `test.each`
- Prefer [Tagged Template Literal](https://jestjs.io/docs/api#2-testeachtablename-fn-timeout) style for `it.each`, Prettier will help with formatting
- See [Example](https://github.com/renovatebot/renovate/blob/768e178419437a98f5ce4996bafd23f169e530b4/lib/modules/platform/util.spec.ts#L8-L18)
- Mock Date/Time when testing a Date/Time dependent module
- For `Luxon` mocking see [Example](https://github.com/renovatebot/renovate/blob/5043379847818ac1fa71ff69c098451975e95710/lib/modules/versioning/distro.spec.ts#L7-L10)
- Prefer `jest.spyOn` for mocking single functions, or mock entire modules
- Avoid overwriting functions, for example: (`func = jest.fn();`)
- Prefer `toEqual`
- Use `toMatchObject` for huge objects when only parts need to be tested
- Avoid `toMatchSnapshot`, only use it for:
- huge strings like the Renovate PR body text
- huge complex objects where you only need to test parts
- Avoid exporting functions purely for the purpose of testing unless you really need to
- Avoid cast or prefer `x as T` instead of `<T>x` cast
- Use `partial<T>()` from `test/util` if only a partial object is required

## Fixtures

Expand All @@ -314,16 +314,16 @@ Declare types and function prototypes with [JSDoc](https://jsdoc.app/index.html)

## Classes

- Use [Typescript getter setters (Accessors) when needed](https://google.github.io/styleguide/tsguide.html#properties-used-outside-of-class-lexical-scope).
The getter must be a `pure function` i.e.
- The function return values are identical for identical arguments
- The function has no side effects
- Use [Typescript getter setters (Accessors) when needed](https://google.github.io/styleguide/tsguide.html#properties-used-outside-of-class-lexical-scope).
The getter must be a `pure function` i.e.
- The function return values are identical for identical arguments
- The function has no side effects

[Source](https://en.wikipedia.org/wiki/Pure_function)

- Omit constructors when defining Static classes
- [No `#private` fields](https://google.github.io/styleguide/tsguide.html#private-fields), use TypeScript's visibility annotations instead
- Avoid underscore suffixes or prefixes like `_prop`, instead use [whole words](https://google.github.io/styleguide/tsguide.html#properties-used-outside-of-class-lexical-scope) as the suffix or prefix like `internalProp`
- Omit constructors when defining Static classes
- [No `#private` fields](https://google.github.io/styleguide/tsguide.html#private-fields), use TypeScript's visibility annotations instead
- Avoid underscore suffixes or prefixes like `_prop`, instead use [whole words](https://google.github.io/styleguide/tsguide.html#properties-used-outside-of-class-lexical-scope) as the suffix or prefix like `internalProp`

## regex

Expand Down
Loading