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

@vkcn/eslint-plugin

v0.5.3

Published

ESLint plugin for ensuring a kebab-ish like class naming convention in Vue files

Downloads

72

Readme

@vkcn/eslint-plugin

@vkcn/eslint-plugin is an ESLint plugin for ensuring a kebab-ish like class naming convention.

This convention was invited and relates only to this plugin. The convention was created to solve styles encapsulation via class naming. The description of the convention can be found in rule documentation.

VKCN stands for vue-kebab-class-naming.

Read more about CSS encapsulation and compare VKCN with other options in this article.

Features

This ESLint plugin provides linting rules related to better class names usage.

  • Provides linting rules for Vue template and style blocks.
  • Supports plain CSS and SCSS.
  • Parses <style> and <template> blocks.
  • ~~Mostly copied~~ Highly inspired by eslint-plugin-vue-scoped-css

Installation

Prerequisite: eslint and eslint-plugin-vue are already installed

npm install --save-dev @vkcn/eslint-plugin
yarn add --dev @vkcn/eslint-plugin
pnpm add --dev @vkcn/eslint-plugin

Usage

Edit .eslintrc.* file to configure rules. See also: http://eslint.org/docs/user-guide/configuring.

Example .eslintrc.js:

module.exports = {
  plugins: ['@vkcn'],
  settings: { "@vkcn/class-attr-name": /custom-reg-exp/ }, // optional
  rules: {
    '@vkcn/<rule-name>': 'error'
  }
}

By using settings: { "@vkcn/class-attr-name": /custom-reg-exp/ } it is possible to run rules throughout any attribute/directive which matches regexp. By default only class is checked.

Please note! When using a custom regexp - class must be included into it

Recommended usage

Configuration

Please note! Recommended set of rules includes several eslint plugins, which are out of this plugin's scope, so install them separately.

module.exports = {
  parser: "vue-eslint-parser",
  plugins: [
    'vue',
    'vue-scoped-css',
    '@vkcn',
  ],
  rules: {
    "vue/no-useless-v-bind": "error",
    "vue/prefer-separate-static-class": "error",

    "vue-scoped-css/enforce-style-type": ["error", { allows: ["plain"] }],
    "vue-scoped-css/no-unused-selector": ["error", { checkUnscoped: true }],
    "vue-scoped-css/require-selector-used-inside": ["error", { checkUnscoped: true }],

    '@vkcn/no-convention-violation': ["error", { enableFix: true }],
    '@vkcn/no-dynamic-class-names': "error",
    '@vkcn/no-undefined-class-names': "error",
  }
}

Additional tools

Since Eslint works only with one file and can not lint the whole project - something else is needed for checking. This tool is intended to be used to ensure that no identical classes are defined in multiple files (to prevent style leaks)

Available rules

The --fix option on the command line automatically fixes problems reported by rules which have a wrench :wrench: below.

Rules which have suggestions - marked with :bulb:

| Rule ID | Description | | |:--------|:------------|:---| | @vkcn/no-dynamic-class-names | disallow dynamic class names usage | | | @vkcn/no-undefined-class-names | disallow class names using in <template> that are not defined in <style> | :bulb: | | @vkcn/no-convention-violation | enforce css/scss code style | :wrench: :bulb: |

Contributing

Welcome contributing!

Please use GitHub's Issues/PRs.

Development Tools

  • yarn test runs tests and measures coverage.
  • yarn t tests/lib/rules/<rule-name>.ts runs all tests for selected rule.
  • put debugger statement in lib code and run task "Debug tests" in VS Code "Run and Debug" tab

License

See the LICENSE file for license rights and limitations (MIT).

Huge thanks to Yosuke Ota for creating eslint-plugin-vue-scoped-css which enabled this eslint plugin creation.