Skip to content

Commit

Permalink
Merge pull request #55 from IvanArkhipov1999/prettier
Browse files Browse the repository at this point in the history
Prettier
  • Loading branch information
gaurav-nelson authored May 28, 2024
2 parents 4ac8576 + bd13744 commit 05447dd
Show file tree
Hide file tree
Showing 25 changed files with 669 additions and 613 deletions.
1 change: 0 additions & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@

liberapay: gaurav-nelson
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
name: Bug report
about: Create a report to help us improve
title: "[BUG] "
title: '[BUG] '
labels: bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
Expand Down
3 changes: 1 addition & 2 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
name: Feature request
about: Suggest an idea for this project
title: "[FEATURE REQ] "
title: '[FEATURE REQ] '
labels: enhancement
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Run prettier check

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
prettier:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm ci
- run: npx prettier --check .
2 changes: 1 addition & 1 deletion .linkspector.test.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
files:
- README.md
useGitIgnore: true
useGitIgnore: true
6 changes: 6 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": false,
"singleQuote": true
}
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Thank you for considering contributing to Linkspector! We welcome contributions
1. [Getting Started](#getting-started)
2. [Code of Conduct](#code-of-conduct)
3. [How to Contribute](#how-to-contribute)
- [Reporting Issues](#reporting-issues)
- [Submitting Pull Requests](#submitting-pull-requests)
- [Reporting Issues](#reporting-issues)
- [Submitting Pull Requests](#submitting-pull-requests)
4. [Development Setup](#development-setup)
5. [Testing](#testing)
6. [Commit Messages](#commit-messages)
Expand Down
12 changes: 6 additions & 6 deletions DEV_SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ To contribute to this project, you'll need to set up your development environmen

Before you begin, make sure you have the following prerequisites installed on your system:

* **Node.js**: This project requires Node.js, a JavaScript runtime, to build and run. You can download and install Node.js from the official website: [Node.js Download](https://nodejs.org/).
- **Node.js**: This project requires Node.js, a JavaScript runtime, to build and run. You can download and install Node.js from the official website: [Node.js Download](https://nodejs.org/).

To check if Node.js is installed, open your terminal and run:
To check if Node.js is installed, open your terminal and run:

```bash
node -v
```
```bash
node -v
```

You should see the installed Node.js version.
You should see the installed Node.js version.

## Installation

Expand Down
38 changes: 28 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ npm install -g @umbrelladocs/linkspector
This command installs Linkspector globally, allowing you to use it from anywhere in your terminal. If you don't want to install using `npm` you can download the binary from GitHub releases.

### GitHub action

For more details, see [action-linkspector](https://github.com/UmbrellaDocs/action-linkspector)

## Checking Hyperlinks
Expand All @@ -48,18 +49,19 @@ To check hyperlinks in your markup language files, follow these steps:
linkspector check
```

* To specify a custom configuration file path:
- To specify a custom configuration file path:

```bash
linkspector check -c /path/to/custom-config.yml
```

* To output the results in JSON format:
- To output the results in JSON format:

```bash
linkspector check -j
```
The JSON output follows [rdjson](https://github.com/reviewdog/reviewdog/tree/master/proto/rdf#rdjson) format.

The JSON output follows [rdjson](https://github.com/reviewdog/reviewdog/tree/master/proto/rdf#rdjson) format.

1. Linkspector starts checking the hyperlinks in your files based on the configuration provided in the configuration file or using the default configuration. It then displays the results in your terminal.

Expand All @@ -84,6 +86,7 @@ useGitIgnore: true
Following are the available configuration options:

### Files to Check

The `files` section specifies the Markdown files that Linkspector should check for broken links. You can add the file paths you want to include in this list. For example:

```yaml
Expand All @@ -94,6 +97,7 @@ files:
```

### Directories to Search

The `dirs` section lists the directories where Linkspector should search for Markdown files. You can specify directories relative to the current working directory. For example:

```yaml
Expand All @@ -103,6 +107,7 @@ dirs:
```

### Excluded Files

The `excludedFiles` section allows you to specify Markdown files that should be excluded from the link checking process. Add the paths of the files you want to exclude. For example:

```yaml
Expand All @@ -112,6 +117,7 @@ excludedFiles:
```

### Excluded Directories

The `excludedDirs` section lets you specify directories that should be excluded from the link checking process. Provide the paths of the directories you want to exclude. For example:

```yaml
Expand All @@ -121,6 +127,7 @@ excludedDirs:
```

### Base URL

The `baseUrl` option sets the base URL that will be used when checking relative links in Markdown files. In this example:

```yaml
Expand All @@ -130,30 +137,33 @@ baseUrl: https://example.com
The base URL is set to `https://example.com`.

### Ignore Patterns

The `ignorePatterns` section allows you to define regular expressions that match URLs to be ignored during the link checking process. For example:

```yaml
ignorePatterns:
- pattern: "^https://example.com/skip/.*$"
- pattern: '^https://example.com/skip/.*$'
- pattern: "^(ftp)://[^\\s/$?#]*\\.[^\\s]*$"
```

In this example, URLs matching the specified patterns will be skipped during link checking.

### Replacement Patterns

The `replacementPatterns` section lets you define regular expressions and replacement strings to modify URLs during link checking. For example:

```yaml
replacementPatterns:
- pattern: "(https?://example.com)/(\\w+)/(\\d+)"
replacement: "$1/id/$3"
replacement: '$1/id/$3'
- pattern: "\\[([^\\]]+)\\]\\((https?://example.com)/file\\)"
replacement: "<a href=\"$2/file\">$1</a>"
replacement: '<a href="$2/file">$1</a>'
```

These patterns and replacements will be applied to URLs found in the Markdown files.

### Alive Status Codes

The `aliveStatusCodes` section allows you to specify a list of HTTP status codes that are considered as "alive" links. In this example:

```yaml
Expand All @@ -166,6 +176,7 @@ aliveStatusCodes:
Links returning any of these status codes will be considered valid.

### Use .gitignore

The `useGitIgnore` option, when set to `true`, indicates that Linkspector should use the rules defined in the `.gitignore` file to exclude files and directories. For example:

```yaml
Expand All @@ -175,17 +186,19 @@ useGitIgnore: true
When enabled, the app will respect the `.gitignore` rules during link checking.

### Check Modified Files Only

The `modifiedFilesOnly` option, when set to `true`, indicates that Linkspector should only check the files that have been modified in the last git commit. For example:

```yaml
modifiedFilesOnly: true
```

When enabled, Linkspector will use `git` to find the list of modified files and only check those files. Please note that this option requires `git` to be installed and available on your system path. If `git` is not installed or not found in the system path, Linkspector will throw an error.

Also, if no modified files are found in the list of files to check, Linkspector will skip link checking and exit with a message indicating that modified files are not specified in the configuration.


### Sample configuration

```yml
files:
- README.md
Expand All @@ -202,13 +215,13 @@ excludedDirs:
- excluded-folder2
baseUrl: https://example.com
ignorePatterns:
- pattern: "^https://example.com/skip/.*$"
- pattern: '^https://example.com/skip/.*$'
- pattern: "^(ftp)://[^\\s/$?#]*\\.[^\\s]*$"
replacementPatterns:
- pattern: "(https?://example.com)/(\\w+)/(\\d+)"
replacement: "$1/id/$3"
replacement: '$1/id/$3'
- pattern: "\\[([^\\]]+)\\]\\((https?://example.com)/file\\)"
replacement: "<a href=\"$2/file\">$1</a>"
replacement: '<a href="$2/file">$1</a>'
aliveStatusCodes:
- 200
- 201
Expand All @@ -227,6 +240,7 @@ REDISTRIBUTED.md, https://unlicense.org/, null, 186, net::ERR_SSL_VERSION_OR_CIP
```

If there are no errors, linkspector shows the following message:

```
✨ Success: All hyperlinks in the specified files are valid.
```
Expand All @@ -241,25 +255,29 @@ To use Linkspector with Docker, follow these steps:
cd linkspector
```
1. Build the docker image locally, while being at the root (`.`) of this project:

```bash
docker build --no-cache --pull --build-arg LINKSPECTOR_PACKAGE= -t umbrelladocs/linkspector .
```

1. To perform a check using the default configuration, while being at the root (`$PWD`) of the project to be checked:

```bash
docker run --rm -it -v $PWD:/app \
--name linkspector umbrelladocs/linkspector \
bash -c 'linkspector check'
```

To specify a custom configuration file path:

```bash
docker run --rm -it -v $PWD:/app -v $PWD/custom-config.yml:/path/to/custom-config.yml \
--name linkspector umbrelladocs/linkspector \
bash -c 'linkspector check -c /path/to/custom-config.yml'
```

## What's planned

- [x] Spinner for local runs.
- [ ] Create a GitHub action.
- [x] Modified files only check.
Expand Down
5 changes: 2 additions & 3 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# Security Policy

We aim to update the supported versions with patches for security vulnerabilities as soon as possible after they are disclosed.
We aim to update the supported versions with patches for security vulnerabilities as soon as possible after they are disclosed.
We recommend keeping your installation of Linkspector up to date, as we only support the latest release version with security updates.

| Version | Supported |
| ------- | ------------------ |
| latest | :white_check_mark: |


## Reporting a Vulnerability

Please report (suspected) security vulnerabilities to **[email protected]**.
Please report (suspected) security vulnerabilities to **[email protected]**.
You will receive a response from us within 48 hours. If the issue is confirmed, we will release a patch as soon as possible depending on the complexity of the issue.

**Please do not report security vulnerabilities through public GitHub issues.**
Loading

0 comments on commit 05447dd

Please sign in to comment.