Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-validate-jsx-nesting

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-validate-jsx-nesting

ESLint Plugin for Validating JSX Nesting

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8.6K
decreased by-9.05%
Maintainers
1
Weekly downloads
 
Created
Source

eslint-plugin-validate-jsx-nesting

Find Invalid HTML Nesting in JSX, like this:

Why this validation is important?

Without such validation, When JSX is converted to HTML and rendered in the DOM, the browser will try to fix the invalid nestings ( such as <p> inside <p> ) and thus the rendered DOM will have a different structure than the JSX structure.

This is a big issue for frameworks that rely on JSX rendering the exact same elements in DOM. This can lead to unexpected behaviors.

This plugin uses the validate-html-nesting library for validating HTML element nesting


Framework agnostic

This ESLint plugin works with any framework that uses JSX


Install

npm i -D eslint-plugin-validate-jsx-nesting

Usage

Step 1: Add the plugin in ESLint Config

Add "eslint-plugin-validate-jsx-nesting" to the plugins section of your ESLint configuration file. You can omit the "eslint-plugin-" prefix if you want.

{
	"plugins": ["validate-jsx-nesting"]
}

Step 2: Add the Plugin's rule

This plugin only has one rule "no-invalid-jsx-nesting".

Add the "validate-jsx-nesting/no-invalid-jsx-nesting" rule in your ESLint config file as shown below

"rules": {
	"validate-jsx-nesting/no-invalid-jsx-nesting": "error"
}

Testing Suite

The core validation logic is in validate-html-nesting library and you can checkout the testing suite here.



Keywords

FAQs

Package last updated on 10 Jul 2022

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc