chore: simplify external tools dependency management

This commit is contained in:
Théo LUDWIG 2024-02-08 21:33:35 +01:00
parent 582bf63624
commit c8c2f73a2f
Signed by: theoludwig
GPG Key ID: ADFE5A563D718F3B
10 changed files with 2646 additions and 89 deletions

View File

@ -10,5 +10,5 @@ charset = utf-8
trim_trailing_whitespace = true trim_trailing_whitespace = true
insert_final_newline = true insert_final_newline = true
[*.{yml,yaml,md}] [*.{yml,yaml,json,md}]
indent_size = 2 indent_size = 2

View File

@ -24,31 +24,14 @@ jobs:
components: "clippy, rustfmt" components: "clippy, rustfmt"
- run: "rustc --version" - run: "rustc --version"
- run: "cargo install cargo-run-bin@1.7.2"
- run: "cargo build --verbose" - run: "cargo build --verbose"
- run: "cargo bin mdbook build"
- run: "cargo test --verbose" - run: "cargo test --verbose"
- run: "cargo clippy --verbose -- -D warnings" - run: "cargo clippy --verbose -- -D warnings"
- run: "cargo fmt -- --check" - run: "cargo fmt -- --check"
lint-markdown:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v4.1.1"
- uses: "DavidAnson/markdownlint-cli2-action@v15.0.0"
with:
config: ".markdownlint-cli2.jsonc"
globs: "**/*.md"
lint-commit:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v4.1.1"
- uses: "wagoid/commitlint-github-action@v5.4.5"
with:
configFile: ".commitlintrc.json"
failOnWarnings: true
lint-general: lint-general:
runs-on: "ubuntu-latest" runs-on: "ubuntu-latest"
steps: steps:
@ -57,10 +40,11 @@ jobs:
- name: "Setup Node.js" - name: "Setup Node.js"
uses: "actions/setup-node@v4.0.1" uses: "actions/setup-node@v4.0.1"
with: with:
node-version: "20.11.0" node-version: "20.x"
- run: "npm install --global editorconfig-checker@5.1.2" - run: "npm clean-install"
- run: "npm install --global prettier@3.2.4"
- run: "editorconfig-checker" - run: 'npm run lint:commit -- --to "${{ github.sha }}"'
- run: "prettier . --check" - run: "npm run lint:editorconfig"
- run: "npm run lint:markdown"
- run: "npm run lint:prettier"

7
.gitignore vendored
View File

@ -1,3 +1,4 @@
target/ target
book/ node_modules
.bin/ book
.bin

View File

@ -1,33 +1,12 @@
{ {
"config": { "config": {
"extends": "markdownlint/style/prettier",
"default": true, "default": true,
"no-inline-html": false, "relative-links": true,
"no-duplicate-heading": false, "no-duplicate-heading": false,
"no-inline-html": false,
/* Disables rules that may conflict with Prettier */
/* Reference: https://github.com/DavidAnson/markdownlint/blob/main/style/prettier.json */
"blanks-around-fences": false,
"blanks-around-headings": false,
"blanks-around-lists": false,
"code-fence-style": false,
"emphasis-style": false,
"heading-start-left": false,
"hr-style": false,
"line-length": false,
"list-indent": false,
"list-marker-space": false,
"no-blanks-blockquote": false,
"no-hard-tabs": false,
"no-missing-space-atx": false,
"no-missing-space-closed-atx": false,
"no-multiple-blanks": false,
"no-multiple-space-atx": false,
"no-multiple-space-blockquote": false,
"no-multiple-space-closed-atx": false,
"no-trailing-spaces": false,
"ol-prefix": false,
"strong-style": false,
"ul-indent": false,
}, },
"globs": ["**/*.md"], "globs": ["**/*.md"],
"ignores": ["**/node_modules", "**/target", "**/book", "**/.bin"],
"customRules": ["markdownlint-rule-relative-links"],
} }

View File

@ -1,3 +1,3 @@
{ {
"semi": false "semi": false
} }

View File

@ -1,9 +1,9 @@
{ {
"recommendations": [ "recommendations": [
"editorconfig.editorconfig", "editorconfig.editorconfig",
"esbenp.prettier-vscode", "esbenp.prettier-vscode",
"davidanson.vscode-markdownlint", "davidanson.vscode-markdownlint",
"rust-lang.rust-analyzer", "rust-lang.rust-analyzer",
"tamasfe.even-better-toml" "tamasfe.even-better-toml"
] ]
} }

32
.vscode/settings.json vendored
View File

@ -1,18 +1,18 @@
{ {
"rust-analyzer.check.command": "clippy", "rust-analyzer.check.command": "clippy",
"[rust]": { "[rust]": {
"editor.defaultFormatter": "rust-lang.rust-analyzer", "editor.defaultFormatter": "rust-lang.rust-analyzer",
"editor.tabSize": 4, "editor.tabSize": 4,
"editor.formatOnSave": true "editor.formatOnSave": true
}, },
"[toml]": { "[toml]": {
"editor.defaultFormatter": "tamasfe.even-better-toml", "editor.defaultFormatter": "tamasfe.even-better-toml",
"editor.formatOnSave": true "editor.formatOnSave": true
}, },
"editor.defaultFormatter": "esbenp.prettier-vscode", "editor.defaultFormatter": "esbenp.prettier-vscode",
"prettier.configPath": ".prettierrc.json", "prettier.configPath": ".prettierrc.json",
"editor.formatOnSave": true, "editor.formatOnSave": true,
"editor.codeActionsOnSave": { "editor.codeActionsOnSave": {
"source.fixAll": "explicit" "source.fixAll": "explicit"
} }
} }

View File

@ -49,14 +49,13 @@ cargo install cargo-run-bin@1.7.2
#### External Linting Tools (optional) #### External Linting Tools (optional)
**External linting tools** are used to ensure a consistent code style and commit message format. They are **used in the Continuous Integration (CI)** pipeline and **can be optionally used locally**. **External linting tools** are used to ensure a consistent code style (external to Rust) and commit message format. They are **used in the Continuous Integration (CI)** pipeline and **can be optionally used locally**.
They have to be installed using [Node.js](https://nodejs.org/) >= v20.0.0 and [npm](https://www.npmjs.com/) >= v10.0.0. They have to be installed using [Node.js](https://nodejs.org/) >= v20.0.0 and [npm](https://www.npmjs.com/) >= v10.0.0.
- [editorconfig-checker](https://editorconfig-checker.github.io/) (`npm install --global editorconfig-checker@5.1.2`) ```sh
- [Prettier](https://prettier.io/) v3.2.4 (`npm install --global prettier@3.2.4`) npm clean-install
- [markdownlint-cli2](https://github.com/DavidAnson/markdownlint-cli2) v0.12.1 (`npm install --global markdownlint-cli2@0.12.1`) ```
- [commitlint](https://commitlint.js.org/#/) v18.6.0 (`npm install --global @commitlint/cli@18.6.0 @commitlint/config-conventional@18.6.0`)
### Usage ### Usage
@ -67,17 +66,17 @@ cargo run -- --help
# Documentation # Documentation
cargo bin mdbook serve cargo bin mdbook serve
# Build, Lint, and Test # Build, Lint, and Test Usage
cargo build cargo build
cargo test cargo test
cargo clippy --verbose -- -D warnings cargo clippy --verbose -- -D warnings
cargo fmt -- --check cargo fmt -- --check
# External Linting Tools Usage (optional) # External Linting Tools Usage (optional)
editorconfig-checker echo 'chore: try commitlint' | npm run lint:commit
prettier . --check npm run lint:editorconfig
markdownlint-cli2 npm run lint:markdown
echo 'chore: try commitlint' | commitlint npm run lint:prettier
``` ```
## 💡 Contributing ## 💡 Contributing

2570
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

24
package.json Normal file
View File

@ -0,0 +1,24 @@
{
"name": "fileformats",
"private": true,
"type": "module",
"engines": {
"node": ">=20.0.0",
"npm": ">=10.0.0"
},
"scripts": {
"lint:commit": "commitlint",
"lint:editorconfig": "editorconfig-checker",
"lint:markdown": "markdownlint-cli2",
"lint:prettier": "prettier . --check"
},
"devDependencies": {
"@commitlint/cli": "18.6.0",
"@commitlint/config-conventional": "18.6.0",
"editorconfig-checker": "5.1.3",
"markdownlint": "0.33.0",
"markdownlint-cli2": "0.12.1",
"markdownlint-rule-relative-links": "2.3.1",
"prettier": "3.2.5"
}
}