Socket
Book a DemoInstallSign in
Socket

babel-plugin-mithril-add-data-attribute

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-mithril-add-data-attribute

Babel plugin adds attributes to m() components - intended for development. Helps debug - find your components in a large repo. Adds component name and file to component data attributes which will be visible in the generated HTML.

1.0.1
Source
npmnpm
Version published
Weekly downloads
7
Maintainers
1
Weekly downloads
 
Created
Source

babel-plugin-mithril-add-data-attribute

BETA. This plugin adds a data-component attribute to top-level DOM elements rendered by mithril component function m. Intended for development - bloats HTML. Helps debug - find your components in a large repo from generated HTML. Adds component name and file to component data attributes which will be visible in the generated HTML.

  • only adds to outer component
  • tries to figure out component name from function or variable def
  • if no name found it tries to use the file name, so you'll know where to start

Needs more tests and better support for function/class-declarations.

Examples

In

const MyComponent = () => m("div");

const InnerComp = {};
const OuterComp = () => {
  return m("div", m(InnerComp));
};

Out

const MyComponent = () =>
  m("div", {
    "data-component": "MyComponent",
  });

const InnerComp = {};
const OuterComp = () => {
  return m(
    "div",
    {
      "data-component": "OuterComp",
    },
    m(InnerComp)
  );
};

Installation

# yarn
yarn add --dev babel-plugin-mithril-add-data-attribute

# npm
npm install --save-dev babel-plugin-mithril-add-data-attribute

Usage

Via .babelrc

.babelrc

{
  "plugins": ["mithril-add-data-attribute"]
}

Via CLI

babel --plugins mithril-add-data-attribute script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["mithril-add-data-attribute"],
});

Options

Under development

Contribute

Please do.

FAQs

Package last updated on 29 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.