Skip to content

Commit

Permalink
chore: add documentation scripts and update contribution guidelines
Browse files Browse the repository at this point in the history
- Added new npm scripts for documentation:
  - `docs:check`: Validates markdown documentation and ensures compliance.
  - `docs:fix`: Automatically fixes formatting issues in documentation.
  - `docs:update`: Updates rules documentation automatically.
- Improved the "Contribution Process" section to reflect the use of documentation-related scripts.
  • Loading branch information
zavoloklom committed Dec 15, 2024
1 parent 1fdbd1f commit 9931320
Show file tree
Hide file tree
Showing 8 changed files with 441 additions and 58 deletions.
180 changes: 149 additions & 31 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@
Please note that this project is released with a [Contributor Code of Conduct](./CODE_OF_CONDUCT.md). By participating
in this project you agree to abide by its causes.

## Table of Contents

1. [Prerequisites](#prerequisites)
2. [Contribution Process](#contribution-process)
- [1. Fork and Clone](#1-fork-and-clone)
- [2. Create a Branch](#2-create-a-branch)
- [3. Development](#3-development)
- [4. Verify Everything](#4-verify-everything)
- [5. Push Changes](#5-push-changes)
- [6. Create a Pull Request](#6-create-a-pull-request)
- [7. Code Review](#7-code-review)
- [8. Merge](#8-merge)
3. [Commit Message Conventions](#commit-message-conventions)
4. [How to Add a New Rule](#how-to-add-a-new-rule)
5. [How to Build the Project](#how-to-build-the-project)
6. [How to Build SEA](#how-to-build-sea)
7. [How to Build Docker Locally](#how-to-build-docker-locally)
8. [How to Update Compose Schema](#how-to-update-compose-schema)

## Prerequisites

Before making contributions, ensure the following:
Expand All @@ -13,15 +32,132 @@ Before making contributions, ensure the following:

## Contribution Process

1. **Fork and Clone**: Fork this project on GitHub and clone your fork locally.
2. **Create a Branch**: Create a new branch in your local repository. This keeps your changes organized and separate
from the main project.
3. **Development**: Make your changes in your branch. Here are a few things to keep in mind:
- **No Lint Errors**: Ensure your code changes adhere to the project's linting rules and do not introduce new lint
errors.
- **Testing**: All changes must be accompanied by passing tests. Add new tests if you are adding functionality or fix
existing tests if you are changing code.
- **Commit Convention**: Commit message must follow our [Commit Message Conventions](#commit-message-conventions).
### 1. Fork and Clone

- **Fork**: Navigate to the repository on GitHub and click the "Fork" button to create a copy of the repository in your
own GitHub account.
- **Clone**: Clone your forked repository to your local machine using the following command:

```bash
git clone https://github.com/<your-username>/docker-compose-linter.git
```

- Change into the project directory:

```bash
cd docker-compose-linter
```

### 2. Create a Branch

- Create a new branch to work on your changes. Use a descriptive name for the branch, such as `feature/add-new-rule` or
`fix/linting-error`:

```bash
git checkout -b <branch-name>
```

### 3. Development

Make your changes in the newly created branch. Follow these steps to ensure quality and consistency:

#### No Lint Errors

- Check your code against the project's linting rules to ensure consistency:

```bash
npm run lint
```

- If linting errors are reported, fix them before proceeding. You can also use the following command to auto-fix issues:

```bash
# eslint
npm run eslint:fix

# md files
npm run docs:fix
```

#### Testing

- All code changes must pass existing tests. If you are adding new functionality, ensure you write appropriate tests to
validate it.
- To run all tests:

```bash
npm run test
```

- If a test fails, resolve the issue before proceeding. For new features or bug fixes, include corresponding test cases.

#### Commit Convention

- Commit messages must follow our [Commit Message Conventions](#commit-message-conventions). This ensures clear and
meaningful commit history.
- Examples:
- For a bug fix: `fix: resolve crash when parsing invalid YAML`
- For a new feature: `feat: add support for custom validation schemas`
- Use the following command to commit your changes:

```bash
git commit -m "<type>: <message>"
```

#### Documentation Updates

- If your changes impact the documentation (e.g., adding a new rule or updating an existing feature), ensure you update
the relevant files in the `docs` folder.
- Validate your changes with `npm run docs:check` to ensure there are no issues.

### 4. Verify Everything

Before submitting your changes:

- **Run all tests**: Verify that your changes have not introduced any test failures.

```bash
npm run test
```

- **Build the project**: Ensure that the project builds successfully to verify that no issues have been introduced in
the build process:

```bash
npm run build
```

For more details on the build process and available configurations, refer to the
[How to Build the Project](#how-to-build-the-project) section.

- **Confirm functionality**: Ensure that your changes (e.g., new rules, fixes) work as intended using the linter.

### 5. Push Changes

Push your branch to your forked repository:

```bash
git push origin <branch-name>
```

### 6. Create a Pull Request

- Navigate to the original repository on GitHub and click the "Compare & Pull Request" button for your branch.
- Provide a clear and detailed description of your changes in the pull request.

### 7. Code Review

- Once your pull request is submitted, it will undergo a review process.
- Be open to feedback and make adjustments as needed. Push updates to your branch, and they will automatically appear in
the pull request.

### 8. Merge

- After your pull request has been approved and all checks have passed, it will be merged into the main repository.

Once your contribution is merged, it will become part of the project. I appreciate your hard work and contribution to
making this tool better. Also, I encourage you to continue participating in the project and joining in discussions and
future enhancements.

## Commit Message Conventions

Expand Down Expand Up @@ -97,6 +233,9 @@ fixable, this method can return the content unchanged.
1. Go to the `docs/rules/` folder.
2. Create a markdown file describing your new rule (for example `new-check-rule.md`) based on
[template](./docs/rules/__TEMPLATE__.md)
3. Run `npm run docs:check` to validate documentation.
4. Use the `npm run docs:update` script to automatically update the documentation for the rule from the source.
5. If there are formatting issues, run `npm run docs:fix` to automatically resolve them.

## How to Build the Project

Expand Down Expand Up @@ -252,7 +391,7 @@ ldd /bin/dclint
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1
```

## Build Docker File Locally
## How to Build Docker Locally

```shell
docker build --file Dockerfile . --tag zavoloklom/dclint:dev \
Expand Down Expand Up @@ -302,24 +441,3 @@ schema update:
```shell
npm run test
```

## Submitting Changes

After you've made your changes:

1. **Run Linters and Tests**: Before submitting your changes, run the linters and tests to ensure everything is in
order.
2. **Push to GitHub**: Push your changes to your fork on GitHub.
3. **Create a Merge Request**: Open a merge request from your fork/branch to the main repository on GitHub. Provide a
clear and detailed description of your changes and why they are necessary.
4. **Code Review**: Once your merge request is opened, it will be reviewed by other contributors. Be open to feedback
and willing to make further adjustments based on the discussions.
5. **Merge**: If your merge request passes the review, it will be merged into the main codebase.

## After Your Contribution

Once your contribution is merged, it will become part of the project. I appreciate your hard work and contribution to
making this tool better. Also, I encourage you to continue participating in the project and joining in discussions and
future enhancements.

**Thank you for contributing!**
46 changes: 32 additions & 14 deletions docs/rules/__TEMPLATE__.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,57 @@
# Rule name
# {{Capital Case ruleName}} Rule

Short rule description.
A concise and clear description of what this rule does and why it's important.

- **Rule Name:**
- **Type:**
- **Category:**
- **Severity:**
- **Fixable:**
- **Rule Name:** {{kebabCase ruleName}}
- **Type:** 'warning' | 'error'
- **Category:** 'style' | 'security' | 'best-practice' | 'performance'
- **Severity:** 'info' | 'minor' | 'major' | 'critical'
- **Fixable:** true | false

## Problematic Code Example

```yaml

# Provide an example
```

## Correct Code Example

```yaml

# Provide an example
```

## Rule Details and Rationale

Long rule description, why you should use it
Provide a detailed explanation of the rationale for this rule, including:

- **Why this rule exists:** Explain the problems it aims to solve.
- **How it works:** Describe its scope and logic.
- **Rationale:** Clarify the benefit or importance of following the rule.

## Options

> OPTIONAL: If this section is not applicable, please remove it.
## Options /OPTIONAL/
If this rule accepts any configuration options, explain them here.

## Known Limitations /OPTIONAL/
## Known Limitations

## When Not To Use It /OPTIONAL/
> OPTIONAL: If this section is not applicable, please remove it.
Document any edge cases or situations where this rule might not work as expected.

## When Not To Use It

> OPTIONAL: If this section is not applicable, please remove it.
Explain scenarios where disabling this rule might make sense or be necessary.

## Version

This rule was introduced in [v1.0.0](https://github.com/zavoloklom/docker-compose-linter/releases).
This rule was introduced in [v{{nextMajorVersion}}](https://github.com/zavoloklom/docker-compose-linter/releases).

## References

Provide all necessary references for this rule.

- [Reference link](https://example.com)
14 changes: 11 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 12 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,28 @@
"schemas"
],
"scripts": {
"commitlint": "commitlint --from=origin/main",
"build": "npm run build:lib & npm run build:cli & npm run build:pkg",
"build:cli": "rimraf bin && rollup -c rollup.config.cli.js",
"build:lib": "rimraf dist && rollup -c rollup.config.lib.js",
"build:pkg": "rimraf pkg && rollup -c rollup.config.pkg.js",
"changelog:fix": "markdownlint-cli2 --fix \"CHANGELOG.md\" && prettier --write \"CHANGELOG.md\"",
"commitlint": "commitlint --from=origin/main",
"debug": "tsc && node --import=tsimp/import --no-warnings --inspect ./src/cli/cli.ts ./tests/mocks/docker-compose.yml -c ./tests/mocks/.dclintrc",
"debug:bin": "node ./bin/dclint.cjs ./tests/mocks/docker-compose.correct.yml --fix",
"docs:check": "node --import=tsimp/import ./scripts/check-documentation.ts && npm run markdownlint",
"docs:fix": "npm run prettier && npm run markdownlint:fix",
"docs:update": "node --import=tsimp/import ./scripts/update-documentation.ts",
"eslint": "eslint .",
"eslint:fix": "eslint . --fix",
"lint": "npm run eslint && npm run markdownlint && npm run commitlint",
"lint": "npm run eslint && npm run docs:check && npm run commitlint",
"markdownlint": "markdownlint-cli2 \"**/*.md\" \"#node_modules\" \"#**/node_modules\"",
"markdownlint:fix": "markdownlint-cli2 --fix \"**/*.md\" \"#node_modules\" \"#**/node_modules\"",
"markdownlint:fix-changelog": "markdownlint-cli2 --fix \"CHANGELOG.md\" && prettier --write \"CHANGELOG.md\"",
"prepare": "husky",
"prettier": "prettier --write \"**/*.md\"",
"test": "ava --verbose",
"test:coverage": "rimraf coverage && mkdir -p coverage && c8 ava --tap | tap-xunit --package='dclint' > ./coverage/junit.xml",
"tsc": "tsc",
"update-compose-schema": "node --import=tsimp/import ./scripts/download-compose-schema.ts",
"prepare": "husky"
"update-compose-schema": "node --import=tsimp/import ./scripts/download-compose-schema.ts"
},
"dependencies": {
"ajv": "^8.17.1",
Expand All @@ -65,8 +68,8 @@
},
"devDependencies": {
"@babel/preset-env": "7.26.0",
"@commitlint/cli": "^19.6.0",
"@commitlint/config-conventional": "^19.6.0",
"@commitlint/cli": "19.6.0",
"@commitlint/config-conventional": "19.6.0",
"@rollup/plugin-babel": "6.0.4",
"@rollup/plugin-commonjs": "28.0.1",
"@rollup/plugin-json": "6.1.0",
Expand All @@ -88,6 +91,7 @@
"@typescript-eslint/parser": "7.14.1",
"ava": "6.2.0",
"c8": "10.1.2",
"change-case": "5.4.4",
"conventional-changelog-conventionalcommits": "8.0.0",
"eslint": "8.57.1",
"eslint-config-airbnb-base": "15.0.0",
Expand All @@ -100,7 +104,7 @@
"eslint-plugin-sonarjs": "1.0.3",
"eslint-plugin-unicorn": "56.0.1",
"esmock": "2.6.9",
"husky": "^9.1.7",
"husky": "9.1.7",
"markdownlint-cli2": "0.16.0",
"semantic-release": "24.2.0",
"tap-xunit": "2.4.1",
Expand Down
2 changes: 1 addition & 1 deletion release.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default {
[
'@semantic-release/exec',
{
prepareCmd: 'npm run markdownlint:fix-changelog || true',
prepareCmd: 'npm run changelog:fix || true',
},
],
[
Expand Down
Loading

0 comments on commit 9931320

Please sign in to comment.