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

@quero/eslint-plugin-vue

v1.1.2

Published

A bunch of rules we decided to create ourselves

Downloads

917

Readme

@quero/eslint-plugin-vue

This project is for rules that we decided to implement ourselves.

Content:

Rules

Legend:

| icon | meaning | | ---- | ------- | | :wrench: | Fixable | | :wrench:* | Partially fixable |

template-kebab-name-for-unregistered-components :wrench:*

This ensures that we have a clear distinction between components that are declared locally vs components that we have to search the project for.

This rule is fixable, but only if the component don't have any extend declaration, because if thats the case, we cannot see which components are being loaded or not.

<template>
  <div>
    <!-- BAD -->
    <GlobalComponent></GlobalComponent>
    <local-component></local-component>

    <!-- GOOD -->
    <global-component></global-component>
    <LocalComponent></LocalComponent>
  </div>
</template>

<script>
const LocalComponent = {
  render(h) {
    return h('div');
  },
};

export default {
  components: {
    LocalComponent,
  },
}
</script>

deprecate-components-in-favor-of

It's super recommended running this rule as warn, otherwise, what would be the point of using this rule at all if the rule will fail everything? Just delete the unused component on this case.

Default

{
  "rules": {
    "@quero/vue/deprecate-components-in-favor-of": ["warn", { }]
  }
}

With the default configuration everything will pass. But if a deprecate option is provided like the example bellow; every component named "deprecate-component-name" will trigger a warn to be substituted by "substituted-component"

{
  "rules": {
    "@quero/vue/deprecate-components-in-favor-of": ["warn", {
      "deprecate": {
        "deprecated-component-name": "substituted-component",
        "AnotherExample": "substituted-component"
      }
    }]
  }
}
<template>
  <div>
    <!-- BAD -->
    <DeprecatedComponentName></GlobalComponeDeprecatedComponentName>
    <deprecated-component-name></deprecated-component-name>
    <deprecated-component-name />
    <AnotherExample />
    <another-example />

    <!-- GOOD -->
    <!-- literally anything else -->
  </div>
</template>

<script>
const LocalComponent = {
  render(h) {
    return h('div');
  },
};

export default {
  components: {
    LocalComponent,
  },
}
</script>

Developing

For constructing and testing the rule, we can use a tool called AST explorer. The AST stats for an abstract syntax tree which is a representation of the source code in a programming language.

When accessing the AST explorer, remember to set the transformer to ESLint v4 (and the parser to eslint-babel, but this should be set automatically once you choose ESLint v4). When this is done, you should see 4 windows in the explorer:

+-[top left]---------------+-[top right]--------------+
| Is used to write a       | Is the explorer of the   |
| source code.             | source code. On hover    |
|                          | you should see the       |
|                          | highlighted parts in     |
|                          | your code.               |
+--------------------------+--------------------------+
| Is the rule.             | Is the output after the  |
|                          | rule, that runs against  |
|                          | the code.                |
|                          |                          |
+-[bottom left]------------+-[bottom right]-----------+

The rule window, should export a function that is the rule you are developing.

For more information on how to create your first rule, see How To Write Your First ESLint Plugin.

More resources that are an interesting read before/while: