Skip to content

v3.12.0

Latest
Compare
Choose a tag to compare
@github-actions github-actions released this 09 Jun 01:19
44c18b3

🚀 New Feature: Views – Targeted Linting for Structured (YAML, JSON, TOML) and Source Code Files

We’re introducing Views, a new way to define custom, structured representations of your files—giving you fine-grained control over what gets linted and how.

Views allow you to extract specific content from structured data (like YAML, JSON, or TOML) and source code and apply scoped linting rules to just those sections.

🔍 What’s a View?

A View is a user-defined configuration that transforms a file into a set of named scopes. This enables you to lint only relevant parts of a file—such as metadata descriptions, comments, or docstrings—without affecting the rest.

Here's an example using an OpenAPI file:

openapi: 3.0.0
info:
  title: sample API
  description: Optional multiline or single-line description in [CommonMark](http://commonmark.org/help/) or HTML.
  version: 0.1.9

servers:
  - url: http://api.example.com/v1
    description: Optional server description, e.g. Main (production) serrver
  - url: http://staging-api.example.com
    description: |
      Optional server description, e.g. 
      Internal staging serrver for testing
  - url: http://api.example.com/v2
    description: Optional server description, e.g. Main (production) serrver

And here's a View that extracts title, description, and each server's description:

# config/views/OpenAPI.yml
engine: dasel
scopes:
  - name: title
    expr: info.title

  - expr: info.description
    type: md

  - expr: servers.all().description
    type: md

type: md indicates that the description values are formatted are Markdown. We enable this be using the View key in our .vale.ini:

StylesPath = ../../styles
MinAlertLevel = suggestion

[API.yml]
BasedOnStyles = Vale

View = OpenAPI

See the documentation for more information.

Changelog

  • 44c18b3 test: add more cases
  • 8ab88af refactor: blueprint -> view
  • 3a996da fix: remove erroneous "+1"
  • fdaa335 chore(deps): bump golang.org/x/net from 0.36.0 to 0.38.0 (#996)