Skip to content

Commit 70c77d5

Browse files
authored
chore: add linter for Markdown files (#1361)
1 parent 3f2cbe9 commit 70c77d5

File tree

7 files changed

+352
-167
lines changed

7 files changed

+352
-167
lines changed

‎.github/workflows/lint.yaml‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ jobs:
3232
find . -type f -name '*.go' -not -path './testdata/*' -exec gofmt -w {} +
3333
git diff --exit-code
3434
35-
lint:
36-
name: Lint
35+
lint-go:
36+
name: Lint Go
3737
runs-on: ubuntu-latest
3838
steps:
3939

@@ -55,3 +55,12 @@ jobs:
5555
uses: golangci/golangci-lint-action@v8
5656
with:
5757
version: v2.1.6
58+
59+
lint-md:
60+
name: Lint Markdown
61+
runs-on: ubuntu-latest
62+
steps:
63+
- uses: actions/checkout@v4
64+
- uses: DavidAnson/markdownlint-cli2-action@v20
65+
with:
66+
config: .markdownlint-cli2.yaml

‎.markdownlint-cli2.yaml‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# A configuration file for markdownlint-cli2.
2+
3+
# Fix any fixable errors
4+
fix: false
5+
6+
# Rules description can be found at https://github.com/DavidAnson/markdownlint/blob/HEAD/doc/Rules.md
7+
config:
8+
# Default state for all rules
9+
default: true
10+
11+
# MD010/no-hard-tabs : Hard tabs : https://github.com/DavidAnson/markdownlint/blob/HEAD/doc/md010.md
12+
MD010:
13+
code_blocks: false
14+
15+
# MD013/line-length : Line length : https://github.com/DavidAnson/markdownlint/blob/HEAD/doc/md013.md
16+
MD013:
17+
line_length: 150
18+
code_block_line_length: 200
19+
20+
# MD033/no-inline-html : Inline HTML : https://github.com/DavidAnson/markdownlint/blob/HEAD/doc/md033.md
21+
MD033: false
22+
23+
# MD055/table-pipe-style : Table pipe style : https://github.com/DavidAnson/markdownlint/blob/HEAD/doc/md055.md
24+
MD055: false
25+
26+
# Define glob expressions to use
27+
globs:
28+
- "*.md"
29+
30+
# Disable banner message on stdout
31+
noBanner: true
32+
33+
# Show found files on stdout
34+
showFound: true

‎CODE_OF_CONDUCT.md‎

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
## Our Pledge
44

5-
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
5+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project
6+
and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression,
7+
level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
68

79
## Our Standards
810

@@ -24,19 +26,29 @@ Examples of unacceptable behavior by participants include:
2426

2527
## Our Responsibilities
2628

27-
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
29+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate
30+
and fair corrective action in response to any instances of unacceptable behavior.
2831

29-
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
32+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues,
33+
and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors
34+
that they deem inappropriate, threatening, offensive, or harmful.
3035

3136
## Scope
3237

33-
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
38+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community.
39+
Examples of representing a project or community include using an official project e-mail address, posting via an official social media account,
40+
or acting as an appointed representative at an online or offline event.
41+
Representation of a project may be further defined and clarified by project maintainers.
3442

3543
## Enforcement
3644

37-
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at minko@gechev.io. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
45+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [minko@gechev.io](mailto:minko@gechev.io).
46+
The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances.
47+
The project team is obligated to maintain confidentiality with regard to the reporter of an incident.
48+
Further details of specific enforcement policies may be posted separately.
3849

39-
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
50+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined
51+
by other members of the project's leadership.
4052

4153
## Attribution
4254

‎CONTRIBUTING.md‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@ Prerequisites:
1616

1717
## Submitting a Pull Request
1818

19-
All submissions, including submissions by project members, require review. We use GitHub pull requests for this purpose. See our [developer guide](DEVELOPING.md) for instructions on building the project.
19+
All submissions, including submissions by project members, require review. We use GitHub pull requests for this purpose.
20+
See our [developer guide](DEVELOPING.md) for instructions on building the project.
2021

21-
Pull requests (fixes, new features, tests) are a great way to contribute to the project and help us make it better. Ideally, try to keep your PRs as focused as possible and keep your commits atomic and readable.
22+
Pull requests (fixes, new features, tests) are a great way to contribute to the project and help us make it better.
23+
Ideally, try to keep your PRs as focused as possible and keep your commits atomic and readable.
2224

23-
To avoid disappointment when working on a PR, please ask us first in case someone else is already working on a PR for a change you wished to make. It's always a good idea to file an issue before starting work on a PR unless it's for something minor (such as a typo fix).
25+
To avoid disappointment when working on a PR, please ask us first in case someone else is already working on a PR for a change you wished to make.
26+
It's always a good idea to file an issue before starting work on a PR unless it's for something minor (such as a typo fix).
2427

2528
We greatly appreciate any attention to tests. These help us validate that new work continues to function as expected over time.
2629

‎DEVELOPING.md‎

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ This document explains how to build, test, and develop features for revive.
66

77
Clone the project:
88

9-
```
9+
```bash
1010
git clone git@github.com:mgechev/revive.git
1111
cd revive
1212
```
13+
1314
## Build
1415

1516
In order to build the project run:
17+
1618
```bash
1719
make build
1820
```
@@ -33,14 +35,17 @@ This will output debug information to `stderr` and to the log file `revive.log`
3335

3436
If you want to develop a new rule, follow as an example the already existing rules in the [rule package](https://github.com/mgechev/revive/tree/master/rule).
3537

36-
Each rule needs to implement the `lint.Rule` interface:
38+
Each rule needs to implement the `lint.Rule` interface:
39+
3740
```go
3841
type Rule interface {
3942
Name() string
4043
Apply(*File, Arguments) []Failure
4144
}
4245
```
46+
4347
All rules with a configuration must implement `lint.ConfigurableRule` interface:
48+
4449
```go
4550
type ConfigurableRule interface {
4651
Configure(Arguments) error
@@ -49,9 +54,10 @@ type ConfigurableRule interface {
4954

5055
The `Arguments` type is an alias of the type `[]any`. The arguments of the rule are passed from the configuration file.
5156

52-
#### Example
57+
### Example
5358

54-
Let's suppose we have developed a rule called `BanStructNameRule` which disallow us to name a structure with a given identifier. We can set the banned identifier by using the TOML configuration file:
59+
Let's suppose we have developed a rule called `BanStructNameRule` which disallow us to name a structure with a given identifier.
60+
We can set the banned identifier by using the TOML configuration file:
5561

5662
```toml
5763
[rule.ban-struct-name]
@@ -61,10 +67,10 @@ Let's suppose we have developed a rule called `BanStructNameRule` which disallow
6167
With the snippet above we:
6268

6369
- Enable the rule with the name `ban-struct-name`. The `Name()` method of our rule should return a string that matches `ban-struct-name`.
64-
- Configure the rule with the argument `Foo`. The list of arguments will be passed to `Apply(*File, Arguments)` together with the target file we're linting currently.
65-
66-
A sample rule implementation can be found [here](/rule/argument_limit.go).
70+
- Configure the rule with the argument `Foo`.
71+
The list of arguments will be passed to `Apply(*File, Arguments)` together with the target file we're linting currently.
6772

73+
A sample rule implementation can be [found here](/rule/argument_limit.go).
6874

6975
## Development of formatters
7076

@@ -78,3 +84,27 @@ type Formatter interface {
7884
Name() string
7985
}
8086
```
87+
88+
## Lint
89+
90+
### Lint Markdown files
91+
92+
We are using [markdownlint](https://github.com/DavidAnson/markdownlint) for checking Markdown files.
93+
94+
1. Install [markdownlint-cli2](https://github.com/DavidAnson/markdownlint-cli2#install).
95+
2. Run the following command:
96+
97+
```sh
98+
$ markdownlint-cli2 .
99+
Finding: *.{md,markdown} *.md
100+
Found:
101+
CODE_OF_CONDUCT.md
102+
CONTRIBUTING.md
103+
DEVELOPING.md
104+
README.md
105+
RULES_DESCRIPTIONS.md
106+
Linting: 5 file(s)
107+
Summary: 0 error(s)
108+
```
109+
110+
The tool automatically uses the config file [.markdownlint-cli2.yaml](./.markdownlint-cli2.yaml).

0 commit comments

Comments
 (0)