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

@gorazdo/eslint-plugin-preact

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gorazdo/eslint-plugin-preact

Eslint rules for Preact in compat mode

  • 1.0.7
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Installation

You'll first need to install ESLint:

npm i eslint --save-dev
# yarn add eslint -D

Next, install @gorazdo/eslint-plugin-preact:

npm install @gorazdo/eslint-plugin-preact --save-dev
# yarn add @gorazdo/eslint-plugin-preact -D

Configuration

Add @gorazdo/preact to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
    "plugins": [
        "@gorazdo/preact"
    ]
}

Then configure the rules you want to use under the rules section.

{
    "rules": {
        "@gorazdo/preact/forbid-render-arguments": 2,
        "@gorazdo/preact/prefer-classname": 2
    }
}

Supported Rules

forbid-render-arguments

Preact allows you to consume props and state in Class-based components directly from the arguments of render() method like this: render(props, state).

Although, it is possible it has downsides:

  1. It is incompatible with React library;
  2. It is required to re-type arguments in Typescript like this: render(props: MyProps, state: MyState);
  3. On Typescript page of Preact docs authors of the library use this.props.

prefer-classname

Preact allows you to use class as JSX Attribute. With preact/compat it is possible to use className.

There is a great discussion why Preact uses class and React className. Although, consider the following theses:

  1. class is still a reserved word in Javascript, which means that the syntax is limited;
  2. className has a wider usage over class.

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