# lint-gitlab-ci

> GitLab-ci script to lint .gitlab-ci.yml files.

Latest version **1.1.1** (published 2020-04-04) · GPL-3.0-only license · 0 weekly downloads

## Install

```sh
npm install lint-gitlab-ci
pnpm add lint-gitlab-ci
yarn add lint-gitlab-ci
bun add lint-gitlab-ci
```

Provides the command `lint-gitlab-ci`.

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2020-04-04 |
| First published | 2020-04-04 |
| Weekly downloads | 0 |
| License | GPL-3.0-only |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 9 |
| Unpacked size | 93.5 KB |
| Known vulnerabilities | 0 (+25 in 1 direct dependencies) |
| Install scripts | no |
| Author | StraightOuttaCrompton |
| Maintainers | straight-outta-crompton |
| Keywords | gitlab, gitlab-ci, lint, .gitlab-ci.yml, module, cli |

## Links

- npm: https://www.npmjs.com/package/lint-gitlab-ci
- Repository: https://gitlab.com/StraightOuttaCrompton/lint-gitlab-ci
- Issues: https://gitlab.com/StraightOuttaCrompton/lint-gitlab-ci/issues
- npm.io page: https://npm.io/package/lint-gitlab-ci

## Dependencies (9)

- [mz](https://npm.io/package/mz.md) ^2.7.0
- [path](https://npm.io/package/path.md) ^0.12.7
- [axios](https://npm.io/package/axios.md) ^0.19.2
- [chalk](https://npm.io/package/chalk.md) ^4.0.0
- [figlet](https://npm.io/package/figlet.md) ^1.3.0
- [@types/mz](https://npm.io/package/@types/mz.md) ^2.7.0
- [commander](https://npm.io/package/commander.md) ^5.0.0
- [@types/figlet](https://npm.io/package/@types/figlet.md) ^1.2.0
- [assign-default-values-to-object](https://npm.io/package/assign-default-values-to-object.md) ^1.0.1

## Alternatives

- [eslint-plugin-sonarjs](https://npm.io/package/eslint-plugin-sonarjs.md) — 2.9M weekly downloads
- [eslint-config-expo](https://npm.io/package/eslint-config-expo.md) — 1.5M weekly downloads
- [@matter/protocol](https://npm.io/package/@matter/protocol.md) — 63.5K weekly downloads
- [@eventcatalog/linter](https://npm.io/package/@eventcatalog/linter.md) — 24.8K weekly downloads
- [@pandacss/eslint-plugin](https://npm.io/package/@pandacss/eslint-plugin.md) — 18.7K weekly downloads

## Recent versions

- 1.1.1 (latest) — 2020-04-04
- 1.1.0 — 2020-04-04
- 1.0.4 — 2020-04-04
- 1.0.3 — 2020-04-04
- 1.0.2 — 2020-04-04
- 1.0.1 — 2020-04-04
- 1.0.0 — 2020-04-04

## README

# Lint GitLab CI

A module and cli that lints a `.gitlab-ci.yml` file, using the [GitLab ci lint api](https://docs.gitlab.com/ee/api/lint.html).

## Installing

```sh
npm install -g lint-gitlab-ci
```

## Module

### Basic usage

```ts
import lintGitlabCi from "lint-gitlab-ci";

lintGitlabCi().then((result) => {
    if (result.isValid) {
        console.log("Yay!");
    } else {
        console.log("Nay!");
    }
});
```

### Options

```ts
import lintGitlabCi, { ILintGitlabCiOptions } from "lint-gitlab-ci";

const options: ILintGitlabCiOptions = {
    filePath: "example-ci.yml",
    api: {
        baseUrl: "https://example.com/api",
        version: "exampleVersion",
        paths: {
            lintCiYml: "example/path",
        },
    },
};

lintGitlabCi(options).then((result) => {
    if (result.isValid) {
        console.log("Yay!");
    } else {
        console.log("Nay!");
    }
});
```

## Cli

### Cli basic usage

```sh
lint-gitlab-ci
```

This will lint a `.gitlab-ci.yml` file and output any errors.

#### Specify file

To specify a different ci file, pass the filename as an argument.

```sh
lint-gitlab-ci example-ci.yml
```

### Cli options

#### `-u, --url`

Specifies the GitLab api url to use - defaults to `https://gitlab.com/api`.

```sh
lint-gitlab-ci --url https://example.com/api
```

#### `-a, --api-version`

Specifies the GitLab api version to use - defaults to `v4`.

```sh
lint-gitlab-ci --api-version exampleVersion
```

#### `-p, --ci-lint-path`

Specifies the GitLab api ci linting path to use - defaults to `ci/lint`.

```sh
lint-gitlab-ci --ci-lint-path example/path
```

## Integration with [husky](https://github.com/typicode/husky)

Install `lint-gitlab-ci` and `husky`.

```sh
npm install -D lint-gitlab-ci husky
```

Configure `husky` to run the `lint-gitlab-ci` cli before committing.

```json
{
    "husky": {
        "hooks": {
            "pre-commit": "lint-gitlab-ci"
        }
    }
}
```

This will validate the current `.gitlab-ci.yml` and block the commit if the file is invalid.

## Credit

This project started as a `TypeScript` implementation of [this project](https://github.com/BuBuaBu/gitlab-ci-lint), but is now a completely new implementation.

---
_Source: https://npm.io/package/lint-gitlab-ci · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
