Skip to content

Latest commit

 

History

History
146 lines (106 loc) · 3.08 KB

File metadata and controls

146 lines (106 loc) · 3.08 KB

Check Types

Every check type has a mirror inverse. File-level checks operate on raw file content. Field-level checks parse structured files and inspect individual fields.

File Checks

file_exists

Passes if the file specified by the table path (or expect) exists in the matched directory.

["services/*"."package.json"]
name = "must-have-package-json"
check = "file_exists"

file_not_exists

Passes if the file does not exist.

["services/*".no-env-files]
check = "file_not_exists"
expect = ".env"

file_contains

Passes if the file exists and contains the substring specified by pattern.

["services/*"."tsconfig.json"]
name = "tsconfig-extends-base"
check = "file_contains"
pattern = "extends"

file_not_contains

Passes if the file exists and does not contain the substring, or if the file does not exist.

["services/*"."src/index.ts"]
name = "no-console-logs"
check = "file_not_contains"
pattern = "console.log"

Field Checks

Field checks require format and field. The field value uses dot-notation to traverse nested objects (e.g. "engines.node").

Supported formats: "json", "yaml", "toml".

field_exists

Passes if the field exists in the parsed file.

["services/*".must-have-engines]
check = "field_exists"
expect = "package.json"
format = "json"
field = "engines"

field_not_exists

Passes if the field does not exist.

["packages/*".no-private-flag]
check = "field_not_exists"
expect = "package.json"
format = "json"
field = "private"

field_contains

Passes if the field exists and its stringified value contains the substring in pattern.

["services/*".correct-node-version]
check = "field_contains"
expect = "package.json"
format = "json"
field = "engines.node"
pattern = "18"

field_not_contains

Passes if the field's value does not contain the substring, or if the field is missing.

["services/*".no-legacy-node]
check = "field_not_contains"
expect = "package.json"
format = "json"
field = "engines.node"
pattern = "14"

Error Messages

Failure messages include context to help you find and fix issues:

  • file_contains / file_not_contains: Shows the line number where the pattern was found.

    FAIL  no-console-logs  services/api  src/index.ts:5 contains "console.log"
    
  • field_contains / field_not_contains: Shows the actual field value.

    FAIL  correct-node-version  services/auth  package.json.engines.node does not contain "18" (found ">=16.0.0")
    
  • field_exists: Names the missing field.

    FAIL  must-have-engines  services/auth  package.json missing field "engines"
    

Format Examples

Field checks work identically across all supported formats. Only the format and expect values change.

YAML

["services/*".k8s-has-replicas]
check = "field_exists"
expect = "deployment.yaml"
format = "yaml"
field = "spec.replicas"

TOML

["crates/*".cargo-has-edition]
check = "field_exists"
expect = "Cargo.toml"
format = "toml"
field = "package.edition"