项目作者: kristerkari

项目描述 :
Stylelint rule for preventing the use of low performance animation and transition properties.
高级语言: JavaScript
项目地址: git://github.com/kristerkari/stylelint-high-performance-animation.git
创建时间: 2018-04-26T20:01:49Z
项目社区:https://github.com/kristerkari/stylelint-high-performance-animation

开源协议:MIT License

下载


stylelint-high-performance-animation

NPM version
Build Status
Downloads per month
contributions welcome

Stylelint rule for preventing the use of low performance animation and transition properties.

This is a fork of stylelint-performance-animation stylelint plugin. It uses a blacklist for harmful properties instead of a whitelist, which makes it easy to avoid false positives and allows you to specify which type of properties to warn for (layout/paint).

Install

  1. npm install stylelint-high-performance-animation --save-dev

or

  1. yarn add stylelint-high-performance-animation --dev

Usage

Add this config to your .stylelintrc or stylelint config inside package.json:

  1. {
  2. "plugins": ["stylelint-high-performance-animation"],
  3. "rules": {
  4. "plugin/no-low-performance-animation-properties": true
  5. }
  6. }

Details

  1. div {
  2. transition: margin 350ms ease-in;
  3. }
  4. /** ^^^^^^
  5. * You should not use low performance animation properties */
  1. @keyframes myAnimation {
  2. 50% {
  3. top: 5px;
  4. }
  5. }
  6. /** ^^^^^^
  7. * You should not use low performance animation properties */

For more information read article By Paul Lewis and Paul Irish

Options

true

The following pattern is considered warning:

  1. div {
  2. transition: margin-left 350ms ease-in;
  3. }

The following pattern is not considered warning:

  1. div {
  2. transition: transform 350ms ease-in;
  3. }

Optional secondary options

ignore: "paint-properties"

Makes the rule not warn for properties that cause paint and only warn for properties that cause layout.

ignoreProperties: [string]

Given:

{ ignoreProperties: ['color', 'background-color'] }

The following pattern is considered warning:

  1. div {
  2. transition-property: color, margin;
  3. }

The following pattern is not considered warning:

  1. div {
  2. transition-property: color, opacity, background-color;
  3. }

Dependencies

This plugin has only stylelint as a dependency.


License

MIT