Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
eslint-plugin-yml
Advanced tools
eslint-plugin-yml is an ESLint plugin that provides linting rules for YAML files. It helps ensure consistency and correctness in YAML files by enforcing specific coding standards and best practices.
Indentation
This rule enforces consistent indentation in YAML files. The example configuration sets the indentation to 2 spaces.
module.exports = {
'yml/indent': ['error', 2]
};
Key Sorting
This rule enforces sorted keys within YAML mappings. The example configuration sorts keys in ascending order, case-insensitively, and using natural sort order.
module.exports = {
'yml/sort-keys': ['error', 'asc', { 'caseSensitive': false, 'natural': true }]
};
No Empty Mapping Values
This rule disallows empty values in YAML mappings. The example configuration treats any empty mapping value as an error.
module.exports = {
'yml/no-empty-mapping-value': 'error'
};
yaml-lint is a simple linter for YAML files that checks for syntax errors. Unlike eslint-plugin-yml, it does not integrate with ESLint and offers fewer customization options.
eslint-plugin-yml is ESLint plugin provides linting rules for YAML.
This ESLint plugin provides linting rules for YAML.
<i18n lang="yaml">
.vue-eslint-parser
v7.3.0 and above.# eslint-disable-next-line
You can check on the Online DEMO.
See documents.
npm install --save-dev eslint eslint-plugin-yml
Requirements
- ESLint v6.0.0 and above
- Node.js v8.10.0 and above
Use .eslintrc.*
file to configure rules. See also: https://eslint.org/docs/user-guide/configuring.
Example .eslintrc.js:
module.exports = {
extends: [
// add more generic rulesets here, such as:
// 'eslint:recommended',
'plugin:yml/recommended'
],
rules: {
// override/add rules settings here, such as:
// 'yml/rule-name': 'error'
}
}
This plugin provides configs:
plugin:yml/base
... Configuration to enable correct YAML parsing.plugin:yml/recommended
... Recommended configuration.See the rule list to get the rules
that this plugin provides.
If you want to run eslint
from the command line, make sure you include the .yaml
extension using the --ext
option or a glob pattern, because ESLint targets only .js
files by default.
Examples:
eslint --ext .js,.yaml,.yml src
eslint "src/**/*.{js,yaml,yml}"
Use the dbaeumer.vscode-eslint extension that Microsoft provides officially.
You have to configure the eslint.validate
option of the extension to check .yaml
files, because the extension targets only *.js
or *.jsx
files by default.
Example .vscode/settings.json:
{
"eslint.validate": [
"javascript",
"javascriptreact",
"yaml"
]
}
The --fix
option on the command line automatically fixes problems reported by rules which have a wrench :wrench: below.
The rules with the following star :star: are included in the config.
Rule ID | Description | Fixable | RECOMMENDED |
---|---|---|---|
yml/block-mapping | require or disallow block style mappings. | :wrench: | |
yml/block-sequence | require or disallow block style sequences. | :wrench: | |
yml/indent | enforce consistent indentation | :wrench: | |
yml/key-name-casing | enforce naming convention to key names | ||
yml/no-empty-key | disallow empty mapping keys | :star: | |
yml/no-empty-mapping-value | disallow empty mapping values | :star: | |
yml/no-empty-sequence-entry | disallow empty sequence entries | :star: | |
yml/no-tab-indent | disallow tabs for indentation. | :star: | |
yml/plain-scalar | require or disallow plain style scalar. | :wrench: | |
yml/quotes | enforce the consistent use of either double, or single quotes | :wrench: | |
yml/require-string-key | disallow mapping keys other than strings | ||
yml/vue-custom-block/no-parsing-error | disallow parsing errors in Vue custom blocks | :star: |
Rule ID | Description | Fixable | RECOMMENDED |
---|---|---|---|
yml/flow-mapping-curly-newline | enforce consistent line breaks inside braces | :wrench: | |
yml/flow-mapping-curly-spacing | enforce consistent spacing inside braces | :wrench: | |
yml/flow-sequence-bracket-newline | enforce linebreaks after opening and before closing flow sequence brackets | :wrench: | |
yml/flow-sequence-bracket-spacing | enforce consistent spacing inside flow sequence brackets | :wrench: | |
yml/key-spacing | enforce consistent spacing between keys and values in mapping pairs | :wrench: | |
yml/no-irregular-whitespace | disallow irregular whitespace | :star: | |
yml/sort-keys | require mapping keys to be sorted | :wrench: | |
yml/spaced-comment | enforce consistent spacing after the # in a comment | :wrench: |
Welcome contributing!
Please use GitHub's Issues/PRs.
npm test
runs tests and measures coverage.npm run update
runs in order to update readme and recommended configuration.See the LICENSE file for license rights and limitations (MIT).
FAQs
This ESLint plugin provides linting rules for YAML.
The npm package eslint-plugin-yml receives a total of 357,437 weekly downloads. As such, eslint-plugin-yml popularity was classified as popular.
We found that eslint-plugin-yml demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.