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

@blueprintjs/eslint-plugin

Package Overview
Dependencies
Maintainers
1
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blueprintjs/eslint-plugin

ESLint rules for use with @blueprintjs packages

  • 0.4.0-rc.2
  • npm
  • Socket score

Version published
Weekly downloads
3.2K
decreased by-29.01%
Maintainers
1
Weekly downloads
 
Created
Source

Blueprint ESLint plugin

Blueprint is a React UI toolkit for the web.

This package contains the ESLint plugin for Blueprint. It provides custom rules which are useful when developing against Blueprint libraries.

Key features:

  • Blueprint-specific rules for use with @blueprintjs components.

Installation

yarn add --dev @blueprintjs/eslint-plugin

Usage

Simply add this plugin in your .eslintrc file to use the add the plugin. The plugin includes Blueprint-specific rules which enforce semantics particular to usage with @blueprintjs packages, but does not turn them on by default.

.eslintrc

plugins: [
    "@blueprintjs"
]

Rules-only usage

To enable the Blueprint-specific rules, extend the plugin:@blueprintjs/recommended config inside the package:

tslint.json

extends: [
+    "plugin:@blueprintjs/recommended"
]

Rules

@blueprintjs/classes-constants

Enforce usage of Classes constants over namespaced string literals.

Each @blueprintjs package exports a Classes object that contains constants for every CSS class defined by the package. While the values of the constants may change between releases, the names of the constants will remain more stable.

{
    "rules": {
        "@blueprintjs/classes-constants": ["error"]
    }
}
-const element = <div className="pt-navbar" />;
+const element = <div className={Classes.NAVBAR} />;

@blueprintjs/html-components

Enforce usage of Blueprint components over regular html components.

  • h1-6 -> H1-6
  • code -> Code
  • pre -> Pre
  • blockquote -> Blockquote
  • table -> HTMLTable
{
  "rules": {
    "@blueprintjs/html-components": ["error"],
  }
}

@blueprintjs/icon-components

Enforce usage of JSX Icon components over IconName string literals (or vice-versa) in icon JSX props. Note that this rule only supports hardcoded values in the icon prop; it does not handle expressions or conditionals.

A fixer is available for this rule that will convert between string literals and named Icon components. Note that the implementation is naive and may require intervention, such as to import a component or fix an invalid name.

Named icon components (TickIcon, GraphIcon, etc) can be imported from the @blueprintjs/icons package.

This rule is disabled in the blueprint-rules config as it is most useful to ensure that the @blueprintjs/icons package can be tree-shaken (an opt-in process which requires using components and never IconName literals).

{
  "rules": {
    // default uses "component"
    "@blueprintjs/icon-components": ["error"],
    // expanded syntax
    "@blueprintjs/icon-components": ["error", "component" | "literal"] // choose one
  }
}

"component"

-<Button icon="tick" />
+<Button icon={<TickIcon />} />

"literal"

-<Button icon={<GraphIcon />} />
+<Button icon="graph" />

Full Documentation | Source Code

FAQs

Package last updated on 21 Mar 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