1.0.11 • Published 4 years ago

eslint-plugin-atomic-design-hierarchy v1.0.11

Weekly downloads
116
License
ISC
Repository
github
Last release
4 years ago

Atomic Design ESLint Plugin

Build Status npm version david-dm codecov.io Code Coverage

A simplistic plugin that enforces atomic design hierarchy. The plugin allows you to define a components folder containing component level divisions (e.g. atoms, molecules, ...). The plugin will check each file in the components folder for imports that don't follow the design hierarchy.

installation

npm i eslint-plugin-atomic-design-hierarchy

Usage

Add the plugin to your eslint config file

"plugins": [
    "atomic-design-hierarchy"
],

Next, enable the rule

"atomic-design-hierarchy/hierarchical-import": "error"

Configuring

default values

component folder: 'components'

design hierarchy:

  • atoms = 0
  • molecules = 1
  • organisms = 2
  • templates = 3
  • pages = 4

options

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

You can also change the root components folder name. The plugin will only check files and imports within this folder.

"atomic-design-hierarchy/hierarchical-import": [
    "error",
    {
        "atoms": 0,
        "molecules": 1,
        "organisms": 2,
        "templates": 3,
        "pages": 4,
    },
    "components"
]

Examples

from **/components/**/molecules/ComponentX

// valid, molecules can import atoms
import { ComponentA } from '../atoms/ComponentA'

// valid, molecules can import molecules
import { ComponentY } from './ComponentY'

// invalid, molecules can't import organisms
import { ComponentB } from '../organisms/ComponentB'
1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago