包详细信息

stylelint-high-performance-animation

kristerkari199.1kMIT1.11.0

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

css, less, lint, linter

自述文件

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

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

or

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

Usage

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

{
  "plugins": ["stylelint-high-performance-animation"],
  "rules": {
    "plugin/no-low-performance-animation-properties": true
  }
}

Details

div {
  transition: margin 350ms ease-in;
}
/**           ^^^^^^
 * You should not use low performance animation properties */
@keyframes myAnimation {
  50% {
    top: 5px;
  }
}
/** ^^^^^^
 * 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:

div {
  transition: margin-left 350ms ease-in;
}

The following pattern is not considered warning:

div {
  transition: transform 350ms ease-in;
}

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:

div {
  transition-property: color, margin;
}

The following pattern is not considered warning:

div {
  transition-property: color, opacity, background-color;
}

Dependencies

This plugin has only stylelint as a dependency.


License

MIT

更新日志

v1.11.0

  • Fixed: allow overwriting transition with transition-property (#233).
  • Fixed: stylelint 16.13.0+ deprecation warning (#229).

v1.10.0

  • Added: support for stylelint version 16.

v1.9.0

  • Added: support for CSS logical properties (#36, #120).

v1.8.0

  • Added: support for stylelint version 15.

v1.7.0

  • Added: postcss-value-parser to dependencies.

v1.6.0

  • Added: support for stylelint version 14.

v1.5.2

  • Fixed: support with PostCSS version 8.

v1.5.1

  • Fixed: transition property without a value throwing an error.

v1.5.0

  • Added: support for stylelint version 13.

v1.4.0

  • Added: support for stylelint version 12.

v1.3.0

  • Added: support for stylelint version 11.

v1.2.1

  • Fixed: the plugin was crashing when CSS variable was used as the transition value.

v1.2.0

  • Added: support for stylelint version 10.

v1.1.1

  • Fixed: move background-color and border-color to paint properties.

v1.1.0

  • Added: now warns when all is used as transition property.

v1.0.0

  • Initial release