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

@garvae/eslint-plugin-comments

v1.0.7

Published

Various rules for ESLint to work with comments

Downloads

56

Readme

eslint-plugin-comments by @Garvae

Various rules for ESLint to work with comments



🛠 Installation

1. Install ESLint if you haven't already

npm i eslint --save-dev

2. Install package

npm:

npm -i --save-dev @garvae/eslint-plugin-comments

yarn:

yarn add -D @garvae/eslint-plugin-comments

3. Add the plugin and the rule to the ESLint config

{
  "plugins": ["@garvae/comments"],
  "rules": {
    "@garvae/comments/no-line-comments": "error"
  }
}

📦 Rules

🧾 no-line-comments

The no-line-comments rule of the @garvae/eslint-plugin-comments plugin can help you to enforce special style for Line (double slash) type comments. This rule returns an error for all comments of type Line (double slash) unless the special options of this rule (ingore*) are specified. The format of this rule can be applied if both --fix option of ESLint and fixable = true option of this rule are specified.

💪 Benefits

✔️ Automatically fixable by the --fix CLI option ✔️ Flexible settings

⚙ Options

| option | description | type | default | | :---------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------- | ----------- | | fixable | Enables auto-fix by the --fix ESLint CLI option. Disabled by default because you may want to check all comments first | boolean | false | | ignore | Defines the conditions under which a comment will be ignored by the rule | Object | undefined | | ignore.startsWith | A comment will be ignored by the rule if it starts with one of the strings defined in the array of strings passed to this rule parameter. | Array<string> | undefined | | ignore.includes | A comment will be ignored by the rule if it includes one of the strings defined in the array of strings passed to this rule parameter. | Array<string> | undefined | | singleLineToSingleLineBlock | If this option is false (default), a 'Line' type (not 'Block' type / starred) comment will be formatted into a multi-line 'Block' type (starred) comment, otherwise the comment will be formatted into a valid single-line 'Block' type (starred) comment | boolean | false |

Example (all options):

{
  "@garvae/comments/no-line-comments": [
    "error",
    {
      "fixable": true,
      "ignore": {
        "startsWith": ["keyword", "key-phrase"],
        "includes": ["keyword", "key-phrase"]
      },
      "singleLineToSingleLineBlock": true
    }
  ]
}

⚡ Examples

⚙ Default options
{
  "@garvae/comments/no-line-comments": "error"
}

Examples of 👎 incorrect code for these options:

// single-line comment
// single-line comment
// single-line comment
/**
 * multiline comment
 * line with wrong offset - Expected all lines to be aligned with the start of the comment
 */
/**
 * multiline comment
   line without a '*' symbol - Expected a '*' symbol at the start of each line of the starred-block comment
 */

Examples of 👍 correct code for these options:

/**
 * single-line comment
 */
/**
 * single-line comment
 * single-line comment
 */
/**
 * multiline comment
 * line with valid offset
 */
/**
 * multiline comment
 * line with a '*' symbol
 */
singleLineToSingleLineBlock option
{
  "@garvae/comments/no-line-comments": [
    "error",
    {
      "singleLineToSingleLineBlock": true
    }
  ]
}

Examples of 👎 incorrect code for these options:

// single-line comment
/* "Block" comment without ending spacing*/
/*"Block" comment without leading spacing */

Examples of 👍 correct code for these options:

/* single-line comment */
/**
 * single-line comment
 */
ignore option + startsWith
{
  "@garvae/comments/no-line-comments": [
    "error",
    {
      "ignore": { "startsWith": ["keyword", "key-phrase"] }
    }
  ]
}

Examples of 👎 incorrect code for these options:

// single line comment

Examples of 👍 correct code for these options:

// keyword single-line comment (will be ignored)
// key-phrase single-line comment (will be ignored)
ignore option + includes
{
  "@garvae/comments/no-line-comments": [
    "error",
    {
      "ignore": { "includes": ["keyword", "key-phrase"] }
    }
  ]
}

Examples of 👎 incorrect code for these options:

// single-line comment

Examples of 👍 correct code for these options:

// single-line comment with keyword (will be ignored)
// single-line comment with key-phrase (will be ignored)

💎 Recommendations

Read about "multiline-comment-style" rule by Teddy Katz.

no-line-comments by @Garvae and multiline-comment-style by Teddy Katz can complement each other

🤝 Contributions

🤝 Contributions, issues and feature requests are welcome! Feel free to check issues page and pull request page.

❤️ Give aif you like this project!

📞 Contact me

🌐 Contact page

🔳 QR code

🔗 Links

🚀 Mentoring

If you want to grow 🚀 fast in front-end development - contact me! 🙋‍♂

📄 License

See license in the "LICENCE" file