Skip to content

Commit

Permalink
AG-25860 Add lint-staged to the integration docs
Browse files Browse the repository at this point in the history
Merge in ADGUARD-FILTERS/aglint from fix/AG-25860 to master

Squashed commit of the following:

commit 0f6b078
Author: Slava Leleka <[email protected]>
Date:   Wed Jan 24 18:45:32 2024 +0300

    docs/repo-integration.md edited online with Bitbucket

commit 0fafeb6
Author: scripthunter7 <[email protected]>
Date:   Wed Jan 24 16:41:08 2024 +0100

    Update

commit 54ac175
Author: scripthunter7 <[email protected]>
Date:   Wed Jan 24 16:35:06 2024 +0100

    Add lint-staged to the integration docs
  • Loading branch information
scripthunter7 committed Jan 24, 2024
1 parent 398dcac commit 31c3ab6
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions docs/repo-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Table of contents:
- [6. Use Husky hooks (optional)](#use-hooks)
- [Add pre-commit hook](#pre-commit)
- [Add post-merge hook](#post-merge)
- [Add lint-staged (optional)](#lint-staged)

If you have a GitHub repository for adblock filters, you can integrate AGLint to your repository. In this document,
we'll help you to do that.
Expand Down Expand Up @@ -264,8 +265,39 @@ If one of them is changed, it will run `npm install` to sync your dependencies,
> To make the hook work in Unix-like operating systems you may need to run
> `chmod ug+x .husky/post-merge`.

### <a name="lint-staged"></a> Add lint-staged (optional)

In most cases, you don't need to lint all files in your repository in the `pre-commit` hook.
You can lint only staged files that are going to be committed.

To do that, you can use [lint-staged] package. You can install it by running the following command:

```bash
npm install -D lint-staged
```

After that, add the following content to your `package.json` file:

```json
"lint-staged": {
"*.txt": "aglint"
}
```

(or simply run `npm pkg set lint-staged='{"*.txt": "aglint"}' --json`)

This will tell lint-staged to run AGLint on all staged `.txt` files.
You can customize this to fit your needs according to [lint-staged documentation][lint-staged-config].

Also, don't forget to update your `pre-commit` hook to run `lint-staged` instead of `npm run lint`:

```bash
npx husky set .husky/pre-commit "npx lint-staged"
```

[git]: https://git-scm.com/
[github-actions-docs]: https://docs.github.com/en/actions
[husky]: https://www.npmjs.com/package/husky
[lint-staged-config]: https://github.com/lint-staged/lint-staged#configuration
[lint-staged]: https://www.npmjs.com/package/lint-staged
[nodejs]: https://nodejs.org/en/

0 comments on commit 31c3ab6

Please sign in to comment.