Introduction
eslint-plugin-toml is ESLint plugin provides linting rules for TOML.
:name_badge: Features
This ESLint plugin provides linting rules for TOML.
- You can use ESLint to lint TOML.
- You can find out the problem with your TOML files.
- You can apply consistent code styles to your TOML files.
- Supports Vue SFC custom blocks such as
<custom-block lang="toml">
.
Requirements vue-eslint-parser
v7.3.0 and above. - Supports ESLint directives. e.g.
# eslint-disable-next-line
- You can check your code in real-time using the ESLint editor integrations.
You can check on the Online DEMO.
:book: Documentation
See documents.
:cd: Installation
npm install --save-dev eslint eslint-plugin-toml
Requirements
- ESLint v6.0.0 and above
- Node.js v8.10.0 and above
:book: Usage
Configuration
Use .eslintrc.*
file to configure rules. See also: https://eslint.org/docs/user-guide/configuring.
Example .eslintrc.js:
module.exports = {
extends: [
'plugin:toml/standard'
],
rules: {
}
}
This plugin provides configs:
plugin:toml/base
... Configuration to enable correct TOML parsing.plugin:toml/recommended
... Above, plus rules to prevent errors or unintended behavior.plugin:toml/standard
... Above, plus rules to enforce the common stylistic conventions.
Note that these configurations do not enable ESLint's core rules.
For example, the following style rules can also be used in TOML.
{
"rules": {
"comma-spacing": "error",
"no-multi-spaces": "error",
"no-multiple-empty-lines": "error",
"no-trailing-spaces": "error"
}
}
See the rule list to get the rules
that this plugin provides.
Running ESLint from the command line
If you want to run eslint
from the command line, make sure you include the .toml
extension using the --ext
option or a glob pattern, because ESLint targets only .js
files by default.
Examples:
eslint --ext .js,.toml src
eslint "src/**/*.{js,toml}"
:computer: Editor Integrations
Visual Studio Code
Use the dbaeumer.vscode-eslint extension that Microsoft provides officially.
You have to configure the eslint.validate
option of the extension to check .toml
files, because the extension targets only *.js
or *.jsx
files by default.
Example .vscode/settings.json:
{
"eslint.validate": [
"javascript",
"javascriptreact",
"toml"
]
}
:white_check_mark: Rules
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 configs.
TOML Rules
Extension Rules
:beers: Contributing
Welcome contributing!
Please use GitHub's Issues/PRs.
Development Tools
npm test
runs tests and measures coverage.npm run update
runs in order to update readme and recommended configuration.
Working With Rules
This plugin uses toml-eslint-parser for the parser. Check here to find out about AST.
:couple: Related Packages
:lock: License
See the LICENSE file for license rights and limitations (MIT).