### Install lintnet with Go Source: https://lintnet.github.io/docs/install Install the lintnet CLI using the Go toolchain. ```bash go install github.com/lintnet/lintnet/cmd/lintnet@latest ``` -------------------------------- ### Install lintnet with Homebrew Source: https://lintnet.github.io/docs/install Use Homebrew to install the lintnet CLI. ```bash brew install lintnet/lintnet/lintnet ``` -------------------------------- ### Example Module Path Source: https://lintnet.github.io/docs/module An example illustrating the module path format, specifying a module from a GitHub archive. ```plaintext github_archive/github.com/lintnet/modules/modules/hello/hello.jsonnet@60a46a4fa4c0e7b1b95f57c479e756afa2f376e9:v0.1.0' ``` -------------------------------- ### Install lintnet with Scoop Source: https://lintnet.github.io/docs/install Add the lintnet bucket and install lintnet using Scoop. ```bash scoop bucket add lintnet https://github.com/lintnet/scoop-bucket ``` ```bash scoop install lintnet ``` -------------------------------- ### Install go-jsonnet with Homebrew Source: https://lintnet.github.io/docs/learn-jsonnet Use Homebrew to install the go-jsonnet CLI for evaluating Jsonnet code. ```bash brew install go-jsonnet ``` -------------------------------- ### Install go-jsonnet with aqua Source: https://lintnet.github.io/docs/learn-jsonnet Install the go-jsonnet CLI using the aqua package manager. ```bash aqua g -i google/go-jsonnet ``` -------------------------------- ### Install lintnet with aqua Source: https://lintnet.github.io/docs/install Install lintnet using the aqua package manager. ```bash aqua g -i lintnet/lintnet ``` -------------------------------- ### YAML Multi-Document Example Source: https://lintnet.github.io/docs/supported-data-format Demonstrates the structure of a YAML file with multiple documents separated by '---'. ```yaml --- # document 0 name: foo --- # document 1 name: bar ``` -------------------------------- ### Get lintnet environment information Source: https://lintnet.github.io/docs/guides/usage The 'lintnet info' command outputs a JSON object with details about the lintnet installation and environment. This is useful for troubleshooting. ```bash $ lintnet info ``` -------------------------------- ### Get module root directory Source: https://lintnet.github.io/docs/guides/usage To display only the root directory where modules are installed, use the '--module-root-dir' flag with the 'lintnet info' command. ```bash $ lintnet info -module-root-dir ``` -------------------------------- ### Getting Lintnet Module Root Directory Source: https://lintnet.github.io/docs/module Use the `lintnet info -module-root-dir` command to retrieve the current module installation path. ```bash lintnet info -module-root-dir ``` -------------------------------- ### Display lint command help Source: https://lintnet.github.io/docs/guides/usage Use the --help flag with the 'lint' command to view detailed usage information, options, and examples for linting files. ```bash $ lintnet lint --help ``` -------------------------------- ### Native Function Usage Source: https://lintnet.github.io/docs/lint-rule Example of using a native function provided by lintnet. This specific example demonstrates the usage of the 'strings.Contains' function to check if a string contains a substring. ```jsonnet local contained = std.native("strings.Contains")("hello", "ll"); // true ``` -------------------------------- ### Lintnet Module Installation Directory Source: https://lintnet.github.io/docs/module Modules are installed in a specific directory determined by the application data directory. This path can be overridden using the `LINTNET_ROOT_DIR` environment variable. ```plaintext ${Application Data Directory}/lintnet/modules ``` -------------------------------- ### Caching Modules in GitHub Actions CI Source: https://lintnet.github.io/docs/module Cache Lintnet modules in CI environments like GitHub Actions to speed up builds. This example demonstrates setting up the cache using the module root directory and a hash of the configuration file. ```yaml - run: echo "module_root_dir=$(lintnet info -module-root-dir)" >> "$GITHUB_OUTPUT" id: lintnet - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 with: path: | ${{steps.lintnet.outputs.module_root_dir}} key: ${{ hashFiles('lintnet.jsonnet') }} - run: lintnet lint env: GITHUB_TOKEN: ${{github.token}} ``` -------------------------------- ### Parse URL Source: https://lintnet.github.io/docs/lint-rule/native-function This example demonstrates the structure of the object returned by the url.Parse function, which converts a URL string into a structured object. The returned object includes fields like Scheme, Host, Path, and Query. ```json [ { "Scheme": "http", "Opaque": "", "Host": "example.com", "Path": "/foo/bar", "RawPath": "", "OmitHost": false, "ForceQuery": false, "RawQuery": "lang=en&tag=go", "Fragment": "top", "RawFragment": "", "Query": { "lang": ["en"], "tag": ["go"], }, }, null ] ``` -------------------------------- ### Access Configuration Parameters in Lint Files Source: https://lintnet.github.io/docs/guides/parameterize-rule Access configuration parameters passed to a lint file using `param.config`. This example shows how to retrieve an 'excludes' list, providing a default empty list if not found. ```jsonnet local excludes = std.get(param.config, 'excludes', []) ``` -------------------------------- ### Precedence of Exclusion Patterns Source: https://lintnet.github.io/docs/config Later patterns take precedence over earlier ones. This example shows how a subsequent inclusion pattern can override a previous exclusion. ```glob **/*.jsonnet !foo/example.jsonnet foo/*.jsonnet ``` -------------------------------- ### Define Lint Rule Error Level Source: https://lintnet.github.io/docs/guides/error-level Specify the 'level' for a lint rule within its definition. This example sets the level to 'warn'. ```jsonnet function(param) if std.objectHas(param.data.value, 'description') then [] else [{ name: 'description is required', level: 'warn', // Error level is 'warn' }] ``` -------------------------------- ### Test lint files in a specific directory Source: https://lintnet.github.io/docs/guides/usage To test lint files within a specific directory and its subdirectories, provide the directory name as an argument. For example, 'lintnet test foo' searches for files matching 'foo/**/*.jsonnet'. ```bash lintnet test foo ``` -------------------------------- ### Basic Lint Rule Structure Source: https://lintnet.github.io/docs/lint-rule This is a basic example of a lint rule written in Jsonnet. It checks if the 'description' field exists in the provided data and returns an empty list if it does, otherwise it returns a list with a single error object. ```jsonnet function(param) // param is a Top level arguments if std.objectHas(param.data.value, 'description') then [] else [{ name: 'description is required', }] ``` -------------------------------- ### Result Normalization Example Source: https://lintnet.github.io/docs/test-rule Lint evaluation results are normalized before comparison. Fields like `description` and `excluded` are removed, and array elements with `excluded: true` are filtered out. ```json [ { "name": "foo", "description": "Hello, lintnet!", "excluded": true }, { "name": "foo", "description": "Hello, lintnet!", "excluded": false } ] ``` ```json [ { "name": "foo" } ] ``` -------------------------------- ### Scaffold lintnet configuration file Source: https://lintnet.github.io/docs/guides/usage Use the 'init' command to scaffold the 'lintnet.jsonnet' configuration file. If the file already exists, this command does nothing. ```bash $ lintnet init --help ``` ```bash $ lintnet init ``` -------------------------------- ### Scaffold Configuration File Source: https://lintnet.github.io/docs/config Initialize a new Lintnet configuration file using the 'lintnet init' command. ```bash lintnet init ``` -------------------------------- ### Display lintnet test help Source: https://lintnet.github.io/docs/guides/usage Use the --help flag with the 'test' command to view detailed usage information and options for testing lint files. ```bash $ lintnet test --help ``` -------------------------------- ### Download and verify lintnet checksums with Cosign Source: https://lintnet.github.io/docs/install Download release assets and verify the checksums file using Cosign, then verify the artifact integrity. ```bash gh release download -R lintnet/lintnet v0.4.8 ``` ```bash cosign verify-blob \ --signature lintnet_0.4.8_checksums.txt.sig \ --certificate lintnet_0.4.8_checksums.txt.pem \ --certificate-identity-regexp 'https://github.com.com/suzuki-shunsuke/go-release-workflow/.github/workflows/release.yaml@.*' \ --certificate-oidc-issuer "https://token.actions.githubusercontent.com" \ lintnet_0.4.8_checksums.txt ``` ```bash cat lintnet_0.4.8_checksums.txt | sha256sum -c --ignore-missing ``` -------------------------------- ### Download and verify lintnet binary with slsa-verifier Source: https://lintnet.github.io/docs/install Download the lintnet binary and its provenance, then verify the artifact using slsa-verifier. ```bash gh release download -R lintnet/lintnet v0.4.8 -p lintnet_darwin_arm64.tar.gz -p multiple.intoto.jsonl ``` ```bash slsa-verifier verify-artifact lintnet_darwin_arm64.tar.gz \ --provenance-path multiple.intoto.jsonl \ --source-uri github.com/lintnet/lintnet \ --source-tag v0.4.8 ``` -------------------------------- ### Display lintnet help information Source: https://lintnet.github.io/docs/guides/usage Use the --help flag to display general help information for the lintnet CLI, including available commands and global options. ```bash $ lintnet --help ``` -------------------------------- ### Display lintnet info Source: https://lintnet.github.io/docs/guides/usage Use the 'info' command to output information about lintnet, including version, configuration file path, and environment details. ```bash $ lintnet info --help ``` -------------------------------- ### Download and verify lintnet binary with GitHub CLI Source: https://lintnet.github.io/docs/install Download a specific version of the lintnet binary and verify its integrity using GitHub CLI and its attestation. ```bash gh release download -R lintnet/lintnet v0.4.8 -p lintnet_darwin_arm64.tar.gz ``` ```bash gh attestation verify lintnet_darwin_arm64.tar.gz \ -R lintnet/lintnet \ --signer-workflow suzuki-shunsuke/go-release-workflow/.github/workflows/release.yaml ``` -------------------------------- ### Specify Configuration File Path Source: https://lintnet.github.io/docs/config Use the --config or -c command-line option to specify a custom configuration file path. ```bash lintnet -c foo.yaml lint ``` -------------------------------- ### Create New Lint File with lintnet new Source: https://lintnet.github.io/docs/guides/usage Use this command to create a new lint file and an associated test file. If no filename is provided, it defaults to 'main.jsonnet'. ```bash $ lintnet new --help ``` -------------------------------- ### Run Tests Source: https://lintnet.github.io/docs/test-rule Execute tests using the `lintnet test` command. You can specify individual files, directories, or let it discover files based on configuration. ```bash lintnet test [ ...] ``` -------------------------------- ### Test lint files with arguments Source: https://lintnet.github.io/docs/guides/usage You can test specific lint files, test files, or directories by providing them as arguments to the 'lintnet test' command. If files are specified explicitly, a configuration file is unnecessary. ```bash $ lintnet test [ ...] ``` -------------------------------- ### Configure Lint Files with Parameters Source: https://lintnet.github.io/docs/guides/parameterize-rule Define configuration parameters for lint files, including local files and modules. The `config` object within each lint file entry specifies the parameters. ```jsonnet lint_files: [ { path: 'examples/lint/filename.jsonnet', config: { excludes: ['foo'], }, }, ], modules: [ { path: 'github_archive/github.com/suzuki-shunsuke/example-lintnet-modules/ghalint.jsonnet@32ca3be646ec5b5861aab72fed30cd71f6eba9bf:v0.1.2', config: { excludes: ['foo'], }, }, ] ``` -------------------------------- ### Scaffold a Lint File Source: https://lintnet.github.io/docs/lint-rule Use this command to create a new lint file. You can specify a name for the file, or it will default to 'main.jsonnet'. ```bash lintnet new [] ``` -------------------------------- ### Module Configuration for Linting Source: https://lintnet.github.io/docs/config Modules can be specified as strings or objects. Objects allow specifying configurations and multiple files within a module. ```jsonnet [ // github_archive/github.com///@[:] // version is optional. 'github_archive/github.com/lintnet-modules/ghalint/workflow/action_ref_should_be_full_length_commit_sha/main.jsonnet@00571db321e413d45be457f39e48cd4237399bb7:v0.3.0', { // path is required path: 'github_archive/github.com/lintnet-modules/ghalint/workflow/action_ref_should_be_full_length_commit_sha/main.jsonnet@00571db321e413d45be457f39e48cd4237399bb7:v0.3.0', config: {}, }, { path: 'github_archive/github.com/lintnet-modules/ghalint@00571db321e413d45be457f39e48cd4237399bb7:v0.3.0', // You can specify file paths in a module with the attribute files. // This style is useful to specify multiple file path patterns in a module and set config parameter by lint rule files: [ 'workflow/**/main.jsonnet', '!workflow/action_ref_should_be_full_length_commit_sha/main.jsonnet', { path: 'workflow/action_ref_should_be_full_length_commit_sha/main.jsonnet', config: {}, }, ], }, ] ``` -------------------------------- ### Access First YAML Document Source: https://lintnet.github.io/docs/supported-data-format Illustrates how to access the first document of a multi-document YAML file by its index in lint rules. ```go param.data.value[0] # Get the first document ``` -------------------------------- ### Test File Structure Source: https://lintnet.github.io/docs/test-rule A test file is a function that returns a list of test cases. Each test case includes a name, optional configuration, and the expected result. ```jsonnet function(param) [ { name: 'Test case name', // ... } // ... ] ``` ```jsonnet { name: 'Test case name', // test data // ... param: { // config is configuration passed to the lint file // config is optional. config: {}, }, result: [ // expected return value of the lint file ], } ``` -------------------------------- ### Check Lintnet Version with lintnet version Source: https://lintnet.github.io/docs/guides/usage Displays the current version of lintnet. Use the --json flag for machine-readable output. ```bash $ lintnet version --help ``` -------------------------------- ### Enable fish shell completion for lintnet Source: https://lintnet.github.io/docs/install Configure fish shell to load lintnet completion scripts from the specified directory. ```bash lintnet completion fish > ~/.config/fish/completions/lintnet.fish ``` -------------------------------- ### Test lint files in current directory Source: https://lintnet.github.io/docs/guides/usage If no arguments are provided and no configuration file is found, 'lintnet test' defaults to testing files matching '**/*.jsonnet' in the current directory and its subdirectories. ```bash lintnet test . ``` -------------------------------- ### Lint Files Configuration Source: https://lintnet.github.io/docs/config Lint files can be specified as strings or objects. Objects allow passing configuration to lint rules. ```jsonnet [ 'main.jsonnet', { path: 'examples/lint/filename.jsonnet', // required config: {}, // optional. lint rule configuration }, ] ``` -------------------------------- ### Using Lint Rule Modules in Configuration Source: https://lintnet.github.io/docs/module Specify lint rule modules in your configuration to apply shared linting rules. Ensure the module path is correctly formatted. ```jsonnet function(param) { targets: [ { modules: [ 'github_archive/github.com/lintnet-modules/nllint/main.jsonnet@8cfc4eae68ec93f9b92d9048ce51b0d9646c976c:v0.1.0', ], data_files: [ '**/*', ], }, ], } ``` -------------------------------- ### Lintnet Configuration File Structure Source: https://lintnet.github.io/docs/config The configuration is a JSONNET function returning an object that defines lint targets, ignored directories, and output settings. ```jsonnet function(param) { // targets is a list of lint configuration. targets: [ // ], // ignored_dirs is a list of ignored directories. // ignored_dirs is optional. // The default value is [".git", "node_modules"]. ignored_dirs: [ ".git", "node_modules", ], // outputs is a list of output configuration. // outputs is optional. // outputs is used to customize output format. outputs: [ // ... ], } ``` -------------------------------- ### Evaluate Jsonnet file with CLI Source: https://lintnet.github.io/docs/learn-jsonnet Execute a Jsonnet file using the jsonnet command-line tool. ```bash jsonnet hello.jsonnet ``` -------------------------------- ### Iterate YAML Documents Source: https://lintnet.github.io/docs/supported-data-format Shows how to iterate through multiple documents within a YAML file in lint rules. ```go for doc in param.data.value # Iterate multiple documents ``` -------------------------------- ### Jsonnet Module Path Format Source: https://lintnet.github.io/docs/module Understand the standard format for module paths, which includes type, host, repository owner, repository name, file path, full commit hash, and an optional tag. ```plaintext ${type}/${host}/${repository_owner}/${repository_name}/${file_path}@${full_commit_hash}[:${tag}] ``` -------------------------------- ### Enable bash shell completion for lintnet Source: https://lintnet.github.io/docs/install Source the bash completion script to enable tab completion for lintnet commands in bash. ```bash source <(lintnet completion bash) ``` -------------------------------- ### Using Data Files in Tests Source: https://lintnet.github.io/docs/test-rule Specify test data using `data_file` for a single file or `data_files` for multiple files. `fake_data_file` can disguise the actual data file path passed to the lint file. ```jsonnet function(param) [ { data_file: 'testdata/pass.json', // relative path from the test file }, // ... ] ``` ```jsonnet data_file: 'testdata/pass.yaml', fake_data_file: '.github/workflows/pass.yaml', ``` ```jsonnet { data_files: [ // a list of data files. // The element is either a string or an object. 'testdata/pass.json', { path: 'testdata/foo.json', fake_path: '/etc/app/foo.json', }, ], } ``` -------------------------------- ### Enable zsh shell completion for lintnet Source: https://lintnet.github.io/docs/install Source the zsh completion script to enable tab completion for lintnet commands in zsh. ```bash source <(lintnet completion zsh) ``` -------------------------------- ### Generate Shell Completions with lintnet completion Source: https://lintnet.github.io/docs/guides/usage Outputs shell completion scripts for bash, zsh, fish, or Powershell. Source the output to enable command completion in your shell. ```bash $ lintnet completion --help ``` ```bash # .bashrc source <(lintnet completion bash) ``` ```bash # .zshrc source <(lintnet completion zsh) ``` ```bash # fish lintnet completion fish > ~/.config/fish/completions/lintnet.fish ``` ```bash # Powershell # Output the script to path/to/autocomplete/lintnet.ps1 an run it. ``` -------------------------------- ### Enable Debug Logging in Lintnet Source: https://lintnet.github.io/docs/troubleshooting Run Lintnet with the '--log-level debug' flag to enable detailed debug logging for troubleshooting. ```bash lintnet -log-level debug lint ``` -------------------------------- ### Output JSON on Success Source: https://lintnet.github.io/docs/guides/customize-output Use the `--output-success` option to ensure JSON output even when linting passes. This is useful for CI/CD pipelines or automated reporting. ```bash lintnet lint -output-success ``` -------------------------------- ### Output success results for linting Source: https://lintnet.github.io/docs/guides/usage To output the result even if the lint succeeds, use the '--output-success' flag. This is useful for piping output to other programs. ```bash $ lintnet lint -output-success ``` -------------------------------- ### Define Target for Linting Source: https://lintnet.github.io/docs/config A target specifies data files and lint files or modules to be processed. 'data_files' is required, and either 'lint_files' or 'modules' must be provided. ```jsonnet { id: 'target id', // optional base_data_path: '', // optional // data_files is a list of glob patterns. data_files: [ 'examples/**/*.csv', // relative path from the configuration file // ... ], // lint_files is a list of local lint files. lint_files: [ 'main.jsonnet', // relative path from the configuration file ], // modules is a list of modules. modules: [ 'github_archive/github.com/suzuki-shunsuke/example-lintnet-modules/newline.jsonnet@32ca3be646ec5b5861aab72fed30cd71f6eba9bf:v0.1.2', ], } ``` -------------------------------- ### Define and use local values in Jsonnet Source: https://lintnet.github.io/docs/learn-jsonnet Demonstrates defining local variables within Jsonnet objects and conditionally adding attributes. ```jsonnet function(param) local foo = 'foo'; { // Define local values in object definitions local factor = if large then 2 else 1, // Add attributes to objects conditionally [if salted then 'garnish']: 'Salt', } ``` -------------------------------- ### Defining Data Inline in Tests Source: https://lintnet.github.io/docs/test-rule Alternatively, define test data directly within the test file using the `param` field. This is recommended for simpler cases but `data_file` and `data_files` are generally more maintainable. ```jsonnet { param: { // These fields are optional. // You only have to set fields used in the lint file. data: { file_path: 'foo.json', file_type: 'json', text: '', // raw text value: { // parsed data }, }, }, // ... } ``` -------------------------------- ### Lint specific files Source: https://lintnet.github.io/docs/guides/usage You can lint only specific files by providing their paths as arguments to the 'lintnet lint' command. ```bash $ lintnet lint [lint file paths and data file paths] ``` -------------------------------- ### Base Data Path for Monorepo Linting Source: https://lintnet.github.io/docs/config Use 'base_data_path' to specify a base directory for data files, useful for linting across multiple services in a monorepo. ```jsonnet { // data files which are on the same directory as tfaction.yaml. base_data_path: '**/tfaction.yaml', data_files: [ // relative path from base_data_path // Glob is also available '*.tf', ], // ... } ``` -------------------------------- ### Exclude Files with '!' Source: https://lintnet.github.io/docs/config Use a leading '!' to exclude files matching a pattern. This is useful for specifying exceptions to broader include rules. ```glob **/*.jsonnet !foo/example.jsonnet ``` -------------------------------- ### Configure Error Levels in lintnet.jsonnet Source: https://lintnet.github.io/docs/guides/error-level Define 'error_level' and 'shown_error_level' in your lintnet.jsonnet configuration file. ```jsonnet error_level: 'warn', shown_error_level: 'debug', ``` -------------------------------- ### Top Level Arguments Schema Source: https://lintnet.github.io/docs/lint-rule This JSON schema describes the structure of the top-level arguments passed to lint files. It includes fields for 'data', 'combined_data', and 'config'. ```json { // A data file // If the lint file name ends with _combine.jsonnet, this field is empty. data: { file_path: 'foo.yaml', file_type: 'yaml', text: '...', value: { // data } }, // A list of data files. // If the lint file name ends with _combine.jsonnet, this field is set. // Otherwise, this field is empty. combined_data: [ { // same as data file_path: 'foo.yaml', file_type: 'yaml', text: '...', value: { // data } }, // ... ], config: {}, // configuration of the lint rule } ``` -------------------------------- ### url.Parse Source: https://lintnet.github.io/docs/lint-rule/native-function Converts a URL string into a structured URL object. This function is based on Go's `net/url` package. ```APIDOC ## url.Parse ### Description This function converts a URL string into a structured object representing the URL. It is based on the `net/url.Parse` function from the Go standard library. ### Example Response Structure ```json [ { "Scheme": "http", "Opaque": "", "Host": "example.com", "Path": "/foo/bar", "RawPath": "", "OmitHost": false, "ForceQuery": false, "RawQuery": "lang=en&tag=go", "Fragment": "top", "RawFragment": "", "Query": { "lang": ["en"], "tag": ["go"] } }, null ] ``` ``` -------------------------------- ### Output Variables with std.trace Source: https://lintnet.github.io/docs/troubleshooting This Jsonnet function uses std.trace to output the string representation of 'param' to stderr before checking for the 'description' field. It returns an error object if the 'description' field is missing. ```jsonnet function(param) std.trace(std.toString(param), // Output param to stderr if std.objectHas(param.data.value, 'description') then [] else [{ name: 'description is required', }] ) ``` -------------------------------- ### Test a specific target Source: https://lintnet.github.io/docs/guides/usage Use the '-target' or '-t' option with the 'lintnet test' command to test only a specific target ID. ```bash $ lintnet test -target [target id] ``` -------------------------------- ### Set Lint Command Error Level Source: https://lintnet.github.io/docs/guides/error-level Use the --error-level flag to specify the minimum severity level for linting. ```bash lintnet lint -e error ``` -------------------------------- ### Mask user information in lintnet info Source: https://lintnet.github.io/docs/guides/usage To mask the current user name when displaying lintnet information, use the '-mask-user' flag. ```bash $ lintnet info -mask-user ``` -------------------------------- ### Importing Jsonnet Modules Source: https://lintnet.github.io/docs/module Import shared variables and functions from other Jsonnet files using the `import` statement. This allows for code reuse across projects. ```jsonnet local hello = import 'github_archive/github.com/lintnet/modules/modules/hello/hello.jsonnet@60a46a4fa4c0e7b1b95f57c479e756afa2f376e9:v0.1.0'; ``` -------------------------------- ### Output Custom Fields for Variables Source: https://lintnet.github.io/docs/troubleshooting This Jsonnet function checks if a 'description' field exists in the 'param.data.value' object. If not, it returns an array with an error object indicating that 'description' is required. ```jsonnet function(param) if std.objectHas(param.data.value, 'description') then [] else [{ name: 'description is required', custom: { param: param, // Output param for debug }, }] ``` -------------------------------- ### Validate JSON Schema Source: https://lintnet.github.io/docs/lint-rule/native-function Use this function to validate a given configuration against a JSON Schema. The schema can be imported directly or defined within the Jsonnet file. It returns an error message string if validation fails, or null if successful. ```jsonnet local schema = import 'main_config_schema.json'; // Import JSON Schema local validateJSONSchema = std.native('jsonschema.Validate'); local vr = validateJSONSchema(schema, param.config); // Validate param.config with JSON Schema main_config_schema.json ``` -------------------------------- ### Defining Expected Results Source: https://lintnet.github.io/docs/test-rule The format of the expected `result` depends on the specific lint rule. It typically includes a name, severity level, and location information. ```jsonnet { result: [ // expected return value of the lint file { name: 'age must be greater or equal than 18', level: 'error', location: { index: 0, line: 'mike,1', }, }, ], } ``` -------------------------------- ### Lint a specific target Source: https://lintnet.github.io/docs/guides/usage To lint only a specific target, use the '-target' or '-t' option followed by the target ID. ```bash $ lintnet lint -target [target id] ``` -------------------------------- ### Jsonnet Output Format Source: https://lintnet.github.io/docs/lint-rule This is the expected JSON output format for lint rules written in Jsonnet. It's an array of objects, where each object represents a linting issue with properties like 'name', 'description', 'message', and 'location'. ```jsonnet function(param) [ { // Only name is required. Other fields are optional. name: 'rule name', description: 'rule description', message: 'error message', // location where errors occur // The format is free. location: {}, // an object location: '', // string is also ok // URLs to the reference of lint rules and errors. // links is either an array or an object. links: [ 'https://example.com/', { title: 'title', link: 'https://example.com/', }, ], // links: { // '': 'https://example.com/', // }, level: 'error', // Error level excluded: false, // If true, the element is excluded. custom: {}, // An object. Users can use this field freely. }, // ... ] ``` -------------------------------- ### jsonschema.Validate Source: https://lintnet.github.io/docs/lint-rule/native-function Validates a given value against a JSON schema. It returns an error message if validation fails, a detailed error object if the value violates the schema, or null if validation is successful. ```APIDOC ## jsonschema.Validate ### Description Validates `v` with JSON Schema `schema`. `schema` is an object representing a JSON Schema. Returns a string error message if validation fails, a detailed error object if `v` violates JSON Schema, or `null` if there is no violation. ### Function Signature ``` func(schema, v any) error ``` ### Example Usage ```jsonnet local schema = import 'main_config_schema.json'; local validateJSONSchema = std.native('jsonschema.Validate'); local vr = validateJSONSchema(schema, param.config); ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.