# `alta lint`

> alta lint: validates every chart and content file (a chart folder, a .json with a 'schema', a universe folder); exit 1 on a problem.

Validates every chart and content file (a chart folder, a .json with a "schema", a universe folder); exit 1 on a problem.

*Les descriptions et les sorties sont en anglais, comme la CLI.*

## Usage

```text
alta lint [path…] [--repo] [--json] [--strict] [--game <file>]
```

## Arguments

| Nom | | Description |
|---|---|---|
| `path…` | *facultatif* | Files or folders to lint; folders are searched for charts and content files. |

## Options

| Nom | Type | Défaut | Description |
|---|---|---|---|
| `--repo` | *flag* |  | Lint all the content of the Alta OS repository. |
| `--json` | *flag* |  | Print the report as JSON (alta.check/1). |
| `--strict` | *flag* |  | Treat warnings as errors. |
| `--game` | *string* | *Défaut: the repository's game* | The game file to check quest packs against. |

## Codes de sortie

| Nom | Description |
|---|---|
| `0` | ok |
| `1` | problèmes trouvés |
| `2` | mauvais usage |
| `3` | pas dans cette version |

## Exemples

*Lint a chart*

```sh [Terminal]
alta lint my-agent
```

```text [Sortie]
ok   my-agent (chart)
     warning: source: The source still holds placeholders (zeros). [chart.source-placeholder]
       fix: Replace them with the commit git prints and the digest alta package prints.
       docs: https://docs.altasystem.ai/reference/errors#chart-source-placeholder
1 checked, 0 errors, 1 warning
```

*Warnings fail too*

```sh [Terminal]
alta lint my-agent --strict
```

```text [Sortie · exit 1]
FAIL my-agent (chart)
     warning: source: The source still holds placeholders (zeros). [chart.source-placeholder]
       fix: Replace them with the commit git prints and the digest alta package prints.
       docs: https://docs.altasystem.ai/reference/errors#chart-source-placeholder
1 checked, 0 errors, 1 warning
```

**JSON:**

*JSON for a CI or an editor*

```sh [Terminal]
alta lint my-agent --json
```

```json [Sortie]
{
  "schema": "alta.check/1",
  "ok": true,
  "files": [
    {
      "path": "my-agent",
      "kind": "chart",
      "ok": true,
      "problems": [],
      "warnings": [
        {
          "level": "warning",
          "message": "source: the source is a placeholder (zeros): `alta package` prints the tree digest, git the commit (chart.source-placeholder)",
          "field": "source",
          "rule": "chart.source-placeholder",
          "guide": "https://docs.altasystem.ai/reference/advanced/specs/alta-chart-0.1",
          "docs": "https://docs.altasystem.ai/reference/errors#chart-source-placeholder"
        }
      ]
    }
  ],
  "skipped": []
}
```

**TypeScript SDK:**

*La même chose en TypeScript, avec `validate` de `@altasystem/sdk` ; lance-le avec `node example.mjs`.*

```js [example.mjs]
// Validate a document in memory: its kind is read from its `schema` field.
import { validate } from "@altasystem/sdk";

const doc = {
  schema: "alta.quests/0.3",
  id: "my-pack",
  branch: "core",
  quests: [{
    uid: "core.my-pack.hello",
    title: { en: "Hello", fr: "Salut" },
    act: 1,
    giver: "daemon",
    steps: [{ id: "wave", kind: "manual", human: "judge", title: { en: "Wave at your agent", fr: "Fais signe à ton agent" } }],
    reward: { xp: 10 },
  }],
};

const ok = validate(doc);
console.log(ok.kind, ok.ok, ok.problems.length);

delete doc.quests[0].steps[0].kind;
const bad = validate(doc);
console.log(bad.ok, bad.problems[0].rule, bad.problems[0].field);
```

```text [Sortie]
quests true 0
false step.kind quests[0].steps[0].kind
```

## Voir aussi

- [Erreurs](https://docs.altasystem.ai/fr/reference/errors)
- [Vérifier un dépôt dans GitHub Actions](https://docs.altasystem.ai/fr/recipes/ci-github-actions)
- [alta dev](https://docs.altasystem.ai/fr/reference/cli/dev)
- [`validate` (SDK)](https://docs.altasystem.ai/fr/reference/sdk/validate)
