diff --git a/docs/getting-started.md b/docs/getting-started.md index 591214a9..bad32489 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -38,10 +38,10 @@ Create a lint file `hello.jsonnet`. This simple rule checks if data has a field `description`. ```jsonnet -function(param) { - name: 'description is required', - failed: !std.objectHas(param.data.value, 'description'), -} +function(param) + if std.objectHas(param.data.value, 'description') then [] else [{ + name: 'description is required', + }] ``` ## Edit the configuration file @@ -71,6 +71,8 @@ Then the command would fail because `hello.json` violates the lint rule of `hell ```console $ lintnet lint { + "lintnet_version": "", + "env": "darwin/arm64", "errors": [ { "rule": "description is required", diff --git a/docs/lint-rule.md b/docs/lint-rule.md index 09bd0bea..2a9ec96e 100644 --- a/docs/lint-rule.md +++ b/docs/lint-rule.md @@ -9,15 +9,10 @@ lintnet uses Jsonnet to write lint rules. e.g. ```jsonnet -function(param) if param.data.file_type != 'csv' then null else std.mapWithIndex(function(idx, line) { - message: 'age must be greater or equal than 18', - failed: std.parseInt(line[1]) < 18, - level: 'warn', - location: { - index: idx, - line: std.join(',', line), - }, -}, param.data.value) +function(param) + if std.objectHas(param.data.value, 'description') then [] else [{ + name: 'description is required', + }] ``` ## Top level arguments @@ -44,7 +39,6 @@ The format of `param` is JSONPath | type | description --- | --- | --- `.name` (required) | string | Rule name -`.failed` (required) | bool | If this is true, this means the file violates the rule `.message` | string | Error message `.level` | string | Error level `.location` | `string` or `any` | Location where errors occur diff --git a/docs/test-rule.md b/docs/test-rule.md index 7531c337..ce6b834d 100644 --- a/docs/test-rule.md +++ b/docs/test-rule.md @@ -24,7 +24,6 @@ function(param) [ result: [ // expected return value of the lint file { message: 'age must be greater or equal than 18', - failed: true, level: 'error', location: { index: 0,