Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
92324ae730 | ||
|
|
7359785ea0 | ||
|
|
579a975b70 | ||
|
|
f3d9196aa0 | ||
|
|
881d301883 | ||
|
|
b62b424dd4 |
@@ -1,6 +1,15 @@
|
|||||||
Changelog
|
Changelog
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
1.18.0 (2019-10-15)
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
- Lint ``.yamllint`` config file by default
|
||||||
|
- Also read config from ``.yamllint.yml`` and ``.yamllint.yaml``
|
||||||
|
- Improve documentation for ``yaml-files``
|
||||||
|
- Update documentation for ``pre-commit``
|
||||||
|
- Explicitly disable ``empty-values`` and ``octal-values`` rules
|
||||||
|
|
||||||
1.17.0 (2019-08-12)
|
1.17.0 (2019-08-12)
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ To use a custom configuration file, use the ``-c`` option:
|
|||||||
If ``-c`` is not provided, yamllint will look for a configuration file in the
|
If ``-c`` is not provided, yamllint will look for a configuration file in the
|
||||||
following locations (by order of preference):
|
following locations (by order of preference):
|
||||||
|
|
||||||
- ``.yamllint`` in the current working directory
|
- ``.yamllint``, ``.yamllint.yaml`` or ``.yamllint.yml`` in the current working
|
||||||
|
directory
|
||||||
- ``$XDG_CONFIG_HOME/yamllint/config``
|
- ``$XDG_CONFIG_HOME/yamllint/config``
|
||||||
- ``~/.config/yamllint/config``
|
- ``~/.config/yamllint/config``
|
||||||
|
|
||||||
@@ -126,6 +127,7 @@ configuration option. The default is:
|
|||||||
yaml-files:
|
yaml-files:
|
||||||
- '*.yaml'
|
- '*.yaml'
|
||||||
- '*.yml'
|
- '*.yml'
|
||||||
|
- '.yamllint'
|
||||||
|
|
||||||
The same rules as for ignoring paths apply (``.gitignore``-style path pattern,
|
The same rules as for ignoring paths apply (``.gitignore``-style path pattern,
|
||||||
see below).
|
see below).
|
||||||
|
|||||||
@@ -10,8 +10,10 @@ Here is an example, to add in your .pre-commit-config.yaml
|
|||||||
.. code:: yaml
|
.. code:: yaml
|
||||||
|
|
||||||
---
|
---
|
||||||
# Update the sha variable with the release version that you want, from the yamllint repo
|
# Update the rev variable with the release version that you want, from the yamllint repo
|
||||||
|
# You can pass your custom .yamllint with args attribute.
|
||||||
- repo: https://github.com/adrienverge/yamllint.git
|
- repo: https://github.com/adrienverge/yamllint.git
|
||||||
sha: v1.8.1
|
rev: v1.17.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: yamllint
|
- id: yamllint
|
||||||
|
args: [-c=/path/to/.yamllint]
|
||||||
|
|||||||
@@ -28,7 +28,9 @@ class OctalValuesTestCase(RuleTestCase):
|
|||||||
self.check('user-city: 0o10', conf)
|
self.check('user-city: 0o10', conf)
|
||||||
|
|
||||||
def test_implicit_octal_values(self):
|
def test_implicit_octal_values(self):
|
||||||
conf = ('octal-values: {forbid-implicit-octal: true}\n'
|
conf = ('octal-values:\n'
|
||||||
|
' forbid-implicit-octal: true\n'
|
||||||
|
' forbid-explicit-octal: false\n'
|
||||||
'new-line-at-end-of-file: disable\n'
|
'new-line-at-end-of-file: disable\n'
|
||||||
'document-start: disable\n')
|
'document-start: disable\n')
|
||||||
self.check('user-city: 010', conf, problem=(1, 15))
|
self.check('user-city: 010', conf, problem=(1, 15))
|
||||||
@@ -50,7 +52,9 @@ class OctalValuesTestCase(RuleTestCase):
|
|||||||
' - 0e3\n', conf)
|
' - 0e3\n', conf)
|
||||||
|
|
||||||
def test_explicit_octal_values(self):
|
def test_explicit_octal_values(self):
|
||||||
conf = ('octal-values: {forbid-explicit-octal: true}\n'
|
conf = ('octal-values:\n'
|
||||||
|
' forbid-implicit-octal: false\n'
|
||||||
|
' forbid-explicit-octal: true\n'
|
||||||
'new-line-at-end-of-file: disable\n'
|
'new-line-at-end-of-file: disable\n'
|
||||||
'document-start: disable\n')
|
'document-start: disable\n')
|
||||||
self.check('user-city: 0o10', conf, problem=(1, 16))
|
self.check('user-city: 0o10', conf, problem=(1, 16))
|
||||||
|
|||||||
@@ -448,11 +448,13 @@ class IgnorePathConfigTestCase(unittest.TestCase):
|
|||||||
out = sys.stdout.getvalue()
|
out = sys.stdout.getvalue()
|
||||||
out = '\n'.join(sorted(out.splitlines()))
|
out = '\n'.join(sorted(out.splitlines()))
|
||||||
|
|
||||||
|
docstart = '[warning] missing document start "---" (document-start)'
|
||||||
keydup = '[error] duplication of key "key" in mapping (key-duplicates)'
|
keydup = '[error] duplication of key "key" in mapping (key-duplicates)'
|
||||||
trailing = '[error] trailing spaces (trailing-spaces)'
|
trailing = '[error] trailing spaces (trailing-spaces)'
|
||||||
hyphen = '[error] too many spaces after hyphen (hyphens)'
|
hyphen = '[error] too many spaces after hyphen (hyphens)'
|
||||||
|
|
||||||
self.assertEqual(out, '\n'.join((
|
self.assertEqual(out, '\n'.join((
|
||||||
|
'./.yamllint:1:1: ' + docstart,
|
||||||
'./bin/file.lint-me-anyway.yaml:3:3: ' + keydup,
|
'./bin/file.lint-me-anyway.yaml:3:3: ' + keydup,
|
||||||
'./bin/file.lint-me-anyway.yaml:4:17: ' + trailing,
|
'./bin/file.lint-me-anyway.yaml:4:17: ' + trailing,
|
||||||
'./bin/file.lint-me-anyway.yaml:5:5: ' + hyphen,
|
'./bin/file.lint-me-anyway.yaml:5:5: ' + hyphen,
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ indentation, etc."""
|
|||||||
|
|
||||||
|
|
||||||
APP_NAME = 'yamllint'
|
APP_NAME = 'yamllint'
|
||||||
APP_VERSION = '1.17.0'
|
APP_VERSION = '1.18.0'
|
||||||
APP_DESCRIPTION = __doc__
|
APP_DESCRIPTION = __doc__
|
||||||
|
|
||||||
__author__ = u'Adrien Vergé'
|
__author__ = u'Adrien Vergé'
|
||||||
|
|||||||
@@ -154,6 +154,10 @@ def run(argv=None):
|
|||||||
conf = YamlLintConfig(file=args.config_file)
|
conf = YamlLintConfig(file=args.config_file)
|
||||||
elif os.path.isfile('.yamllint'):
|
elif os.path.isfile('.yamllint'):
|
||||||
conf = YamlLintConfig(file='.yamllint')
|
conf = YamlLintConfig(file='.yamllint')
|
||||||
|
elif os.path.isfile('.yamllint.yaml'):
|
||||||
|
conf = YamlLintConfig(file='.yamllint.yaml')
|
||||||
|
elif os.path.isfile('.yamllint.yml'):
|
||||||
|
conf = YamlLintConfig(file='.yamllint.yml')
|
||||||
elif os.path.isfile(user_global_config):
|
elif os.path.isfile(user_global_config):
|
||||||
conf = YamlLintConfig(file=user_global_config)
|
conf = YamlLintConfig(file=user_global_config)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
yaml-files:
|
yaml-files:
|
||||||
- '*.yaml'
|
- '*.yaml'
|
||||||
- '*.yml'
|
- '*.yml'
|
||||||
|
- '.yamllint'
|
||||||
|
|
||||||
rules:
|
rules:
|
||||||
braces: enable
|
braces: enable
|
||||||
@@ -17,7 +18,7 @@ rules:
|
|||||||
document-start:
|
document-start:
|
||||||
level: warning
|
level: warning
|
||||||
empty-lines: enable
|
empty-lines: enable
|
||||||
empty-values: enable
|
empty-values: disable
|
||||||
hyphens: enable
|
hyphens: enable
|
||||||
indentation: enable
|
indentation: enable
|
||||||
key-duplicates: enable
|
key-duplicates: enable
|
||||||
@@ -25,7 +26,7 @@ rules:
|
|||||||
line-length: enable
|
line-length: enable
|
||||||
new-line-at-end-of-file: enable
|
new-line-at-end-of-file: enable
|
||||||
new-lines: enable
|
new-lines: enable
|
||||||
octal-values: enable
|
octal-values: disable
|
||||||
quoted-strings: disable
|
quoted-strings: disable
|
||||||
trailing-spaces: enable
|
trailing-spaces: enable
|
||||||
truthy:
|
truthy:
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class YamlLintConfig(object):
|
|||||||
self.ignore = None
|
self.ignore = None
|
||||||
|
|
||||||
self.yaml_files = pathspec.PathSpec.from_lines(
|
self.yaml_files = pathspec.PathSpec.from_lines(
|
||||||
'gitwildmatch', ['*.yaml', '*.yml'])
|
'gitwildmatch', ['*.yaml', '*.yml', '.yamllint'])
|
||||||
|
|
||||||
if file is not None:
|
if file is not None:
|
||||||
with open(file) as f:
|
with open(file) as f:
|
||||||
|
|||||||
@@ -75,8 +75,8 @@ ID = 'empty-values'
|
|||||||
TYPE = 'token'
|
TYPE = 'token'
|
||||||
CONF = {'forbid-in-block-mappings': bool,
|
CONF = {'forbid-in-block-mappings': bool,
|
||||||
'forbid-in-flow-mappings': bool}
|
'forbid-in-flow-mappings': bool}
|
||||||
DEFAULT = {'forbid-in-block-mappings': False,
|
DEFAULT = {'forbid-in-block-mappings': True,
|
||||||
'forbid-in-flow-mappings': False}
|
'forbid-in-flow-mappings': True}
|
||||||
|
|
||||||
|
|
||||||
def check(conf, token, prev, next, nextnext, context):
|
def check(conf, token, prev, next, nextnext, context):
|
||||||
|
|||||||
@@ -66,8 +66,8 @@ ID = 'octal-values'
|
|||||||
TYPE = 'token'
|
TYPE = 'token'
|
||||||
CONF = {'forbid-implicit-octal': bool,
|
CONF = {'forbid-implicit-octal': bool,
|
||||||
'forbid-explicit-octal': bool}
|
'forbid-explicit-octal': bool}
|
||||||
DEFAULT = {'forbid-implicit-octal': False,
|
DEFAULT = {'forbid-implicit-octal': True,
|
||||||
'forbid-explicit-octal': False}
|
'forbid-explicit-octal': True}
|
||||||
|
|
||||||
|
|
||||||
def check(conf, token, prev, next, nextnext, context):
|
def check(conf, token, prev, next, nextnext, context):
|
||||||
|
|||||||
Reference in New Issue
Block a user