A compact command line utility for checking YAML file syntax

Overview

yaml-lint

Latest Version on Packagist Software License Total Downloads Scrutinizer Code Quality

A compact command line utility for checking YAML file syntax. Uses the parsing facility of the Symfony Yaml Component.

Usage

usage: yaml-lint [options] [input source]

  input source    Path to file(s), or "-" to read from standard input

  -q, --quiet     Restrict output to syntax errors
  -h, --help      Display this help
  -V, --version   Display application version

Install

Install as a project component with Composer (executable from the project's vendor/bin directory):

composer require j13k/yaml-lint

Typically, a binary edition (yaml-lint.phar) is also available for download with each release. This embeds the latest stable version of the Symfony Yaml component that is current at the time of the release.

Change log

Please see CHANGELOG for information on what has changed recently.

Credits

License

The MIT License (MIT). Please see LICENCE for more information.

Comments
  • Added multi-file support

    Added multi-file support

    parsing will stop on the first invalid yml file.

    • [x] remove note about not supporting multiple files from Readme

    closes https://github.com/j13k/yaml-lint/issues/3

    because of the re-indent of several lines at best review with whitespaces ignored: https://github.com/j13k/yaml-lint/pull/9/files?w=1

    opened by staabm 10
  • Allow multiple input files and/or directories

    Allow multiple input files and/or directories

    I've just created a git hook and I have to call the binary foreach file, I would prefer to call it with all files I want to check.

    edit: I've seen that already does that, may I have a problem in my hook, but if I have multiples wrong yaml files, it only tells me what is wrong with one file

    Good project, I was looking for a yaml linter I could install with composer

    enhancement 
    opened by xgc1986 4
  • Tag Minor Release

    Tag Minor Release

    Hi there,

    Could you tag a minor release with the 'name' field fix? Or just the latest master-commit? The latest tagged version is currently breaking builds in CI pipelines, unfortunately.

    / Yassin

    opened by ymakhloufi 3
  • Missing GPG signature for PHAR file

    Missing GPG signature for PHAR file

    Hi,

    maybe we could add GPG signature to PHAR file in releases in order to make your PHAR file installable via phive tool.

    Here is guide https://phar.io/howto/sign-and-upload-to-github.html

    opened by lukaszuznanski 2
  • Linter config via XML

    Linter config via XML

    Added optional linter config via .yaml-lint.xml:

    * <quiet> - true|false
    * <includes> - Include paths, globs like src/*.yml are allowed
    * <excludes> - Exclude paths, can exclude previous included path
    
    opened by christingruber 1
  • Bump symfony/yaml from 5.1.7 to 5.1.8

    Bump symfony/yaml from 5.1.7 to 5.1.8

    Bumps symfony/yaml from 5.1.7 to 5.1.8.

    Release notes

    Sourced from symfony/yaml's releases.

    v5.1.8

    Changelog (https://github.com/symfony/yaml/compare/v5.1.7...v5.1.8)

    • no changes
    Commits
    • f284e03 fix merge
    • f06777b Merge branch '4.4' into 5.1
    • 543cb4d Merge branch '3.4' into 4.4
    • 88289ca Remove branch-version (keep them for contracts only)
    • 22a640f [CI] Fixed build on AppVeyor
    • f4805c0 Merge branch '3.4' into 4.4
    • 9ae9181 [CI] Silence errors when remove file/dir on test tearDown()
    • 0fd4738 Merge branch '4.4' into 5.1
    • 6113602 Merge branch '3.4' into 4.4
    • 482fcb6 Fix branch-version
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 1
  • Glob style pathspecs are not handled correctly, and no warning is given

    Glob style pathspecs are not handled correctly, and no warning is given

    Problem

    As reported in feature request https://github.com/j13k/yaml-lint/issues/3 and https://github.com/lmc-eu/php-coding-standard/pull/8, there is an issue with glob style path specs (e.g. *.yml) not being handled correctlyโ€”only the last file in the set of filenames is parsed, but this is not clear in the output. This is confusing for users and could result in false reports.

    Proposed Fix

    Until the tool is upgraded to handle multiple files, it should be patched to reject glob style path specs and warn the user. The documentation should also clarify this.

    Analysis

    It seems $_SERVER['argv'] expands globs automatically, behaviour which was unexpected on my part. The script loops over the values of argv, assigning path values to a scalar argPath variable, which is then parsed. When multiple paths are specified (as in case of the expanded glob file set), the value of argPath ultimately rests on the last filename in the list.

    This scratch script illustrates the issue using the Symfony Yaml component test fixture files as an example:

    <?php print var_export($_SERVER['argv']) . PHP_EOL;
    

    The script output demonstrates the implicit glob expansion:

    $ php php-argv-test.php vendor/symfony/yaml/Tests/Fixtures/*.yml
    array (
      0 => 'php-argv-test.php',
      1 => 'vendor/symfony/yaml/Tests/Fixtures/YtsAnchorAlias.yml',
      2 => 'vendor/symfony/yaml/Tests/Fixtures/YtsBasicTests.yml',
    ... lines deleted ...
      28 => 'vendor/symfony/yaml/Tests/Fixtures/sfTests.yml',
      29 => 'vendor/symfony/yaml/Tests/Fixtures/unindentedCollections.yml',
    )
    

    In the case of this path spec, only the last file, vendor/symfony/yaml/Tests/Fixtures/unindentedCollections.yml, is processed.

    bug 
    opened by j13k 1
  • Support symfony 3.0

    Support symfony 3.0

    Hi! Can you please enable symfony 3.0 support for your library? As I can see, you are need to set version of symfony/yaml as ^2|^3 and it will be fixed.

    enhancement 
    opened by sc0rp10 1
  • YAML component version not listed

    YAML component version not listed

    The YAML component version is extracted from the installed.json manifest file created in vendor/composer on installation.

    The format of this file seem to have changed, so the version is no longer extracted correctly.

    opened by j13k 0
  • Bump symfony/yaml from 5.4.2 to 5.4.3

    Bump symfony/yaml from 5.4.2 to 5.4.3

    Bumps symfony/yaml from 5.4.2 to 5.4.3.

    Release notes

    Sourced from symfony/yaml's releases.

    v5.4.3

    Changelog (https://github.com/symfony/yaml/compare/v5.4.2...v5.4.3)

    • bug #45140 Making the parser stateless (mamazu)
    Commits
    • e80f87d minor #45085 [Yaml] Improve the deprecation warnings for octal numbers to sug...
    • ee79e7e [Yaml] Improve the deprecation warnings for octal numbers to suggest migrating
    • 3ed802c Merge branch '5.3' into 5.4
    • c441e9d Merge branch '4.4' into 5.3
    • d7f637c Making the parser stateless
    • 37bcbbb Merge branch '5.3' into 5.4
    • 32e33ce Merge branch '4.4' into 5.3
    • d7827c7 Bump license year
    • See full diff in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 0
  • Bump symfony/yaml from 5.4.0 to 5.4.2

    Bump symfony/yaml from 5.4.0 to 5.4.2

    Bumps symfony/yaml from 5.4.0 to 5.4.2.

    Release notes

    Sourced from symfony/yaml's releases.

    v5.4.2

    Changelog (https://github.com/symfony/yaml/compare/v5.4.1...v5.4.2)

    • no significant changes
    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies 
    opened by dependabot[bot] 0
  • Erroring on files missing trailing newline shouldn't fail linting

    Erroring on files missing trailing newline shouldn't fail linting

    We use this project to review YAML files and the intent is that linting should prevent any errors from malformed files, but we often get some errors on different sites when YAML files do not contain a trailing empty line, which isn't malformed. Can we separate out this error to a "strict" mode instead or maybe disable this check?

    question waiting 
    opened by davereid-pfg 1
  • Multiple files mode should gracefully handle file paths that are directories

    Multiple files mode should gracefully handle file paths that are directories

    Currently an ugly error is thrown:

     ./bin/yaml-lint ~/foo/ 
    PHP Notice:  file_get_contents(): read of 8192 bytes failed with errno=21 Is a directory in yaml-lint/src/yaml-lint.php on line 87
    
    bug 
    opened by j13k 0
  • Support for results cache file

    Support for results cache file

    Description

    Store linted filenames and signatures in a .gitignoreable results cache file, to allow unchanged files to be skipped.

    Example

    Cache filename: .yaml-lint-results-cache

    Cache file contents:

    /home/j13k/tests/test1.yml 9f57cb6838d2e1f2d0e0d9b1dacc36abe1946c61
    
    enhancement 
    opened by j13k 0
  • Unit tests

    Unit tests

    Create unit tests to facilitate automated testing across PHP versions.

    These can piggy back off the tests and fixtures in the main symfony/yaml module, but will need to capture and parse the console output instead.

    enhancement 
    opened by j13k 0
Releases(1.1.4)
  • 1.1.4(Mar 11, 2021)

    See CHANGELOG.md for details.

    What's Changed

    • Added multi-file support by @staabm in https://github.com/j13k/yaml-lint/pull/9
    • Support Symfony 5 by @OndraM in https://github.com/j13k/yaml-lint/pull/10
    • 1.1.x-dev docs by @j13k in https://github.com/j13k/yaml-lint/pull/15
    • Dependabot scan config by @j13k in https://github.com/j13k/yaml-lint/pull/16
    • Bump symfony/yaml from 5.0.5 to 5.1.5 by @dependabot in https://github.com/j13k/yaml-lint/pull/17
    • Bump symfony/yaml from 5.1.5 to 5.1.6 by @dependabot in https://github.com/j13k/yaml-lint/pull/18
    • Bump symfony/yaml from 5.1.6 to 5.1.7 by @dependabot in https://github.com/j13k/yaml-lint/pull/19
    • Stop php notice when name key is undefined by @SimonMacIntyre in https://github.com/j13k/yaml-lint/pull/21
    • Bump symfony/yaml from 5.1.7 to 5.2.0 by @dependabot in https://github.com/j13k/yaml-lint/pull/23
    • Bump symfony/yaml from 5.2.0 to 5.2.1 by @dependabot in https://github.com/j13k/yaml-lint/pull/25
    • Bump symfony/yaml from 5.2.1 to 5.2.2 by @dependabot in https://github.com/j13k/yaml-lint/pull/27
    • Bump symfony/yaml from 5.2.2 to 5.2.3 by @dependabot in https://github.com/j13k/yaml-lint/pull/28
    • Bump symfony/yaml from 5.2.3 to 5.2.4 by @dependabot in https://github.com/j13k/yaml-lint/pull/30
    • Bump symfony/yaml from 5.2.4 to 5.2.5 by @dependabot in https://github.com/j13k/yaml-lint/pull/31
    • Prep 1.1.4 by @j13k in https://github.com/j13k/yaml-lint/pull/32

    New Contributors

    • @staabm made their first contribution in https://github.com/j13k/yaml-lint/pull/9
    • @OndraM made their first contribution in https://github.com/j13k/yaml-lint/pull/10
    • @SimonMacIntyre made their first contribution in https://github.com/j13k/yaml-lint/pull/21

    Full Changelog: https://github.com/j13k/yaml-lint/compare/1.1.3...1.1.4

    Source code(tar.gz)
    Source code(zip)
    yaml-lint.phar(69.36 KB)
    yaml-lint.phar.asc(591 bytes)
  • 1.1.3(Mar 27, 2018)

    Updated

    • composer.lock tracks symfony/yaml v4.0.6

    Fixed

    • Added input args validation to check for multiple files and updated README (fixes #7)
    • Improved syntax in README docs (resolves #4)

    Full Changelog: https://github.com/j13k/yaml-lint/compare/1.1.2...1.1.3

    Source code(tar.gz)
    Source code(zip)
    yaml-lint.phar(50.96 KB)
  • 1.1.2(Dec 7, 2017)

    Added

    • Added support for Symfony 4 YAML component
    • New CLI option for displaying application version
    • README documentation now includes 'dependencies' badge

    Updated

    • Refactored custom 'UsageException' class into standalone file
    • Updated application descriptions to emphasise 'compact' design of the application
    • composer update now tracks latest Symfony 4 YAML in local sandbox (composer.lock)

    Fixed

    • Fix to accommodate changes in the Yaml::parse method introduced in v3

    Full Changelog: https://github.com/j13k/yaml-lint/compare/1.1.1...1.1.2

    Source code(tar.gz)
    Source code(zip)
    yaml-lint.phar(50.13 KB)
  • 1.1.1(Nov 11, 2016)

    • Switched to full array notation, allowing legacy PHP support
    • composer update tracks latest Symfony 3 YAML in local sandbox installations (those installing from composer.lock)

    What's Changed

    • Fix compatibility with php version which does not support "[]" array declaration by @neilime in https://github.com/j13k/yaml-lint/pull/2

    New Contributors

    • @neilime made their first contribution in https://github.com/j13k/yaml-lint/pull/2

    Full Changelog: https://github.com/j13k/yaml-lint/compare/1.1.0...1.1.1

    Source code(tar.gz)
    Source code(zip)
    yaml-lint.phar(39.42 KB)
  • 1.1.0(Sep 12, 2016)

  • 1.0.0(Mar 3, 2016)

Owner
John Fitzpatrick
John Fitzpatrick
An object-oriented option parser library for PHP, which supports type constraints, flag, multiple flag, multiple values, required value checking

GetOptionKit Code Quality Versions & Stats A powerful option parser toolkit for PHP, supporting type constraints, flag, multiple flag, multiple values

Yo-An Lin 140 Sep 28, 2022
Lovely PHP wrapper for using the command-line

ShellWrap What is it? It's a beautiful way to use powerful Linux/Unix tools in PHP. Easily and logically pipe commands together, capture errors as PHP

James Hall 745 Dec 30, 2022
A PHP library for command-line argument processing

GetOpt.PHP GetOpt.PHP is a library for command-line argument processing. It supports PHP version 5.4 and above. Releases For an overview of the releas

null 324 Dec 8, 2022
Command-Line Interface tools

Aura.Cli Provides the equivalent of request ( Context ) and response ( Stdio ) objects for the command line interface, including Getopt support, and a

Aura for PHP 102 Dec 31, 2022
Another Command Line Argument Parser

Optparse โ€” Another Command Line Argument Parser Install 1. Get composer. 2. Put this into your local composer.json: { "require": { "chh/optparse

Christoph Hochstrasser 18 Nov 1, 2019
๐Ÿ‘จ๐Ÿปโ€๐Ÿš€ A command-line tool that gives you the Alpine Day 2021 schedule in your timezone. ๐Ÿš€

Alpine Day Schedule a command-line tool that gives you the Alpine Day 2021 schedule in your timezone. ?? Quick start Requires PHP 7.4+ # First, instal

Nuno Maduro 11 Jun 10, 2021
PHP Interminal is a command-line tool that gives you access to PHP Internals discussions in your terminal.

PHP Interminal is a command-line tool that gives you access to PHP Internals discussions in your terminal. ??

Nuno Maduro 32 Dec 26, 2022
Patrol is an elegant command-line tool that keeps your PHP Project's dependencies in check.

Patrol is an elegant command-line tool that keeps your PHP Project's dependencies in check. Installation / Usage Requires PHP 8.0+ First, install Patr

Nuno Maduro 237 Nov 14, 2022
Twitter raffles in the command line, with PHP and minicli

Rafflebird Rafflebird is a highly experimental CLI application for giveaways / raffles on Twitter, built in PHP with Minicli. Disclaimer: The recent s

Erika Heidi 33 Nov 16, 2022
A command line code generator for Drupal.

Drupal Code Generator A command line code generator for Drupal. Installation Download the latest stable release of the code generator.

Ivan 227 Dec 14, 2022
A PHP command line tool used to install shlink

Shlink installer A PHP command line tool used to install shlink. Installation Install this tool using composer.

null 8 Nov 3, 2022
Laracon Schedule a command-line tool that gives you the Laracon Online schedule in your timezone.

Laracon Schedule a command-line tool that gives you the Laracon Online schedule in your timezone. ?? Quick start Requires PHP 7.4+ # First, install: c

Nuno Maduro 101 Sep 16, 2022
Command-line control panel for Nginx Server to manage WordPress sites running on Nginx, PHP, MySQL, and Let's Encrypt

EasyEngine v4 EasyEngine makes it greatly easy to manage nginx, a fast web-server software that consumes little memory when handling increasing volume

EasyEngine 2k Jan 4, 2023
Generic PHP command line flags parse library

PHP Flag Generic PHP command line flags parse library Features Generic CLI options and arguments parser. Support set value data type(int,string,bool,a

PHP Toolkit 23 Nov 13, 2022
A simple command-line tool whose aim is to facilitate the continous delivery of PHP apps

Deployer Simple command-line tool that aims to facilitate the continous delivery of PHP apps, particularly Laravel apps. Imagine you want to update yo

Fernando Bevilacqua 4 Sep 8, 2021
๐Ÿƒ In short, it's like Tailwind CSS, but for the PHP command-line applications.

Termwind Termwind allows you to build unique and beautiful PHP command-line applications, using the Tailwind CSS API. In short, it's like Tailwind CSS

Nuno Maduro 1.8k Dec 30, 2022
A PHP Command Line tool that makes it easy to compile, concat, and minify front-end Javascript and CSS/SCSS dependencies.

Front End Compiler A PHP Command Line tool that makes it easy to compile, concat, and minify front-end Javascript and CSS/SCSS dependencies. The minif

Happy Medium 2 Nov 12, 2021
php command line script to DCA crypto from Coinbase Pro

dca.php A simple php script designed to be run via the command line via a cron job. This will connect to coinbase pro and buy the crypto coins specifi

Ben Suffolk 2 Oct 22, 2021
Simple command-line tool to access HiWeb account information

Simple command-line tool to access HiWeb account information.

Milad Nekofar 2 Dec 26, 2022