Socket
Socket
Sign inDemoInstall

@gorazdo/eslint-plugin-preact

Package Overview
Dependencies
2
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gorazdo/eslint-plugin-preact


Version published
Weekly downloads
986
increased by2.28%
Maintainers
1
Created
Weekly downloads
 

Readme

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

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc