npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

eslint-plugin-toml

v0.11.1

Published

This ESLint plugin provides linting rules for TOML.

Downloads

481,665

Readme

Introduction

eslint-plugin-toml is ESLint plugin provides linting rules for TOML.

NPM license NPM version NPM downloads NPM downloads NPM downloads NPM downloads NPM downloads Build Status

: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 v12.22.x, v14.17.x, v16.x and above

:book: Usage

Configuration

New Config (eslint.config.js)

Use eslint.config.js file to configure rules. See also: https://eslint.org/docs/latest/use/configure/configuration-files-new.

Example eslint.config.js:

import eslintPluginToml from 'eslint-plugin-toml';
export default [
  // add more generic rule sets here, such as:
  // js.configs.recommended,
  ...eslintPluginToml.configs['flat/recommended'],
  {
    rules: {
      // override/add rules settings here, such as:
    // 'toml/rule-name': 'error'
    }
  }
];

This plugin provides configs:

  • *.configs['flat/base'] ... Configuration to enable correct TOML parsing.
  • *.configs['flat/recommended'] ... Above, plus rules to prevent errors or unintended behavior.
  • *.configs['flat/standard'] ... Above, plus rules to enforce the common stylistic conventions.

See the rule list to get the rules that this plugin provides.

Legacy Config (.eslintrc)

Use .eslintrc.* file to configure rules. See also: https://eslint.org/docs/latest/use/configure/.

Example .eslintrc.js:

module.exports = {
  extends: [
    // add more generic rulesets here, such as:
    // 'eslint:recommended',
    'plugin:toml/standard'
  ],
  rules: {
    // override/add rules settings here, such as:
    // 'toml/rule-name': 'error'
  }
}

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", { "exceptions": { "TOMLKeyValue": true } }],
        "no-multiple-empty-lines": "error",
        "no-trailing-spaces": "error"
    }
}

See the rule list to get the rules that this plugin provides.

Parser Configuration

If you have specified a parser, you need to configure a parser for .toml.

For example, if you are using the "@babel/eslint-parser", configure it as follows:

module.exports = {
  // ...
  extends: ["plugin:toml/standard"],
  // ...
  parser: "@babel/eslint-parser",
  // Add an `overrides` section to add a parser configuration for TOML.
  overrides: [
    {
      files: ["*.toml"],
      parser: "toml-eslint-parser",
    },
  ],
  // ...
};

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

| Rule ID | Description | Fixable | RECOMMENDED | STANDARD | |:--------|:------------|:-------:|:-----------:|:--------:| | toml/indent | enforce consistent indentation | :wrench: | | :star: | | toml/keys-order | disallow defining pair keys out-of-order | :wrench: | | :star: | | toml/no-mixed-type-in-array | disallow mixed data types in array | | | | | toml/no-non-decimal-integer | disallow hexadecimal, octal and binary integer | :wrench: | | | | toml/no-space-dots | disallow spacing around infix operators | :wrench: | | :star: | | toml/no-unreadable-number-separator | disallow number separators that to not enhance readability. | | :star: | :star: | | toml/padding-line-between-pairs | require or disallow padding lines between pairs | :wrench: | | :star: | | toml/padding-line-between-tables | require or disallow padding lines between tables | :wrench: | | :star: | | toml/precision-of-fractional-seconds | disallow precision of fractional seconds greater than the specified value. | | :star: | :star: | | toml/precision-of-integer | disallow precision of integer greater than the specified value. | | :star: | :star: | | toml/quoted-keys | require or disallow quotes around keys | :wrench: | | :star: | | toml/tables-order | disallow defining tables out-of-order | :wrench: | | :star: | | toml/vue-custom-block/no-parsing-error | disallow parsing errors in Vue custom blocks | | :star: | :star: |

Extension Rules

| Rule ID | Description | Fixable | RECOMMENDED | STANDARD | |:--------|:------------|:-------:|:-----------:|:--------:| | toml/array-bracket-newline | enforce linebreaks after opening and before closing array brackets | :wrench: | | :star: | | toml/array-bracket-spacing | enforce consistent spacing inside array brackets | :wrench: | | :star: | | toml/array-element-newline | enforce line breaks between array elements | :wrench: | | :star: | | toml/comma-style | enforce consistent comma style in array | :wrench: | | :star: | | toml/inline-table-curly-spacing | enforce consistent spacing inside braces | :wrench: | | :star: | | toml/key-spacing | enforce consistent spacing between keys and values in key/value pairs | :wrench: | | :star: | | toml/spaced-comment | enforce consistent spacing after the # in a comment | :wrench: | | :star: | | toml/table-bracket-spacing | enforce consistent spacing inside table brackets | :wrench: | | :star: |

Deprecated

  • :warning: We're going to remove deprecated rules in the next major release. Please migrate to successor/new rules.
  • :innocent: We don't fix bugs which are in deprecated rules since we don't have enough resources.

| Rule ID | Replaced by | |:--------|:------------| | toml/space-eq-sign | toml/key-spacing |

: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).