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-architector-import

v1.0.1

Published

Eslint plugin for enforcing atomic design hierarchy

Downloads

5

Readme

eslint-plugin-architector

The Dependency Rule states that the source code dependencies can only point inwards.

Image alt

This means nothing in an inner circle can know anything at all about something in an outer circle. i.e. the inner circle shouldn’t depend on anything in the outer circle. The Black arrows represented in the diagram show the dependency rule. This plugin helps to avoid dependency rule errors

The plugin supports aliases that you specify in the "jsconfig.json" file and also works with require and asinc import.

Image alt

installation

npm i eslint-plugin-architector-import

Usage

Add the plugin to your eslint config file

"plugins": [
    "eslint-plugin-architector-import"
],

Next, enable the rule

     "architector-import/architector-import": [
      "error",

      {
        "errorPostfix": "see www.wiki for details.",
        "levels": [
            {
            "level": "UILib",
            "independentChildren": true,
            "children": [
              {
                "level": "UiLibA",
                "children": [
                  {
                    "level": "UiLibD",
                    "children": []
                  },
                  {
                    "level": "UiLibE",
                    "children": []
                  }
                ]
              },
              {
                "level": "UiLibB",
                "children": []
              }
            ]
          },
          {
            "level": "Global",
            "children": [
              {
                "level": "GlobalA",
                "children": []
              },
              {
                "level": "GlobalB",
                "children": []
              }
            ]
          },
          {
            "level": "Services",
            "children": [
              {
                "level": "ServicesA",
                "children": []
              },
              {
                "level": "ServicesB",
                "children": []
              },
              {
                "level": "ServicesC",
                "children": []
              }
            ]
          }

        ]
      },

      "components"
    ]

You can change the hierarchy, both levels and child levels are configurable. The plugin will only check imports in these folders, located in the components folder.

You can also change the name of the root component folder. The plugin will only check files and import in this folder.

"level" - Folder name(Required field).

"children" - Array with child folders (Required if there are no child levels- "children": []).

"errorPostfix" - The message that will be shown with an error if the import is not correct (Optional field).

"independentChildren": true,- This setting will allow you to import all child levels into each other, regardless of the hierarchy, but not deeper than one level of nesting (Optional field).

Case 1

**/components/**/UILib/UILib.js Level "UILib" is the highest in the tree, so only its children can be imported into it

// valid, UILiB can import childrens  Level A
import { UILibA } from "./UILibA/UILibA.js";
import { UILibB } from "./UILibB/UILibB.js";

// invalid, UILib cannot import Global, Services
import { Global } from "../Global/Global.js";
import { Services } from "Services/Services.js";
-Aliase;

// invalid, UILib can't import "children" Level B
import { GlobalB } from "GlobalB/GlobalB.js";
-Aliase;

Case 2

**/components/**/Global/GlobalB/GlobalB.js Level "GlobalB" is a child of level "Global", level "Global" is above "Services", but below "UILib", so it can import "UILib" and its children

// valid, Global can import childrens Level UILib and Level UILib
import { UILib } from "../../UILib/UILib.js";
import { UILibA } from "../../UILib/UILibA/UILibA.js";

// invalid, GlobalB can't import  Level Global and Level Services
import { Global } from "../Global.js";
import { Services } from "Services/Services.js";

Case 3

**/components/**/Services/Services.js Level "Services" is below all levels in the rules tree, so you can import all levels into it

// valid
import { GlobalB } from "GlobalB/GlobalB.js";
import { UILib } from "../UILib/UILib.js";
import { UILibA } from "../UILib/UILibA/UILibA.js";
import { Global } from "../Global/Global.js";