Skip to content

Commit 76025de

Browse files
authored
Merge pull request #813 from crowdsecurity/code-improvments
✨ Migrate linting & formatting to Biome + TypeScript improvements
2 parents 6f7745e + 1a637c1 commit 76025de

158 files changed

Lines changed: 5358 additions & 4493 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/lint.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Code quality
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
quality:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v4
12+
13+
- name: Setup Node.js
14+
uses: actions/setup-node@v4
15+
with:
16+
node-version: 20
17+
cache: "npm"
18+
cache-dependency-path: crowdsec-docs/package-lock.json
19+
20+
21+
- name: Install dependencies
22+
run: npm ci
23+
working-directory: ./crowdsec-docs/
24+
25+
- name: Setup Biome
26+
uses: biomejs/setup-biome@v2
27+
with:
28+
version: latest
29+
30+
- name: Run Biome
31+
run: biome ci .

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.vscode
22
node_modules
3+
.history

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ Online version of this documentation is available here: https://doc.crowdsec.net
66

77
The documentation is built using [Docusaurus](https://docusaurus.io/), a modern static website generator.
88

9+
## Pre-requisites
10+
11+
- Node.js (version 20 or later)
12+
- npm (Node package manager)
13+
- VSCode with recommended extensions installed (see `.vscode/extensions.json`)
14+
915
## Installation
1016

1117
```console
@@ -28,3 +34,12 @@ npm run build
2834

2935
This command generates static content into the `build` directory and can be served using any static contents hosting service.
3036
you can also use the `npm run serve` command to test the build locally.
37+
38+
## Linting and Formatting
39+
40+
This project uses [Biomes](https://biomejs.dev/) for linting and formatting. You can run the following commands:
41+
42+
```console
43+
npm run lint
44+
npm run format
45+
```

biome.json

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/2.0.6/schema.json",
3+
"vcs": { "enabled": false, "clientKind": "git", "useIgnoreFile": false },
4+
"files": {
5+
"ignoreUnknown": false,
6+
"includes": [
7+
"crowdsec-docs/**/*.ts",
8+
"crowdsec-docs/**/*.tsx",
9+
"crowdsec-docs/**/*.css",
10+
"!**/node_modules/**",
11+
"!crowdsec-docs/plugins/**",
12+
"!crowdsec-docs/build/**"
13+
]
14+
},
15+
"formatter": {
16+
"enabled": true,
17+
"formatWithErrors": false,
18+
"indentStyle": "tab",
19+
"indentWidth": 4,
20+
"lineEnding": "lf",
21+
"lineWidth": 140,
22+
"attributePosition": "auto",
23+
"bracketSameLine": false,
24+
"bracketSpacing": true,
25+
"expand": "auto",
26+
"useEditorconfig": true
27+
},
28+
"linter": {
29+
"enabled": true,
30+
"rules": {
31+
"recommended": true,
32+
"style": {
33+
"useImportType": "off"
34+
}
35+
}
36+
},
37+
"javascript": {
38+
"formatter": {
39+
"jsxQuoteStyle": "double",
40+
"quoteProperties": "asNeeded",
41+
"trailingCommas": "es5",
42+
"semicolons": "always",
43+
"arrowParentheses": "always",
44+
"bracketSameLine": false,
45+
"quoteStyle": "double",
46+
"attributePosition": "auto",
47+
"bracketSpacing": true
48+
}
49+
},
50+
"html": { "formatter": { "selfCloseVoidElements": "always" } },
51+
"css": {
52+
"formatter": {
53+
"enabled": true,
54+
"indentStyle": "tab",
55+
"indentWidth": 4,
56+
"lineEnding": "lf",
57+
"lineWidth": 140
58+
}
59+
},
60+
"assist": {
61+
"enabled": true,
62+
"actions": { "source": { "organizeImports": "on" } }
63+
}
64+
}

crowdsec-docs/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v20.18.1

crowdsec-docs/.prettierrc

Lines changed: 0 additions & 6 deletions
This file was deleted.

crowdsec-docs/babel.config.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

crowdsec-docs/components.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,19 @@
33
"tailwind": {
44
"config": "tailwind.config.js",
55
"css": "src/css/custom.css",
6-
"baseColor": "neutral",
7-
"prefix": "tw-",
8-
"cssVariables": false
6+
"baseColor": "gray",
7+
"prefix": "",
8+
"cssVariables": true
99
},
1010
"rsc": true,
1111
"aliases": {
12-
"utils": "@/src/utils",
13-
"components": "@/src/components",
14-
"ui": "@/src/ui",
15-
"hooks": "@/src/hooks",
16-
"lib": "@/src/lib"
12+
"utils": "@site/src/utils",
13+
"components": "@site/src/components",
14+
"ui": "@site/src/ui",
15+
"hooks": "@site/src/hooks",
16+
"lib": "@site/src/lib"
1717
},
18-
"style": "default"
18+
"style": "default",
19+
"iconLibrary": "lucide"
1920
}
2021

crowdsec-docs/docs/appsec/quickstart/traefik.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ id: traefik
33
title: Traefik
44
---
55

6-
import FormattedTabs from '@site/src/components/FormattedTabs';
6+
import FormattedTabs from '@site/src/components/formatted-tabs';
77

88
# CrowdSec WAF QuickStart for Traefik
99

crowdsec-docs/docs/getting_started/getting_started.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ id: getting_started
33
title: Getting Started
44
---
55

6-
import AcademyPromo from '@site/src/components/AcademyPromo';
6+
import AcademyPromo from '@site/src/components/academy-promo';
77

88
Welcome to CrowdSec!
99

@@ -15,8 +15,7 @@ To embark on your CrowdSec journey, the optimal starting point is to set up a co
1515

1616
The CrowdSec console serves as a web-based interface enabling you to conveniently monitor all your CrowdSec instances from a centralized hub. To get started, simply [sign up here](https://app.crowdsec.net/signup).
1717

18-
19-
## Deploy
18+
## Deploy
2019

2120
### Walkthrough
2221

@@ -43,8 +42,9 @@ In our updated documentation, we now refer to CrowdSec as the "Security Engine"
4342
#### Prerequisites
4443

4544
The Security Engine by default uses the following ports:
46-
- 8080/tcp for the API
47-
- 6060/tcp for the Prometheus metrics / Debugging
45+
46+
- 8080/tcp for the API
47+
- 6060/tcp for the Prometheus metrics / Debugging
4848

4949
If these ports are not available on your system, you can change them in the configuration file post installation. See [Configuration](/configuration/crowdsec_configuration.md) for more information.
5050

@@ -55,15 +55,15 @@ Please note that the API is mandatory for your security engine, do not remove it
5555
For the most straightforward installation of the Security Engine, utilize the official repository, guaranteeing you'll constantly have the latest version.
5656

5757
Please see the relevant documentation for your OS:
58-
- [Linux](/getting_started/install.mdx)
59-
- [FreeBSD](/getting_started/install_freebsd.md)
60-
- [Windows](/getting_started/getting_started_on_windows.md)
58+
59+
- [Linux](/getting_started/install.mdx)
60+
- [FreeBSD](/getting_started/install_freebsd.md)
61+
- [Windows](/getting_started/getting_started_on_windows.md)
6162

6263
#### Installing from source
6364

6465
Should you opt for a source-based installation, you can follow the steps outlined [here](/getting_started/install_source.mdx).
6566

66-
6767
### Remediation Component
6868

6969
After installing the Security Engine, you can proceed to install a Remediation Component, which is responsible for executing actions based on the decisions made by the Security Engine.
@@ -76,4 +76,4 @@ If you are uncertain about which one to install, please refer to our [Remediatio
7676

7777
Since you created your account on the CrowdSec console, you can now [enroll your Security Engine to your account](https://app.crowdsec.net/security-engines?enroll-engine=true).
7878

79-
To do so, you can find steps outlined [here](/u/getting_started/post_installation/console/#engines-page).
79+
To do so, you can find steps outlined [here](/u/getting_started/post_installation/console/#engines-page).

0 commit comments

Comments
 (0)