eslint-plugin-backpack

6.0.0 • Public • Published

eslint-plugin-backpack

Build Status

Eslint plugin to prevent magic arbitrary values and promote the use of Backpack tokens

You'll first need to install ESLint:

$ npm i eslint --save-dev

Next, install eslint-plugin-backpack:

$ npm install eslint-plugin-backpack --save-dev

Note: If you installed ESLint globally (using the -g flag) then you must also install eslint-plugin-backpack globally.

Usage

Add backpack to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
  "plugins": ["backpack"]
}

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

{
  "rules": {
    "backpack/rule-name": 2
  }
}

Supported Rules

use-tokens

Available for colours and length values. Will prevent the use of a hardcoded colour if a Backpack token is available for the given value.

Configuration

Name Type Required
autoImport boolean false
platform string false
tokensPackage shape({ web: string, native: string }) false
typeof boolean false
{
  "rules": {
    "backpack/use-tokens": [2, {
      "autoImport": true,
      "platform": "web",
      "tokensPackage": {
        "web": "@skyscanner/bpk-foundations-web/tokens/base.es6",
      },
    }]
  }
}

use-components

Will prevent the usage of built-in components when a Backpack option is available.

Configuration

Name Type Required
autoImport boolean false
platform string false
{
  "rules": {
    "backpack/use-components": [2, {
      "autoImport": true,
      "platform": "web"
    }]
  }
}

/eslint-plugin-backpack/

    Package Sidebar

    Install

    npm i eslint-plugin-backpack

    Weekly Downloads

    77

    Version

    6.0.0

    License

    Apache-2.0

    Unpacked Size

    55.9 kB

    Total Files

    18

    Last publish

    Collaborators

    • mungodewar
    • anambl
    • skyscanner-koalasquad
    • gert-jan.vercauteren
    • frugoman
    • marianeumayer-skyscanner
    • ojcurt
    • mhdev